Commit 4351f882 authored by Tom Lane's avatar Tom Lane

Fix portability bugs: char values passed to <ctype.h> functions must

be cast to unsigned char.  We have learned this the hard way before.
parent 558ed5ae
...@@ -464,7 +464,7 @@ rstrdate(char *str, date * d) ...@@ -464,7 +464,7 @@ rstrdate(char *str, date * d)
for (i=0,j=0; i < 10; i++ ) for (i=0,j=0; i < 10; i++ )
{ {
/* ignore non-digits */ /* ignore non-digits */
if ( isdigit(str[i]) ) if ( isdigit((unsigned char) str[i]) )
{ {
/* j only increments if it is a digit */ /* j only increments if it is a digit */
...@@ -910,8 +910,8 @@ void ...@@ -910,8 +910,8 @@ void
rupshift(char *str) rupshift(char *str)
{ {
for (; *str != '\0'; str++) for (; *str != '\0'; str++)
if (islower(*str)) if (islower((unsigned char) *str))
*str = toupper(*str); *str = toupper((unsigned char) *str);
return; return;
} }
......
...@@ -405,7 +405,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) ...@@ -405,7 +405,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
reading_digit = 1; reading_digit = 1;
for (i = 0; str[i]; i++) for (i = 0; str[i]; i++)
{ {
if (!isdigit(str[i])) if (!isdigit((unsigned char) str[i]))
{ {
reading_digit = 0; reading_digit = 0;
break; break;
...@@ -495,7 +495,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) ...@@ -495,7 +495,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
/* convert the whole string to lower case */ /* convert the whole string to lower case */
for (i = 0; str_copy[i]; i++) for (i = 0; str_copy[i]; i++)
str_copy[i] = (char) tolower(str_copy[i]); str_copy[i] = (char) tolower((unsigned char) str_copy[i]);
} }
/* look for numerical tokens */ /* look for numerical tokens */
...@@ -503,14 +503,14 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) ...@@ -503,14 +503,14 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
token_count = 0; token_count = 0;
for (i = 0; i < strlen(str_copy); i++) for (i = 0; i < strlen(str_copy); i++)
{ {
if (!isdigit(str_copy[i]) && reading_digit) if (!isdigit((unsigned char) str_copy[i]) && reading_digit)
{ {
/* the token is finished */ /* the token is finished */
token[token_count][1] = i - 1; token[token_count][1] = i - 1;
reading_digit = 0; reading_digit = 0;
token_count++; token_count++;
} }
else if (isdigit(str_copy[i]) && !reading_digit) else if (isdigit((unsigned char) str_copy[i]) && !reading_digit)
{ {
/* we have found a token */ /* we have found a token */
token[token_count][0] = i; token[token_count][0] = i;
...@@ -565,7 +565,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) ...@@ -565,7 +565,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
{ {
for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++) for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++)
{ {
month_lower_tmp[j] = (char) tolower(list[i][j]); month_lower_tmp[j] = (char) tolower((unsigned char) list[i][j]);
if (!month_lower_tmp[j]) if (!month_lower_tmp[j])
{ {
/* properly terminated */ /* properly terminated */
......
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