From 6a0a6cdf1572523b52f30ca110ab358f5e088f18 Mon Sep 17 00:00:00 2001 From: Mark Lumsden Date: Thu, 20 Mar 2014 07:47:30 +0000 Subject: Add some missing dobeeps. ok florian@ --- usr.bin/mg/dired.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'usr.bin/mg/dired.c') 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); } -- cgit v1.2.3