From c280ff3fc48ebc02f868fbaf11e060465d29375d Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Thu, 29 Aug 2019 11:06:05 +0100 Subject: [PATCH] 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. --- Nasal/prop_key_handler.nas | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Nasal/prop_key_handler.nas b/Nasal/prop_key_handler.nas index 8ae79267d..586dae5a1 100644 --- a/Nasal/prop_key_handler.nas +++ b/Nasal/prop_key_handler.nas @@ -134,7 +134,8 @@ var handle_key = func(key, shift) { return 0; # pass other funny events } elsif (key == `?` and state.value == nil) { - print("\n-- property search: '", text, "' ----------------------------------"); + text = substr(text, 1); + print("\n-- property search: '", text, "' ----------------------------------"); search(props.globals, text); print("-- done --\n"); stop(0); @@ -344,8 +345,16 @@ var print_prop = func(n) { var search = func(n, s) { if (find(s, n.getPath()) >= 0) print_prop(n); - elsif (n.getType() != "NONE" and find(s, "" ~ n.getValue()) >= 0) - print_prop(n); + elsif (n.getType() != "NONE") { + 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()) search(c, s); }