skip-ws, #6/6, rename to match inpcom.c

This commit is contained in:
rlar 2016-03-21 18:04:39 +01:00
parent 22875d056b
commit b1d8b99018
15 changed files with 48 additions and 48 deletions

View File

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

View File

@ -246,7 +246,7 @@ ft_cpinit(void)
/* jump over leading spaces */
for (copys = s = cp_tildexpand(Lib_Path); copys && *copys; ) {
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
/* copy s into buf until space is seen, r is the actual position */
for (r = buf; *s && !isspace_c(*s); r++, s++)
*r = *s;

View File

@ -133,11 +133,11 @@ atodims(char *p, int *data, int *outlength)
return 0;
}
p = TEMPORARY_SKIP_WS_X1(p);
p = skip_ws(p);
if (*p == '[') {
p++;
p = TEMPORARY_SKIP_WS_X1(p);
p = skip_ws(p);
needbracket = 1;
}
@ -184,7 +184,7 @@ atodims(char *p, int *data, int *outlength)
break;
}
p = TEMPORARY_SKIP_WS_X1(p);
p = skip_ws(p);
}
*outlength = length;

View File

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

View File

@ -396,7 +396,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* get temp from deck */
if (ciprefix(".temp", dd->li_line)) {
s = dd->li_line + 5;
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
if (temperature)
txfree(temperature);
temperature = strdup(s);
@ -404,7 +404,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* Ignore comment lines, but not lines begining with '*#',
but remove them, if they are in a .control ... .endc section */
s = dd->li_line;
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
if ((*s == '*') && ((s != dd->li_line) || (s[1] != '#'))) {
if (commands) {
/* Remove comment lines in control sections, so they don't
@ -420,9 +420,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* Put the first token from line into s */
strncpy(name, dd->li_line, BSIZE_SP);
s = name;
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
t = s;
t = TEMPORARY_SKIP_NON_WS_X0(t);
t = skip_non_ws(t);
*t = '\0';
if (ciprefix(".control", dd->li_line)) {
@ -566,7 +566,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
s = dd->li_line;
*s = '*';
s = dd->li_line + 8;
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
cstoken[0] = gettok_char(&s, '=', FALSE, FALSE);
cstoken[1] = gettok_char(&s, '=', TRUE, FALSE);
cstoken[2] = gettok(&s);
@ -806,7 +806,7 @@ inp_dodeck(
struct line *opt_beg = options;
for (; options; options = options->li_next) {
s = options->li_line;
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = skip_non_ws(s);
ii = cp_interactive;
cp_interactive = FALSE;
@ -987,7 +987,7 @@ inp_dodeck(
/*
* for (; options; options = options->li_next) {
* s = options->li_line;
* s = TEMPORARY_SKIP_NON_WS_X0(s);
* s = skip_non_ws(s);
* ii = cp_interactive;
* cp_interactive = FALSE;
* wl = cp_lexer(s);

View File

@ -80,7 +80,7 @@ com_reshape(wordlist *wl)
wlast = wlast->wl_next;
}
p = TEMPORARY_SKIP_WS_X1(p);
p = skip_ws(p);
switch (state) {
case 0: /* p just at or before a number */
@ -131,7 +131,7 @@ com_reshape(wordlist *wl)
}
}
p = TEMPORARY_SKIP_WS_X1(p);
p = skip_ws(p);
} while (state < 3);

View File

@ -832,7 +832,7 @@ nupa_eval(char *s, int linenum, int orig_linenum)
} else if (c == 'X') {
/* compute args of subcircuit, if required */
ptr = s;
ptr = TEMPORARY_SKIP_NON_WS_X0(ptr);
ptr = skip_non_ws(ptr);
keep = *ptr;
*ptr = '\0';
nupa_inst_name = strdup(s);

View File

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

View File

@ -1036,7 +1036,7 @@ readtics(char *string)
for (k = 0; *words && k < MAXTICS; words = worde) {
words = TEMPORARY_SKIP_WS_X1(words);
words = skip_ws(words);
worde = words;
while (isalpha_c(*worde) || isdigit_c(*worde))

View File

@ -153,9 +153,9 @@ collect_global_nodes(struct line *c)
txfree(gettok(&s));
while (*s) {
char *t = s;
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = skip_non_ws(s);
global_nodes[num_global_nodes++] = copy_substring(t, s);
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
}
c->li_line[0] = '*'; /* comment it out */
}
@ -321,8 +321,8 @@ inp_subcktexpand(struct line *deck) {
} else if (*s == '.') {
continue; /* skip .commands */
} else { /* any other line . . . */
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_non_ws(s);
s = skip_ws(s);
if (*s == '(') {
int level = 0;
@ -492,10 +492,10 @@ doit(struct line *deck, wordlist *modnames) {
/* count the number of args in the .subckt line */
sss->su_numargs = 0;
for (;;) {
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
if (*s == '\0')
break;
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = skip_non_ws(s);
sss->su_numargs ++;
}
}
@ -1310,7 +1310,7 @@ finishLine(struct bxx_buffer *t, char *src, char *scname)
continue;
}
s = src + 1;
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
if (!*s || (*s != '(')) {
lastwasalpha = isalpha_c(*src);
bxx_putc(t, *src++);
@ -1320,7 +1320,7 @@ finishLine(struct bxx_buffer *t, char *src, char *scname)
bxx_putc(t, which = *src);
src = s;
bxx_putc(t, *src++);
src = TEMPORARY_SKIP_WS_X1(src);
src = skip_ws(src);
for (buf = src; *src && !isspace_c(*src) && *src != ',' && *src != ')'; )
src++;
buf_end = src;
@ -1467,7 +1467,7 @@ numnodes(char *name, struct subs *subs, wordlist const *modnames)
const wordlist *wl;
int n, i, gotit;
name = TEMPORARY_SKIP_WS_X1(name);
name = skip_ws(name);
c = *name;
if (isupper_c(c))
@ -1497,8 +1497,8 @@ numnodes(char *name, struct subs *subs, wordlist const *modnames)
int nodes = -2;
for (s = buf; *s; ) {
nodes++;
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_non_ws(s);
s = skip_ws(s);
}
return (nodes);
}
@ -1571,7 +1571,7 @@ static int
numdevs(char *s)
{
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
switch (*s) {
case 'K':
case 'k':
@ -1680,7 +1680,7 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
printf("In devmodtranslate, examining line %s.\n", t);
#endif
t = TEMPORARY_SKIP_WS_X1(t);
t = skip_ws(t);
c = *t; /* set c to first char in line. . . . */
if (isupper_c(c))
c = tolower_c(c);

View File

@ -939,7 +939,7 @@ vec_basename(struct dvec *v)
strtolower(buf);
t = buf;
t = TEMPORARY_SKIP_WS_X1(t);
t = skip_ws(t);
s = t;
for (t = s; *t; t++)
;

View File

@ -1,7 +1,7 @@
#ifndef ngspice_STRINGSKIP_H
#define ngspice_STRINGSKIP_H
static inline char *TEMPORARY_SKIP_NON_WS_X0(char *s) { while (*s && !isspace_c(*s)) s++; return s; }
static inline char *TEMPORARY_SKIP_WS_X1(char *s) { while ( isspace_c(*s)) s++; return s; }
static inline char *skip_non_ws(char *s) { while (*s && !isspace_c(*s)) s++; return s; }
static inline char *skip_ws(char *s) { while ( isspace_c(*s)) s++; return s; }
#endif

View File

@ -283,7 +283,7 @@ gettok(char **s)
char *beg, *token ; /* return token */
paren = 0;
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
if (!**s)
return (NULL);
beg = *s ;
@ -357,7 +357,7 @@ gettok_noparens(char **s)
char c;
char *beg, *token ; /* return token */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
if (!**s)
return (NULL); /* return NULL if we come to end of line */
@ -375,7 +375,7 @@ gettok_noparens(char **s)
token = copy_substring(beg, *s) ;
/* Now iterate up to next non-whitespace char */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
return ( token ) ;
}
@ -386,7 +386,7 @@ gettok_instance(char **s)
char c;
char *beg, *token ; /* return token */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
if (!**s)
return (NULL); /* return NULL if we come to end of line */
@ -403,7 +403,7 @@ gettok_instance(char **s)
token = copy_substring(beg, *s) ;
/* Now iterate up to next non-whitespace char */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
return ( token ) ;
}
@ -420,7 +420,7 @@ gettok_char(char **s, char p, bool inc_p, bool nested)
char c;
char *beg, *token ; /* return token */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
if (!**s)
return (NULL); /* return NULL if we come to end of line */
@ -467,7 +467,7 @@ gettok_char(char **s, char p, bool inc_p, bool nested)
token = copy_substring(beg, *s) ;
/* Now iterate up to next non-whitespace char */
*s = TEMPORARY_SKIP_WS_X1(*s);
*s = skip_ws(*s);
return ( token ) ;
}
@ -664,7 +664,7 @@ get_comma_separated_values( char *values[], char *str ) {
values[count++] = strdup(str);
*ptr = keep;
str = comma_ptr + 1;
str = TEMPORARY_SKIP_WS_X1(str);
str = skip_ws(str);
}
values[count++] = strdup(str);
return count;

View File

@ -43,7 +43,7 @@ tildexpand(char *string)
if (!string)
return NULL;
string = TEMPORARY_SKIP_WS_X1(string);
string = skip_ws(string);
if (*string != '~')
return copy(string);

View File

@ -86,7 +86,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
s += 2;
/* skip any white space */
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
/* reject if not '=' */
if(*s != '=')
@ -95,7 +95,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
s++;
/* skip any white space */
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
/* if we now have +, - or a decimal digit then assume we have a number,
otherwise reject */
@ -103,12 +103,12 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
continue;
/* look for next white space or null */
s = TEMPORARY_SKIP_NON_WS_X0(s);
s = skip_non_ws(s);
left_length = (size_t) (s - current->line);
/* skip any additional white space */
s = TEMPORARY_SKIP_WS_X1(s);
s = skip_ws(s);
/* if we now have +, - or a decimal digit then assume we have the
second number, otherwise reject */