diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2014-03-20 07:47:30 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2014-03-20 07:47:30 +0000 |
commit | 6a0a6cdf1572523b52f30ca110ab358f5e088f18 (patch) | |
tree | 891437e7fbf1d01d5ed42b26a4eb03b841647009 | |
parent | 45063cff1b518142d40e1fc7d5212dc56ca6d266 (diff) |
Add some missing dobeeps.
ok florian@
-rw-r--r-- | usr.bin/mg/basic.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/buffer.c | 13 | ||||
-rw-r--r-- | usr.bin/mg/cscope.c | 18 | ||||
-rw-r--r-- | usr.bin/mg/dir.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/dired.c | 22 | ||||
-rw-r--r-- | usr.bin/mg/echo.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/extend.c | 21 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 12 | ||||
-rw-r--r-- | usr.bin/mg/fileio.c | 12 | ||||
-rw-r--r-- | usr.bin/mg/grep.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/line.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/macro.c | 3 | ||||
-rw-r--r-- | usr.bin/mg/modes.c | 6 | ||||
-rw-r--r-- | usr.bin/mg/paragraph.c | 3 | ||||
-rw-r--r-- | usr.bin/mg/re_search.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/region.c | 16 | ||||
-rw-r--r-- | usr.bin/mg/search.c | 10 | ||||
-rw-r--r-- | usr.bin/mg/tags.c | 27 | ||||
-rw-r--r-- | usr.bin/mg/ttyio.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/undo.c | 6 | ||||
-rw-r--r-- | usr.bin/mg/window.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/word.c | 7 | ||||
-rw-r--r-- | usr.bin/mg/yank.c | 4 |
23 files changed, 207 insertions, 31 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 488acc35218..5d6f093cdb4 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.41 2013/05/31 18:19:19 florian Exp $ */ +/* $OpenBSD: basic.c,v 1.42 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain */ @@ -416,6 +416,7 @@ pagenext(int f, int n) struct mgwin *wp; if (wheadp->w_wndp == NULL) { + dobeep(); ewprintf("No other window"); return (FALSE); } @@ -482,6 +483,7 @@ swapmark(int f, int n) int odoto, odotline; if (curwp->w_markp == NULL) { + dobeep(); ewprintf("No mark in this window"); return (FALSE); } @@ -520,6 +522,7 @@ gotoline(int f, int n) return (ABORT); n = (int)strtonum(buf, INT_MIN, INT_MAX, &err); if (err) { + dobeep(); ewprintf("Line number %s", err); return (FALSE); } diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c index f6f432b8655..331fbbb0dd0 100644 --- a/usr.bin/mg/buffer.c +++ b/usr.bin/mg/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.92 2013/12/23 14:58:16 lum Exp $ */ +/* $OpenBSD: buffer.c,v 1.93 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -372,6 +372,7 @@ listbuf_goto_buffer_helper(int f, int n, int only) int i, ret = FALSE; if (curwp->w_dotp->l_text[listbuf_ncol/2 - 1] == '$') { + dobeep(); ewprintf("buffer name truncated"); return (FALSE); } @@ -462,6 +463,7 @@ anycb(int f) ret = snprintf(pbuf, sizeof(pbuf), "Save file %s", bp->b_fname); if (ret < 0 || ret >= sizeof(pbuf)) { + dobeep(); ewprintf("Error: filename too long!"); return (UERROR); } @@ -523,6 +525,7 @@ bnew(const char *bname) bp = calloc(1, sizeof(struct buffer)); if (bp == NULL) { + dobeep(); ewprintf("Can't get %d bytes", sizeof(struct buffer)); return (NULL); } @@ -561,6 +564,7 @@ bnew(const char *bname) bp->b_dotline = bp->b_markline = 1; bp->b_lines = 1; if ((bp->b_bname = strdup(bname)) == NULL) { + dobeep(); ewprintf("Can't get %d bytes", strlen(bname) + 1); return (NULL); } @@ -745,6 +749,7 @@ bufferinsert(int f, int n) return (FALSE); if (bp == curbp) { + dobeep(); ewprintf("Cannot insert buffer into self"); return (FALSE); } @@ -886,6 +891,7 @@ revertbuffer(int f, int n) char fbuf[NFILEN + 32]; if (curbp->b_fname[0] == 0) { + dobeep(); ewprintf("Cannot revert buffer not associated with any files."); return (FALSE); } @@ -906,6 +912,7 @@ dorevert(void) struct undo_rec *rec; if (access(curbp->b_fname, F_OK|R_OK) != 0) { + dobeep(); if (errno == ENOENT) ewprintf("File %s no longer exists!", curbp->b_fname); @@ -954,11 +961,13 @@ diffbuffer(int f, int n) return (ABORT); if (access(DIFFTOOL, X_OK) != 0) { + dobeep(); ewprintf("%s not found or not executable.", DIFFTOOL); return (FALSE); } if (curbp->b_fname[0] == 0) { + dobeep(); ewprintf("Cannot diff buffer not associated with any files."); return (FALSE); } @@ -970,6 +979,7 @@ diffbuffer(int f, int n) len++; } if ((text = calloc(len + 1, sizeof(char))) == NULL) { + dobeep(); ewprintf("Cannot allocate memory."); return (FALSE); } @@ -1014,6 +1024,7 @@ findbuffer(char *fn) char bname[NBUFN], fname[NBUFN]; if (strlcpy(fname, fn, sizeof(fname)) >= sizeof(fname)) { + dobeep(); ewprintf("filename too long"); return (NULL); } diff --git a/usr.bin/mg/cscope.c b/usr.bin/mg/cscope.c index 1dc9f901909..b3de0182559 100644 --- a/usr.bin/mg/cscope.c +++ b/usr.bin/mg/cscope.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cscope.c,v 1.4 2014/01/22 09:43:53 jsg Exp $ */ +/* $OpenBSD: cscope.c,v 1.5 2014/03/20 07:47:29 lum Exp $ */ /* * This file is in the public domain. @@ -178,14 +178,17 @@ cscreatelist(int f, int n) return (FALSE); if (stat(dir, &sb) == -1) { + dobeep(); ewprintf("stat: %s", strerror(errno)); return (FALSE); } else if (S_ISDIR(sb.st_mode) == 0) { + dobeep(); ewprintf("%s: Not a directory", dir); return (FALSE); } if (csexists("cscope-indexer") == FALSE) { + dobeep(); ewprintf("no such file or directory, cscope-indexer"); return (FALSE); } @@ -195,6 +198,7 @@ cscreatelist(int f, int n) return (FALSE); if ((fpipe = popen(cmd, "r")) == NULL) { + dobeep(); ewprintf("problem opening pipe"); return (FALSE); } @@ -233,6 +237,7 @@ csnextmatch(int f, int n) if (curmatch == NULL) { if ((r = TAILQ_FIRST(&csrecords)) == NULL) { + dobeep(); ewprintf("The *cscope* buffer does not exist yet"); return (FALSE); } @@ -243,6 +248,7 @@ csnextmatch(int f, int n) if (m == NULL) { r = TAILQ_NEXT(currecord, entry); if (r == NULL) { + dobeep(); ewprintf("The end of *cscope* buffer has been" " reached"); return (FALSE); @@ -275,6 +281,7 @@ csprevmatch(int f, int n) else { r = TAILQ_PREV(currecord, csrecords, entry); if (r == NULL) { + dobeep(); ewprintf("The beginning of *cscope* buffer has" " been reached"); return (FALSE); @@ -298,12 +305,14 @@ csnextfile(int f, int n) if (curmatch == NULL) { if ((r = TAILQ_FIRST(&csrecords)) == NULL) { + dobeep(); ewprintf("The *cscope* buffer does not exist yet"); return (FALSE); } } else { if ((r = TAILQ_NEXT(currecord, entry)) == NULL) { + dobeep(); ewprintf("The end of *cscope* buffer has been reached"); return (FALSE); } @@ -323,12 +332,14 @@ csprevfile(int f, int n) if (curmatch == NULL) { if ((r = TAILQ_FIRST(&csrecords)) == NULL) { + dobeep(); ewprintf("The *cscope* buffer does not exist yet"); return (FALSE); } } else { if ((r = TAILQ_PREV(currecord, csrecords, entry)) == NULL) { + dobeep(); ewprintf("The beginning of *cscope* buffer has been" " reached"); return (FALSE); @@ -386,6 +397,7 @@ do_cscope(int i) /* If current buffer isn't a source file just return */ if (fnmatch("*.[chy]", curbp->b_fname, 0) != 0) { + dobeep(); ewprintf("C-c s not defined"); return (FALSE); } @@ -399,6 +411,7 @@ do_cscope(int i) return (FALSE); if (csexists("cscope") == FALSE) { + dobeep(); ewprintf("no such file or directory, cscope"); return (FALSE); } @@ -410,6 +423,7 @@ do_cscope(int i) return (FALSE); if ((fpipe = popen(cmd, "r")) == NULL) { + dobeep(); ewprintf("problem opening pipe"); return (FALSE); } @@ -585,6 +599,7 @@ csexists(const char *cmd) if ((tmp = getenv("PATH")) == NULL) return (FALSE); if ((pathc = path = strndup(tmp, NFILEN)) == NULL) { + dobeep(); ewprintf("out of memory"); return (FALSE); } @@ -598,6 +613,7 @@ csexists(const char *cmd) dir[--dlen] = '\0'; /* strip trailing '/' */ if (dlen + 1 + cmdlen >= sizeof(fname)) { + dobeep(); ewprintf("path too long"); goto cleanup; } diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index 2d5b8607a6a..ab4b4128fea 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.24 2013/10/21 19:04:56 florian Exp $ */ +/* $OpenBSD: dir.c,v 1.25 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -47,6 +47,7 @@ changedir(int f, int n) return (FALSE); /* Append trailing slash */ if (chdir(bufc) == -1) { + dobeep(); ewprintf("Can't change dir to %s", bufc); return (FALSE); } @@ -125,6 +126,7 @@ do_makedir(void) ishere = !stat(path, &sb); if (finished && ishere) { + dobeep(); ewprintf("Cannot create directory %s: file exists", path); return(FALSE); @@ -140,10 +142,11 @@ do_makedir(void) } } else { if (!ishere || !S_ISDIR(sb.st_mode)) { - if (!ishere) + if (!ishere) { + dobeep(); ewprintf("Creating directory: " "permission denied, %s", path); - else + } else eerase(); umask(oumask); diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index 6ba26322e1f..aeb22a4d6d1 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.65 2013/12/20 15:49:00 lum Exp $ */ +/* $OpenBSD: dired.c,v 1.66 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -372,11 +372,13 @@ d_expunge(int f, int n) if (llength(lp) && lgetc(lp, 0) == 'D') { switch (d_makename(lp, fname, sizeof(fname))) { case ABORT: + dobeep(); ewprintf("Bad line in dired buffer"); return (FALSE); case FALSE: if (unlink(fname) < 0) { (void)xbasename(sname, fname, NFILEN); + dobeep(); ewprintf("Could not delete '%s'", sname); return (FALSE); } @@ -384,6 +386,7 @@ d_expunge(int f, int n) case TRUE: if (rmdir(fname) < 0) { (void)xbasename(sname, fname, NFILEN); + dobeep(); ewprintf("Could not delete directory " "'%s'", sname); return (FALSE); @@ -409,11 +412,13 @@ d_copy(int f, int n) struct buffer *bp; if (d_makename(curwp->w_dotp, frname, sizeof(frname)) != FALSE) { + dobeep(); ewprintf("Not a file"); return (FALSE); } off = strlcpy(toname, curbp->b_fname, sizeof(toname)); if (off >= sizeof(toname) - 1) { /* can't happen, really */ + dobeep(); ewprintf("Directory name too long"); return (FALSE); } @@ -446,11 +451,13 @@ d_rename(int f, int n) char sname[NFILEN]; if (d_makename(curwp->w_dotp, frname, sizeof(frname)) != FALSE) { + dobeep(); ewprintf("Not a file"); return (FALSE); } off = strlcpy(toname, curbp->b_fname, sizeof(toname)); if (off >= sizeof(toname) - 1) { /* can't happen, really */ + dobeep(); ewprintf("Directory name too long"); return (FALSE); } @@ -499,6 +506,7 @@ d_shell_command(int f, int n) return (ABORT); if (d_makename(curwp->w_dotp, fname, sizeof(fname)) != FALSE) { + dobeep(); ewprintf("bad line"); return (ABORT); } @@ -548,6 +556,7 @@ d_exec(int space, struct buffer *bp, const char *input, const char *cmd, ...) /* Allocate and build the argv. */ if ((argv = calloc(n, sizeof(*argv))) == NULL) { + dobeep(); ewprintf("Can't allocate argv : %s", strerror(errno)); goto out; } @@ -563,11 +572,13 @@ d_exec(int space, struct buffer *bp, const char *input, const char *cmd, ...) input = "/dev/null"; if ((infd = open(input, O_RDONLY)) == -1) { + dobeep(); ewprintf("Can't open input file : %s", strerror(errno)); goto out; } if (pipe(fds) == -1) { + dobeep(); ewprintf("Can't create pipe : %s", strerror(errno)); goto out; } @@ -578,6 +589,7 @@ d_exec(int space, struct buffer *bp, const char *input, const char *cmd, ...) goto out; if ((pid = fork()) == -1) { + dobeep(); ewprintf("Can't fork"); goto out; } @@ -671,6 +683,7 @@ refreshbuffer(struct buffer *bp) tmp = strdup(bp->b_fname); if (tmp == NULL) { + dobeep(); ewprintf("Out of memory"); return (NULL); } @@ -774,6 +787,7 @@ dired_(char *dname) size_t len; if ((dname = adjustname(dname, FALSE)) == NULL) { + dobeep(); ewprintf("Bad directory name"); return (NULL); } @@ -784,11 +798,14 @@ dired_(char *dname) dname[len] = '\0'; } if ((access(dname, R_OK | X_OK)) == -1) { - if (errno == EACCES) + if (errno == EACCES) { + dobeep(); ewprintf("Permission denied"); + } return (NULL); } if ((bp = findbuffer(dname)) == NULL) { + dobeep(); ewprintf("Could not create buffer"); return (NULL); } @@ -818,6 +835,7 @@ dired_(char *dname) (void)strlcpy(bp->b_cwd, dname, sizeof(bp->b_cwd)); if ((bp->b_modes[1] = name_mode("dired")) == NULL) { bp->b_modes[0] = name_mode("fundamental"); + dobeep(); ewprintf("Could not find mode dired"); return (NULL); } diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c index 0100ef5b041..3fcedace735 100644 --- a/usr.bin/mg/echo.c +++ b/usr.bin/mg/echo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: echo.c,v 1.55 2013/05/31 18:03:44 lum Exp $ */ +/* $OpenBSD: echo.c,v 1.56 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -316,6 +316,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap) nbuf = newsize; } if (!dynbuf && epos + 1 >= nbuf) { + dobeep(); ewprintf("Line too long"); return (emptyval); } @@ -471,6 +472,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap) nbuf = newsize; } if (!dynbuf && epos + 1 >= nbuf) { + dobeep(); ewprintf("Line too long"); return (emptyval); } @@ -504,6 +506,7 @@ done: memfail: if (dynbuf && buf) free(buf); + dobeep(); ewprintf("Out of memory"); return (emptyval); } diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 2f47de6b5fb..9d41769a4d3 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.53 2012/05/25 04:56:58 lum Exp $ */ +/* $OpenBSD: extend.c,v 1.54 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -115,6 +115,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) ele--; if ((pfp = calloc(c - ele->k_base + 1, sizeof(PF))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -129,6 +130,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) } else if (n2 <= MAPELEDEF) { if ((pfp = calloc(ele->k_num - c + 1, sizeof(PF))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -147,6 +149,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) curmap = newmap; } if ((pfp = malloc(sizeof(PF))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -170,6 +173,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) else { if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) * sizeof(struct map_element))) == NULL) { + dobeep(); ewprintf("Out of memory"); ele->k_funcp[c - ele->k_base] = curmap->map_default; @@ -199,6 +203,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) * sizeof(struct map_element))) == NULL) { + dobeep(); ewprintf("Out of memory"); ele->k_funcp[c - ele->k_base] = curmap->map_default; @@ -226,6 +231,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) } if ((pfp = calloc(ele->k_num - c + !n2, sizeof(PF))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -248,6 +254,7 @@ remap(KEYMAP *curmap, int c, PF funct, KEYMAP *pref_map) if (pref_map == NULL) { if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) * sizeof(struct map_element))) == NULL) { + dobeep(); ewprintf("Out of memory"); ele->k_funcp[c - ele->k_base] = curmap->map_default; @@ -276,11 +283,13 @@ reallocmap(KEYMAP *curmap) int i; if (curmap->map_max > SHRT_MAX - MAPGROW) { + dobeep(); ewprintf("keymap too large"); return (NULL); } if ((mp = malloc(sizeof(KEYMAP) + (curmap->map_max + (MAPGROW - 1)) * sizeof(struct map_element))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (NULL); } @@ -338,6 +347,7 @@ dobind(KEYMAP *curmap, const char *p, int unbind) * Keystrokes aren't collected. Not hard, but pretty useless. * Would not work for function keys in any case. */ + dobeep(); ewprintf("Can't rebind key in macro"); return (FALSE); } @@ -378,6 +388,7 @@ dobind(KEYMAP *curmap, const char *p, int unbind) return (FALSE); if (((funct = name_function(bprompt)) == NULL) ? (pref_map = name_map(bprompt)) == NULL : funct == NULL) { + dobeep(); ewprintf("[No match]"); return (FALSE); } @@ -404,6 +415,7 @@ bindkey(KEYMAP **mapp, const char *fname, KCHAR *keys, int kcount) funct = rescan; else if (((funct = name_function(fname)) == NULL) ? (pref_map = name_map(fname)) == NULL : funct == NULL) { + dobeep(); ewprintf("[No match: %s]", fname); return (FALSE); } @@ -509,6 +521,7 @@ redefine_key(int f, int n) return (FALSE); (void)strlcat(buf, tmp, sizeof(buf)); if ((mp = name_map(tmp)) == NULL) { + dobeep(); ewprintf("Unknown map %s", tmp); return (FALSE); } @@ -563,6 +576,7 @@ extend(int f, int n) } return ((*funct)(f, n)); } + dobeep(); ewprintf("[No match]"); return (FALSE); } @@ -668,6 +682,7 @@ load(const char *fname) excbuf[nbytes] = '\0'; if (excline(excbuf) != TRUE) { s = FIOERR; + dobeep(); ewprintf("Error loading file %s at line %d", fname, line); break; } @@ -708,6 +723,7 @@ excline(char *line) lp = NULL; if (macrodef || inmacro) { + dobeep(); ewprintf("Not now!"); return (FALSE); } @@ -735,6 +751,7 @@ excline(char *line) n = (int)nl; } if ((fp = name_function(funcp)) == NULL) { + dobeep(); ewprintf("Unknown function: %s", funcp); return (FALSE); } @@ -876,6 +893,7 @@ excline(char *line) case BINDNEXT: lp->l_text[lp->l_used] = '\0'; if ((curmap = name_map(lp->l_text)) == NULL) { + dobeep(); ewprintf("No such mode: %s", lp->l_text); status = FALSE; free(lp); @@ -897,6 +915,7 @@ excline(char *line) #ifdef FKEYS switch (bind) { default: + dobeep(); ewprintf("Bad args to set key"); status = FALSE; break; diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 8e0fa6a3130..428dbed8d5b 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.91 2014/03/14 10:02:52 lum Exp $ */ +/* $OpenBSD: file.c,v 1.92 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -191,6 +191,7 @@ readin(char *fname) /* Clear readonly. May be set by autoexec path */ curbp->b_flag &= ~BFREADONLY; if ((status = insertfile(fname, fname, TRUE)) != TRUE) { + dobeep(); ewprintf("File is not readable: %s", fname); return (FALSE); } @@ -322,6 +323,7 @@ insertfile(char *fname, char *newname, int replacebuf) } else if (s == FIODIR) { /* file was a directory */ if (replacebuf == FALSE) { + dobeep(); ewprintf("Cannot insert: file is a directory, %s", fname); goto cleanup; @@ -385,6 +387,7 @@ retry: newsize = linesize * 2; if (newsize < 0 || (cp = malloc(newsize)) == NULL) { + dobeep(); ewprintf("Could not allocate %d bytes", newsize); s = FIOERR; @@ -402,6 +405,7 @@ retry: goto retry; } default: + dobeep(); ewprintf("Unknown code %d reading file", s); s = FIOERR; break; @@ -578,6 +582,7 @@ buffsave(struct buffer *bp) /* must have a name */ if (bp->b_fname[0] == '\0') { + dobeep(); ewprintf("No file name"); return (FALSE); } @@ -655,10 +660,12 @@ writeout(FILE ** ffp, struct buffer *bp, char *fn) (void)xdirname(dp, fn, sizeof(dp)); (void)strlcat(dp, "/", sizeof(dp)); if (access(dp, W_OK) && errno == EACCES) { + dobeep(); ewprintf("Directory %s write-protected", dp); return (FIOERR); } else if (errno == ENOENT) { - ewprintf("%s: no such directory", dp); + dobeep(); + ewprintf("%s: no such directory", dp); return (FIOERR); } } @@ -674,6 +681,7 @@ writeout(FILE ** ffp, struct buffer *bp, char *fn) } else { /* print a message indicating write error */ (void)ffclose(*ffp, bp); + dobeep(); ewprintf("Unable to write %s", fn); } return (s == FIOSUC); diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 78bd8768ed7..685066c2655 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.96 2013/05/18 05:53:58 lum Exp $ */ +/* $OpenBSD: fileio.c,v 1.97 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -103,11 +103,13 @@ ffwopen(FILE ** ffp, const char *fn, struct buffer *bp) fd = open(fn, O_RDWR | O_CREAT | O_TRUNC, fmode); if (fd == -1) { ffp = NULL; + dobeep(); ewprintf("Cannot open file for writing : %s", strerror(errno)); return (FIOERR); } if ((*ffp = fdopen(fd, "w")) == NULL) { + dobeep(); ewprintf("Cannot open file for writing : %s", strerror(errno)); close(fd); return (FIOERR); @@ -151,6 +153,7 @@ ffputbuf(FILE *ffp, struct buffer *bp) lpend = bp->b_headp; for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) { if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) { + dobeep(); ewprintf("Write I/O error"); return (FIOERR); } @@ -188,6 +191,7 @@ ffgetline(FILE *ffp, char *buf, int nbuf, int *nbytes) return (FIOLONG); } if (c == EOF && ferror(ffp) != FALSE) { + dobeep(); ewprintf("File read error"); return (FIOERR); } @@ -213,6 +217,7 @@ fbackupfile(const char *fn) char *nname, *tname, *bkpth; if (stat(fn, &sb) == -1) { + dobeep(); ewprintf("Can't stat %s : %s", fn, strerror(errno)); return (FALSE); } @@ -221,11 +226,13 @@ fbackupfile(const char *fn) return (FALSE); if (asprintf(&nname, "%s~", bkpth) == -1) { + dobeep(); ewprintf("Can't allocate backup file name : %s", strerror(errno)); free(bkpth); return (ABORT); } if (asprintf(&tname, "%s.XXXXXXXXXX", bkpth) == -1) { + dobeep(); ewprintf("Can't allocate temp file name : %s", strerror(errno)); free(bkpth); free(nname); @@ -368,6 +375,7 @@ copy(char *frname, char *toname) if ((ifd = open(frname, O_RDONLY)) == -1) return (FALSE); if (fstat(ifd, &orig) == -1) { + dobeep(); ewprintf("fstat: %s", strerror(errno)); close(ifd); return (FALSE); @@ -734,6 +742,7 @@ expandtilde(const char *fn) plen = strlcpy(path, pw->pw_dir, sizeof(path)); if (plen == 0 || path[plen - 1] != '/') { if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) { + dobeep(); ewprintf("Path too long"); return (NULL); } @@ -743,6 +752,7 @@ expandtilde(const char *fn) fn++; } if (strlcat(path, fn, sizeof(path)) >= sizeof(path)) { + dobeep(); ewprintf("Path too long"); return (NULL); } diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c index 7373949c91f..6a4c1c4e4aa 100644 --- a/usr.bin/mg/grep.c +++ b/usr.bin/mg/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.39 2013/06/01 17:31:11 lum Exp $ */ +/* $OpenBSD: grep.c,v 1.40 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain */ @@ -193,10 +193,12 @@ compile_mode(const char *name, const char *command) if (getcwd(cwd, sizeof(cwd)) == NULL) panic("Can't get current directory!"); if (chdir(bp->b_cwd) == -1) { + dobeep(); ewprintf("Can't change dir to %s", bp->b_cwd); return (NULL); } if ((fpipe = popen(qcmd, "r")) == NULL) { + dobeep(); ewprintf("Problem opening pipe"); return (NULL); } @@ -227,6 +229,7 @@ compile_mode(const char *name, const char *command) compile_buffer = bp; if (chdir(cwd) == -1) { + dobeep(); ewprintf("Can't change dir back to %s", cwd); return (NULL); } @@ -296,6 +299,7 @@ fail: curwp->w_rflag |= WFMOVE; goto retry; } + dobeep(); ewprintf("No more hits"); return (FALSE); } @@ -305,12 +309,14 @@ int next_error(int f, int n) { if (compile_win == NULL || compile_buffer == NULL) { + dobeep(); ewprintf("No compilation active"); return (FALSE); } curwp = compile_win; curbp = compile_buffer; if (curwp->w_dotp == blastlp(curbp)) { + dobeep(); ewprintf("No more hits"); return (FALSE); } diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c index e67a2e55be1..51d17657d98 100644 --- a/usr.bin/mg/line.c +++ b/usr.bin/mg/line.c @@ -1,4 +1,4 @@ -/* $OpenBSD: line.c,v 1.52 2013/12/23 21:47:32 florian Exp $ */ +/* $OpenBSD: line.c,v 1.53 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -147,6 +147,7 @@ linsert_str(const char *s, int n) return (k); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); return (FALSE); } @@ -244,6 +245,7 @@ linsert(int n, int c) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); return (FALSE); } @@ -259,6 +261,7 @@ linsert(int n, int c) /* now should only happen in empty buffer */ if (curwp->w_doto != 0) { + dobeep(); ewprintf("bug: linsert"); return (FALSE); } @@ -405,6 +408,7 @@ lnewline(void) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); return (FALSE); } @@ -436,6 +440,7 @@ ldelete(RSIZE n, int kflag) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); goto out; } @@ -524,6 +529,7 @@ ldelnewline(void) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); return (FALSE); } @@ -601,6 +607,7 @@ lreplace(RSIZE plen, char *st) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read only"); return (FALSE); } diff --git a/usr.bin/mg/macro.c b/usr.bin/mg/macro.c index 19104783017..1f9bce8e352 100644 --- a/usr.bin/mg/macro.c +++ b/usr.bin/mg/macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: macro.c,v 1.14 2012/04/12 04:47:59 lum Exp $ */ +/* $OpenBSD: macro.c,v 1.15 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -71,6 +71,7 @@ executemacro(int f, int n) if (macrodef || (macrocount >= MAXMACRO && macro[MAXMACRO - 1].m_funct != finishmacro)) { + dobeep(); ewprintf("Macro too long. Aborting."); return (FALSE); } diff --git a/usr.bin/mg/modes.c b/usr.bin/mg/modes.c index cde87284e65..02c2c898fa4 100644 --- a/usr.bin/mg/modes.c +++ b/usr.bin/mg/modes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modes.c,v 1.18 2008/06/14 08:46:30 kjell Exp $ */ +/* $OpenBSD: modes.c,v 1.19 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -24,6 +24,7 @@ changemode(int f, int n, char *mode) struct maps_s *m; if ((m = name_mode(mode)) == NULL) { + dobeep(); ewprintf("Can't find mode %s", mode); return (FALSE); } @@ -41,6 +42,7 @@ changemode(int f, int n, char *mode) /* mode already set */ return (TRUE); if (curbp->b_nmodes >= PBMODES - 1) { + dobeep(); ewprintf("Too many modes"); return (FALSE); } @@ -116,6 +118,7 @@ set_default_mode(int f, int n) else if (bufp[0] == '\0') return (FALSE); if ((m = name_mode(modebuf)) == NULL) { + dobeep(); ewprintf("can't find mode %s", modebuf); return (FALSE); } @@ -133,6 +136,7 @@ set_default_mode(int f, int n) /* mode already set */ return (TRUE); if (defb_nmodes >= PBMODES - 1) { + dobeep(); ewprintf("Too many modes"); return (FALSE); } diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c index f42b98ee9b4..842462990f9 100644 --- a/usr.bin/mg/paragraph.c +++ b/usr.bin/mg/paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paragraph.c,v 1.29 2013/06/15 19:58:39 lum Exp $ */ +/* $OpenBSD: paragraph.c,v 1.30 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -335,6 +335,7 @@ setfillcol(int f, int n) return (FALSE); nfill = strtonum(rep, 0, INT_MAX, &es); if (es != NULL) { + dobeep(); ewprintf("Invalid fill column: %s", rep); return (FALSE); } diff --git a/usr.bin/mg/re_search.c b/usr.bin/mg/re_search.c index f24e6cf7ea1..7e5d989e5f2 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.29 2013/12/20 18:44:13 florian Exp $ */ +/* $OpenBSD: re_search.c,v 1.30 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -57,6 +57,7 @@ re_forwsearch(int f, int n) if ((s = re_readpattern("RE Search")) != TRUE) return (s); if (re_forwsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", re_pat); return (FALSE); } @@ -80,6 +81,7 @@ re_backsearch(int f, int n) if ((s = re_readpattern("RE Search backward")) != TRUE) return (s); if (re_backsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", re_pat); return (FALSE); } @@ -100,11 +102,13 @@ int re_searchagain(int f, int n) { if (re_srch_lastdir == SRCH_NOPR) { + dobeep(); ewprintf("No last search"); return (FALSE); } if (re_srch_lastdir == SRCH_FORW) { if (re_forwsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", re_pat); return (FALSE); } @@ -112,6 +116,7 @@ re_searchagain(int f, int n) } if (re_srch_lastdir == SRCH_BACK) if (re_backsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", re_pat); return (FALSE); } @@ -438,6 +443,7 @@ re_readpattern(char *prompt) if (error != 0) { char message[256]; regerror(error, ®ex_buff, message, sizeof(message)); + dobeep(); ewprintf("Regex Error: %s", message); re_pat[0] = '\0'; return (FALSE); diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c index 4095cd5694e..dfdd0e982e9 100644 --- a/usr.bin/mg/region.c +++ b/usr.bin/mg/region.c @@ -1,4 +1,4 @@ -/* $OpenBSD: region.c,v 1.33 2013/05/22 19:23:45 lum Exp $ */ +/* $OpenBSD: region.c,v 1.34 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -118,6 +118,7 @@ lowerregion(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -161,6 +162,7 @@ upperregion(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -204,6 +206,7 @@ getregion(struct region *rp) long fsize, bsize; if (curwp->w_markp == NULL) { + dobeep(); ewprintf("No mark set in this window"); return (FALSE); } @@ -249,6 +252,7 @@ getregion(struct region *rp) } } } + dobeep(); ewprintf("Bug: lost mark"); return (FALSE); } @@ -261,6 +265,7 @@ setsize(struct region *rp, RSIZE size) { rp->r_size = size; if (rp->r_size != size) { + dobeep(); ewprintf("Region is too large"); return (FALSE); } @@ -288,6 +293,7 @@ prefixregion(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -416,6 +422,7 @@ piperegion(int f, int n) return (ABORT); if (curwp->w_markp == NULL) { + dobeep(); ewprintf("The mark is not set now, so there is no region"); return (FALSE); } @@ -432,6 +439,7 @@ piperegion(int f, int n) len = region.r_size; if ((text = malloc(len + 1)) == NULL) { + dobeep(); ewprintf("Cannot allocate memory."); return (FALSE); } @@ -507,12 +515,14 @@ pipeio(const char* const path, char* const argv[], char* const text, int len, char *err; if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, s) == -1) { + dobeep(); ewprintf("socketpair error"); return (FALSE); } switch(fork()) { case -1: + dobeep(); ewprintf("Can't fork"); return (FALSE); case 0: @@ -584,9 +594,11 @@ iomux(int fd, char* const text, int len, struct buffer *outbp) leftover[0] = '\0'; } if (nfds == 0) { + dobeep(); ewprintf("poll timed out"); return (FALSE); } else if (nfds == -1) { + dobeep(); ewprintf("poll error"); return (FALSE); } @@ -638,6 +650,7 @@ preadin(int fd, struct buffer *bp) *q++ = '\0'; if (strlcat(leftover, p, sizeof(leftover)) >= sizeof(leftover)) { + dobeep(); ewprintf("line too long"); return (FALSE); } @@ -651,6 +664,7 @@ preadin(int fd, struct buffer *bp) p = q; } if (strlcpy(leftover, p, sizeof(leftover)) >= sizeof(leftover)) { + dobeep(); ewprintf("line too long"); return (FALSE); } diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c index 1ad15afb8af..c3b350aa00c 100644 --- a/usr.bin/mg/search.c +++ b/usr.bin/mg/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.42 2013/05/31 18:03:45 lum Exp $ */ +/* $OpenBSD: search.c,v 1.43 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -62,6 +62,7 @@ forwsearch(int f, int n) if ((s = readpattern("Search")) != TRUE) return (s); if (forwsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", pat); return (FALSE); } @@ -84,6 +85,7 @@ backsearch(int f, int n) if ((s = readpattern("Search backward")) != TRUE) return (s); if (backsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", pat); return (FALSE); } @@ -102,6 +104,7 @@ searchagain(int f, int n) { if (srch_lastdir == SRCH_FORW) { if (forwsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", pat); return (FALSE); } @@ -109,11 +112,13 @@ searchagain(int f, int n) } if (srch_lastdir == SRCH_BACK) { if (backsrch() == FALSE) { + dobeep(); ewprintf("Search failed: \"%s\"", pat); return (FALSE); } return (TRUE); } + dobeep(); ewprintf("No last search"); return (FALSE); } @@ -174,6 +179,7 @@ isearch(int dir) int cdotline; /* Saved line number */ if (macrodef) { + dobeep(); ewprintf("Can't isearch in macro"); return (FALSE); } @@ -502,6 +508,7 @@ is_find(int dir) } return (TRUE); } + dobeep(); ewprintf("bad call to is_find"); return (FALSE); } @@ -558,6 +565,7 @@ queryrepl(int f, int n) char news[NPAT], *rep; /* replacement string */ if (macrodef) { + dobeep(); ewprintf("Can't query replace in macro"); return (FALSE); } diff --git a/usr.bin/mg/tags.c b/usr.bin/mg/tags.c index 62e4aa96052..b1f3788c442 100644 --- a/usr.bin/mg/tags.c +++ b/usr.bin/mg/tags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tags.c,v 1.7 2014/03/06 14:51:48 jasper Exp $ */ +/* $OpenBSD: tags.c,v 1.8 2014/03/20 07:47:29 lum Exp $ */ /* * This file is in the public domain. @@ -79,6 +79,7 @@ tagsvisit(int f, int n) fname[0] = '\0'; if (strlcat(fname, DEFAULTFN, sizeof(fname)) >= sizeof(fname)) { + dobeep(); ewprintf("Filename too long"); return (FALSE); } @@ -87,12 +88,15 @@ tagsvisit(int f, int n) NFILEN, EFFILE | EFCR | EFNEW | EFDEF, DEFAULTFN); if (stat(bufp, &sb) == -1) { + dobeep(); ewprintf("stat: %s", strerror(errno)); return (FALSE); } else if (S_ISREG(sb.st_mode) == 0) { + dobeep(); ewprintf("Not a regular file"); return (FALSE); } else if (access(bufp, R_OK) == -1) { + dobeep(); ewprintf("Cannot access file %s", bufp); return (FALSE); } @@ -102,18 +106,21 @@ tagsvisit(int f, int n) return (ABORT); else if (bufp[0] == '\0') { if ((tagsfn = strdup(fname)) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } } else { /* bufp points to local variable, so duplicate. */ if ((tagsfn = strdup(bufp)) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } } } else { if ((temp = strdup(bufp)) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -153,6 +160,7 @@ findtag(int f, int n) tok = utok; if (tok[0] == '\0') { + dobeep(); ewprintf("There is no default tag"); return (FALSE); } @@ -211,12 +219,14 @@ pushtag(char *tok) * same as buffer's directory. */ if (strlcpy(bname, curbp->b_cwd, sizeof(bname)) >= sizeof(bname)) { - ewprintf("filename too long"); - return (FALSE); + dobeep(); + ewprintf("filename too long"); + return (FALSE); } if (strlcat(bname, curbp->b_bname, sizeof(bname)) >= sizeof(bname)) { - ewprintf("filename too long"); - return (FALSE); + dobeep(); + ewprintf("filename too long"); + return (FALSE); } if (loadbuffer(res->fname) == FALSE) @@ -224,10 +234,12 @@ pushtag(char *tok) if (searchpat(res->pat) == TRUE) { if ((s = malloc(sizeof(struct tagpos))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } if ((s->bname = strdup(bname)) == NULL) { + dobeep(); ewprintf("Out of memory"); free(s); return (FALSE); @@ -237,6 +249,7 @@ pushtag(char *tok) SLIST_INSERT_HEAD(&shead, s, entry); return (TRUE); } else { + dobeep(); ewprintf("%s: pattern not found", res->tag); return (FALSE); } @@ -255,6 +268,7 @@ poptag(int f, int n) struct tagpos *s; if (SLIST_EMPTY(&shead)) { + dobeep(); ewprintf("No previous location for find-tag invocation"); return (FALSE); } @@ -290,6 +304,7 @@ loadtags(const char *fn) FILE *fd; if ((fd = fopen(fn, "r")) == NULL) { + dobeep(); ewprintf("Unable to open tags file: %s", fn); return (FALSE); } @@ -357,6 +372,7 @@ addctag(char *l) struct ctag *t; if ((t = malloc(sizeof(struct ctag))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -489,6 +505,7 @@ searchtag(char *tok) t.tag = tok; if ((res = RB_FIND(tagtree, &tags, &t)) == NULL) { + dobeep(); ewprintf("No tag containing %s", tok); return (NULL); } diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c index 7f94db52235..e3def5bd388 100644 --- a/usr.bin/mg/ttyio.c +++ b/usr.bin/mg/ttyio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttyio.c,v 1.34 2013/04/20 17:39:50 deraadt Exp $ */ +/* $OpenBSD: ttyio.c,v 1.35 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -59,6 +59,7 @@ int ttraw(void) { if (tcgetattr(0, &oldtty) < 0) { + dobeep(); ewprintf("ttopen can't get terminal attributes"); return (FALSE); } @@ -81,6 +82,7 @@ ttraw(void) newtty.c_cflag |= CS8; #endif if (tcsetattr(0, TCSASOFT | TCSADRAIN, &newtty) < 0) { + dobeep(); ewprintf("ttopen can't tcsetattr"); return (FALSE); } @@ -114,6 +116,7 @@ ttcooked(void) { ttflush(); if (tcsetattr(0, TCSASOFT | TCSADRAIN, &oldtty) < 0) { + dobeep(); ewprintf("ttclose can't tcsetattr"); return (FALSE); } diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c index f95da63e951..b8a4e88bf77 100644 --- a/usr.bin/mg/undo.c +++ b/usr.bin/mg/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.54 2013/06/01 16:27:56 lum Exp $ */ +/* $OpenBSD: undo.c,v 1.55 2014/03/20 07:47:29 lum Exp $ */ /* * This file is in the public domain */ @@ -41,6 +41,7 @@ find_dot(struct line *lp, int off) for (p = curbp->b_headp; p != lp; p = lforw(p)) { if (count != 0) { if (p == curbp->b_headp) { + dobeep(); ewprintf("Error: Undo stuff called with a" "nonexistent line"); return (FALSE); @@ -421,6 +422,7 @@ undo_dump(int f, int n) } snprintf(tmp, sizeof(tmp), " [%d]", rec->region.r_size); if (strlcat(buf, tmp, sizeof(buf)) >= sizeof(buf)) { + dobeep(); ewprintf("Undo record too large. Aborted."); return (FALSE); } @@ -507,6 +509,7 @@ undo(int f, int n) * its creation. */ if (ptr == NULL) { + dobeep(); ewprintf("No further undo information"); rval = FALSE; nulled = TRUE; @@ -536,6 +539,7 @@ undo(int f, int n) if (ptr->type != BOUNDARY && ptr->type != MODIFIED) { if (find_lo(ptr->pos, &lp, &offset, &lineno) == FALSE) { + dobeep(); ewprintf("Internal error in Undo!"); rval = FALSE; break; diff --git a/usr.bin/mg/window.c b/usr.bin/mg/window.c index c93e713be84..1b5bd920a68 100644 --- a/usr.bin/mg/window.c +++ b/usr.bin/mg/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.29 2013/05/31 18:03:45 lum Exp $ */ +/* $OpenBSD: window.c,v 1.30 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -92,6 +92,7 @@ do_redraw(int f, int n, int force) /* check if too small */ if (nrow < wp->w_toprow + 3) { + dobeep(); ewprintf("Display unusable"); return (FALSE); } @@ -211,11 +212,13 @@ splitwind(int f, int n) int ntru, ntrd, ntrl; if (curwp->w_ntrows < 3) { + dobeep(); ewprintf("Cannot split a %d line window", curwp->w_ntrows); return (FALSE); } wp = new_window(curbp); if (wp == NULL) { + dobeep(); ewprintf("Unable to create a window"); return (FALSE); } @@ -302,6 +305,7 @@ enlargewind(int f, int n) if (n < 0) return (shrinkwind(f, -n)); if (wheadp->w_wndp == NULL) { + dobeep(); ewprintf("Only one window"); return (FALSE); } @@ -311,6 +315,7 @@ enlargewind(int f, int n) adjwp = adjwp->w_wndp; } if (adjwp->w_ntrows <= n) { + dobeep(); ewprintf("Impossible change"); return (FALSE); } @@ -351,6 +356,7 @@ shrinkwind(int f, int n) if (n < 0) return (enlargewind(f, -n)); if (wheadp->w_wndp == NULL) { + dobeep(); ewprintf("Only one window"); return (FALSE); } @@ -359,6 +365,7 @@ shrinkwind(int f, int n) * to be trusted implicitly about sizes. */ if (!(f & FFRAND) && curwp->w_ntrows <= n) { + dobeep(); ewprintf("Impossible change"); return (FALSE); } diff --git a/usr.bin/mg/word.c b/usr.bin/mg/word.c index c18b620e672..f79dcf4c2c0 100644 --- a/usr.bin/mg/word.c +++ b/usr.bin/mg/word.c @@ -1,4 +1,4 @@ -/* $OpenBSD: word.c,v 1.15 2008/09/15 16:11:35 kjell Exp $ */ +/* $OpenBSD: word.c,v 1.16 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -74,6 +74,7 @@ upperword(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -116,6 +117,7 @@ lowerword(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -159,6 +161,7 @@ capword(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -239,6 +242,7 @@ delfword(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } @@ -293,6 +297,7 @@ delbword(int f, int n) if ((s = checkdirty(curbp)) != TRUE) return (s); if (curbp->b_flag & BFREADONLY) { + dobeep(); ewprintf("Buffer is read-only"); return (FALSE); } diff --git a/usr.bin/mg/yank.c b/usr.bin/mg/yank.c index d408286ecc7..feafc7cd31b 100644 --- a/usr.bin/mg/yank.c +++ b/usr.bin/mg/yank.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yank.c,v 1.10 2011/07/15 16:50:52 deraadt Exp $ */ +/* $OpenBSD: yank.c,v 1.11 2014/03/20 07:47:29 lum Exp $ */ /* This file is in the public domain. */ @@ -74,10 +74,12 @@ kgrow(int dir) if ((unsigned)(ksize + KBLOCK) <= (unsigned)ksize) { /* probably 16 bit unsigned */ + dobeep(); ewprintf("Kill buffer size at maximum"); return (FALSE); } if ((nbufp = malloc((unsigned)(ksize + KBLOCK))) == NULL) { + dobeep(); ewprintf("Can't get %ld bytes", (long)(ksize + KBLOCK)); return (FALSE); } |