v(/out) --> v("/out") when node name starts with math or number char
for 'plot', 'write', 'print'
This commit is contained in:
parent
6cc5ed3dbf
commit
0de8fb8783
|
|
@ -297,6 +297,9 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
char *nxlabel = NULL, *nylabel = NULL, *ntitle = NULL;
|
char *nxlabel = NULL, *nylabel = NULL, *ntitle = NULL;
|
||||||
double tstep, tstart, tstop, ttime;
|
double tstep, tstart, tstop, ttime;
|
||||||
|
|
||||||
|
/* v(/out) --> v("/out") when node name starts with math or number char */
|
||||||
|
set_double_quotes(wl);
|
||||||
|
|
||||||
/* Save start of vectors on entry for cleaning up junk left behind
|
/* Save start of vectors on entry for cleaning up junk left behind
|
||||||
* by ft_getpnames() */
|
* by ft_getpnames() */
|
||||||
struct dvec *dv_head_orig =
|
struct dvec *dv_head_orig =
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
||||||
|
|
||||||
#include "ngspice/compatmode.h"
|
#include "ngspice/compatmode.h"
|
||||||
|
|
||||||
|
bool set_double_quotes(wordlist* wl);
|
||||||
static void killplot(struct plot *pl);
|
static void killplot(struct plot *pl);
|
||||||
static void DelPlotWindows(struct plot *pl);
|
static void DelPlotWindows(struct plot *pl);
|
||||||
|
|
||||||
|
|
@ -47,6 +48,50 @@ is_scale_vec_of_current_plot(const char *v_name)
|
||||||
} /* end of function is_scale_vec_of_current_plot */
|
} /* end of function is_scale_vec_of_current_plot */
|
||||||
|
|
||||||
|
|
||||||
|
/* writing, printing or plotting will fail when the node name starts with
|
||||||
|
a number or math character, even when enclosed in V() like V(2p). So
|
||||||
|
automatically place "" around, like V("2p"). Take care in the code
|
||||||
|
following set_double_quotes() that the double quotes are removed when
|
||||||
|
printing the name. Returns TRUE when quotes have been set. Multiple
|
||||||
|
v() may occur in a row.
|
||||||
|
*/
|
||||||
|
bool set_double_quotes(wordlist* wl)
|
||||||
|
{
|
||||||
|
wordlist* wltmp;
|
||||||
|
bool retval = FALSE;
|
||||||
|
for (wltmp = wl; wltmp; wltmp = wltmp->wl_next) {
|
||||||
|
char* tmpstr, *tmpstr1, *tmpstr2 = NULL, *newstr;
|
||||||
|
tmpstr = tmpstr1 = wltmp->wl_word;
|
||||||
|
while (tmpstr && *tmpstr != '\0') {
|
||||||
|
tmpstr = strstr(tmpstr, "v(");
|
||||||
|
if (!tmpstr)
|
||||||
|
continue;
|
||||||
|
else if (tmpstr == wltmp->wl_word && tmpstr[2] != '\"')
|
||||||
|
tmpstr2 = tmpstr;
|
||||||
|
else if (tmpstr[2] == '\"' || (!isspace_c(tmpstr[-1]) && !is_arith_char(tmpstr[-1]))) {
|
||||||
|
tmpstr++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmpstr2 = tmpstr;
|
||||||
|
/* test if math character or number */
|
||||||
|
if (tmpstr2 && (is_arith_char(tmpstr2[2]) || isdigit(tmpstr2[2]))) {
|
||||||
|
char* mstr;
|
||||||
|
tmpstr2 += 2;
|
||||||
|
char* bstr = copy_substring(wltmp->wl_word, tmpstr2);
|
||||||
|
mstr = gettok_char(&tmpstr2, ')', FALSE, FALSE);
|
||||||
|
newstr = tprintf("%s%s%s%s%s", bstr, "\"", mstr, "\"", tmpstr2);
|
||||||
|
tfree(bstr);
|
||||||
|
tfree(mstr);
|
||||||
|
tfree(wltmp->wl_word);
|
||||||
|
wltmp->wl_word = tmpstr = newstr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmpstr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove vectors in the wordlist from the current plot */
|
/* Remove vectors in the wordlist from the current plot */
|
||||||
void
|
void
|
||||||
|
|
@ -133,6 +178,8 @@ com_print(wordlist *wl)
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
set_double_quotes(wl);
|
||||||
|
|
||||||
buf = TMALLOC(char, BSIZE_SP);
|
buf = TMALLOC(char, BSIZE_SP);
|
||||||
buf2 = TMALLOC(char, BSIZE_SP);
|
buf2 = TMALLOC(char, BSIZE_SP);
|
||||||
|
|
||||||
|
|
@ -441,6 +488,7 @@ com_write(wordlist *wl)
|
||||||
if (wl) {
|
if (wl) {
|
||||||
file = wl->wl_word;
|
file = wl->wl_word;
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
|
set_double_quotes(wl);
|
||||||
} else {
|
} else {
|
||||||
file = ft_rawfile;
|
file = ft_rawfile;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,9 @@ extern int ft_findpoint(double pt, double *lims, int maxp, int minp, bool islog)
|
||||||
extern double *ft_minmax(struct dvec *v, bool real);
|
extern double *ft_minmax(struct dvec *v, bool real);
|
||||||
extern void ft_graf(struct dvec *v, struct dvec *xs, bool nostart);
|
extern void ft_graf(struct dvec *v, struct dvec *xs, bool nostart);
|
||||||
|
|
||||||
|
/* postcoms.c */
|
||||||
|
extern bool set_double_quotes(wordlist * wl);
|
||||||
|
|
||||||
/* rawfile.c */
|
/* rawfile.c */
|
||||||
extern int raw_prec;
|
extern int raw_prec;
|
||||||
extern void raw_write(char *name, struct plot *pl, bool app, bool binary);
|
extern void raw_write(char *name, struct plot *pl, bool app, bool binary);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue