1
0
Fork 0

Nasal/prop_key_handler.nas: fixed couple of issues in search ('?') code.

Don't include initial '/' in search string.

Don't fail if a property value is -Nan.
This commit is contained in:
Julian Smith 2019-08-29 11:06:05 +01:00
parent 96fd272a51
commit c280ff3fc4

View file

@ -134,7 +134,8 @@ var handle_key = func(key, shift) {
return 0; # pass other funny events return 0; # pass other funny events
} elsif (key == `?` and state.value == nil) { } elsif (key == `?` and state.value == nil) {
print("\n-- property search: '", text, "' ----------------------------------"); text = substr(text, 1);
print("\n-- property search: '", text, "' ----------------------------------");
search(props.globals, text); search(props.globals, text);
print("-- done --\n"); print("-- done --\n");
stop(0); stop(0);
@ -344,8 +345,16 @@ var print_prop = func(n) {
var search = func(n, s) { var search = func(n, s) {
if (find(s, n.getPath()) >= 0) if (find(s, n.getPath()) >= 0)
print_prop(n); print_prop(n);
elsif (n.getType() != "NONE" and find(s, "" ~ n.getValue()) >= 0) elsif (n.getType() != "NONE") {
print_prop(n); var f = call(func { return find(s, "" ~ n.getValue());}, nil, var err=[]);
if (size(err)) {
# This can happen if value is '-nan'.
printf("got error from n.getValue() for n.getPath()=%s", n.getPath());
}
else if (f >= 0) {
print_prop(n);
}
}
foreach (var c; n.getChildren()) foreach (var c; n.getChildren())
search(c, s); search(c, s);
} }