summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTom Lane2000-12-03 20:45:40 +0000
committerTom Lane2000-12-03 20:45:40 +0000
commita27b691e2903a886be640db801677f6f988d3793 (patch)
treec68f25c9edef18954e9c5b3d74893f1df87b8871 /contrib
parent4d2a506526ceacab5f75df040596a5287ab40612 (diff)
Ensure that all uses of <ctype.h> 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.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/fulltextindex/fti.c15
-rw-r--r--contrib/soundex/soundex.c11
-rw-r--r--contrib/spi/preprocessor/step1.c2
-rw-r--r--contrib/spi/refint.c4
-rw-r--r--contrib/spi/timetravel.c4
-rw-r--r--contrib/string/string_io.c5
6 files changed, 21 insertions, 20 deletions
diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c
index bb4636ff3e0..75358958c5b 100644
--- a/contrib/fulltextindex/fti.c
+++ b/contrib/fulltextindex/fti.c
@@ -1,7 +1,7 @@
#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
-#include <ctype.h> /* tolower */
+#include <ctype.h>
#include <stdio.h> /* debugging */
/*
@@ -256,10 +256,9 @@ fti(PG_FUNCTION_ARGS)
char *string = column;
while (*string != '\0')
- { /* placed 'really' inline. */
- *string = tolower(*string); /* some compilers will
- * choke */
- string++; /* on 'inline' keyword */
+ {
+ *string = tolower((unsigned char) *string);
+ string++;
}
data = (struct varlena *) palloc(sizeof(int32) + strlen(column) +1);
@@ -312,9 +311,9 @@ breakup(char *string, char *substring)
* (ie. 'string$%^&', last_start first points to '&', and after
* this to 'g'
*/
- if (!isalnum((int) *last_start))
+ if (!isalnum((unsigned char) *last_start))
{
- while (!isalnum((int) *last_start) &&
+ while (!isalnum((unsigned char) *last_start) &&
last_start > string)
last_start--;
cur_pos = last_start;
@@ -323,7 +322,7 @@ breakup(char *string, char *substring)
cur_pos--; /* substrings are at minimum 2 characters
* long */
- if (isalnum((int) *cur_pos))
+ if (isalnum((unsigned char) *cur_pos))
{
/* Houston, we have a substring! :) */
memcpy(substring, cur_pos, last_start - cur_pos + 1);
diff --git a/contrib/soundex/soundex.c b/contrib/soundex/soundex.c
index f66cb21f242..165202d5ef5 100644
--- a/contrib/soundex/soundex.c
+++ b/contrib/soundex/soundex.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.8 2000/11/20 20:36:57 tgl Exp $ */
+/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.9 2000/12/03 20:45:31 tgl Exp $ */
#include "postgres.h"
#include "fmgr.h"
#include "utils/builtins.h"
@@ -42,7 +42,7 @@ text_soundex(PG_FUNCTION_ARGS)
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
static const char *soundex_table = "01230120022455012623010202";
-#define soundex_code(letter) soundex_table[toupper(letter) - 'A']
+#define soundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A']
static void
@@ -56,7 +56,7 @@ soundex(const char *instr, char *outstr)
outstr[SOUNDEX_LEN] = '\0';
/* Skip leading non-alphabetic characters */
- while (!isalpha(instr[0]) && instr[0])
+ while (!isalpha((unsigned char) instr[0]) && instr[0])
++instr;
/* No string left */
@@ -67,12 +67,13 @@ soundex(const char *instr, char *outstr)
}
/* Take the first letter as is */
- *outstr++ = (char) toupper(*instr++);
+ *outstr++ = (char) toupper((unsigned char) *instr++);
count = 1;
while (*instr && count < SOUNDEX_LEN)
{
- if (isalpha(*instr) && soundex_code(*instr) != soundex_code(*(instr - 1)))
+ if (isalpha((unsigned char) *instr) &&
+ soundex_code(*instr) != soundex_code(*(instr - 1)))
{
*outstr = soundex_code(instr[0]);
if (*outstr != '0')
diff --git a/contrib/spi/preprocessor/step1.c b/contrib/spi/preprocessor/step1.c
index 1f2c5380d51..8a5379e8e04 100644
--- a/contrib/spi/preprocessor/step1.c
+++ b/contrib/spi/preprocessor/step1.c
@@ -6,7 +6,7 @@ strtoupper(char *string)
int i;
for (i = 0; i < strlen(string); i++)
- string[i] = toupper(string[i]);
+ string[i] = toupper((unsigned char) string[i]);
return string;
}
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index d7a8d73c8e1..ea8851816f5 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -5,7 +5,7 @@
#include "executor/spi.h" /* this is what you need to work with SPI */
#include "commands/trigger.h" /* -"- and triggers */
-#include <ctype.h> /* tolower () */
+#include <ctype.h>
extern Datum check_primary_key(PG_FUNCTION_ARGS);
@@ -293,7 +293,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
nrefs = pg_atoi(args[0], sizeof(int), 0);
if (nrefs < 1)
elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
- action = tolower(*(args[1]));
+ action = tolower((unsigned char) *(args[1]));
if (action != 'r' && action != 'c' && action != 's')
elog(ERROR, "check_foreign_key: invalid action %s", args[1]);
nargs -= 2;
diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c
index 41e7b092b32..90341e208d2 100644
--- a/contrib/spi/timetravel.c
+++ b/contrib/spi/timetravel.c
@@ -5,7 +5,7 @@
#include "executor/spi.h" /* this is what you need to work with SPI */
#include "commands/trigger.h" /* -"- and triggers */
-#include <ctype.h> /* tolower () */
+#include <ctype.h>
#define ABSTIMEOID 702 /* it should be in pg_type.h */
@@ -376,7 +376,7 @@ set_timetravel(PG_FUNCTION_ARGS)
NameGetDatum(relname)));
d = TTOff[nTTOff] = malloc(strlen(rname) + 1);
while (*s)
- *d++ = tolower(*s++);
+ *d++ = tolower((unsigned char) *s++);
*d = 0;
pfree(rname);
nTTOff++;
diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c
index c329fec1e9e..8c4e5b45e1a 100644
--- a/contrib/string/string_io.c
+++ b/contrib/string/string_io.c
@@ -28,9 +28,10 @@
#define DIGIT(val) ((val) + '0')
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
#ifndef ISO8859
-#define NOTPRINTABLE(c) (!isprint(c))
+#define NOTPRINTABLE(c) (!isprint((unsigned char) (c)))
#else
-#define NOTPRINTABLE(c) (!isprint(c) && ((c) < 0xa0))
+#define NOTPRINTABLE(c) (!isprint((unsigned char) (c)) && \
+ ((unsigned char) (c) < (unsigned char) 0xa0))
#endif
/*