=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/tags.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- src/usr.bin/mg/tags.c 2014/03/06 14:51:48 1.7 +++ src/usr.bin/mg/tags.c 2014/03/20 07:47:29 1.8 @@ -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 @@ fname[0] = '\0'; if (strlcat(fname, DEFAULTFN, sizeof(fname)) >= sizeof(fname)) { + dobeep(); ewprintf("Filename too long"); return (FALSE); } @@ -87,12 +88,15 @@ 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 @@ 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 @@ tok = utok; if (tok[0] == '\0') { + dobeep(); ewprintf("There is no default tag"); return (FALSE); } @@ -211,12 +219,14 @@ * 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 @@ 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 @@ SLIST_INSERT_HEAD(&shead, s, entry); return (TRUE); } else { + dobeep(); ewprintf("%s: pattern not found", res->tag); return (FALSE); } @@ -255,6 +268,7 @@ struct tagpos *s; if (SLIST_EMPTY(&shead)) { + dobeep(); ewprintf("No previous location for find-tag invocation"); return (FALSE); } @@ -290,6 +304,7 @@ FILE *fd; if ((fd = fopen(fn, "r")) == NULL) { + dobeep(); ewprintf("Unable to open tags file: %s", fn); return (FALSE); } @@ -357,6 +372,7 @@ struct ctag *t; if ((t = malloc(sizeof(struct ctag))) == NULL) { + dobeep(); ewprintf("Out of memory"); return (FALSE); } @@ -489,6 +505,7 @@ t.tag = tok; if ((res = RB_FIND(tagtree, &tags, &t)) == NULL) { + dobeep(); ewprintf("No tag containing %s", tok); return (NULL); }