From 6e3bbd49aee93da3849fb0944e4db9d87c4bf8e9 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 2 Nov 2010 17:31:19 +0000 Subject: [PATCH] casts, to make int <-> char conversions explicit --- ChangeLog | 14 ++++++++++++ src/frontend/inpcom.c | 12 ++++++----- src/frontend/parser/lexical.c | 26 +++++++++++------------ src/frontend/quote.c | 4 ++-- src/frontend/subckt.c | 2 +- src/main.c | 2 +- src/spicelib/parser/inpcfix.c | 2 +- src/xspice/cmpp/pp_lst.c | 2 +- src/xspice/cmpp/util.c | 2 +- src/xspice/icm/digital/d_source/cfunc.mod | 4 ++-- src/xspice/icm/digital/d_state/cfunc.mod | 4 ++-- src/xspice/ipc/ipctiein.c | 6 +++--- 12 files changed, 48 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index eba0a674a..ddca71f32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-11-02 Robert Larice + * src/frontend/inpcom.c , + * src/frontend/parser/lexical.c , + * src/frontend/quote.c , + * src/frontend/subckt.c , + * src/main.c , + * src/spicelib/parser/inpcfix.c , + * src/xspice/cmpp/pp_lst.c , + * src/xspice/cmpp/util.c , + * src/xspice/icm/digital/d_source/cfunc.mod , + * src/xspice/icm/digital/d_state/cfunc.mod , + * src/xspice/ipc/ipctiein.c : + casts, to make int <-> char conversions explicit + 2010-11-02 Robert Larice * src/frontend/display.c , * src/frontend/numparam/mystring.c : diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index a3d218106..66c9a6c06 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -135,7 +135,7 @@ readline(FILE *fd) while((c = getc(fd)) != EOF) { if (strlen == 0 && (c == '\t' || c == ' ')) /* Leading spaces away */ continue; - strptr[strlen] = c; + strptr[strlen] = (char) c; strlen++; if( strlen >= memlen ) { memlen += STRGROW; @@ -1217,7 +1217,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c /* lower case the file name for later string compares */ /* s_ptr = strdup(s); */ s_lower = strdup(s); - for(s_ptr = s_lower; *s_ptr && (*s_ptr != '\n'); s_ptr++) *s_ptr = tolower(*s_ptr); + for(s_ptr = s_lower; *s_ptr && (*s_ptr != '\n'); s_ptr++) + *s_ptr = (char) tolower(*s_ptr); found_library = FALSE; for ( i = 0; i < num_libraries; i++ ) { @@ -1356,7 +1357,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c premature end. If premature end is reached, spew error and zap the line. */ if ( !ciprefix( "write", buffer ) ) { // exclude 'write' command so filename case preserved - for (s = buffer; *s && (*s != '\n') && (*s != '\0'); s++) *s = tolower(*s); + for (s = buffer; *s && (*s != '\n') && (*s != '\0'); s++) + *s = (char) tolower(*s); if (!*s) { //fprintf(cp_err, "Warning: premature EOF\n"); } @@ -1701,7 +1703,7 @@ inp_casefix(char *string) while (*string) { #ifdef HAS_ASCII /* ((*string) & 0177): mask off all but the first seven bits, 0177: octal */ - *string = strip(*string); + *string = (char) strip(*string); #endif if (*string == '"') { *string++ = ' '; @@ -1714,7 +1716,7 @@ inp_casefix(char *string) if (!isspace(*string) && !isprint(*string)) *string = '_'; if (isupper(*string)) - *string = tolower(*string); + *string = (char) tolower(*string); string++; } return; diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index ee034cdb6..84d42fd53 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -138,7 +138,7 @@ nloop: i = 0; gotchar: if ((c != EOF) && (c != ESCAPE)) - linebuf[j++] = c; + linebuf[j++] = (char) c; if (c != EOF) numeofs = 0; if (i == NEW_BSIZE_SP - 1) { @@ -156,7 +156,7 @@ gotchar: c = strip(c); /* Don't need to do this really. */ if ((c == '\\' && DIR_TERM != '\\') || (c == '\026') /* ^V */ ) { c = quote(string ? *string++ : input(cp_inp_cur)); - linebuf[j++] = strip(c); + linebuf[j++] = (char) strip(c); } if ((c == '\n') && cp_bqflag) c = ' '; @@ -202,8 +202,8 @@ gotchar: if ((c == '\n') || (c == EOF) || (c == ESCAPE)) goto gotchar; else { - buf[i++] = quote(c); - linebuf[j++] = c; + buf[i++] = (char) quote(c); + linebuf[j++] = (char) c; } } linebuf[j++] = '\''; @@ -218,14 +218,14 @@ gotchar: if ((c == '\n') || (c == EOF) || (c == ESCAPE)) goto gotchar; else if (c == '\\') { - linebuf[j++] = c; + linebuf[j++] = (char) c; c = (string ? *string++ : input(cp_inp_cur)); - buf[i++] = quote(c); - linebuf[j++] = c; + buf[i++] = (char) quote(c); + linebuf[j++] = (char) c; } else { - buf[i++] = c; - linebuf[j++] = c; + buf[i++] = (char) c; + linebuf[j++] = (char) c; } } buf[i++] = d; @@ -289,19 +289,19 @@ gotchar: } goto ldefault; case ';': /*CDHW semicolon inside parentheses is part of expression CDHW*/ if (paren > 0) { - buf[i++]=c; + buf[i++] = (char) c; break; } goto ldefault; case '&': /* va: $&name is one word */ if (i==1 && buf[i-1]=='$' && c=='&') { - buf[i++]=c; + buf[i++] = (char) c; break; } goto ldefault; /* else continue with default ... */ case '<': case '>': /* va: <=, >= are unbreakable words */ if(string) if (i==0 && (*string=='=')) { - buf[i++]=c; + buf[i++] = (char) c; break; } goto ldefault; /* else continue with default ... */ default: @@ -313,7 +313,7 @@ ldefault: if ((cp_chars[c] & CPC_BRL) && (i > 0)) { newword; } } - buf[i++] = c; + buf[i++] = (char) c; if (cp_chars[c] & CPC_BRR) { if ((c != '<') || (i < 2) || (buf[i - 2] != '$')) { diff --git a/src/frontend/quote.c b/src/frontend/quote.c index 1f9c8e406..8316c01dd 100644 --- a/src/frontend/quote.c +++ b/src/frontend/quote.c @@ -24,7 +24,7 @@ cp_wstrip(char *str) if (str) while ((c = *str)) { /* assign and test */ - d = strip(c); + d = (char) strip(c); if (c != d) *str = d; str++; @@ -39,7 +39,7 @@ cp_quoteword(char *str) { if (str) while (*str) { - *str = quote(*str); + *str = (char) quote(*str); str++; } return; diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 1f932c1b5..7ea18f219 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -2095,7 +2095,7 @@ static int inp_numnodes(char c) { if (isupper(c)) - c = tolower(c); + c = (char) tolower(c); switch (c) { case ' ': case '\t': diff --git a/src/main.c b/src/main.c index dfa907a7f..12de56a91 100644 --- a/src/main.c +++ b/src/main.c @@ -472,7 +472,7 @@ prompt(void) if (*(s + 1)) p += sprintf(p, "%c", strip(*++s)); default: - *p = strip(*s); ++p; + *p = (char) strip(*s); ++p; break; } s++; diff --git a/src/spicelib/parser/inpcfix.c b/src/spicelib/parser/inpcfix.c index d83f56582..16dcc7edc 100644 --- a/src/spicelib/parser/inpcfix.c +++ b/src/spicelib/parser/inpcfix.c @@ -17,7 +17,7 @@ void INPcaseFix(register char *string) while (*string) { if (isupper(*string)) { - *string = tolower(*string); + *string = (char) tolower(*string); } string++; } diff --git a/src/xspice/cmpp/pp_lst.c b/src/xspice/cmpp/pp_lst.c index 0b59e5d2b..91a80a629 100755 --- a/src/xspice/cmpp/pp_lst.c +++ b/src/xspice/cmpp/pp_lst.c @@ -1061,7 +1061,7 @@ static Status_t read_udn_type_name( name[i] = '\0'; } else if(c != EOF) - name[i++] = c; + name[i++] = (char) c; } while((c != EOF) && (! found)); } } while((c != EOF) && (! found)); diff --git a/src/xspice/cmpp/util.c b/src/xspice/cmpp/util.c index 079ecb1d0..e092ceef3 100755 --- a/src/xspice/cmpp/util.c +++ b/src/xspice/cmpp/util.c @@ -79,7 +79,7 @@ void str_to_lower(char *s) for(i = 0; (c = s[i]) != '\0'; i++) if(isalpha(c)) if(isupper(c)) - s[i] = tolower(c); + s[i] = (char) tolower(c); } diff --git a/src/xspice/icm/digital/d_source/cfunc.mod b/src/xspice/icm/digital/d_source/cfunc.mod index 36614bfc5..c33cba50a 100644 --- a/src/xspice/icm/digital/d_source/cfunc.mod +++ b/src/xspice/icm/digital/d_source/cfunc.mod @@ -381,7 +381,7 @@ float *p_value ) /* OUT - The numerical value */ else { if(isupper(c)) - c = tolower(c); + c = (char) tolower(c); switch(c) { @@ -425,7 +425,7 @@ float *p_value ) /* OUT - The numerical value */ break; } if(islower(c1)) - c1 = toupper(c1); + c1 = (char) toupper(c1); if(c1 == 'E') scale_factor = 1.0e6; else if(c1 == 'I') diff --git a/src/xspice/icm/digital/d_state/cfunc.mod b/src/xspice/icm/digital/d_state/cfunc.mod index 49d2f71e8..ed0f82742 100644 --- a/src/xspice/icm/digital/d_state/cfunc.mod +++ b/src/xspice/icm/digital/d_state/cfunc.mod @@ -440,7 +440,7 @@ float *p_value ) /* OUT - The numerical value */ else { if(islower(c)) - c = tolower(c); + c = (char) tolower(c); switch(c) { @@ -484,7 +484,7 @@ float *p_value ) /* OUT - The numerical value */ break; } if(islower(c1)) - c1 = toupper(c1); + c1 = (char) toupper(c1); if(c1 == 'E') scale_factor = 1.0e6; else if(c1 == 'I') diff --git a/src/xspice/ipc/ipctiein.c b/src/xspice/ipc/ipctiein.c index 9e223c048..bd32de09b 100755 --- a/src/xspice/ipc/ipctiein.c +++ b/src/xspice/ipc/ipctiein.c @@ -206,7 +206,7 @@ void ipc_send_stdout(void) len = 0; while( (c=fgetc(stdout)) != EOF) { if(c != '\n') { - buf[len] = c; + buf[len] = (char) c; len++; } if((c == '\n') || (len == IPC_MAX_LINE_LEN)) { @@ -252,7 +252,7 @@ void ipc_send_stderr(void) len = 0; while( (c=fgetc(stderr)) != EOF) { if(c != '\n') { - buf[len] = c; + buf[len] = (char) c; len++; } if((c == '\n') || (len == IPC_MAX_LINE_LEN)) { @@ -336,7 +336,7 @@ Ipc_Boolean_t ipc_screen_name(char *name, char *mapped_name) } else { if(islower(name[i])) - mapped_name[i] = toupper(name[i]); + mapped_name[i] = (char) toupper(name[i]); else mapped_name[i] = name[i]; }