Browse Source

cleanup `skip_ws()' usage

pre-master-46
rlar 10 years ago
parent
commit
5e04924890
  1. 3
      src/frontend/com_let.c
  2. 3
      src/frontend/dimens.c
  3. 3
      src/frontend/help/textdisp.c
  4. 24
      src/frontend/inp.c
  5. 3
      src/frontend/numparam/spicenum.c
  6. 6
      src/frontend/nutinp.c
  7. 10
      src/frontend/subckt.c
  8. 4
      src/frontend/vectors.c
  9. 3
      src/misc/string.c
  10. 10
      src/spicelib/parser/inp2r.c

3
src/frontend/com_let.c

@ -112,8 +112,7 @@ com_let(wordlist *wl)
vec_free(t); vec_free(t);
free_pnode(names); /* frees also t, if pnode `names' is simple value */ free_pnode(names); /* frees also t, if pnode `names' is simple value */
s = q;
s = skip_ws(s);
s = skip_ws(q);
} }
} }
/* vector name at p */ /* vector name at p */

3
src/frontend/dimens.c

@ -136,8 +136,7 @@ atodims(char *p, int *data, int *outlength)
p = skip_ws(p); p = skip_ws(p);
if (*p == '[') { if (*p == '[') {
p++;
p = skip_ws(p);
p = skip_ws(p + 1);
needbracket = 1; needbracket = 1;
} }

3
src/frontend/help/textdisp.c

@ -73,8 +73,7 @@ hlp_thandle(topic **parent)
return (NULL); return (NULL);
} }
s = buf;
s = skip_ws(s);
s = skip_ws(buf);
switch (*s) { switch (*s) {
case '?': case '?':
fprintf(cp_out, fprintf(cp_out,

24
src/frontend/inp.c

@ -395,16 +395,14 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
for (dd = deck->li_next; dd; dd = ld->li_next) { for (dd = deck->li_next; dd; dd = ld->li_next) {
/* get temp from deck */ /* get temp from deck */
if (ciprefix(".temp", dd->li_line)) { if (ciprefix(".temp", dd->li_line)) {
s = dd->li_line + 5;
s = skip_ws(s);
s = skip_ws(dd->li_line + 5);
if (temperature) if (temperature)
txfree(temperature); txfree(temperature);
temperature = strdup(s); temperature = strdup(s);
} }
/* Ignore comment lines, but not lines begining with '*#', /* Ignore comment lines, but not lines begining with '*#',
but remove them, if they are in a .control ... .endc section */ but remove them, if they are in a .control ... .endc section */
s = dd->li_line;
s = skip_ws(s);
s = skip_ws(dd->li_line);
if ((*s == '*') && ((s != dd->li_line) || (s[1] != '#'))) { if ((*s == '*') && ((s != dd->li_line) || (s[1] != '#'))) {
if (commands) { if (commands) {
/* Remove comment lines in control sections, so they don't /* Remove comment lines in control sections, so they don't
@ -419,10 +417,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* Put the first token from line into s */ /* Put the first token from line into s */
strncpy(name, dd->li_line, BSIZE_SP); strncpy(name, dd->li_line, BSIZE_SP);
s = name;
s = skip_ws(s);
t = s;
t = skip_non_ws(t);
s = skip_ws(name);
t = skip_non_ws(s);
*t = '\0'; *t = '\0';
if (ciprefix(".control", dd->li_line)) { if (ciprefix(".control", dd->li_line)) {
@ -563,10 +559,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
wordlist *wlist = NULL; wordlist *wlist = NULL;
char *cstoken[3]; char *cstoken[3];
int i; int i;
s = dd->li_line;
*s = '*';
s = dd->li_line + 8;
s = skip_ws(s);
dd->li_line[0] = '*';
s = skip_ws(dd->li_line + 8);
cstoken[0] = gettok_char(&s, '=', FALSE, FALSE); cstoken[0] = gettok_char(&s, '=', FALSE, FALSE);
cstoken[1] = gettok_char(&s, '=', TRUE, FALSE); cstoken[1] = gettok_char(&s, '=', TRUE, FALSE);
cstoken[2] = gettok(&s); cstoken[2] = gettok(&s);
@ -805,8 +799,7 @@ inp_dodeck(
if (!noparse) { if (!noparse) {
struct line *opt_beg = options; struct line *opt_beg = options;
for (; options; options = options->li_next) { for (; options; options = options->li_next) {
s = options->li_line;
s = skip_non_ws(s);
s = skip_non_ws(options->li_line);
ii = cp_interactive; ii = cp_interactive;
cp_interactive = FALSE; cp_interactive = FALSE;
@ -986,8 +979,7 @@ inp_dodeck(
if (!noparse) { if (!noparse) {
/* /*
* for (; options; options = options->li_next) { * for (; options; options = options->li_next) {
* s = options->li_line;
* s = skip_non_ws(s);
* s = skip_non_ws(options->li_line);
* ii = cp_interactive; * ii = cp_interactive;
* cp_interactive = FALSE; * cp_interactive = FALSE;
* wl = cp_lexer(s); * wl = cp_lexer(s);

3
src/frontend/numparam/spicenum.c

@ -831,8 +831,7 @@ nupa_eval(char *s, int linenum, int orig_linenum)
err = nupa_substitute(dicoS, dicoS->dynrefptr[linenum], s, 0); err = nupa_substitute(dicoS, dicoS->dynrefptr[linenum], s, 0);
} else if (c == 'X') { } else if (c == 'X') {
/* compute args of subcircuit, if required */ /* compute args of subcircuit, if required */
ptr = s;
ptr = skip_non_ws(ptr);
ptr = skip_non_ws(s);
keep = *ptr; keep = *ptr;
*ptr = '\0'; *ptr = '\0';
nupa_inst_name = strdup(s); nupa_inst_name = strdup(s);

6
src/frontend/nutinp.c

@ -94,10 +94,8 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
continue; continue;
} }
(void) strncpy(name, dd->li_line, BSIZE_SP); (void) strncpy(name, dd->li_line, BSIZE_SP);
s = name;
s = skip_ws(s);
t = s;
t = skip_non_ws(t);
s = skip_ws(name);
t = skip_non_ws(s);
*t = '\0'; *t = '\0';
if (ciprefix(".control", dd->li_line)) { if (ciprefix(".control", dd->li_line)) {

10
src/frontend/subckt.c

@ -152,10 +152,9 @@ collect_global_nodes(struct line *c)
char *s = c->li_line; char *s = c->li_line;
txfree(gettok(&s)); txfree(gettok(&s));
while (*s) { while (*s) {
char *t = s;
s = skip_non_ws(s);
global_nodes[num_global_nodes++] = copy_substring(t, s);
s = skip_ws(s);
char *t = skip_non_ws(s);
global_nodes[num_global_nodes++] = copy_substring(s, t);
s = skip_ws(t);
} }
c->li_line[0] = '*'; /* comment it out */ c->li_line[0] = '*'; /* comment it out */
} }
@ -1309,8 +1308,7 @@ finishLine(struct bxx_buffer *t, char *src, char *scname)
bxx_putc(t, *src++); bxx_putc(t, *src++);
continue; continue;
} }
s = src + 1;
s = skip_ws(s);
s = skip_ws(src + 1);
if (!*s || (*s != '(')) { if (!*s || (*s != '(')) {
lastwasalpha = isalpha_c(*src); lastwasalpha = isalpha_c(*src);
bxx_putc(t, *src++); bxx_putc(t, *src++);

4
src/frontend/vectors.c

@ -938,9 +938,7 @@ vec_basename(struct dvec *v)
} }
strtolower(buf); strtolower(buf);
t = buf;
t = skip_ws(t);
s = t;
s = skip_ws(buf);
for (t = s; *t; t++) for (t = s; *t; t++)
; ;
while ((t > s) && isspace_c(t[-1])) while ((t > s) && isspace_c(t[-1]))

3
src/misc/string.c

@ -663,8 +663,7 @@ get_comma_separated_values( char *values[], char *str ) {
ptr++; keep = *ptr; *ptr = '\0'; ptr++; keep = *ptr; *ptr = '\0';
values[count++] = strdup(str); values[count++] = strdup(str);
*ptr = keep; *ptr = keep;
str = comma_ptr + 1;
str = skip_ws(str);
str = skip_ws(comma_ptr + 1);
} }
values[count++] = strdup(str); values[count++] = strdup(str);
return count; return count;

10
src/spicelib/parser/inp2r.c

@ -83,19 +83,13 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
char *p; char *p;
size_t left_length; size_t left_length;
s += 2;
/* skip any white space */
s = skip_ws(s);
s = skip_ws(s + 2);
/* reject if not '=' */ /* reject if not '=' */
if(*s != '=') if(*s != '=')
continue; continue;
s++;
/* skip any white space */
s = skip_ws(s);
s = skip_ws(s + 1);
/* if we now have +, - or a decimal digit then assume we have a number, /* if we now have +, - or a decimal digit then assume we have a number,
otherwise reject */ otherwise reject */

Loading…
Cancel
Save