char *line = NULL;
int i, ret = FALSE;
- if (curwp->w_dotp->l_text[listbuf_ncol/2 - 1] == '$') {
- dobeep();
- ewprintf("buffer name truncated");
- return (FALSE);
- }
+ if (curwp->w_dotp->l_text[listbuf_ncol/2 - 1] == '$')
+ return(dobeep_msg("buffer name truncated"));
if ((line = malloc(listbuf_ncol/2)) == NULL)
return (FALSE);
ret = snprintf(pbuf, sizeof(pbuf), "Save file %s",
bp->b_fname);
if (ret < 0 || ret >= sizeof(pbuf)) {
- dobeep();
- ewprintf("Error: filename too long!");
+ (void)dobeep_msg("Error: filename too long!");
return (UERROR);
}
if ((f == TRUE || (save = eyorn(pbuf)) == TRUE) &&
else if ((bp = bfind(bufn, FALSE)) == NULL)
return (FALSE);
- if (bp == curbp) {
- dobeep();
- ewprintf("Cannot insert buffer into self");
- return (FALSE);
- }
+ if (bp == curbp)
+ return(dobeep_msg("Cannot insert buffer into self"));
+
/* insert the buffer */
nline = 0;
clp = bfirstlp(bp);
{
char fbuf[NFILEN + 32];
- if (curbp->b_fname[0] == 0) {
- dobeep();
- ewprintf("Cannot revert buffer not associated with any files.");
- return (FALSE);
- }
+ if (curbp->b_fname[0] == 0)
+ return(dobeep_msg("Cannot revert buffer not associated "
+ "with any files."));
snprintf(fbuf, sizeof(fbuf), "Revert buffer from file %s",
curbp->b_fname);
return (FALSE);
}
- if (curbp->b_fname[0] == 0) {
- dobeep();
- ewprintf("Cannot diff buffer not associated with any files.");
- return (FALSE);
- }
+ if (curbp->b_fname[0] == 0)
+ return(dobeep_msg("Cannot diff buffer not associated with "
+ "any files."));
lpend = curbp->b_headp;
for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) {
if (lforw(lp) != lpend) /* no implied \n on last line */
len++;
}
- if ((text = calloc(len + 1, sizeof(char))) == NULL) {
- dobeep();
- ewprintf("Cannot allocate memory.");
- return (FALSE);
- }
+ if ((text = calloc(len + 1, sizeof(char))) == NULL)
+ return(dobeep_msg("Cannot allocate memory."));
+
ttext = text;
for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) {
char bname[NBUFN], fname[NBUFN];
if (strlcpy(fname, fn, sizeof(fname)) >= sizeof(fname)) {
- dobeep();
- ewprintf("filename too long");
+ (void)dobeep_msg("filename too long");
return (NULL);
}
-/* $OpenBSD: cscope.c,v 1.18 2019/07/03 03:24:02 deraadt Exp $ */
+/* $OpenBSD: cscope.c,v 1.19 2021/02/28 15:30:35 lum Exp $ */
/*
* This file is in the public domain.
else if (bufp[0] == '\0')
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 (stat(dir, &sb) == -1)
+ return(dobeep_msgs("stat: %s", strerror(errno)));
+ else if (S_ISDIR(sb.st_mode) == 0)
+ return(dobeep_msgs("%s: Not a directory", dir));
- if (csexists("cscope-indexer") == FALSE) {
- dobeep();
- ewprintf("no such file or directory, cscope-indexer");
- return (FALSE);
- }
+ if (csexists("cscope-indexer") == FALSE)
+ return(dobeep_msg("no such file or directory, cscope-indexer"));
clen = snprintf(cmd, sizeof(cmd), "cscope-indexer -v %s", dir);
if (clen < 0 || clen >= sizeof(cmd))
return (FALSE);
- if ((fpipe = popen(cmd, "r")) == NULL) {
- dobeep();
- ewprintf("problem opening pipe");
- return (FALSE);
- }
+ if ((fpipe = popen(cmd, "r")) == NULL)
+ return(dobeep_msg("problem opening pipe"));
bp = bfind("*cscope*", TRUE);
if (bclear(bp) != TRUE) {
struct csmatch *m;
if (curmatch == NULL) {
- if ((r = TAILQ_FIRST(&csrecords)) == NULL) {
- dobeep();
- ewprintf("The *cscope* buffer does not exist yet");
- return (FALSE);
- }
+ if ((r = TAILQ_FIRST(&csrecords)) == NULL)
+ return(dobeep_msg("The *cscope* buffer does "
+ "not exist yet"));
+
currecord = r;
curmatch = TAILQ_FIRST(&r->matches);
} else {
if (m == NULL) {
r = TAILQ_NEXT(currecord, entry);
if (r == NULL) {
- dobeep();
- ewprintf("The end of *cscope* buffer has been"
- " reached");
- return (FALSE);
+ return(dobeep_msg("The end of *cscope* buffer "
+ "has been reached"));
} else {
currecord = r;
curmatch = TAILQ_FIRST(&currecord->matches);
else {
r = TAILQ_PREV(currecord, csrecords, entry);
if (r == NULL) {
- dobeep();
- ewprintf("The beginning of *cscope* buffer has"
- " been reached");
- return (FALSE);
+ return(dobeep_msg("The beginning of *cscope* "
+ "buffer has been reached"));
} else {
currecord = r;
curmatch = TAILQ_LAST(&currecord->matches,
struct csrecord *r;
if (curmatch == NULL) {
- if ((r = TAILQ_FIRST(&csrecords)) == NULL) {
- dobeep();
- ewprintf("The *cscope* buffer does not exist yet");
- return (FALSE);
- }
-
+ if ((r = TAILQ_FIRST(&csrecords)) == NULL)
+ return(dobeep_msg("The *cscope* buffer does not "
+ "exist yet"));
} else {
- if ((r = TAILQ_NEXT(currecord, entry)) == NULL) {
- dobeep();
- ewprintf("The end of *cscope* buffer has been reached");
- return (FALSE);
- }
+ if ((r = TAILQ_NEXT(currecord, entry)) == NULL)
+ return(dobeep_msg("The end of *cscope* buffer has "
+ "been reached"));
}
currecord = r;
curmatch = TAILQ_FIRST(&currecord->matches);
struct csrecord *r;
if (curmatch == NULL) {
- if ((r = TAILQ_FIRST(&csrecords)) == NULL) {
- dobeep();
- ewprintf("The *cscope* buffer does not exist yet");
- return (FALSE);
- }
-
+ if ((r = TAILQ_FIRST(&csrecords)) == NULL)
+ return(dobeep_msg("The *cscope* buffer does not"
+ "exist yet"));
} else {
- if ((r = TAILQ_PREV(currecord, csrecords, entry)) == NULL) {
- dobeep();
- ewprintf("The beginning of *cscope* buffer has been"
- " reached");
- return (FALSE);
- }
+ if ((r = TAILQ_PREV(currecord, csrecords, entry)) == NULL)
+ return(dobeep_msg("The beginning of *cscope* buffer "
+ "has been reached"));
}
currecord = r;
curmatch = TAILQ_FIRST(&currecord->matches);
sz = 0;
/* 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);
- }
+ if (fnmatch("*.[chy]", curbp->b_fname, 0) != 0)
+ return(dobeep_msg("C-c s not defined"));
if (curtoken(0, 1, pattern) == FALSE)
return (FALSE);
else if (p[0] == '\0')
return (FALSE);
- if (csexists("cscope") == FALSE) {
- dobeep();
- ewprintf("no such file or directory, cscope");
- return (FALSE);
- }
+ if (csexists("cscope") == FALSE)
+ return(dobeep_msg("no such file or directory, cscope"));
csflush();
clen = snprintf(cmd, sizeof(cmd), "cscope -L -%d %s 2>/dev/null",
if (clen < 0 || clen >= sizeof(cmd))
return (FALSE);
- if ((fpipe = popen(cmd, "r")) == NULL) {
- dobeep();
- ewprintf("problem opening pipe");
- return (FALSE);
- }
+ if ((fpipe = popen(cmd, "r")) == NULL)
+ return(dobeep_msg("problem opening pipe"));
bp = bfind("*cscope*", TRUE);
if (bclear(bp) != TRUE) {
}
if ((tmp = getenv("PATH")) == NULL)
return (FALSE);
- if ((pathc = path = strndup(tmp, NFILEN)) == NULL) {
- dobeep();
- ewprintf("out of memory");
- return (FALSE);
- }
+ if ((pathc = path = strndup(tmp, NFILEN)) == NULL)
+ return(dobeep_msg("out of memory"));
+
while ((dir = strsep(&path, ":")) != NULL) {
if (*dir == '\0')
continue;
len = snprintf(fname, sizeof(fname), "%s/%s", dir, cmd);
if (len < 0 || len >= sizeof(fname)) {
- dobeep();
- ewprintf("path too long");
+ (void)dobeep_msg("path too long");
goto cleanup;
}
if(access(fname, F_OK) == 0) {