rename gettok_nc() --> nexttok(), and functionalize it
This commit is contained in:
parent
f338dfe27e
commit
45ad60b738
|
|
@ -66,7 +66,7 @@ ft_dotsaves(void)
|
|||
if (ciprefix(".save", iline->wl_word)) {
|
||||
s = iline->wl_word;
|
||||
/* skip .save */
|
||||
gettok_nc(&s);
|
||||
s = nexttok(s);
|
||||
wl = wl_append(wl, gettoks(s));
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ ft_savedotargs(void)
|
|||
isaplot = 0;
|
||||
|
||||
if (isaplot || ciprefix(".print", s)) {
|
||||
gettok_nc(&s);
|
||||
s = nexttok(s);
|
||||
name = gettok(&s);
|
||||
|
||||
if ((w = gettoks(s)) == NULL) {
|
||||
|
|
@ -137,8 +137,8 @@ ft_savedotargs(void)
|
|||
com_save2(w, name);
|
||||
}
|
||||
} else if (ciprefix(".four", s)) {
|
||||
gettok_nc(&s);
|
||||
gettok_nc(&s);
|
||||
s = nexttok(s);
|
||||
s = nexttok(s);
|
||||
if ((w = gettoks(s)) == NULL) {
|
||||
fprintf(cp_err, "Warning: no nodes given: %s\n", iline->wl_word);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1456,7 +1456,7 @@ inp_parse_temper(struct line *card)
|
|||
if (prefix(".model", curr_line)) {
|
||||
struct pt_temper *modtlistnew = NULL;
|
||||
/* remove '.model' */
|
||||
gettok_nc(&curr_line);
|
||||
curr_line = nexttok(curr_line);
|
||||
devmodname = gettok(&curr_line);
|
||||
beg_tstr = curr_line;
|
||||
while ((end_tstr = beg_tstr = strstr(beg_tstr, "temper")) != NULL) {
|
||||
|
|
|
|||
|
|
@ -5295,14 +5295,14 @@ replace_token(char *string, char *token, int wherereplace, int total)
|
|||
|
||||
/* get total number of tokens */
|
||||
while (*actstring) {
|
||||
gettok_nc(&actstring);
|
||||
actstring = nexttok(actstring);
|
||||
count++;
|
||||
}
|
||||
/* If total number of tokens correct */
|
||||
if (count == total) {
|
||||
actstring = string;
|
||||
for (i = 1; i < wherereplace; i++)
|
||||
gettok_nc(&actstring);
|
||||
actstring = nexttok(actstring);
|
||||
/* If token to be replaced at right position */
|
||||
if (ciprefix(token, actstring)) {
|
||||
actstring[0] = ' ';
|
||||
|
|
@ -5776,9 +5776,9 @@ inp_poly_err(struct line *card)
|
|||
if ((ciprefix("e", curr_line)) || (ciprefix("g", curr_line)) ||
|
||||
(ciprefix("f", curr_line)) || (ciprefix("h", curr_line)))
|
||||
{
|
||||
gettok_nc(&curr_line);
|
||||
gettok_nc(&curr_line);
|
||||
gettok_nc(&curr_line);
|
||||
curr_line = nexttok(curr_line);
|
||||
curr_line = nexttok(curr_line);
|
||||
curr_line = nexttok(curr_line);
|
||||
if (ciprefix("poly", curr_line)) {
|
||||
fprintf(stderr,
|
||||
"\nError: XSPICE is required to run the 'poly' option in line %d\n",
|
||||
|
|
@ -6037,7 +6037,7 @@ inp_fix_temper_in_param(struct line *deck)
|
|||
/* if we have inserted into a .param line, convert to .func */
|
||||
if (prefix(".param", new_str)) {
|
||||
char *new_tmp_str = new_str;
|
||||
gettok_nc(&new_tmp_str);
|
||||
new_tmp_str = nexttok(new_tmp_str);
|
||||
funcname = gettok_char(&new_tmp_str, '=', FALSE, FALSE);
|
||||
funcbody = copy(new_tmp_str + 1);
|
||||
*funcs_tail_ptr =
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ do_measure(
|
|||
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->li_next) {
|
||||
line = meas_card->li_line;
|
||||
|
||||
gettok_nc(&line); /* discard .meas */
|
||||
line = nexttok(line); /* discard .meas */
|
||||
|
||||
an_type = gettok(&line);
|
||||
resname = gettok(&line);
|
||||
|
|
@ -359,7 +359,7 @@ do_measure(
|
|||
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->li_next) {
|
||||
line = meas_card->li_line;
|
||||
|
||||
gettok_nc(&line); /* discard .meas */
|
||||
line = nexttok(line); /* discard .meas */
|
||||
|
||||
an_type = gettok(&line);
|
||||
resname = gettok(&line);
|
||||
|
|
@ -466,7 +466,7 @@ measure_parse_line(char *line)
|
|||
char *extra_item; /* extra item */
|
||||
|
||||
wl = NULL;
|
||||
gettok_nc(&line);
|
||||
line = nexttok(line);
|
||||
do {
|
||||
item = gettok(&line);
|
||||
if (!(item))
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ inp_getopts(struct line *deck)
|
|||
struct line *
|
||||
inp_getoptsc(char *line, struct line *options)
|
||||
{
|
||||
gettok_nc(&line); /* skip option */
|
||||
line = nexttok(line); /* skip option */
|
||||
|
||||
struct line *next = TMALLOC(struct line, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ raw_read(char *name) {
|
|||
(void) fgets(buf, BSIZE_SP, fp);
|
||||
s = buf;
|
||||
}
|
||||
gettok_nc(&s); /* The strchr field. */
|
||||
s = nexttok(s); /* The strchr field. */
|
||||
if ((t = gettok(&s)) != NULL) {
|
||||
v->v_name = t;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ collect_global_nodes(struct line *c)
|
|||
for (; c; c = c->li_next)
|
||||
if (ciprefix(".global", c->li_line)) {
|
||||
char *s = c->li_line;
|
||||
gettok_nc(&s);
|
||||
s = nexttok(s);
|
||||
while (*s) {
|
||||
char *t = skip_non_ws(s);
|
||||
global_nodes[num_global_nodes++] = copy_substring(s, t);
|
||||
|
|
@ -268,7 +268,7 @@ inp_subcktexpand(struct line *deck) {
|
|||
|
||||
if (ciprefix(model, c->li_line)) {
|
||||
char *s = c->li_line;
|
||||
gettok_nc(&s); /* discard the model keyword */
|
||||
s = nexttok(s); /* discard the model keyword */
|
||||
modnames = wl_cons(gettok(&s), modnames);
|
||||
} /* model name finding routine */
|
||||
}
|
||||
|
|
@ -480,7 +480,7 @@ doit(struct line *deck, wordlist *modnames) {
|
|||
|
||||
sss = TMALLOC(struct subs, 1);
|
||||
|
||||
gettok_nc(&s);
|
||||
s = nexttok(s);
|
||||
|
||||
sss->su_name = gettok(&s);
|
||||
sss->su_args = copy(s);
|
||||
|
|
@ -613,7 +613,7 @@ doit(struct line *deck, wordlist *modnames) {
|
|||
/* prepend the translated model names to the list `modnames' */
|
||||
modnames = modtranslate(su_deck, scname, modnames);
|
||||
|
||||
gettok_nc(&t); /* Throw out the subcircuit refdes */
|
||||
t = nexttok(t); /* Throw out the subcircuit refdes */
|
||||
|
||||
/* now invoke translate, which handles the remainder of the
|
||||
* translation.
|
||||
|
|
@ -1512,7 +1512,7 @@ numnodes(char *name, struct subs *subs, wordlist const *modnames)
|
|||
i = 0;
|
||||
s = buf;
|
||||
gotit = 0;
|
||||
gettok_nc(&s); /* Skip component name */
|
||||
s = nexttok(s); /* Skip component name */
|
||||
while ((i <= n) && (*s) && !gotit) {
|
||||
t = gettok_node(&s); /* get nodenames . . . */
|
||||
for (wl = modnames; wl; wl = wl->wl_next)
|
||||
|
|
@ -1606,7 +1606,7 @@ modtranslate(struct line *c, char *subname, wordlist *new_modnames)
|
|||
#endif
|
||||
|
||||
/* swallow ".model" */
|
||||
gettok_nc(&t);
|
||||
t = nexttok(t);
|
||||
|
||||
model_name = gettok(&t);
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ extern double x_atanh(double);
|
|||
extern char *gettok_noparens(char **s);
|
||||
extern char *gettok_node(char **s);
|
||||
extern char *gettok_iv(char **s);
|
||||
extern int gettok_nc(char **s);
|
||||
extern char *nexttok(char *s);
|
||||
extern int get_l_paren(char **s);
|
||||
extern int get_r_paren(char **s);
|
||||
|
||||
|
|
|
|||
|
|
@ -308,35 +308,34 @@ gettok(char **s)
|
|||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* gettok_nc skips over whitespaces and the next token in s, but does not
|
||||
* use TMALLOC or not return anything * but 1 for empty s and 0 if o.k. .
|
||||
* nexttok skips over whitespaces and the next token in s
|
||||
* returns NULL if there is nothing left to skip.
|
||||
* It replaces constructs like txfree(gettok(&actstring)) by
|
||||
* gettok_nc(&actstring). This is derived from the original gettok version.
|
||||
* actstring = nexttok(actstring). This is derived from the original gettok version.
|
||||
* It does not "do the right thing" when
|
||||
* you have parens or commas anywhere in the nodelist.
|
||||
*-------------------------------------------------------------------------*/
|
||||
int
|
||||
gettok_nc(char **s)
|
||||
char *
|
||||
nexttok(char *s)
|
||||
{
|
||||
char c;
|
||||
int paren;
|
||||
int paren = 0;
|
||||
|
||||
paren = 0;
|
||||
*s = skip_ws(*s);
|
||||
if (!**s)
|
||||
return (1);
|
||||
while ((c = **s) != '\0' && !isspace_c(c)) {
|
||||
if (c == '(')
|
||||
s = skip_ws(s);
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
for (;*s && !isspace_c(*s); s++)
|
||||
if (*s == '(')
|
||||
paren += 1;
|
||||
else if (c == ')')
|
||||
else if (*s == ')')
|
||||
paren -= 1;
|
||||
else if (c == ',' && paren < 1)
|
||||
else if (*s == ',' && paren < 1)
|
||||
break;
|
||||
(*s)++;
|
||||
}
|
||||
while (isspace_c(**s) || **s == ',')
|
||||
(*s)++;
|
||||
return (0);
|
||||
|
||||
while (isspace_c(*s) || *s == ',')
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue