From a60dac61249af548a3e87f0b6cb62335de5f2841 Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Sat, 17 May 2025 20:29:38 -0400 Subject: [PATCH] Modified the primary SPICE token reading routine so that the call to strdtok() can differentiate between reading verilog and reading SPICE. Otherwise, SPICE containing the (dubious) syntax of using backslashes in names will get treated as a verilog name with verilog backslash notation, with generally undesirable results. When called from the SPICE reading routine, backslashes are treated as-is and not as verilog notation. --- VERSION | 2 +- base/netfile.c | 17 ++++++++++++++--- base/netfile.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index e5777e5..d7965c4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.294 +1.5.295 diff --git a/base/netfile.c b/base/netfile.c index ff1781b..421acfa 100644 --- a/base/netfile.c +++ b/base/netfile.c @@ -599,7 +599,7 @@ void SpiceTokNoNewline(void) { int contline; - if ((nexttok = strdtok(NULL, WHITESPACE_DELIMITER, NULL)) != NULL) return; + if ((nexttok = strdtok0(NULL, WHITESPACE_DELIMITER, NULL, FALSE)) != NULL) return; while (nexttok == NULL) { contline = getc(infile); @@ -701,7 +701,7 @@ void SpiceSkipNewLine(void) /* the boundary between two-character and one-character delimiters. */ /*----------------------------------------------------------------------*/ -char *strdtok(char *pstring, char *delim1, char *delim2) +char *strdtok0(char *pstring, char *delim1, char *delim2, char isverilog) { static char *stoken = NULL; static char *sstring = NULL; @@ -746,7 +746,7 @@ char *strdtok(char *pstring, char *delim1, char *delim2) /* should know whether it is parsing SPICE or verilog and handle the syntax */ /* accordingly (needs to be done). */ - if (*s == '\\') { + if (isverilog && (*s == '\\')) { s++; while (*s != '\0') { if ((*s == ' ') || ((*s == '\\') && (*(s + 1) == '\0'))) { @@ -817,6 +817,17 @@ char *strdtok(char *pstring, char *delim1, char *delim2) return sstring; } +/*----------------------------------------------------------------------*/ +/* strdtok() is the original string tokenizer. It calls strdtok0() */ +/* with isverilog=TRUE, so that tokens are parsed as (potentially) */ +/* verilog names, which includes verilog backslash notation. */ +/*----------------------------------------------------------------------*/ + +char *strdtok(char *pstring, char *delim1, char *delim2) +{ + return strdtok0(pstring, delim1, delim2, TRUE); +} + /*----------------------------------------------------------------------*/ void InputParseError(FILE *f) diff --git a/base/netfile.h b/base/netfile.h index 84227ad..459712f 100644 --- a/base/netfile.h +++ b/base/netfile.h @@ -36,6 +36,7 @@ extern struct hashdict *definitions; extern char *nexttok; #define SKIPTO(a) do {SkipTok(NULL);} while (!match(nexttok,a)) +extern char *strdtok0(char *pstring, char *delim1, char *delim2, char isverilog); extern char *strdtok(char *pstring, char *delim1, char *delim2); extern char *GetLineAtTok(); extern void SkipTok(char *delimiter);