version 1.28, 2006/05/02 17:10:25 |
version 1.29, 2006/05/27 21:22:45 |
|
|
static int |
static int |
grep(int f, int n) |
grep(int f, int n) |
{ |
{ |
char command[NFILEN + 21]; |
|
char cprompt[NFILEN], *bufp; |
char cprompt[NFILEN], *bufp; |
struct buffer *bp; |
struct buffer *bp; |
struct mgwin *wp; |
struct mgwin *wp; |
|
|
return (ABORT); |
return (ABORT); |
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
(void)snprintf(command, sizeof(command), "%s /dev/null", bufp); |
if (strlcat(cprompt, " /dev/null", sizeof(cprompt)) >= sizeof(cprompt)) |
|
return (FALSE); |
|
|
if ((bp = compile_mode("*grep*", command)) == NULL) |
if ((bp = compile_mode("*grep*", cprompt)) == NULL) |
return (FALSE); |
return (FALSE); |
if ((wp = popbuf(bp)) == NULL) |
if ((wp = popbuf(bp)) == NULL) |
return (FALSE); |
return (FALSE); |
|
|
static int |
static int |
xlint(int f, int n) |
xlint(int f, int n) |
{ |
{ |
char command[NFILEN + 16]; |
|
char cprompt[NFILEN], *bufp; |
char cprompt[NFILEN], *bufp; |
struct buffer *bp; |
struct buffer *bp; |
struct mgwin *wp; |
struct mgwin *wp; |
|
|
return (ABORT); |
return (ABORT); |
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
(void)snprintf(command, sizeof(command), "%s 2>&1", bufp); |
|
|
|
if ((bp = compile_mode("*lint*", command)) == NULL) |
if ((bp = compile_mode("*lint*", cprompt)) == NULL) |
return (FALSE); |
return (FALSE); |
if ((wp = popbuf(bp)) == NULL) |
if ((wp = popbuf(bp)) == NULL) |
return (FALSE); |
return (FALSE); |
|
|
static int |
static int |
compile(int f, int n) |
compile(int f, int n) |
{ |
{ |
char command[NFILEN + 20]; |
|
char cprompt[NFILEN], *bufp; |
char cprompt[NFILEN], *bufp; |
struct buffer *bp; |
struct buffer *bp; |
struct mgwin *wp; |
struct mgwin *wp; |
|
|
return (ABORT); |
return (ABORT); |
(void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command)); |
(void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command)); |
|
|
(void)snprintf(command, sizeof(command), "%s 2>&1", bufp); |
if ((bp = compile_mode("*compile*", cprompt)) == NULL) |
|
|
if ((bp = compile_mode("*compile*", command)) == NULL) |
|
return (FALSE); |
return (FALSE); |
if ((wp = popbuf(bp)) == NULL) |
if ((wp = popbuf(bp)) == NULL) |
return (FALSE); |
return (FALSE); |
|
|
static int |
static int |
gid(int f, int n) |
gid(int f, int n) |
{ |
{ |
char command[NFILEN + 20]; |
char command[NFILEN]; |
char cprompt[NFILEN], c, *bufp; |
char cprompt[NFILEN], c, *bufp; |
struct buffer *bp; |
struct buffer *bp; |
struct mgwin *wp; |
struct mgwin *wp; |
int i, j; |
int i, j, len; |
|
|
/* catch ([^\s(){}]+)[\s(){}]* */ |
/* catch ([^\s(){}]+)[\s(){}]* */ |
|
|
|
|
return (ABORT); |
return (ABORT); |
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
(void)snprintf(command, sizeof(command), "gid %s", cprompt); |
len = snprintf(command, sizeof(command), "gid %s", cprompt); |
|
if (len < 0 || len >= sizeof(command)) |
|
return (FALSE); |
|
|
if ((bp = compile_mode("*gid*", command)) == NULL) |
if ((bp = compile_mode("*gid*", command)) == NULL) |
return (FALSE); |
return (FALSE); |
|
|
FILE *fpipe; |
FILE *fpipe; |
char *buf; |
char *buf; |
size_t len; |
size_t len; |
int ret; |
int ret, n; |
char cwd[NFILEN]; |
char cwd[NFILEN], qcmd[NFILEN]; |
char timestr[NTIME]; |
char timestr[NTIME]; |
time_t t; |
time_t t; |
|
|
|
n = snprintf(qcmd, sizeof(qcmd), "%s 2>&1", command); |
|
if (n < 0 || n >= sizeof(qcmd)) |
|
return (NULL); |
|
|
bp = bfind(name, TRUE); |
bp = bfind(name, TRUE); |
if (bclear(bp) != TRUE) |
if (bclear(bp) != TRUE) |
return (NULL); |
return (NULL); |
|
|
if (getbufcwd(bp->b_cwd, sizeof(bp->b_cwd)) != TRUE) |
if (getbufcwd(bp->b_cwd, sizeof(bp->b_cwd)) != TRUE) |
return (NULL); |
return (NULL); |
addlinef(bp, "cd %s", bp->b_cwd); |
addlinef(bp, "cd %s", bp->b_cwd); |
addline(bp, command); |
addline(bp, qcmd); |
addline(bp, ""); |
addline(bp, ""); |
|
|
if (getcwd(cwd, sizeof(cwd)) == NULL) |
if (getcwd(cwd, sizeof(cwd)) == NULL) |
|
|
ewprintf("Can't change dir to %s", bp->b_cwd); |
ewprintf("Can't change dir to %s", bp->b_cwd); |
return (NULL); |
return (NULL); |
} |
} |
if ((fpipe = popen(command, "r")) == NULL) { |
if ((fpipe = popen(qcmd, "r")) == NULL) { |
ewprintf("Problem opening pipe"); |
ewprintf("Problem opening pipe"); |
return (NULL); |
return (NULL); |
} |
} |
|
|
struct buffer *bp; |
struct buffer *bp; |
struct mgwin *wp; |
struct mgwin *wp; |
char *fname, *line, *lp, *ln; |
char *fname, *line, *lp, *ln; |
int lineno, len; |
int lineno; |
char *adjf, path[NFILEN]; |
char *adjf, path[NFILEN]; |
const char *errstr; |
const char *errstr; |
struct line *last; |
struct line *last; |
|
|
/* last line is compilation result */ |
/* last line is compilation result */ |
if (curwp->w_dotp == last) |
if (curwp->w_dotp == last) |
return (FALSE); |
return (FALSE); |
|
|
len = llength(curwp->w_dotp); |
if ((line = linetostr(curwp->w_dotp)) == NULL) |
|
|
if ((line = malloc(len + 1)) == NULL) |
|
return (FALSE); |
return (FALSE); |
|
|
(void)memcpy(line, curwp->w_dotp->l_text, len); |
|
line[len] = '\0'; |
|
|
|
lp = line; |
lp = line; |
if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') |
if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') |
goto fail; |
goto fail; |