Commit ee051bae authored by Tom Lane's avatar Tom Lane

Make sure that all <ctype.h> routines are called with unsigned char

values; it's not portable to call them with signed chars.  I recall doing
this for the last release, but a few more uncasted calls have snuck in.
parent e7d9a6bf
...@@ -78,7 +78,7 @@ isinteger(char *buff) ...@@ -78,7 +78,7 @@ isinteger(char *buff)
i++; i++;
continue; continue;
} }
if (!isdigit((int) *i)) if (!isdigit((unsigned char) *i))
return 0; return 0;
i++; i++;
} }
...@@ -90,7 +90,7 @@ strtoupper(char *string) ...@@ -90,7 +90,7 @@ strtoupper(char *string)
{ {
while (*string != '\0') while (*string != '\0')
{ {
*string = toupper(*string); *string = toupper((unsigned char) *string);
string++; string++;
} }
} }
...@@ -100,7 +100,7 @@ strtolower(char *string) ...@@ -100,7 +100,7 @@ strtolower(char *string)
{ {
while (*string != '\0') while (*string != '\0')
{ {
*string = tolower(*string); *string = tolower((unsigned char) *string);
string++; string++;
} }
} }
......
...@@ -253,17 +253,18 @@ metaphone(PG_FUNCTION_ARGS) ...@@ -253,17 +253,18 @@ metaphone(PG_FUNCTION_ARGS)
* accesssing the array directly... */ * accesssing the array directly... */
/* Look at the next letter in the word */ /* Look at the next letter in the word */
#define Next_Letter (toupper(word[w_idx+1])) #define Next_Letter (toupper((unsigned char) word[w_idx+1]))
/* Look at the current letter in the word */ /* Look at the current letter in the word */
#define Curr_Letter (toupper(word[w_idx])) #define Curr_Letter (toupper((unsigned char) word[w_idx]))
/* Go N letters back. */ /* Go N letters back. */
#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0') #define Look_Back_Letter(n) \
(w_idx >= (n) ? toupper((unsigned char) word[w_idx-(n)]) : '\0')
/* Previous letter. I dunno, should this return null on failure? */ /* Previous letter. I dunno, should this return null on failure? */
#define Prev_Letter (Look_Back_Letter(1)) #define Prev_Letter (Look_Back_Letter(1))
/* Look two letters down. It makes sure you don't walk off the string. */ /* Look two letters down. It makes sure you don't walk off the string. */
#define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \ #define After_Next_Letter \
: '\0') (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0')
#define Look_Ahead_Letter(n) (toupper(Lookahead(word+w_idx, n))) #define Look_Ahead_Letter(n) toupper((unsigned char) Lookahead(word+w_idx, n))
/* Allows us to safely look ahead an arbitrary # of letters */ /* Allows us to safely look ahead an arbitrary # of letters */
...@@ -291,7 +292,7 @@ Lookahead(char *word, int how_far) ...@@ -291,7 +292,7 @@ Lookahead(char *word, int how_far)
#define Phone_Len (p_idx) #define Phone_Len (p_idx)
/* Note is a letter is a 'break' in the word */ /* Note is a letter is a 'break' in the word */
#define Isbreak(c) (!isalpha(c)) #define Isbreak(c) (!isalpha((unsigned char) (c)))
int int
...@@ -336,7 +337,7 @@ _metaphone( ...@@ -336,7 +337,7 @@ _metaphone(
/*-- The first phoneme has to be processed specially. --*/ /*-- The first phoneme has to be processed specially. --*/
/* Find our first letter */ /* Find our first letter */
for (; !isalpha(Curr_Letter); w_idx++) for (; !isalpha((unsigned char) (Curr_Letter)); w_idx++)
{ {
/* On the off chance we were given nothing but crap... */ /* On the off chance we were given nothing but crap... */
if (Curr_Letter == '\0') if (Curr_Letter == '\0')
...@@ -435,7 +436,7 @@ _metaphone( ...@@ -435,7 +436,7 @@ _metaphone(
*/ */
/* Ignore non-alphas */ /* Ignore non-alphas */
if (!isalpha(Curr_Letter)) if (!isalpha((unsigned char) (Curr_Letter)))
continue; continue;
/* Drop duplicates, except CC */ /* Drop duplicates, except CC */
......
...@@ -153,7 +153,7 @@ char _codes[26] = { ...@@ -153,7 +153,7 @@ char _codes[26] = {
}; };
#define ENCODE(c) (isalpha(c) ? _codes[((toupper(c)) - 'A')] : 0) #define ENCODE(c) (isalpha((unsigned char) (c)) ? _codes[((toupper((unsigned char) (c))) - 'A')] : 0)
#define isvowel(c) (ENCODE(c) & 1) /* AEIOU */ #define isvowel(c) (ENCODE(c) & 1) /* AEIOU */
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: pgcrypto.c,v 1.11 2001/11/20 15:50:53 momjian Exp $ * $Id: pgcrypto.c,v 1.12 2001/12/30 23:09:41 tgl Exp $
*/ */
#include <postgres.h> #include <postgres.h>
...@@ -556,7 +556,7 @@ find_provider(text *name, ...@@ -556,7 +556,7 @@ find_provider(text *name,
p = VARDATA(name); p = VARDATA(name);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
buf[i] = tolower(p[i]); buf[i] = tolower((unsigned char) p[i]);
buf[len] = 0; buf[len] = 0;
err = provider_lookup(buf, &res); err = provider_lookup(buf, &res);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.85 2001/12/29 21:28:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.86 2001/12/30 23:09:41 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -959,7 +959,7 @@ DecodeDateTime(char **field, int *ftype, int nf, ...@@ -959,7 +959,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
if (tzp == NULL) if (tzp == NULL)
return -1; return -1;
if (isdigit(*field[i]) || ptype != 0) if (isdigit((unsigned char) *field[i]) || ptype != 0)
{ {
char *cp; char *cp;
...@@ -1573,7 +1573,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, ...@@ -1573,7 +1573,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
/* otherwise, this is a time and/or time zone */ /* otherwise, this is a time and/or time zone */
else else
{ {
if (isdigit(*field[i])) if (isdigit((unsigned char) *field[i]))
{ {
char *cp; char *cp;
......
...@@ -1092,7 +1092,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) ...@@ -1092,7 +1092,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
ReadyToReturn = FALSE; ReadyToReturn = FALSE;
empty_reqs = 0; empty_reqs = 0;
for (wq = query; isspace(*wq); wq++) for (wq = query; isspace((unsigned char) *wq); wq++)
; ;
if (*wq == '\0') if (*wq == '\0')
empty_reqs = 1; empty_reqs = 1;
......
...@@ -193,7 +193,7 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone) ...@@ -193,7 +193,7 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone)
} }
for (i = 1; i < 10; i++) for (i = 1; i < 10; i++)
{ {
if (!isdigit(rest[i])) if (!isdigit((unsigned char) rest[i]))
break; break;
} }
for (; i < 10; i++) for (; i < 10; i++)
...@@ -1351,7 +1351,7 @@ copy_statement_with_parameters(StatementClass *stmt) ...@@ -1351,7 +1351,7 @@ copy_statement_with_parameters(StatementClass *stmt)
while (isspace((unsigned char) old_statement[++opos])); while (isspace((unsigned char) old_statement[++opos]));
} }
if (strnicmp(&old_statement[opos], "call", lit_call_len) || if (strnicmp(&old_statement[opos], "call", lit_call_len) ||
!isspace(old_statement[opos + lit_call_len])) !isspace((unsigned char) old_statement[opos + lit_call_len]))
{ {
opos--; opos--;
continue; continue;
...@@ -1407,7 +1407,7 @@ copy_statement_with_parameters(StatementClass *stmt) ...@@ -1407,7 +1407,7 @@ copy_statement_with_parameters(StatementClass *stmt)
in_dquote = TRUE; in_dquote = TRUE;
else else
{ {
if (isspace(oldchar)) if (isspace((unsigned char) oldchar))
{ {
if (!prev_token_end) if (!prev_token_end)
{ {
......
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