Skip to content

Commit

Permalink
General: lstring::gettok: If a token starts with single or double
Browse files Browse the repository at this point in the history
quote, the returned token will contain the entire quoted string, with
the quotes.
WRspice:  forms like v(xx<0>) are now handled in ipc from Xic and from
the Vectors panel without a syntax error when not double quoted.
Xic:  Avoid spurious message and possibly worse from the check function
attempting to connect by location a connect-by-name terminal.
  • Loading branch information
wrcad committed Apr 18, 2020
1 parent aebaf1d commit d752d4c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions wrspice/include/cshell.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ enum CPflag {
CP_NOTTYIO, // Prevent changes to terminal.
CP_WAITING, // True when waiting for input.
CP_RAWMODE, // stdin is in raw mode.
CP_NOBRKTOK, // Lexer shouldn't take <>&; as token sep.
CP_NUMFLAGS
};

Expand Down
2 changes: 1 addition & 1 deletion wrspice/src/cp/front.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ CshPar::FreeBlock(const char *name)

// Prevent redirection for listed commands.
namespace {
const char *const noredirect[] = { "stop", 0 } ; // Only one??
const char *const noredirect[] = { "stop", "plot", "iplot", 0 } ; // More?
}

// If there is an argument, give this to cshpar to use instead of stdin. In
Expand Down
8 changes: 8 additions & 0 deletions wrspice/src/cp/ipcomm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ CshPar::MessageHandler(int fc)

s = buf;
cp_flags[CP_MESSAGE] = true;

// some "secret" interface functions
if (lstring::eq(buf, "inprogress")) {
// Return whether or not a simulation is in progress.
Expand Down Expand Up @@ -519,6 +520,12 @@ CshPar::MessageHandler(int fc)
// Run as WRspice built-in command.
bool intr = cp_flags[CP_INTERACTIVE];
cp_flags[CP_INTERACTIVE] = false;

if (lstring::match("plot", buf) || lstring::match("iplot", buf)) {
// Avoid syntax error on unquoted form like v(xx<0>).
cp_flags[CP_NOBRKTOK] = true;
}

#ifdef WIN32
extern jmp_buf msw_jbf[4];
extern int msw_jbf_sp;
Expand All @@ -541,6 +548,7 @@ CshPar::MessageHandler(int fc)
#endif
cp_flags[CP_CWAIT] = true; // have to reset this
cp_flags[CP_INTERACTIVE] = intr;
cp_flags[CP_NOBRKTOK] = false;
Sp.Periodic();
write_msg("ok");
}
Expand Down
5 changes: 4 additions & 1 deletion wrspice/src/cp/lexical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,12 @@ namespace {


// Return true if c is one of the special characters included, which
// break words
// break words.
//
inline bool breakword(char c)
{
if (CP.GetFlag(CP_NOBRKTOK))
return (false);
return (c == '<' || c == '>' || c == ';' || c == '&');
}
}
Expand All @@ -599,6 +601,7 @@ namespace {

#define FILENO(fp) ((fp) ? fileno(fp) : -1)


wordlist *
CshPar::Lexer(const char *string)
{
Expand Down
7 changes: 6 additions & 1 deletion wrspice/src/plot/doplot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,13 @@ SPgraphics::Plot(wordlist *wl, sGraph *fromgraph, const char *hcopy,
// The plot arguments are converted back to a wordlist, since
// GetPtree(wordlist*,...) handles quoted tokens properly, i.e.,
// quoted tokens are evaluated as separate expressions.
//

CP.SetFlag(CP_NOBRKTOK, true);
// NOBRKTOK allows forms like v(aa<0>) to lex without a syntax
// error when not double-quoted.
wordlist *plotcmd = CP.Lexer(ls_plot.string());
CP.SetFlag(CP_NOBRKTOK, true);

pnlist *pl0 = Sp.GetPtree(plotcmd, false);
wordlist::destroy(plotcmd);
if (pl0 == 0) {
Expand Down
4 changes: 4 additions & 0 deletions xic/src/sced/sced_check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,8 @@ cSced::prptyCheckInst(CDs *sdesc, CDc *cdesc, char **str)
//
CDp_cnode *pcn = (CDp_cnode*)cdesc->prpty(P_NODE);
for ( ; pcn; pcn = pcn->next()) {
if (pcn->has_flag(TE_BYNAME))
continue;
for (unsigned int ix = 0; ; ix++) {
int x, y;
if (!pcn->get_pos(ix, &x, &y))
Expand All @@ -1151,6 +1153,8 @@ cSced::prptyCheckInst(CDs *sdesc, CDc *cdesc, char **str)
}
CDp_bcnode *pb = (CDp_bcnode*)cdesc->prpty(P_BNODE);
for ( ; pb; pb = pb->next()) {
if (pb->has_flag(TE_BYNAME))
continue;
for (unsigned int ix = 0; ; ix++) {
int x, y;
if (!pb->get_pos(ix, &x, &y))
Expand Down
16 changes: 15 additions & 1 deletion xt_base/include/miscutil/lstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,22 @@ namespace lstring {
if (!**s)
return (0);
T *st = *s;
while (is_not_sepchar(**s, sepchars))
if (**s == '"' || **s == '\'') {
// Keep quotes and keep content verbatim.
char q = **s;
(*s)++;
while (**s) {
if (**s == q)
break;
(*s)++;
}
if (**s)
(*s)++;
}
else {
while (is_not_sepchar(**s, sepchars))
(*s)++;
}
char *cbuf = new char[*s - st + 1];
char *c = cbuf;
while (st < *s)
Expand Down

0 comments on commit d752d4c

Please sign in to comment.