37 int offset, size, rsize;
53 if (rhs = strchr(p,
'=')) {
57 fprintf(
cp_err,
"Error: bad let syntax\n");
62 if (
eq(p,
"all") || strchr(p,
'@')) {
63 fprintf(
cp_err,
"Error: bad variable name %s\n", p);
69 if (s = strchr(p,
'[')) {
72 while (!need_open || *s ==
'[') {
76 for (q = s; *q && (*q !=
']' && *q !=
',' || depth > 0); q++) {
87 if (depth != 0 || !*q) {
88 printf(
"Error: bad syntax specifying index\n");
109 fprintf(
cp_err,
"Error: index is not a scalar.\n");
115 printf(
"Error: negative index (%d) is not allowed\n", j);
119 indices[numdims++] = j;
121 for (s = q; *s && isspace(*s); s++)
127 for (q = p + strlen(p) - 1; *q <=
' ' && p <= q; q--)
141 fprintf(
cp_err,
"Warning: extra wildcard values ignored\n");
151 fprintf(
cp_err,
"Error: too many dimensions\n");
182 for ( ; i < numdims - 1; i++) {
183 n->
v_dims[i] = indices[i] + 1;
185 n->
v_dims[numdims-1] = indices[numdims-1];
193 for (i++,j = 1; j < t->
v_numdims; i++,j++) {
206 offset = size - rsize;
209 fprintf(
cp_err,
"Error: internal, bad length\n");
278 fprintf(
cp_err,
"Error: can't set %s to higher dimension\n",
282 for (i = 0; i < numdims-1; i++) {
283 if (indices[i] >= n->
v_dims[i]) {
284 fprintf(
cp_err,
"Error: dimension spec. out of range for %s\n",
290 for (i = numdims, j = 1; j < t->
v_numdims; i++,j++) {
293 "Error: subdimension of %s is incompatible with %s\n",
301 fprintf(
cp_err,
"Error: too few dimensions specified\n");
307 i = indices[numdims-1];
313 "Error: operation would overflow block in %s\n",
323 offset += indices[i]*size;
331 fprintf(
cp_err,
"Error: internal, bad length\n");
361 for (i = 0,j = offset; i < t->
v_length; i++,j++)
367 for (i = 0,j = offset; i < t->
v_length; i++,j++) {
410 char *
s =
copy(wl->wl_word);
427 struct dvlist *tl, *bl, *dl, *dl0, xl;
428 int i, j, ll, width = 0, height = 0, npoints, lineno;
431 bool col =
true, nobreak =
false, noprintscale, plotnames =
false;
432 bool optgiven =
false;
439 if (
eq(wl->wl_word,
"col")) {
444 else if (
eq(wl->wl_word,
"line")) {
469 for (dl = dl0; dl; dl = dl->
dl_next) {
479 for (dl = dl0; dl; dl = dl->
dl_next) {
489 for (s = buf; *s; s++)
492 while (isspace(*s)) {
527 (void) sprintf(buf,
"%s",
529 (void) sprintf(buf+strlen(buf),
",%s",
585 for (dl = bl; dl; dl = dl->
dl_next) {
591 if ((ll > width) && (dl != bl) && (dl != bl->
dl_next))
597 j = (width - strlen(p->
pl_title)) / 2;
598 for (i = 0; i < j; i++)
606 j = (width - strlen(buf)) / 2;
609 for (i = 0; i < width; i++)
612 buf2[width+1] =
'\0';
614 (void) sprintf(buf,
"Index ");
615 for (tl = bl; tl && tl != dl; tl = tl->
dl_next) {
618 (
void) sprintf(buf2,
"%-16.15s", v->
v_name);
620 (
void) sprintf(buf2,
"%-32.31s", v->
v_name);
621 (void) strcat(buf, buf2);
626 for (tl = bl; tl && tl != dl; tl = tl->
dl_next) {
635 for (i = 0; i < width; i++)
638 buf2[width+1] =
'\0';
642 while ((j < npoints) && (lineno < height)) {
644 for (tl = bl; tl && tl != dl; tl = tl->
dl_next) {
667 if ((j == npoints) && (dl ==
NULL))
705 struct dvlist *dl, *dn, *dp, *dl0;
707 struct plot *tpl, newplot;
711 bool scalefound, appendwrite;
721 if (
eq(buf,
"binary"))
723 else if(
eq(buf,
"oct"))
725 else if (!
eq(buf,
"ascii"))
726 fprintf(
cp_err,
"Warning: strange file type %s\n", buf);
748 bcopy((
char *) tpl, (
char *) &newplot,
sizeof (
struct plot));
757 for (dl = dl0; dl; dl = dl->
dl_next) {
790 for (tl = wl0; tl; tl = tl->
wl_next) {
793 for (tll = wl0; tll; tll = tll->
wl_next) {
818 raw_write(file, &newplot, appendwrite, ascii ?
false :
true);
821 for (dp =
NULL, dl = dl0; dl; dl = dn) {
835 for (tl = wl0; tl; tl = tl->
wl_next) {
893 s =
copy(wl->wl_word);
898 fprintf(
cp_err,
"Error: no such vector as %s.\n",
908 if (wl->wl_next ==
NULL)
913 fprintf(
cp_err,
"Error (internal): no current plot\n");
919 out_printf(
"There are no vectors currently active.\n");
924 out_printf(
"Here are the vectors currently active:\n\n");
931 for (tl = tl0; tl; tl = tl->
wl_next) {
938 for (tl = tl0; tl; tl = tl->
wl_next) {
957 sprintf(buf,
" %-20s: %s, %s, %d long", d->v_name,
959 "complex", d->v_length);
961 sprintf(buf2,
", min = %lg", d->v_minsignal);
965 sprintf(buf,
", max = %lg", d->v_maxsignal);
968 switch (d->v_gridtype) {
971 strcat(buf,
", grid = loglog");
975 strcat(buf,
", grid = xlog");
979 strcat(buf,
", grid = ylog");
983 strcat(buf,
", grid = polar");
987 strcat(buf,
", grid = smith");
990 switch (d->v_plottype) {
993 strcat(buf,
", plot = comb");
997 strcat(buf,
", plot = point");
1001 if (d->v_defcolor) {
1002 sprintf(buf2,
", color = %s", d->v_defcolor);
1006 sprintf(buf2,
", scale = %s", d->v_scale->v_name);
1009 if (d->v_numdims > 1) {
1010 sprintf(buf2,
", dims = [");
1012 for (i = 0; i < d->v_numdims; i++) {
1013 sprintf(buf2,
"%d%s", d->v_dims[i],
1018 if (d->v_plot->pl_scale == d) {
1019 strcat(buf,
" [default scale]\n");
1038 char *zz =
"Type the name of the desired plot: ";
1053 for (s = buf; *s && !isspace(*s); s++)
1058 (void)
strcpy(buf, wl->wl_word);
1060 if (
prefix(
"new", buf)) {
1072 fprintf(
cp_err,
"Error: no such plot.\n");
1091 struct
dvec **v1, **v2;
1093 return (strcmp((*v1)->v_name, (*v2)->v_name));
1106 static char buf[128];
1109 for (s = d->
v_name; *s; s++)
1114 (void) sprintf(buf,
"V(%s)", d->
v_name);
1117 (void) sprintf(buf,
"I(%s)", d->
v_name);
1133 struct pnode *pn, *p0;
1134 struct dvlist *dl, *tl, *dl0;
1139 newvec = wl->wl_word;
1143 fprintf(
cp_err,
"Error: bad number %s\n", wl->wl_word);
1146 if ((ind = *d) < 0) {
1147 fprintf(
cp_err,
"Error: bad index %d\n", ind);
1156 for (pn = p0; pn; pn = pn->
pn_next) {
1182 for (dl = dl0; dl; dl = dl->
dl_next) {
1201 for (dl = dl0, i = 0; dl; dl = dl->
dl_next, i++) {
1239 else if (
eq(wl->wl_word,
"all")) {
1254 fprintf(
cp_err,
"Error: no such plot %s\n",
struct dvec * ft_evaluate()
static char buf[MAXPROMPT]
bool cp_getvar(char *n, int t, char *r)
struct plot * plot_alloc()
void com_destroy(wordlist *wl)
struct dvlist * ft_dvlist()
void com_cross(wordlist *wl)
struct pnode * ft_getpnames()
void com_splot(wordlist *wl)
void com_let(wordlist *wl)
static struct dvec * copyvec()
void com_print(wordlist *wl)
void com_display(wordlist *wl)
void com_write(wordlist *wl)
char * SCEDfgets(char *s, int n, FILE *fp, char *prompt)
void com_load(wordlist *wl)
void com_unlet(wordlist *wl)
struct wordlist * wl_next
void bcopy(char *from, char *to, int num)