From c56b31c6320b09b9d41dbbb2200cc13b7351ad75 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 Apr 2010 10:31:34 -0700 Subject: [PATCH] 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). --- driver/cfparse.y | 4 ++-- ivlpp/lexor.lex | 12 ++++++------ ivlpp/main.c | 6 +++--- vpi/sys_priv.c | 6 +++--- vpi/sys_readmem.c | 4 ++-- vpi/sys_scanf.c | 8 ++++---- vpi/vcd_priv.c | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/driver/cfparse.y b/driver/cfparse.y index 002bd289d..0ef9489c6 100644 --- a/driver/cfparse.y +++ b/driver/cfparse.y @@ -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; diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 2a34f8c74..cf2f03ef9 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -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; } diff --git a/ivlpp/main.c b/ivlpp/main.c index 8086bee0e..b256fb632 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -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; diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 231001d1a..c0d13f5c8 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -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:", diff --git a/vpi/sys_readmem.c b/vpi/sys_readmem.c index 8a522625f..638d2ee83 100644 --- a/vpi/sys_readmem.c +++ b/vpi/sys_readmem.c @@ -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:", diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index d17fec3a9..52cd923ee 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -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; diff --git a/vpi/vcd_priv.c b/vpi/vcd_priv.c index cac66f968..1055b7f1a 100644 --- a/vpi/vcd_priv.c +++ b/vpi/vcd_priv.c @@ -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; } }