Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9e20406

Browse files
committed
Fix unportable use of isprint().
We must cast the arguments of <ctype.h> functions to unsigned char to avoid problems where char is signed. Speaking of which, considering that this *is* a <ctype.h> function, it's rather remarkable that we aren't seeing more complaints about not having included that header. Per buildfarm.
1 parent f1be740 commit 9e20406

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/interfaces/libpq/fe-trace.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "postgres_fe.h"
1616

17+
#include <ctype.h>
1718
#include <limits.h>
1819
#include <time.h>
1920

@@ -28,6 +29,7 @@
2829
#include "libpq-int.h"
2930
#include "port/pg_bswap.h"
3031

32+
3133
/* Enable tracing */
3234
void
3335
PQtrace(PGconn *conn, FILE *debug_port)
@@ -102,7 +104,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor)
102104
* Show non-printable data in hex format, including the terminating \0
103105
* that completes ErrorResponse and NoticeResponse messages.
104106
*/
105-
if (!isprint(*v))
107+
if (!isprint((unsigned char) *v))
106108
fprintf(pfdebug, " \\x%02x", *v);
107109
else
108110
fprintf(pfdebug, " %c", *v);
@@ -186,7 +188,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor)
186188

187189
for (next = i = 0; i < len; ++i)
188190
{
189-
if (isprint(v[i]))
191+
if (isprint((unsigned char) v[i]))
190192
continue;
191193
else
192194
{

0 commit comments

Comments
 (0)