mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
@ -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')
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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++;
|
||||
|
@ -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
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user