#include "spice.h"
#include "misc.h"
#include "cpdefs.h"
#include "suffix.h"
Go to the source code of this file.
#define VALIDCHARS "_<#?@.()[]&" |
Definition at line 1007 of file variable.c.
1024 s = (
char *) &vars->va_bool;
1027 s = (
char *) &vars->va_num;
1030 s = (
char *) &vars->va_real;
1033 s = vars->va_string;
1036 s = (
char *)
va_copy(vars->va_vlist);
void va_free(struct variable *v)
struct variable * va_copy(struct variable *v)
struct variable * va_next
struct variable * cp_setparse(wordlist *wl)
void cp_vset(char *varname, char type, char *value)
Definition at line 1226 of file variable.c.
1243 fprintf(
cp_err,
"Error: %s: no such variable\n", n);
1247 fprintf(
cp_err,
"Error: %s not of type list\n", n);
1252 for (vv = v->va_vlist; vv && (num > 0); num--) {
1258 fprintf(
cp_err,
"Error: variable %s not long enough\n", n);
void va_free(struct variable *v)
struct wordlist * wl_next
struct variable * va_next
Definition at line 1197 of file variable.c.
1207 for (tl = wl0; tl; tl = tl->
wl_next)
1212 while (wl !=
NULL) {
void cp_remvar(char *varname)
struct wordlist * wl_next
bool cp_getvar |
( |
char * |
name, |
|
|
int |
type, |
|
|
char * |
retval |
|
) |
| |
Definition at line 1276 of file variable.c.
1286 * (
bool *) retval =
false;
1292 * (
bool *) retval =
true;
1302 d = (
double *) retval;
1308 s =
copy(v->va_string);
1311 (void)
strcpy(retval, s);
1323 "cp_getvar: Internal Error: bad var type %d.\n",
type);
1333 *i = (int) v->va_real;
1338 d = (
double *) retval;
1339 *d = (double) v->va_num;
1343 (void) sprintf(retval,
"%d", v->va_num);
1347 (void) sprintf(retval,
"%f", v->va_real);
Definition at line 1500 of file variable.c.
void va_free(struct variable *v)
static struct avstack av_stack[DEPTH]
Definition at line 1424 of file variable.c.
1464 fprintf(
cp_err,
"Warning: stack overflow\n");
1475 if (td && *ss ==
'\0') {
static struct avstack av_stack[DEPTH]
struct wordlist * wl_next
struct variable * va_next
void cp_remvar |
( |
char * |
varname | ) |
|
Definition at line 942 of file variable.c.
950 if (
eq(varname,
"argv") ||
eq(varname,
"argc")) {
977 "cp_remvar: Internal Error: var %d in list but shouldn't be\n",
983 fprintf(
cp_err,
"Error: %s is a read-only variable.\n",
987 "cp_remvar: Internal Error: var %d in list but shouldn't be\n",
992 fprintf(
cp_err,
"cp_remvar: Internal Error: bad US val %d\n",i);
void va_free(struct variable *v)
Definition at line 1048 of file variable.c.
1052 char *name, *val, *
s, *st;
1062 strchr(name,
'=') ==
NULL) {
1073 if (wl ==
NULL || strchr(name,
'=') !=
NULL)
1078 else if (wl && (*wl->
wl_word ==
'=')) {
1079 if (strchr(name,
'=') !=
NULL)
1084 else if (s = strchr(name,
'=')) {
1085 if (s == name)
goto bad;
1091 "Error: %s equals what?.\n",name);
1124 if (td && *st ==
'\0') {
1131 vv->va_string = val;
1136 fprintf(
cp_err,
"Error: bad set form.\n");
void va_free(struct variable *v)
static struct variable * getlist()
struct wordlist * wl_next
struct variable * va_next
void cp_variablesubst |
( |
wordlist ** |
list | ) |
|
Definition at line 62 of file variable.c.
74 for (wl = wlist; wl; wl = wl->
wl_next) {
77 while (s = strchr(t,
cp_dol)) {
91 for ( ; *s; t++,s++) {
122 if (!*s && (lev1 || lev2)) {
145 "Error: unbalanced parentheses or brackets\n");
158 (void) strcat(buf, nwl->
wl_word);
176 (void) strcat(buf, t);
181 for (i = 0; s < t; s++)
static char buf[MAXPROMPT]
static wordlist * vareval()
struct wordlist * wl_prev
struct wordlist * wl_next
Definition at line 718 of file variable.c.
729 (void) sprintf(buf,
"%s", var->va_bool ?
"true" :
"false");
732 (void) sprintf(buf,
"%d", var->va_num);
736 (void) sprintf(buf,
"%g", var->va_real);
740 if (var->va_string ==
NULL)
741 (void)
strcpy(buf,
"(null)");
743 char *
t =
copy(var->va_string);
750 for (vt = var->va_vlist; vt; vt = vt->
va_next) {
766 "cp_varwl: Internal Error: bad variable type %d\n",
static char buf[MAXPROMPT]
struct wordlist * wl_prev
wordlist * cp_varwl(struct variable *var)
struct wordlist * wl_next
struct variable * va_next
Definition at line 638 of file variable.c.
649 for (v = uv1, i = 0; v; v = v->
va_next)
651 for (v = uv2; v; v = v->
va_next)
658 for (wl = wl0, i = 0; wl; wl = wl->
wl_next, i++) {
662 for (v = uv1; v; v = v->
va_next, i++) {
666 for (v = uv2; v; v = v->
va_next, i++) {
674 for (j = 0; j < i; j++) {
675 if (j &&
eq(vars[j].x_v->va_name, vars[j - 1].
x_v->
va_name))
static wordlist * vareval()
void va_free(struct variable *v)
struct wordlist * wl_next
struct variable * va_next
void cp_vset |
( |
char * |
varname, |
|
|
char |
type, |
|
|
char * |
value |
|
) |
| |
Definition at line 784 of file variable.c.
792 bool alreadythere =
false, rangefound =
false;
799 if (
eq(vname,
"argv") ||
eq(vname,
"argc"))
802 range = strchr(vname,
'[');
808 for (rnum = 0,t = range; isdigit(*t); t++)
809 rnum = rnum * 10 + *t -
'0';
815 "Error: %s is not set, length unknown.\n",vname);
825 fprintf(
cp_err,
"Error: %s is not a list.\n",vname);
828 for (vv = v->va_vlist,i = rnum; vv && i; vv = vv->
va_next,i--);
831 "Error: %d out of range for %s.\n",rnum,vname);
835 fprintf(
cp_err,
"Error: type mismatch for %s.\n",vname);
840 vv->va_bool = *(
int*)value;
843 vv->va_num = *(
int*)value;
846 vv->va_real = *(
double*)value;
850 vv->va_string =
copy(value);
854 vv->va_vlist = (
struct variable*)value;
858 "cp_vset: Internal Error: bad variable type %d.\n",
871 if (* ((
bool *) value) ==
false) {
880 v->va_num = * (
int *) value;
884 v->va_real = * (
double *) value;
888 v->va_string =
copy(value);
892 v->va_vlist = (
struct variable *) value;
897 "cp_vset: Internal Error: bad variable type %d.\n",
type);
919 "cp_vset: Internal Error: %s already there, but 'dont record'\n",
926 fprintf(
cp_err,
"Error: %s is a read-only variable.\n",
930 "cp_vset: Internal Error: it was already there too!!\n");
934 fprintf(
cp_err,
"cp_vset: Internal Error: bad US val %d\n", i);
void va_free(struct variable *v)
void cp_remvar(char *varname)
static char * eval_range()
struct variable * va_next
static char* eval_range |
( |
| ) |
|
|
static |
static char* eval_range |
( |
char * |
string | ) |
|
|
static |
Definition at line 446 of file variable.c.
453 char *
s, *
t, *tok1, *tok2, *tokd =
NULL, *tokb =
NULL;
469 if (!strchr(
string,
'$'))
479 else if (*s ==
']') {
486 else if (*s ==
')') {
490 else if (*s ==
'-' && !lev1 && !lev2) {
510 else if (*s ==
')') {
514 else if (*s ==
']') {
531 if (!*s && tok2 == s) {
560 sprintf(buf,
"%s",tok1);
576 sprintf(buf + strlen(buf),
"%d",i);
579 sprintf(buf + strlen(buf),
"%s",tok2);
static char buf[MAXPROMPT]
static wordlist * vareval()
Definition at line 1144 of file variable.c.
1169 if (vv->va_vlist ==
NULL) {
1179 if (td && *ss ==
'\0') {
void va_free(struct variable *v)
static struct variable * getlist()
struct wordlist * wl_next
static char* iv_special |
( |
| ) |
|
|
static |
static char* iv_special |
( |
char * |
str | ) |
|
|
static |
Definition at line 589 of file variable.c.
599 for (s = str+4; *s; s++) {
618 u =
tmalloc(strlen(t) + strlen(s) + 4);
static wordlist * vareval()
Definition at line 1377 of file variable.c.
1393 nv->va_bool = v->va_bool;
1395 nv->va_real = v->va_real;
1397 nv->va_num = v->va_num;
1399 nv->va_string =
copy(v->va_string);
1401 nv->va_vlist =
va_copy(v->va_vlist);
struct variable * va_copy(struct variable *v)
struct variable * va_next
Definition at line 1357 of file variable.c.
1363 for ( ; v; v = vv) {
void va_free(struct variable *v)
struct variable * va_next
Definition at line 374 of file variable.c.
379 struct variable *vx, *tx, *vn, *vlo, *vl0, *vl1;
385 if (lo != 0 && hi != 0)
399 for (i = 0; i < lo; i++) {
405 for (i = lo; i < hi; i++) {
417 for ( ; vlo; vlo = vn) {
430 for ( ; vlo; vlo = vn) {
wordlist * cp_varwl(struct variable *var)
struct variable * va_next
static wordlist* vareval |
( |
char * |
string | ) |
|
|
static |
Definition at line 193 of file variable.c.
203 string =
copy(
string);
206 if (s = strchr(
string,
'[')) {
215 (void) sprintf(buf,
"%d",
getpid());
223 (void)
strcpy(buf,
"EOF");
225 for (s = buf; *s && (*s !=
'\n'); s++) ;
255 for (v = v->va_vlist, i = 0; v; v = v->
va_next,i++);
262 sprintf(buf,
"%s[%s",s,range);
269 for (v = v->va_vlist, i = 0; v; v = v->
va_next,i++);
275 fprintf(
cp_err,
"Error: %s: no such variable.\n",s);
280 (void) sprintf(buf,
"%d", i);
295 if (!v && isdigit(*
string)) {
299 range =
copy(
string);
305 sprintf(buf,
"%s[%s",
string,range);
310 if (*
string ==
'&' && strchr(
"vViI",*(
string+1)) &&
311 *(
string+2) ==
'(' && *(
string+3) ==
'$')
329 fprintf(
cp_err,
"Error: %s: no such variable.\n",
string);
337 if (!isdigit(*s) && *s !=
'-')
339 "Warning: nonparseable range specified, %s[%s\n",
string,s);
341 for (low = 0; isdigit(*s); s++)
342 low = low * 10 + *s -
'0';
343 if ((*s ==
'-') && isdigit(s[1]))
344 for (up = 0, s++; isdigit(*s); s++)
345 up = up * 10 + *s -
'0';
346 else if (*s ==
'-') {
350 for (up = 0, vv = v->va_vlist; vv; vv = vv->
va_next,up++) ;
static char buf[MAXPROMPT]
void va_free(struct variable *v)
static wordlist * var2wl()
static char * iv_special()
static char * eval_range()
wordlist * cp_varwl(struct variable *var)
struct variable * cp_enqvar()
struct variable * va_next
static int vcmp |
( |
struct xxx * |
v1, |
|
|
struct xxx * |
v2 |
|
) |
| |
|
static |