From 888a934fc56459ebdb51c024bcc40526a4b1f852 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 29 Dec 2007 21:13:23 +0000 Subject: [PATCH] token function for bjt instance --- src/misc/string.c | 29 +++++++++++++++++++++++++++++ src/misc/stringutil.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/misc/string.c b/src/misc/string.c index 7b643ff8d..5b5997730 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -264,6 +264,35 @@ gettok_noparens(char **s) return (copy(buf)); } +char * +gettok_instance(char **s) +{ + char buf[BSIZE_SP]; + int i = 0; + char c; + + while ( isspace(**s) ) + (*s)++; /* iterate over whitespace */ + + if (!**s) + return (NULL); /* return NULL if we come to end of line */ + + while ((c = **s) && + !isspace(c) && + ( **s != '(' ) && + ( **s != ')' ) + ) { + buf[i++] = *(*s)++; + } + buf[i] = '\0'; + + /* Now iterate up to next non-whitespace char */ + while ( isspace(**s) ) + (*s)++; + + return (copy(buf)); +} + /*-------------------------------------------------------------------------* * gettok_node was added by SDB on 12.3.2003 * It acts like gettok, except that it treats parens and commas like diff --git a/src/misc/stringutil.h b/src/misc/stringutil.h index 5085b9472..df5f9b033 100644 --- a/src/misc/stringutil.h +++ b/src/misc/stringutil.h @@ -18,6 +18,8 @@ int ciprefix(register char *p, register char *s); void strtolower(char *str); char * stripWhiteSpacesInsideParens(char *str); char * gettok(char **s); +char * gettok_instance(char **); + #ifdef CIDER /* cider integration */