diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/autoexec.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/basic.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/buffer.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/dir.c | 10 | ||||
-rw-r--r-- | usr.bin/mg/dired.c | 33 | ||||
-rw-r--r-- | usr.bin/mg/echo.c | 35 | ||||
-rw-r--r-- | usr.bin/mg/extend.c | 14 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/grep.c | 18 | ||||
-rw-r--r-- | usr.bin/mg/help.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/mail.c | 7 | ||||
-rw-r--r-- | usr.bin/mg/main.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/modes.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/re_search.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/region.c | 15 | ||||
-rw-r--r-- | usr.bin/mg/search.c | 8 |
16 files changed, 99 insertions, 93 deletions
diff --git a/usr.bin/mg/autoexec.c b/usr.bin/mg/autoexec.c index 9815c3a089d..b3b1542545c 100644 --- a/usr.bin/mg/autoexec.c +++ b/usr.bin/mg/autoexec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoexec.c,v 1.7 2005/04/29 07:22:38 otto Exp $ */ +/* $OpenBSD: autoexec.c,v 1.8 2005/08/09 00:53:47 kjell Exp $ */ /* this file is in the public domain */ /* Author: Vincent Labrecque <vincent@openbsd.org> April 2002 */ @@ -86,11 +86,13 @@ auto_execute(int f, int n) char patbuf[128], funcbuf[128], *patp, *funcp; int s; - if ((patp = ereply("Filename pattern: ", patbuf, sizeof(patbuf))) == NULL) + if ((patp = eread("Filename pattern: ", patbuf, sizeof(patbuf), + EFNEW | EFCR)) == NULL) return (ABORT); else if (patp[0] == '\0') return (FALSE); - if ((funcp = ereply("Execute: ", funcbuf, sizeof(funcbuf))) == NULL) + if ((funcp = eread("Execute: ", funcbuf, sizeof(funcbuf), + EFNEW | EFCR)) == NULL) return (ABORT); else if (funcp[0] == '\0') return (FALSE); diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 31706dad4af..c24f0a242e0 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.19 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: basic.c,v 1.20 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain */ @@ -439,11 +439,9 @@ gotoline(int f, int n) long nl; if (!(f & FFARG)) { - if ((bufp = ereply("Goto line: ", buf, sizeof(buf))) == NULL) + if ((bufp = eread("Goto line: ", buf, sizeof(buf), + EFNUL | EFNEW | EFCR)) == NULL) return (ABORT); - else if (bufp[0] == '\0') - return (FALSE); - nl = strtol(bufp, &tmp, 10); if (bufp[0] == '\0' || *tmp != '\0') { ewprintf("Invalid number"); diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c index 1cfad3cf97a..45b8e45cfb5 100644 --- a/usr.bin/mg/buffer.c +++ b/usr.bin/mg/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.43 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: buffer.c,v 1.44 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -51,7 +51,7 @@ usebuffer(int f, int n) if (bufp == NULL) return (ABORT); - if (bufn[0] == 0 && curbp->b_altb != NULL) + if (bufp[0] == '\0' && curbp->b_altb != NULL) bp = curbp->b_altb; else if ((bp = bfind(bufn, TRUE)) == NULL) return (FALSE); @@ -82,7 +82,7 @@ poptobuffer(int f, int n) bufn, NBUFN, EFNUL | EFNEW | EFBUF, curbp->b_altb->b_bname); if (bufp == NULL) return (ABORT); - if (bufp[0] == 0 && curbp->b_altb != NULL) + if (bufp[0] == '\0' && curbp->b_altb != NULL) bp = curbp->b_altb; else if ((bp = bfind(bufn, TRUE)) == NULL) return (FALSE); @@ -112,7 +112,7 @@ killbuffer_cmd(int f, int n) if ((bufp = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNUL | EFNEW | EFBUF, curbp->b_bname)) == NULL) return (ABORT); - else if (bufp[0] == 0) + else if (bufp[0] == '\0') bp = curbp; else if ((bp = bfind(bufn, FALSE)) == NULL) return (FALSE); diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index f0db5ff53ec..45b19382137 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.13 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: dir.c,v 1.14 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -37,10 +37,12 @@ changedir(int f, int n) { char bufc[NPAT], *bufp; - if ((bufp = ereply("Change default directory: ", bufc, NPAT)) == NULL) + (void)strlcpy(bufc, wdir, sizeof(bufc)); + if ((bufp = eread("Change default directory: ", bufc, NPAT, + EFDEF | EFNEW | EFCR)) == NULL) return (ABORT); - if (bufc[0] == '\0') - (void)strlcpy(bufc, wdir, sizeof(bufc)); + else if (bufp[0] == '\0') + return (FALSE); if (chdir(bufc) == -1) { ewprintf("Can't change dir to %s", bufc); return (FALSE); diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index 6289e166a30..c4a78f1ca67 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.20 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: dired.c,v 1.21 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -127,7 +127,7 @@ dired(int f, int n) } if (curbp->b_fname && curbp->b_fname[0] != '\0') { - strlcpy(dirname, curbp->b_fname, sizeof(dirname)); + (void)strlcpy(dirname, curbp->b_fname, sizeof(dirname)); if ((slash = strrchr(dirname, '/')) != NULL) { *(slash + 1) = '\0'; } @@ -136,8 +136,11 @@ dired(int f, int n) dirname[0] = '\0'; } - if ((bufp = eread("Dired: ", dirname, NFILEN, EFDEF | EFNEW | EFCR)) == NULL) + if ((bufp = eread("Dired: ", dirname, NFILEN, + EFDEF | EFNEW | EFCR)) == NULL) return (ABORT); + if (bufp[0] == '\0') + return (FALSE); if ((bp = dired_(bufp)) == NULL) return (FALSE); bp->b_modes[0] = name_mode("fundamental"); @@ -157,8 +160,10 @@ d_otherwindow(int f, int n) dirname[0] = '\0'; if ((bufp = eread("Dired other window: ", dirname, NFILEN, - EFNEW | EFCR)) == NULL) + EFDEF | EFNEW | EFCR)) == NULL) return (ABORT); + else if (bufp[0] == '\0') + return (FALSE); if ((bp = dired_(bufp)) == NULL) return (FALSE); if ((wp = popbuf(bp)) == NULL) @@ -319,8 +324,8 @@ d_copy(int f, int n) ewprintf("Directory name too long"); return (FALSE); } - if ((bufp = eread("Copy %s to: ", toname + off, sizeof(toname) - off, - EFNEW | EFCR, basename(frname))) == NULL) + if ((bufp = eread("Copy %s to: ", toname, sizeof(toname), + EFDEF | EFNEW | EFCR, basename(frname))) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); @@ -349,8 +354,8 @@ d_rename(int f, int n) ewprintf("Directory name too long"); return (FALSE); } - if ((bufp = eread("Rename %s to: ", toname + off, - sizeof(toname) - off, EFNEW | EFCR, basename(frname))) == NULL) + if ((bufp = eread("Rename %s to: ", toname, + sizeof(toname), EFDEF | EFNEW | EFCR, basename(frname))) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); @@ -396,18 +401,18 @@ d_shell_command(int f, int n) } command[0] = '\0'; - if ((bufp = eread("! on %s: ", command, sizeof(command), 0, + if ((bufp = eread("! on %s: ", command, sizeof(command), EFNEW, basename(fname))) == NULL) return (ABORT); infd = open(fname, O_RDONLY); if (infd == -1) { ewprintf("Can't open input file : %s", strerror(errno)); - return (ABORT); + return (FALSE); } if (pipe(fds) == -1) { ewprintf("Can't create pipe : %s", strerror(errno)); close(infd); - return (ABORT); + return (FALSE); } newa.sa_handler = reaper; @@ -472,15 +477,15 @@ d_create_directory(int f, int n) off = strlcpy(tocreate, curbp->b_fname, sizeof(tocreate)); if (off >= sizeof(tocreate) - 1) return (FALSE); - if ((bufp = ereply("Create directory: ", tocreate + off, - sizeof(tocreate) - off)) == NULL) + if ((bufp = eread("Create directory: ", tocreate, + sizeof(tocreate), EFDEF | EFNEW | EFCR)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); if (mkdir(tocreate, 0755) == -1) { ewprintf("Creating directory: %s, %s", strerror(errno), tocreate); - return (ABORT); + return (FALSE); } bp = dired_(curbp->b_fname); return (showbuffer(bp, curwp, WFHARD | WFMODE)); diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c index 1dab9a0df0e..79405202862 100644 --- a/usr.bin/mg/echo.c +++ b/usr.bin/mg/echo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: echo.c,v 1.35 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: echo.c,v 1.36 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -86,7 +86,8 @@ eyesno(const char *sp) if (inmacro) return (TRUE); #endif /* !NO_MACRO */ - rep = ereply("%s? (yes or no) ", buf, sizeof(buf), sp); + rep = eread("%s? (yes or no) ", buf, sizeof(buf), + EFNUL | EFNEW | EFCR, sp); for (;;) { if (rep == NULL) return (ABORT); @@ -110,37 +111,19 @@ eyesno(const char *sp) (rep[2] == '\0')) return (FALSE); } - rep = ereply("Please answer yes or no. %s? (yes or no) ", - buf, sizeof(buf), sp); + rep = eread("Please answer yes or no. %s? (yes or no) ", + buf, sizeof(buf), EFNUL | EFNEW | EFCR, sp); } /* NOTREACHED */ } /* - * Write out a prompt and read back a reply. The prompt is now written - * out with full "ewprintf" formatting, although the arguments are in a - * rather strange place. This is always a new message, there is no auto - * completion, and the return is echoed as such. - */ -/* VARARGS */ -char * -ereply(const char *fmt, char *buf, size_t nbuf, ...) -{ - va_list ap; - char *rep; - - va_start(ap, nbuf); - rep = veread(fmt, buf, nbuf, EFNEW | EFCR, ap); - va_end(ap); - return (rep); -} - -/* * This is the general "read input from the echo line" routine. The basic * idea is that the prompt string "prompt" is written to the echo line, and * a one line reply is read back into the supplied "buf" (with maximum - * length "len"). The "flag" contains EFNEW (a new prompt), an EFFUNC - * (autocomplete), or EFCR (echo the carriage return as CR). + * length "len"). + * XXX: When checking for an empty return value, always check rep, *not* buf + * as buf may be freed in pathological cases. */ /* VARARGS */ char * @@ -205,7 +188,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap) c = CCHR('M'); /* FALLTHROUGH */ case CCHR('M'): /* return, done */ - /* if there's nothing in the minibuffer, quit */ + /* if there's nothing in the minibuffer, abort */ if (cpos == 0 && !(flag & EFNUL)) { (void)ctrlg(FFRAND, 0); ttflush(); diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 13f849ba3b3..d5c41a26514 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.34 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: extend.c,v 1.35 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -367,8 +367,8 @@ dobind(KEYMAP *curmap, const char *p, int unbind) if (unbind) funct = rescan; else { - if ((bufp = eread("%s to command: ", prompt, 80, EFFUNC | EFNEW, - prompt)) == NULL) + if ((bufp = eread("%s to command: ", prompt, sizeof(prompt), + EFFUNC | EFNEW, prompt)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); @@ -496,7 +496,7 @@ define_key(int f, int n) return (ABORT); else if (bufp[0] == '\0') return (FALSE); - strlcat(buf, tmp, sizeof(buf)); + (void)strlcat(buf, tmp, sizeof(buf)); if ((mp = name_map(tmp)) == NULL) { ewprintf("Unknown map %s", tmp); return (FALSE); @@ -580,7 +580,8 @@ evalexpr(int f, int n) { char exbuf[128], *bufp; - if ((bufp = ereply("Eval: ", exbuf, sizeof(exbuf))) == NULL) + if ((bufp = eread("Eval: ", exbuf, sizeof(exbuf), + EFNEW | EFCR)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); @@ -623,7 +624,8 @@ evalfile(int f, int n) { char fname[NFILEN], *bufp; - if ((bufp = ereply("Load file: ", fname, NFILEN)) == NULL) + if ((bufp = eread("Load file: ", fname, NFILEN, + EFNEW | EFCR)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 7a9ee8407bc..0e137a44990 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.37 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: file.c,v 1.38 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -52,7 +52,8 @@ filevisit(int f, int n) else fname[0] = '\0'; - bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE | EFDEF); + bufp = eread("Find file: ", fname, NFILEN, + EFNEW | EFCR | EFFILE | EFDEF); if (bufp == NULL) return (ABORT); else if (bufp[0] == '\0') 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) diff --git a/usr.bin/mg/help.c b/usr.bin/mg/help.c index bfafa34c286..d94ce06c7b6 100644 --- a/usr.bin/mg/help.c +++ b/usr.bin/mg/help.c @@ -1,4 +1,4 @@ -/* $OpenBSD: help.c,v 1.24 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: help.c,v 1.25 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -181,7 +181,8 @@ apropos_command(int f, int n) LIST *fnames, *el; char string[32], *bufp; - if ((bufp = eread("apropos: ", string, sizeof(string), EFNEW)) == NULL) + if ((bufp = eread("apropos: ", string, sizeof(string), + EFNUL | EFNEW)) == NULL) return (ABORT); /* FALSE means we got a 0 character string, which is fine */ bp = bfind("*help*", TRUE); diff --git a/usr.bin/mg/mail.c b/usr.bin/mg/mail.c index 8f046a61f70..0ddfa6fcfab 100644 --- a/usr.bin/mg/mail.c +++ b/usr.bin/mg/mail.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mail.c,v 1.5 2005/04/03 02:09:28 db Exp $ */ +/* $OpenBSD: mail.c,v 1.6 2005/08/09 00:53:48 kjell Exp $ */ /* * This file is in the public domain. * @@ -60,9 +60,10 @@ mail_set_limit(int f, int n) if ((f & FFARG) != 0) { limit = n; } else { - if ((rep = ereply("Margin: ", buf, sizeof(buf))) == NULL) + if ((rep = eread("Margin: ", buf, sizeof(buf), + EFNEW | EFCR)) == NULL) return (ABORT); - else if (*rep == '\0') + else if (rep[0] == '\0') return (FALSE); limit = atoi(rep); } diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index ae6a4abc48c..a51fc4bd0c7 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.40 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: main.c,v 1.41 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -203,7 +203,7 @@ quit(int f, int n) if ((s = anycb(FALSE)) == ABORT) return (ABORT); if (s == FALSE - || eyesno("Some modified buffers exist, really exit") == TRUE) { + || eyesno("Modified buffers exist; really exit") == TRUE) { vttidy(); #ifdef SYSCLEANUP SYSCLEANUP; diff --git a/usr.bin/mg/modes.c b/usr.bin/mg/modes.c index 9ccdcd24d43..df9f30c8b98 100644 --- a/usr.bin/mg/modes.c +++ b/usr.bin/mg/modes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modes.c,v 1.11 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: modes.c,v 1.12 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -119,7 +119,8 @@ set_default_mode(int f, int n) MAPS *m; char mode[32], *bufp; - if ((bufp = eread("Set Default Mode: ", mode, 32, EFNEW)) == NULL) + if ((bufp = eread("Set Default Mode: ", mode, sizeof(mode), + EFNEW)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); diff --git a/usr.bin/mg/re_search.c b/usr.bin/mg/re_search.c index 1a0fe8b8f8e..295406102f1 100644 --- a/usr.bin/mg/re_search.c +++ b/usr.bin/mg/re_search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re_search.c,v 1.17 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: re_search.c,v 1.18 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -414,12 +414,13 @@ re_readpattern(char *prompt) char tpat[NPAT], *rep; if (re_pat[0] == '\0') - rep = ereply("%s: ", tpat, NPAT, prompt); + rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, prompt); else rep = eread("%s: (default %s) ", tpat, NPAT, EFNUL | EFNEW | EFCR, prompt, re_pat); - - if (rep != NULL && *rep != '\0') { + if (rep == NULL) + return (ABORT); + if (rep[0] != '\0') { /* New pattern given */ (void)strlcpy(re_pat, tpat, sizeof(re_pat)); if (casefoldsearch) diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c index aa3f285ebdc..c1af414f488 100644 --- a/usr.bin/mg/region.c +++ b/usr.bin/mg/region.c @@ -1,4 +1,4 @@ -/* $OpenBSD: region.c,v 1.17 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: region.c,v 1.18 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -305,14 +305,17 @@ setprefix(int f, int n) int retval; if (prefix_string[0] == '\0') - rep = ereply("Prefix string: ", buf, sizeof(buf)); + rep = eread("Prefix string: ", buf, sizeof(buf), + EFNEW | EFCR); else - rep = eread("Prefix string (default %s): ", - buf, sizeof(buf), EFNUL | EFNEW | EFCR, prefix_string); - if (rep != NULL && *rep != '\0') { + rep = eread("Prefix string (default %s): ", buf, sizeof(buf), + EFNUL | EFNEW | EFCR, prefix_string); + if (rep == NULL) + return (ABORT); + if (rep[0] != '\0') { (void)strlcpy(prefix_string, rep, sizeof(prefix_string)); retval = TRUE; - } else if (*rep == '\0' && prefix_string[0] != '\0') { + } else if (rep[0] == '\0' && prefix_string[0] != '\0') { /* CR -- use old one */ retval = TRUE; } else diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c index 709a0a5262a..437874a78da 100644 --- a/usr.bin/mg/search.c +++ b/usr.bin/mg/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.21 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: search.c,v 1.22 2005/08/09 00:53:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -777,7 +777,7 @@ readpattern(char *prompt) int retval; if (pat[0] == '\0') - rep = ereply("%s: ", tpat, NPAT, prompt); + rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, prompt); else rep = eread("%s: (default %s) ", tpat, NPAT, EFNUL | EFNEW | EFCR, prompt, pat); @@ -785,8 +785,8 @@ readpattern(char *prompt) /* specified */ if (rep == NULL) { retval = ABORT; - } else if (*rep != '\0') { - (void) strlcpy(pat, tpat, sizeof(pat)); + } else if (rep[0] != '\0') { + (void)strlcpy(pat, tpat, sizeof(pat)); retval = TRUE; } else if (pat[0] != '\0') { retval = TRUE; |