Commit 9e20406d authored by Tom Lane's avatar Tom Lane

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.
parent f1be740a
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include <ctype.h>
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "libpq-int.h" #include "libpq-int.h"
#include "port/pg_bswap.h" #include "port/pg_bswap.h"
/* Enable tracing */ /* Enable tracing */
void void
PQtrace(PGconn *conn, FILE *debug_port) PQtrace(PGconn *conn, FILE *debug_port)
...@@ -102,7 +104,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor) ...@@ -102,7 +104,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor)
* Show non-printable data in hex format, including the terminating \0 * Show non-printable data in hex format, including the terminating \0
* that completes ErrorResponse and NoticeResponse messages. * that completes ErrorResponse and NoticeResponse messages.
*/ */
if (!isprint(*v)) if (!isprint((unsigned char) *v))
fprintf(pfdebug, " \\x%02x", *v); fprintf(pfdebug, " \\x%02x", *v);
else else
fprintf(pfdebug, " %c", *v); fprintf(pfdebug, " %c", *v);
...@@ -186,7 +188,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor) ...@@ -186,7 +188,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor)
for (next = i = 0; i < len; ++i) for (next = i = 0; i < len; ++i)
{ {
if (isprint(v[i])) if (isprint((unsigned char) v[i]))
continue; continue;
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment