(xdprval): Fix for strings with characters printed as escapes. Print
null pointer as `nil' to distinguish it from empty string.
This commit is contained in:
parent
7a4f133d1c
commit
5346422665
1 changed files with 11 additions and 9 deletions
|
@ -303,17 +303,19 @@ xdprval(struct valstr *val, char *sep)
|
||||||
pr("%s%g", sep, val->val_as.dbl);
|
pr("%s%g", sep, val->val_as.dbl);
|
||||||
break;
|
break;
|
||||||
case NSC_STRING:
|
case NSC_STRING:
|
||||||
pr("%s\"", sep);
|
|
||||||
s = val->val_as.str;
|
s = val->val_as.str;
|
||||||
while (s && *s) {
|
if (s) {
|
||||||
|
pr("%s\"", sep);
|
||||||
|
while (*s) {
|
||||||
for (e = s; *e != '"' && isprint(*e); ++e) ;
|
for (e = s; *e != '"' && isprint(*e); ++e) ;
|
||||||
pr("%*s", (int)(e-s), s);
|
pr("%.*s", (int)(e-s), s);
|
||||||
for (; *e && !isprint(*e); ++e) {
|
if (*e)
|
||||||
pr("\\%3o", *e);
|
pr("\\%03o", *e++);
|
||||||
}
|
|
||||||
s = e;
|
s = e;
|
||||||
}
|
}
|
||||||
prnf("\"");
|
prnf("\"");
|
||||||
|
} else
|
||||||
|
pr("%snil", sep);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CANT_HAPPEN("Bad VAL type");
|
CANT_HAPPEN("Bad VAL type");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue