From adaeb6ca819c325448936d783db0b375eb3b7593 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sun, 2 Dec 2007 22:00:25 +0000 Subject: [PATCH] strip WhiteSpaces inside parens of dot cards --- src/frontend/dotcards.c | 6 ++++-- src/misc/string.c | 29 +++++++++++++++++++++++++++++ src/misc/stringutil.h | 1 + 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/frontend/dotcards.c b/src/frontend/dotcards.c index 0abf04320..cd92466ed 100644 --- a/src/frontend/dotcards.c +++ b/src/frontend/dotcards.c @@ -8,8 +8,8 @@ $Id$ /* * Spice-2 compatibility stuff for .plot, .print, .four, and .width. */ -#include -#include + +#include "ngspice.h" #include #include "cpdefs.h" @@ -495,6 +495,7 @@ fixem(char *string) return (string); } + static wordlist * gettoks(char *s) { @@ -506,6 +507,7 @@ gettoks(char *s) list = NULL; prevp = &list; + s = stripWhiteSpacesInsideParens(s); while ((t = gettok(&s))) { if (*t == '(') continue; diff --git a/src/misc/string.c b/src/misc/string.c index e2c4d058a..7b643ff8d 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -353,6 +353,35 @@ get_r_paren(char **s) return 0; } +/*-------------------------------------------------------------------------* + * this function strips all white space inside parens + * is needed in gettoks (dotcards.c) for right processing of expressions + * like ".plot v( 5,4) v(6)" + *-------------------------------------------------------------------------*/ +char * +stripWhiteSpacesInsideParens(char *str) +{ + char buf[BSIZE_SP]; + int i = 0, j = 0; + + while ( (str[i] == ' ') || (str[i] == '\t') ) + i++; + + for(i=i; str[i]!='\0'; i++) + { + if ( str[i] != '(' ) { + buf[j++] = str[i]; + } else { + buf[j++] = str[i]; + while ( (str[i++] != ')') ) { + if ( str[i] != ' ' ) buf[j++] = str[i]; + } + i--; + } + } + buf[j] = '\0'; + return copy(buf); +} #ifndef HAVE_BCOPY diff --git a/src/misc/stringutil.h b/src/misc/stringutil.h index c17e28827..5085b9472 100644 --- a/src/misc/stringutil.h +++ b/src/misc/stringutil.h @@ -16,6 +16,7 @@ int scannum(char *str); int cieq(register char *p, register char *s); int ciprefix(register char *p, register char *s); void strtolower(char *str); +char * stripWhiteSpacesInsideParens(char *str); char * gettok(char **s); #ifdef CIDER