summaryrefslogtreecommitdiff
path: root/usr.bin/mg/grep.c
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2005-08-09 00:53:49 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2005-08-09 00:53:49 +0000
commit4eb0925bb60444898b6f1128f225265056cba493 (patch)
tree3ec53231b1f94ee702addb34b93c61049c48d3d8 /usr.bin/mg/grep.c
parent00ce1e5a9f30584652a80b25b75ae622e9f4acdb (diff)
Clean up eread handling in mg. (basically, fallout from the 'enter often
means abort' behaviour added during the hackathon). Eliminates redundant ereply function, fixes miscellaneous cores when aborting, and move a number of assumed pathnames into the prompt text, since they are used there anyway. All changes consistent with emacs behavior ok beck@ many, many moons ago.
Diffstat (limited to 'usr.bin/mg/grep.c')
-rw-r--r--usr.bin/mg/grep.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c
index 8149856fc15..39e543cc286 100644
--- a/usr.bin/mg/grep.c
+++ b/usr.bin/mg/grep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.c,v 1.15 2005/06/03 23:39:55 cloder Exp $ */
+/* $OpenBSD: grep.c,v 1.16 2005/08/09 00:53:48 kjell Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -82,10 +82,11 @@ grep(int f, int n)
MGWIN *wp;
(void)strlcpy(prompt, "grep -n ", sizeof(prompt));
- if ((bufp = eread("Run grep: ", prompt, NFILEN, EFDEF|EFNEW|EFCR))
- == NULL)
+ if ((bufp = eread("Run grep: ", prompt, NFILEN,
+ EFDEF | EFNEW | EFCR)) == NULL)
return (ABORT);
-
+ else if (bufp[0] == '\0')
+ return (FALSE);
(void)snprintf(command, sizeof(command), "%s /dev/null", bufp);
if ((bp = compile_mode("*grep*", command)) == NULL)
@@ -106,8 +107,11 @@ compile(int f, int n)
MGWIN *wp;
(void)strlcpy(prompt, compile_last_command, sizeof(prompt));
- if ((bufp = eread("Compile command: ", prompt, NFILEN, EFDEF|EFNEW|EFCR)) == NULL)
+ if ((bufp = eread("Compile command: ", prompt, NFILEN,
+ EFDEF | EFNEW | EFCR)) == NULL)
return (ABORT);
+ else if (bufp[0] == '\0')
+ return (FALSE);
if (savebuffers(f, n) == ABORT)
return (ABORT);
(void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command));
@@ -162,8 +166,10 @@ gid(int f, int n)
prompt[j] = '\0';
if ((bufp = eread("Run gid (with args): ", prompt, NFILEN,
- (j ? EFDEF : 0)|EFNEW|EFCR)) == NULL)
+ (j ? EFDEF : 0) | EFNEW | EFCR)) == NULL)
return (ABORT);
+ else if (bufp[0] == '\0')
+ return (FALSE);
(void)snprintf(command, sizeof(command), "gid %s", prompt);
if ((bp = compile_mode("*gid*", command)) == NULL)