char *i;
for (i = s->str; *i; i++)
- *i = toupper(*i);
+ *i = toupper((unsigned char) *i);
}
elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
} else if ( *(state->ptr) == '\\' ) {
st = GV_WAITESCIN;
- } else if ( !isspace(*(state->ptr)) ) {
+ } else if ( !isspace((unsigned char) *(state->ptr)) ) {
*(state->cur) = *(state->ptr);
state->cur++;
st = GV_INVAL;
} else if ( *(state->ptr) == ',' && ignoreeq ) {
state->ptr--;
return true;
- } else if ( isspace(*(state->ptr)) ) {
+ } else if ( isspace((unsigned char) *(state->ptr)) ) {
return true;
} else if ( *(state->ptr) == '\0' ) {
state->ptr--;
st = WGT;
} else if ( *(state->ptr) == '\0' ) {
elog(ERROR,"Unexpectd end of string");
- } else if (!isspace(*(state->ptr))) {
+ } else if (!isspace((unsigned char) *(state->ptr))) {
elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
}
} else if ( st == WGT ) {
st = WKEY;
} else if ( *(state->ptr) == '\0' ) {
return;
- } else if (!isspace(*(state->ptr))) {
+ } else if (!isspace((unsigned char) *(state->ptr))) {
elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
}
} else
aux2 = TABLE[i][1];
/* must always start with a digit: */
- if(!isdigit(*aux1) || !isdigit(*aux2)) goto invalidtable;
+ if (!isdigit((unsigned char) *aux1) || !isdigit((unsigned char) *aux2))
+ goto invalidtable;
a = *aux1 - '0';
b = *aux2 - '0';
/* must always have the same format and length: */
while(*aux1 && *aux2) {
- if(!(isdigit(*aux1) && isdigit(*aux2)) && (*aux1!=*aux2 || *aux1 != '-'))
+ if (!(isdigit((unsigned char) *aux1) &&
+ isdigit((unsigned char) *aux2)) &&
+ (*aux1 != *aux2 || *aux1 != '-'))
goto invalidtable;
aux1++;
aux2++;
{
unsigned ret = 0;
while(*bufI) {
- if(isdigit(*bufI)) {
+ if(isdigit((unsigned char) *bufI)) {
*bufO++ = *bufI;
ret++;
}
firstdig++, ean_aux1++, ean_aux2++;
if(!(*ean_aux1 && *ean_aux2 && *firstdig)) break;
- if(!isdigit(*ean_aux1)) ean_aux1++, ean_aux2++;
+ if(!isdigit((unsigned char) *ean_aux1)) ean_aux1++, ean_aux2++;
} else {
/* check in what direction we should go and move the pointer accordingly */
if(*firstdig < *ean_aux1 && !ean_in1) upper = search;
{
unsigned weight = 0;
while(*isn && size>1) {
- if(isdigit(*isn)) {
+ if(isdigit((unsigned char) *isn)) {
weight += size-- * (*isn - '0');
}
isn++;
pos = 1;
}
while(*num && size>1) {
- if(isdigit(*num)) {
+ if(isdigit((unsigned char) *num)) {
if(pos++%2) check3 += *num - '0';
else check += *num - '0';
size--;
hyphenate(isn, isn+4, NULL, NULL);
check = weight_checkdig(isn, 10);
aux = strchr(isn, '\0');
- while(!isdigit(*--aux));
+ while(!isdigit((unsigned char) *--aux));
if(check == 10) *aux = 'X';
else *aux = check + '0';
}
{
ean13 ean = 0; /* current ean */
while(*num) {
- if(isdigit(*num)) ean = 10 * ean + (*num - '0');
+ if(isdigit((unsigned char) *num)) ean = 10 * ean + (*num - '0');
num++;
}
return (ean<<1); /* also give room to a flag */
/* recognize and validate the number: */
while(*aux2 && length <= 13) {
last = (*(aux2+1) == '!' || *(aux2+1) == '\0'); /* is the last character */
- digit = (isdigit(*aux2)!=0); /* is current character a digit? */
+ digit = (isdigit((unsigned char) *aux2)!=0); /* is current character a digit? */
if(*aux2=='?' && last) /* automagically calculate check digit if it's '?' */
magic = digit = true;
if(length == 0 && (*aux2=='M' || *aux2=='m')) {
/* only ISSN can be here */
if(type != INVALID) goto eaninvalid;
type = ISSN;
- *aux1++ = toupper(*aux2);
+ *aux1++ = toupper((unsigned char) *aux2);
length++;
} else if(length == 9 && (digit || *aux2=='X' || *aux2=='x') && last) {
/* only ISBN and ISMN can be here */
if(type != INVALID && type != ISMN) goto eaninvalid;
if(type == INVALID) type = ISBN; /* ISMN must start with 'M' */
- *aux1++ = toupper(*aux2);
+ *aux1++ = toupper((unsigned char) *aux2);
length++;
} else if(length == 11 && digit && last) {
/* only UPC can be here */
#ifdef LOWER_NODE
#include <ctype.h>
-#define TOLOWER(x) tolower(x)
+#define TOLOWER(x) tolower((unsigned char) (x))
#else
#define TOLOWER(x) (x)
#endif
{
if (*ptr == ',')
state = LQPRS_WAITSNUM;
- else if (isdigit((unsigned int) *ptr))
+ else if (isdigit((unsigned char) *ptr))
{
curqlevel->low = atoi(ptr);
state = LQPRS_WAITND;
}
else if (state == LQPRS_WAITSNUM)
{
- if (isdigit((unsigned int) *ptr))
+ if (isdigit((unsigned char) *ptr))
{
curqlevel->high = atoi(ptr);
state = LQPRS_WAITCLOSE;
{
if (*ptr == '}')
state = LQPRS_WAITEND;
- else if (!isdigit((unsigned int) *ptr))
+ else if (!isdigit((unsigned char) *ptr))
UNCHAR;
}
else if (state == LQPRS_WAITND)
}
else if (*ptr == ',')
state = LQPRS_WAITSNUM;
- else if (!isdigit((unsigned int) *ptr))
+ else if (!isdigit((unsigned char) *ptr))
UNCHAR;
}
else if (state == LQPRS_WAITEND)
*lenval = 1;
*flag = 0;
}
- else if (!isspace((unsigned int) *(state->buf)))
+ else if (!isspace((unsigned char) *(state->buf)))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("operand syntax error")));
return MP_RANGE;
/* Skip leading whitespace */
- while(isspace((int)*str))
+ while(isspace((unsigned char) *str))
++str;
/* Handle leading sign tag (+/-, positive default) */
{
int out;
- if(isdigit((int)c))
+ if(isdigit((unsigned char)c))
out = c - '0';
- else if(r > 10 && isalpha((int)c))
- out = toupper(c) - 'A' + 10;
+ else if(r > 10 && isalpha((unsigned char) c))
+ out = toupper((unsigned char) c) - 'A' + 10;
else
return -1;
char out = (v - 10) + 'a';
if(caps)
- return toupper(out);
+ return toupper((unsigned char) out);
else
return out;
}
* did not end with a newline.
*
* XXX perhaps \f (formfeed) should be treated as a newline as well?
+ *
+ * XXX if you change the set of whitespace characters, fix scanner_isspace()
+ * to agree, and see also the plpgsql lexer.
*/
space [ \t\n\r\f]
ident[len] = '\0';
}
}
+
+/*
+ * scanner_isspace() --- return TRUE if flex scanner considers char whitespace
+ *
+ * This should be used instead of the potentially locale-dependent isspace()
+ * function when it's important to match the lexer's behavior.
+ *
+ * In principle we might need similar functions for isalnum etc, but for the
+ * moment only isspace seems needed.
+ */
+bool
+scanner_isspace(char ch)
+{
+ /* This must match scan.l's list of {space} characters */
+ /* and plpgsql's scan.l as well */
+ if (ch == ' ' ||
+ ch == '\t' ||
+ ch == '\n' ||
+ ch == '\r' ||
+ ch == '\f')
+ return true;
+ return false;
+}
initStringInfo(&buf);
while ((c = *cp++) != 0)
{
- if (isspace(c))
+ if (isspace((unsigned char) c))
{
if (symLen > 0)
hasSpaceAfterToken = true;
continue;
}
- if (hasSpaceAfterToken || !isalnum(c))
+ if (hasSpaceAfterToken || !isalnum((unsigned char) c))
{
/*
* Syntax error due to token following space after token or non
new_obj_name->next = NULL;
new_obj_name->name = strdup(optarg);
- new_obj_name->is_include = islower(c) ? true : false;
+ new_obj_name->is_include = islower((unsigned char) c) ? true : false;
/* add new entry to the proper list */
- if (tolower(c) == 'n')
+ if (tolower((unsigned char) c) == 'n')
{
if (!schemaList_tail)
schemaList_tail = schemaList = new_obj_name;
/* Complete "AS ON <sth with a 'T' :)>" with a "TO" */
else if (pg_strcasecmp(prev3_wd, "AS") == 0 &&
pg_strcasecmp(prev2_wd, "ON") == 0 &&
- (toupper((unsigned char) prev_wd[4]) == 'T' ||
- toupper((unsigned char) prev_wd[5]) == 'T'))
+ (pg_toupper((unsigned char) prev_wd[4]) == 'T' ||
+ pg_toupper((unsigned char) prev_wd[5]) == 'T'))
COMPLETE_WITH_CONST("TO");
/* Complete "AS ON <sth> TO" with a table name */
else if (pg_strcasecmp(prev4_wd, "AS") == 0 &&
extern void truncate_identifier(char *ident, int len, bool warn);
+extern bool scanner_isspace(char ch);
+
#endif /* SCANSUP_H */
( \
((filename)[0] == '/') || \
(filename)[0] == '\\' || \
- (isalpha((filename)[0]) && (filename)[1] == ':' && \
+ (isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
((filename)[2] == '\\' || (filename)[2] == '/')) \
)
#endif
static void addlitchar (unsigned char);
static void parse_include (void);
static void check_escape_warning(void);
+static bool ecpg_isspace(char ch);
char *token_start;
int state_before;
* did not end with a newline.
*
* XXX perhaps \f (formfeed) should be treated as a newline as well?
+ *
+ * XXX if you change the set of whitespace characters, fix ecpg_isspace()
+ * to agree.
*/
ccomment "//".*\n
* contains at least one non-space character plus the ";"
*/
for (i = strlen(yytext)-2;
- i > 0 && isspace((unsigned char) yytext[i]);
+ i > 0 && ecpg_isspace(yytext[i]);
i-- )
;
yytext[i+1] = '\0';
* contains at least one non-space character plus the ";"
*/
for (i = strlen(yytext)-2;
- i > 0 && isspace((unsigned char) yytext[i]);
+ i > 0 && ecpg_isspace(yytext[i]);
i-- )
;
yytext[i+1] = '\0';
* yytext contains at least one non-space character plus the ";"
*/
for (i = strlen(yytext)-2;
- i > 0 && isspace((unsigned char) yytext[i]);
+ i > 0 && ecpg_isspace(yytext[i]);
i--)
;
mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");
warn_on_first_escape = false; /* warn only once per string */
}
+
+/*
+ * ecpg_isspace() --- return TRUE if flex scanner considers char whitespace
+ */
+static bool
+ecpg_isspace(char ch)
+{
+ if (ch == ' ' ||
+ ch == '\t' ||
+ ch == '\n' ||
+ ch == '\r' ||
+ ch == '\f')
+ return true;
+ return false;
+}
*p = '\0';
#ifdef WIN32
for (p = aname; *p; p++)
- *p = pg_tolower(*p);
+ *p = pg_tolower((unsigned char) *p);
#endif
return aname;
#include "funcapi.h"
#include "optimizer/clauses.h"
#include "parser/parse_expr.h"
+#include "parser/scansup.h"
#include "tcop/tcopprot.h"
#include "utils/array.h"
#include "utils/builtins.h"
char *ptr;
for (ptr = querystr; *ptr; ptr++)
- if (!isspace((unsigned char) *ptr))
+ if (!scanner_isspace(*ptr))
break;
if (*ptr == 'S' || *ptr == 's')
ereport(ERROR,
/* Normal identifier: extends till dot or whitespace */
const char *thisstart = s;
- while (*s && *s != '.' && !isspace((unsigned char) *s))
+ while (*s && *s != '.' && !scanner_isspace(*s))
s++;
/* Downcase and truncate to NAMEDATALEN */
curident = downcase_truncate_identifier(thisstart, s - thisstart,
/* If not done, skip whitespace, dot, whitespace */
if (*s)
{
- while (*s && isspace((unsigned char) *s))
+ while (*s && scanner_isspace(*s))
s++;
if (*s++ != '.')
elog(ERROR, "expected dot between identifiers: %s", sstart);
- while (*s && isspace((unsigned char) *s))
+ while (*s && scanner_isspace(*s))
s++;
if (*s == '\0')
elog(ERROR, "expected another identifier: %s", sstart);
while (*path && !IS_DIR_SEP(*path))
path++;
}
- else if (isalpha(path[0]) && path[1] == ':')
+ else if (isalpha((unsigned char) path[0]) && path[1] == ':')
{
path += 2;
}