strip WhiteSpaces inside parens of dot cards

This commit is contained in:
dwarning 2007-12-02 22:00:25 +00:00
parent 75d721a38f
commit adaeb6ca81
3 changed files with 34 additions and 2 deletions

View File

@ -8,8 +8,8 @@ $Id$
/*
* Spice-2 compatibility stuff for .plot, .print, .four, and .width.
*/
#include <config.h>
#include <ngspice.h>
#include "ngspice.h"
#include <assert.h>
#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;

View File

@ -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

View File

@ -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