Improved error message: more info on the bad set form
This commit is contained in:
parent
26c687b088
commit
037293c81e
|
|
@ -390,10 +390,13 @@ static void update_option_variables(const char *sz_var_name,
|
||||||
Without quotes tokens like 2N5401_C will be evaluated as real number 2n, i.e. 2e-9 */
|
Without quotes tokens like 2N5401_C will be evaluated as real number 2n, i.e. 2e-9 */
|
||||||
struct variable *cp_setparse(wordlist *wl)
|
struct variable *cp_setparse(wordlist *wl)
|
||||||
{
|
{
|
||||||
char *name = NULL, *val, *copyval, *s, *ss;
|
char *name = NULL, *val, *copyval, *s, *ss, *printout = NULL;
|
||||||
struct variable *listv = NULL, *vv, *lv = NULL;
|
struct variable *listv = NULL, *vv, *lv = NULL;
|
||||||
struct variable *vars = NULL;
|
struct variable *vars = NULL;
|
||||||
|
|
||||||
|
if (wl)
|
||||||
|
printout = wl_flatten(wl);
|
||||||
|
|
||||||
/* Step through the list of words. Words may be various combinations of
|
/* Step through the list of words. Words may be various combinations of
|
||||||
* the information needed to set a variable. For example, to set x to
|
* the information needed to set a variable. For example, to set x to
|
||||||
* the value 3, the data could be supplied as one word x=3, two words
|
* the value 3, the data could be supplied as one word x=3, two words
|
||||||
|
|
@ -417,8 +420,9 @@ struct variable *cp_setparse(wordlist *wl)
|
||||||
if (wl && eq(wl->wl_word, "=")) { /* name<space>= */
|
if (wl && eq(wl->wl_word, "=")) { /* name<space>= */
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
fprintf(cp_err, "Error: bad set form.\n");
|
fprintf(cp_err, "Error: bad set form in line\n %s", printout);
|
||||||
tfree(name); /*DG: cp_unquote Memory leak*/
|
tfree(name);
|
||||||
|
tfree(printout);
|
||||||
if (ft_stricterror)
|
if (ft_stricterror)
|
||||||
controlled_exit(EXIT_BAD);
|
controlled_exit(EXIT_BAD);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -446,8 +450,9 @@ struct variable *cp_setparse(wordlist *wl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(cp_err, "Error: bad set form.\n");
|
fprintf(cp_err, "Error: bad set form in line\n %s", printout);
|
||||||
tfree(name); /*DG: cp_unquote Memory leak: free name befor exiting */
|
tfree(name);
|
||||||
|
tfree(printout);
|
||||||
if (ft_stricterror)
|
if (ft_stricterror)
|
||||||
controlled_exit(EXIT_BAD);
|
controlled_exit(EXIT_BAD);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -505,8 +510,9 @@ struct variable *cp_setparse(wordlist *wl)
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
}
|
}
|
||||||
if (balance && !wl) {
|
if (balance && !wl) {
|
||||||
fprintf(cp_err, "Error: bad set form.\n");
|
fprintf(cp_err, "Error: bad set form in line\n %s", printout);
|
||||||
tfree(name); /* va: cp_unquote memory leak: free name before exiting */
|
tfree(name);
|
||||||
|
tfree(printout);
|
||||||
if (ft_stricterror)
|
if (ft_stricterror)
|
||||||
controlled_exit(EXIT_BAD);
|
controlled_exit(EXIT_BAD);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -546,6 +552,9 @@ struct variable *cp_setparse(wordlist *wl)
|
||||||
if (name) {
|
if (name) {
|
||||||
tfree(name);
|
tfree(name);
|
||||||
}
|
}
|
||||||
|
if (printout) {
|
||||||
|
tfree(printout);
|
||||||
|
}
|
||||||
return vars;
|
return vars;
|
||||||
} /* end of function cp_setparse */
|
} /* end of function cp_setparse */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue