diff options
author | hoek <hoek@FreeBSD.org> | 1999-09-14 21:20:58 +0000 |
---|---|---|
committer | hoek <hoek@FreeBSD.org> | 1999-09-14 21:20:58 +0000 |
commit | 86df52f412c220bacae074173eb61b229ecdbbf3 (patch) | |
tree | 0cc71e9519426a0ddc1a7ea39a6ae9f78af2d4e5 /usr.bin | |
parent | 177173e8b398772758eacc73bae7457c7488ac8d (diff) | |
download | FreeBSD-src-86df52f412c220bacae074173eb61b229ecdbbf3.zip FreeBSD-src-86df52f412c220bacae074173eb61b229ecdbbf3.tar.gz |
Don't disallow null search patterns --- they are interpreted as being
identical to the previous pattern.
Noticed-by: Jeroen Ruigrok/Asmodai
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/more/ncommand.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/more/ncommand.c b/usr.bin/more/ncommand.c index a6c3b64..1806922 100644 --- a/usr.bin/more/ncommand.c +++ b/usr.bin/more/ncommand.c @@ -1280,7 +1280,8 @@ cstat(cident, args) * * The magicasksearch will ask the user for a regexp and intuit whether they * want to invert the sense of matching or not: if the first character of the - * regexp is a '!', it is removed and the sense is inverted. + * regexp is a '!', it is removed and the sense is inverted. If the regexp + * entered is null, then we will use ${_ls_regexp} (error if not set). * * The toggle options are called _ls_direction and _ls_sense. In addition, * ${_ls_regexp} is set to the regexp used. These variables are only set @@ -1315,9 +1316,6 @@ csearch(cident, args) else getinput("Search: ?", buf, 2); switch (*buf) { - case '\0': - /* Cancelled */ - return args; case '!': /* Magic */ if (direction == FORW) @@ -1333,11 +1331,10 @@ csearch(cident, args) getinput("Search: /", buf, sizeof(buf)); else getinput("Search: ?", buf, sizeof(buf)); + case '\0': sense = NOINVERT; break; } - if (!*buf) - return args; str = buf; break; case SEARCH: @@ -1350,8 +1347,14 @@ csearch(cident, args) if (cident == SEARCH || cident == MAGICASKSEARCH) { settog("_ls_direction", direction, 2, "forw", "back"); settog("_ls_sense", sense, 2, "noinvert", "invert"); - setvar("_ls_regexp", str); + if (*str) + setvar("_ls_regexp", str); } + /* + * XXX Currently search() contains magic to deal with (*str=='\0'). + * This magic should be moved into this function so that we can work + * as described in the function comment header. + */ search(!direction, str, N, !sense); return args; } |