add new function gettok_node_br which adds braces { } on its list
of ignored characters.
This commit is contained in:
parent
85a04c5693
commit
e25c70b2bb
|
|
@ -236,6 +236,7 @@ extern FILE *newfopen(const char *fn, const char* md);
|
|||
void findtok_noparen(char **p_str, char **p_token, char **p_token_end);
|
||||
extern char *gettok_noparens(char **s);
|
||||
extern char *gettok_node(char **s);
|
||||
extern char *gettok_node_br(char **s);
|
||||
extern char *gettok_iv(char **s);
|
||||
extern char *nexttok(const char *s);
|
||||
extern char *nexttok_noparens(const char *s);
|
||||
|
|
|
|||
|
|
@ -861,6 +861,57 @@ gettok_node(char **s)
|
|||
return copy_substring(token, token_e);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* gettok_node_br acts like gettok_node, including braces { }.
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
char*
|
||||
gettok_node_br(char** s)
|
||||
{
|
||||
char c;
|
||||
const char* token, * token_e;
|
||||
|
||||
if (*s == NULL)
|
||||
return NULL;
|
||||
|
||||
while (isspace_c(**s) ||
|
||||
(**s == '(') ||
|
||||
(**s == ')') ||
|
||||
(**s == '{') ||
|
||||
(**s == '}') ||
|
||||
(**s == ',')
|
||||
)
|
||||
(*s)++; /* iterate over whitespace and ( , ) */
|
||||
|
||||
if (!**s)
|
||||
return NULL; /* return NULL if we come to end of line */
|
||||
|
||||
token = *s;
|
||||
while ((c = **s) != '\0' &&
|
||||
!isspace_c(c) &&
|
||||
(**s != '(') &&
|
||||
(**s != ')') &&
|
||||
(**s != '{') &&
|
||||
(**s != '}') &&
|
||||
(**s != ',')
|
||||
) /* collect chars until whitespace or ( , ) */
|
||||
(*s)++;
|
||||
|
||||
token_e = *s;
|
||||
|
||||
/* Now iterate up to next non-whitespace char */
|
||||
while (isspace_c(**s) ||
|
||||
(**s == '(') ||
|
||||
(**s == ')') ||
|
||||
(**s == '{') ||
|
||||
(**s == '}') ||
|
||||
(**s == ',')
|
||||
)
|
||||
(*s)++; /* iterate over whitespace and ( , ) */
|
||||
|
||||
return copy_substring(token, token_e);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* get_l_paren iterates the pointer forward in a string until it hits
|
||||
|
|
|
|||
Loading…
Reference in New Issue