Re-enable devices like E2 1 0 (2,3) 1

Add a new function nexttok_noparens(const char *s) which
skips tokens. Characters , ( and ) are treated like spaces.
This commit is contained in:
Holger Vogt 2021-01-28 17:06:02 +01:00
parent 433a76a1f2
commit 5747982ae8
3 changed files with 40 additions and 5 deletions

View File

@ -9455,9 +9455,9 @@ static int inp_poly_2g6_compat(struct card* deck) {
case 'g':
case 'e':
case 'f':
curr_line = nexttok(curr_line);
curr_line = nexttok(curr_line);
curr_line = nexttok(curr_line);
curr_line = nexttok_noparens(curr_line);
curr_line = nexttok_noparens(curr_line);
curr_line = nexttok_noparens(curr_line);
/* exclude all of the following fourth tokens */
if (ciprefix("poly", curr_line))
continue;
@ -9488,8 +9488,8 @@ static int inp_poly_2g6_compat(struct card* deck) {
switch (*thisline) {
case 'g':
case 'e':
curr_line = nexttok(curr_line);
curr_line = nexttok(curr_line);
curr_line = nexttok_noparens(curr_line);
curr_line = nexttok_noparens(curr_line);
if (!curr_line) {
fprintf(stderr, "Error: not enough parameters in line\n %s\n", thisline);
fprintf(stderr, "No circuit loaded!\n");

View File

@ -253,6 +253,7 @@ extern char *gettok_noparens(char **s);
extern char *gettok_node(char **s);
extern char *gettok_iv(char **s);
extern char *nexttok(const char *s);
extern char *nexttok_noparens(const char *s);
extern char *gettok_model(char **s);
extern int get_l_paren(char **s);
extern int get_r_paren(char **s);

View File

@ -450,6 +450,40 @@ nexttok(const char *s)
return (char *) s;
}
/*-------------------------------------------------------------------------*
* 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
* actstring = nexttok(actstring). This is derived from the gettok_noparens version.
* It acts like gettok, except that it treats parens and commas like
* whitespace.
*-------------------------------------------------------------------------*/
char*
nexttok_noparens(const char* s)
{
if (!s)
return NULL;
int paren = 0;
s = skip_ws(s);
if (!*s)
return NULL;
for (; *s && !isspace_c(*s); s++)
if (*s == '(')
break;
else if (*s == ')')
break;
else if (*s == ',')
break;
while (isspace_c(*s) || *s == ',' || *s == '(' || *s == ')')
s++;
return (char*)s;
}
/*-------------------------------------------------------------------------*
* gettok skips over whitespaces or '=' and returns the next token found,