summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2012-05-25 05:17:00 +0000
committerlum <lum@cvs.openbsd.org>2012-05-25 05:17:00 +0000
commitb82cffb2fafdead0cd147da659e1ba08785fabf1 (patch)
tree8a345c82141222065918504d2ac5b79b3d3f2bac /usr.bin/mg
parentc06f9338e431f5d8aa884d8e9ecaa833239a6e2e (diff)
Allow searching (C-s or C-r) to wrap around the ends of a buffer.
Even if the search string is located at the beginning or end of a buffer.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/search.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c
index 1226cb6e144..c825c517532 100644
--- a/usr.bin/mg/search.c
+++ b/usr.bin/mg/search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: search.c,v 1.39 2012/04/12 04:47:59 lum Exp $ */
+/* $OpenBSD: search.c,v 1.40 2012/05/25 05:16:59 lum Exp $ */
/* This file is in the public domain. */
@@ -245,17 +245,21 @@ isearch(int dir)
ewprintf("Overwrapped I-search: %s", pat);
break;
}
-
is_lpush();
pptr = strlen(pat);
- (void)forwchar(FFRAND, 1);
- if (is_find(SRCH_FORW) != FALSE)
- is_cpush(SRCH_MARK);
- else {
- (void)backchar(FFRAND, 1);
- ttbeep();
- success = FALSE;
- ewprintf("Failed I-search: %s", pat);
+ if (forwchar(FFRAND, 1) == FALSE) {
+ ttbeep();
+ success = FALSE;
+ ewprintf("Failed I-search: %s", pat);
+ } else {
+ if (is_find(SRCH_FORW) != FALSE)
+ is_cpush(SRCH_MARK);
+ else {
+ (void)backchar(FFRAND, 1);
+ ttbeep();
+ success = FALSE;
+ ewprintf("Failed I-search: %s", pat);
+ }
}
is_prompt(dir, pptr < 0, success);
break;
@@ -280,13 +284,17 @@ isearch(int dir)
}
is_lpush();
pptr = strlen(pat);
- (void)backchar(FFRAND, 1);
- if (is_find(SRCH_BACK) != FALSE)
- is_cpush(SRCH_MARK);
- else {
- (void)forwchar(FFRAND, 1);
- ttbeep();
- success = FALSE;
+ if (backchar(FFRAND, 1) == FALSE) {
+ ttbeep();
+ success = FALSE;
+ } else {
+ if (is_find(SRCH_BACK) != FALSE)
+ is_cpush(SRCH_MARK);
+ else {
+ (void)forwchar(FFRAND, 1);
+ ttbeep();
+ success = FALSE;
+ }
}
is_prompt(dir, pptr < 0, success);
break;