From a93c3ddc9b3f07494e1996785a35f3826be8220b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 3 Dec 2000 20:45:39 +0000 Subject: [PATCH] Ensure that all uses of functions are applied to unsigned-char values, whether the local char type is signed or not. This is necessary for portability. Per discussion on pghackers around 9/16/00. --- convert.c | 24 +++++++++++++----------- gpps.c | 6 +++--- info.c | 4 ++-- parse.c | 15 ++++++++------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/convert.c b/convert.c index 876c840..95ac701 100644 --- a/convert.c +++ b/convert.c @@ -284,9 +284,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 nval++; /* skip the current token */ - while ((*vp != '\0') && (! isspace(*vp))) vp++; + while ((*vp != '\0') && (! isspace((unsigned char) *vp))) vp++; /* and skip the space to the next token */ - while ((*vp != '\0') && (isspace(*vp))) vp++; + while ((*vp != '\0') && (isspace((unsigned char) *vp))) vp++; if (*vp == '\0') break; } @@ -1126,10 +1126,10 @@ static char escape[1024]; char key[33]; /* Separate off the key, skipping leading and trailing whitespace */ - while ((*value != '\0') && isspace(*value)) value++; + while ((*value != '\0') && isspace((unsigned char) *value)) value++; sscanf(value, "%32s", key); - while ((*value != '\0') && (! isspace(*value))) value++; - while ((*value != '\0') && isspace(*value)) value++; + while ((*value != '\0') && (! isspace((unsigned char) *value))) value++; + while ((*value != '\0') && isspace((unsigned char) *value)) value++; mylog("convert_escape: key='%s', val='%s'\n", key, value); @@ -1149,12 +1149,14 @@ char key[33]; char *mapFunc; while ((*funcEnd != '\0') && (*funcEnd != '(') && - (! isspace(*funcEnd))) funcEnd++; + (! isspace((unsigned char) *funcEnd))) + funcEnd++; svchar = *funcEnd; *funcEnd = '\0'; sscanf(value, "%32s", key); *funcEnd = svchar; - while ((*funcEnd != '\0') && isspace(*funcEnd)) funcEnd++; + while ((*funcEnd != '\0') && isspace((unsigned char) *funcEnd)) + funcEnd++; /* We expect left parenthesis here, * else return fn body as-is since it is @@ -1430,18 +1432,18 @@ int i, o=0; void encode(char *in, char *out) { -unsigned int i, o = 0; + unsigned int i, o = 0; for (i = 0; i < strlen(in); i++) { if ( in[i] == '+') { sprintf(&out[o], "%%2B"); o += 3; } - else if ( isspace(in[i])) { + else if ( isspace((unsigned char) in[i])) { out[o++] = '+'; } - else if ( ! isalnum(in[i])) { - sprintf(&out[o], "%%%02x", in[i]); + else if ( ! isalnum((unsigned char) in[i])) { + sprintf(&out[o], "%%%02x", (unsigned char) in[i]); o += 3; } else diff --git a/gpps.c b/gpps.c index 55a8deb..f14e95f 100644 --- a/gpps.c +++ b/gpps.c @@ -144,8 +144,8 @@ GetPrivateProfileString(char *theSection, /* section name */ { aStart = aLine + 1; aString--; - while (isspace(*aStart)) aStart++; - while (isspace(*aString)) aString--; + while (isspace((unsigned char) *aStart)) aStart++; + while (isspace((unsigned char) *aString)) aString--; *(aString+1) = '\0'; /* accept as matched if NULL key or exact match */ @@ -188,7 +188,7 @@ GetPrivateProfileString(char *theSection, /* section name */ } aStart = aLine; - while(isspace(*aStart)) aStart++; + while (isspace((unsigned char) *aStart)) aStart++; /* strip trailing blanks from key */ diff --git a/info.c b/info.c index 9d4e75a..f796f8a 100644 --- a/info.c +++ b/info.c @@ -28,7 +28,7 @@ #include "iodbc.h" #include "isql.h" #include "isqlext.h" -#include /* for tolower function */ +#include #else #include #include @@ -2615,7 +2615,7 @@ Int2 result_cols; /* Handle action (i.e., 'cascade', 'restrict', 'setnull') */ - switch(tolower(ptr[0])) { + switch(tolower((unsigned char) ptr[0])) { case 'c': action = SQL_CASCADE; break; diff --git a/parse.c b/parse.c index dac931a..690a902 100644 --- a/parse.c +++ b/parse.c @@ -55,7 +55,7 @@ char qc, in_escape = FALSE; smax--; /* skip leading delimiters */ - while (isspace(s[i]) || s[i] == ',') { + while (isspace((unsigned char) s[i]) || s[i] == ',') { /* mylog("skipping '%c'\n", s[i]); */ i++; } @@ -70,7 +70,8 @@ char qc, in_escape = FALSE; if (numeric) *numeric = FALSE; /* get the next token */ - while ( ! isspace(s[i]) && s[i] != ',' && s[i] != '\0' && out != smax) { + while ( ! isspace((unsigned char) s[i]) && s[i] != ',' && + s[i] != '\0' && out != smax) { /* Handle quoted stuff */ if ( out == 0 && (s[i] == '\"' || s[i] == '\'')) { @@ -102,16 +103,16 @@ char qc, in_escape = FALSE; } /* Check for numeric literals */ - if ( out == 0 && isdigit(s[i])) { + if ( out == 0 && isdigit((unsigned char) s[i])) { if (numeric) *numeric = TRUE; token[out++] = s[i++]; - while ( isalnum(s[i]) || s[i] == '.') + while ( isalnum((unsigned char) s[i]) || s[i] == '.') token[out++] = s[i++]; break; } - if ( ispunct(s[i]) && s[i] != '_') { + if ( ispunct((unsigned char) s[i]) && s[i] != '_') { mylog("got ispunct: s[%d] = '%c'\n", i, s[i]); if (out == 0) { @@ -133,7 +134,7 @@ char qc, in_escape = FALSE; token[out] = '\0'; /* find the delimiter */ - while ( isspace(s[i])) + while ( isspace((unsigned char) s[i])) i++; /* return the most priority delimiter */ @@ -148,7 +149,7 @@ char qc, in_escape = FALSE; } /* skip trailing blanks */ - while ( isspace(s[i])) { + while ( isspace((unsigned char) s[i])) { i++; } -- 2.39.5