]> granicus.if.org Git - postgresql/commitdiff
Make sure that all <ctype.h> routines are called with unsigned char
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2001 23:09:42 +0000 (23:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2001 23:09:42 +0000 (23:09 +0000)
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.

contrib/dbase/dbf2pg.c
contrib/fuzzystrmatch/fuzzystrmatch.c
contrib/fuzzystrmatch/fuzzystrmatch.h
contrib/pgcrypto/pgcrypto.c
src/backend/utils/adt/datetime.c
src/interfaces/odbc/connection.c
src/interfaces/odbc/convert.c

index a635e09122c63abc09527d76a12e777b343594b8..038c2b5aba22357beda32b44f5367a1a98fe876e 100644 (file)
@@ -78,7 +78,7 @@ isinteger(char *buff)
                                i++;
                                continue;
                        }
-               if (!isdigit((int) *i))
+               if (!isdigit((unsigned char) *i))
                        return 0;
                i++;
        }
@@ -90,7 +90,7 @@ strtoupper(char *string)
 {
        while (*string != '\0')
        {
-               *string = toupper(*string);
+               *string = toupper((unsigned char) *string);
                string++;
        }
 }
@@ -100,7 +100,7 @@ strtolower(char *string)
 {
        while (*string != '\0')
        {
-               *string = tolower(*string);
+               *string = tolower((unsigned char) *string);
                string++;
        }
 }
index 3f863a4fa95e3c5a608a539917500a813b9e65f4..fbb16f66b335ba01b16474e023d9b4a7b4f9a3e8 100644 (file)
@@ -253,17 +253,18 @@ metaphone(PG_FUNCTION_ARGS)
  * accesssing the array directly... */
 
 /* 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 */
-#define Curr_Letter (toupper(word[w_idx]))
+#define Curr_Letter (toupper((unsigned char) word[w_idx]))
 /* 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? */
 #define Prev_Letter (Look_Back_Letter(1))
 /* 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]) \
-                                                                                                : '\0')
-#define Look_Ahead_Letter(n) (toupper(Lookahead(word+w_idx, n)))
+#define After_Next_Letter \
+       (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0')
+#define Look_Ahead_Letter(n) toupper((unsigned char) Lookahead(word+w_idx, n))
 
 
 /* Allows us to safely look ahead an arbitrary # of letters */
@@ -291,7 +292,7 @@ Lookahead(char *word, int how_far)
 #define Phone_Len      (p_idx)
 
 /* Note is a letter is a 'break' in the word */
-#define Isbreak(c)     (!isalpha(c))
+#define Isbreak(c)     (!isalpha((unsigned char) (c)))
 
 
 int
@@ -336,7 +337,7 @@ _metaphone(
 
        /*-- The first phoneme has to be processed specially. --*/
        /* 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... */
                if (Curr_Letter == '\0')
@@ -435,7 +436,7 @@ _metaphone(
                 */
 
                /* Ignore non-alphas */
-               if (!isalpha(Curr_Letter))
+               if (!isalpha((unsigned char) (Curr_Letter)))
                        continue;
 
                /* Drop duplicates, except CC */
index 23e5e57d925a87a87b4a8f08c63ba61e46089de9..59e0d9258c930bb387b77d8449e5b5f41d826612 100644 (file)
@@ -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 */
 
index bf700e3da9827e37cf546bac70ee28dae000328f..d3dc36dc9ae0ae60ba8de625abc3c85621be7f8c 100644 (file)
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * 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>
@@ -556,7 +556,7 @@ find_provider(text *name,
 
        p = VARDATA(name);
        for (i = 0; i < len; i++)
-               buf[i] = tolower(p[i]);
+               buf[i] = tolower((unsigned char) p[i]);
        buf[len] = 0;
 
        err = provider_lookup(buf, &res);
index 674eaeb91a17fa1f35204826005764146e6f66a0..49e93abe99a240986e753f714e6f77914c71c336 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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,
                                        if (tzp == NULL)
                                                return -1;
 
-                                       if (isdigit(*field[i]) || ptype != 0)
+                                       if (isdigit((unsigned char) *field[i]) || ptype != 0)
                                        {
                                                char *cp;
 
@@ -1573,7 +1573,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                                /* otherwise, this is a time and/or time zone */
                                else
                                {
-                                       if (isdigit(*field[i]))
+                                       if (isdigit((unsigned char) *field[i]))
                                        {
                                                char *cp;
 
index e39501f800700e20d9681da9eb098eae50466363..e057d7b73f9cac0606b4458812f2040827339ea3 100644 (file)
@@ -1092,7 +1092,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
 
        ReadyToReturn = FALSE;
        empty_reqs = 0;
-       for (wq = query; isspace(*wq); wq++)
+       for (wq = query; isspace((unsigned char) *wq); wq++)
                ;
        if (*wq == '\0')
                empty_reqs = 1;
index 57bf6b70dfcd418ade5ad4d71ca593419e247948..0b609a07dbecc139852772db2c1f0603efb58908 100644 (file)
@@ -193,7 +193,7 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone)
                        }
                        for (i = 1; i < 10; i++)
                        {
-                               if (!isdigit(rest[i]))
+                               if (!isdigit((unsigned char) rest[i]))
                                        break;
                        }
                        for (; i < 10; i++)
@@ -1351,7 +1351,7 @@ copy_statement_with_parameters(StatementClass *stmt)
                                        while (isspace((unsigned char) old_statement[++opos]));
                                }
                                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--;
                                        continue;
@@ -1407,7 +1407,7 @@ copy_statement_with_parameters(StatementClass *stmt)
                                in_dquote = TRUE;
                        else
                        {
-                               if (isspace(oldchar))
+                               if (isspace((unsigned char) oldchar))
                                {
                                        if (!prev_token_end)
                                        {