V0.9 Remove some gcc-4.3.4 warnings (Cygwin)

The latest gcc with the latest Cygwin complains when passing a char to
the toupper, tolower, isspace, isalnum, isprint, isdigit or isalpha
functions/macros. These functions are defined to take an integer. This
patch adds cast to int as needed to remove the warnings. After this
there are still two warnings related to a signed/unsigned comparison
in yy_get_next_buffer() (part of flex).
This commit is contained in:
Cary R 2010-04-14 10:31:34 -07:00 committed by Stephen Williams
parent 2b63da8920
commit c56b31c632
7 changed files with 23 additions and 23 deletions

View File

@ -37,13 +37,13 @@ static void translate_file_name(char*text)
break;
case 1:
while (*text) {
*text = toupper(*text);
*text = toupper((int)*text);
text += 1;
}
break;
case 2:
while (*text) {
*text = tolower(*text);
*text = tolower((int)*text);
text += 1;
}
break;

View File

@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 1999-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -754,7 +754,7 @@ static void def_add_arg()
check_for_max_args();
/* Remove trailing white space and, if necessary, opening brace. */
while (isspace(yytext[length - 1]))
while (isspace((int)yytext[length - 1]))
length--;
if (yytext[length - 1] == '(')
@ -884,8 +884,8 @@ static char *find_arg(char*ptr, char*head, char*arg)
* match is not in the middle of another identifier.
*/
if (cp != head &&
(isalnum(*(cp-1)) || *(cp-1) == '_' || *(cp-1) == '$' ||
isalnum(*(cp+len)) || *(cp+len) == '_' || *(cp+len) == '$')) {
(isalnum((int)*(cp-1)) || *(cp-1) == '_' || *(cp-1) == '$' ||
isalnum((int)*(cp+len)) || *(cp+len) == '_' || *(cp+len) == '$')) {
cp++;
continue;
}
@ -952,7 +952,7 @@ static void do_define()
cp = yytext + strlen(yytext);
while (cp > yytext)
{
if (!isspace(cp[-1]))
if (!isspace((int)cp[-1]))
break;
cp -= 1;
@ -968,7 +968,7 @@ static void do_define()
cp -= 1;
cp[0] = 0;
while ((cp > yytext) && isspace(cp[-1])) {
while ((cp > yytext) && isspace((int)cp[-1])) {
cp -= 1;
*cp = 0;
}

View File

@ -1,5 +1,5 @@
const char COPYRIGHT[] =
"Copyright (c) 1999-2009 Stephen Williams (steve@icarus.com)";
"Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)";
/*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -108,7 +108,7 @@ static int flist_read_flags(const char*path)
char*arg;
while (tail > cp) {
if (! isspace(tail[-1]))
if (! isspace((int)tail[-1]))
break;
tail -= 1;
tail[0] = 0;
@ -189,7 +189,7 @@ static int flist_read_names(const char*path)
char*cp = line_buf + strspn(line_buf, " \t\r\b\f");
char*tail = cp + strlen(cp);
while (tail > cp) {
if (! isspace(tail[-1]))
if (! isspace((int)tail[-1]))
break;
tail -= 1;
tail[0] = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -41,7 +41,7 @@ char *as_escaped(char *arg)
cur = 0;
cnt = len;
for (idx = 0; idx < cnt; idx++) {
if (isprint(arg[idx])) {
if (isprint((int)arg[idx])) {
res[cur] = arg[idx];
cur += 1;
} else {
@ -84,7 +84,7 @@ char *get_filename(vpiHandle callh, char *name, vpiHandle file)
*/
len = strlen(val.value.str);
for (idx = 0; idx < len; idx++) {
if (! isprint(val.value.str[idx])) {
if (! isprint((int)val.value.str[idx])) {
char msg [64];
char *esc_fname = as_escaped(val.value.str);
snprintf(msg, 64, "WARNING: %s:%d:",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -450,7 +450,7 @@ static PLI_INT32 sys_readmempath_calltf(PLI_BYTE8*name)
*/
len = strlen(val.value.str);
for (idx = 0; idx < len; idx++) {
if (! isprint(val.value.str[idx])) {
if (! isprint((int)val.value.str[idx])) {
char msg [64];
char *esc_path = as_escaped(val.value.str);
snprintf(msg, 64, "WARNING: %s:%d:",

View File

@ -251,12 +251,12 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
while ( fmtp && *fmtp != 0 && !match_fail) {
if (isspace(*fmtp)) {
if (isspace((int)*fmtp)) {
/* White space matches a string of white space in
the input. The number of spaces is not
relevant, and the match may be 0 or more
spaces. */
while (*fmtp && isspace(*fmtp)) fmtp += 1;
while (*fmtp && isspace((int)*fmtp)) fmtp += 1;
ch = byte_getc(src);
while (isspace(ch)) ch = byte_getc(src);
@ -291,9 +291,9 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
suppress_flag = 1;
fmtp += 1;
}
if (isdigit(*fmtp)) {
if (isdigit((int)*fmtp)) {
length_field = 0;
while (isdigit(*fmtp)) {
while (isdigit((int)*fmtp)) {
length_field *= 10;
length_field += *fmtp - '0';
fmtp += 1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -36,11 +36,11 @@ int is_escaped_id(const char *name)
assert(name);
/* The first digit must be alpha or '_' to be a normal id. */
if (isalpha(name[0]) || name[0] == '_') {
if (isalpha((int)name[0]) || name[0] == '_') {
for (lp=1; name[lp] != '\0'; lp++) {
/* If this digit is not alpha-numeric or '_' we have
* an escaped identifier. */
if (!(isalnum(name[lp]) || name[lp] == '_')) {
if (!(isalnum((int)name[lp]) || name[lp] == '_')) {
return 1;
}
}