(nstr_resolve_id): Resolve ambigous name into string if string_ok.
(nstr_comp_val): Break long line.
This commit is contained in:
parent
433f223a14
commit
ba578e0e23
1 changed files with 13 additions and 10 deletions
|
@ -389,22 +389,23 @@ nstr_resolve_id(struct valstr *val, struct castr *ca, int idx, int string_ok)
|
||||||
if (val->val_cat != NSC_ID)
|
if (val->val_cat != NSC_ID)
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
if (idx == M_NOTUNIQUE) {
|
if (idx == M_NOTUNIQUE && !string_ok) {
|
||||||
pr("%.*s -- ambiguous name\n",
|
pr("%.*s -- ambiguous name\n",
|
||||||
(int)val->val_as.str.maxsz, val->val_as.str.base);
|
(int)val->val_as.str.maxsz, val->val_as.str.base);
|
||||||
val->val_cat = NSC_NOCAT;
|
val->val_cat = NSC_NOCAT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idx == M_NOTFOUND && !string_ok) {
|
||||||
|
pr("%.*s -- unknown name\n",
|
||||||
|
(int)val->val_as.str.maxsz, val->val_as.str.base);
|
||||||
|
val->val_cat = NSC_NOCAT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
CANT_HAPPEN(idx != M_NOTFOUND);
|
CANT_HAPPEN(!string_ok);
|
||||||
if (!string_ok) {
|
/* interpret unresolvable identifier as string */
|
||||||
pr("%.*s -- unknown name\n",
|
|
||||||
(int)val->val_as.str.maxsz, val->val_as.str.base);
|
|
||||||
val->val_cat = NSC_NOCAT;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* interpret unbound identifier as string */
|
|
||||||
val->val_type = NSC_STRING;
|
val->val_type = NSC_STRING;
|
||||||
val->val_cat = NSC_VAL;
|
val->val_cat = NSC_VAL;
|
||||||
return val;
|
return val;
|
||||||
|
@ -473,7 +474,9 @@ nstr_comp_val(char *str, struct valstr *val, int type)
|
||||||
{
|
{
|
||||||
struct castr *ca = ef_cadef(type);
|
struct castr *ca = ef_cadef(type);
|
||||||
char *tail = nstr_parse_val(str, val);
|
char *tail = nstr_parse_val(str, val);
|
||||||
return nstr_resolve_id(val, ca, nstr_match_ca(val, ca), 0) ? tail : NULL;
|
if (!nstr_resolve_id(val, ca, nstr_match_ca(val, ca), 0))
|
||||||
|
return NULL;
|
||||||
|
return tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue