version 1.9, 2015/03/19 21:22:15 |
version 1.10, 2015/09/26 21:51:58 |
|
|
char dir[NFILEN], cmd[BUFSIZ], title[BUFSIZ], *line, *bufp; |
char dir[NFILEN], cmd[BUFSIZ], title[BUFSIZ], *line, *bufp; |
size_t len; |
size_t len; |
int clen; |
int clen; |
|
|
if (getbufcwd(dir, sizeof(dir)) == FALSE) |
if (getbufcwd(dir, sizeof(dir)) == FALSE) |
dir[0] = '\0'; |
dir[0] = '\0'; |
|
|
bufp = eread("Index files in directory: ", dir, |
bufp = eread("Index files in directory: ", dir, |
sizeof(dir), EFCR | EFDEF | EFNEW | EFNUL); |
sizeof(dir), EFCR | EFDEF | EFNEW | EFNUL); |
|
|
if (bufp == NULL) |
if (bufp == NULL) |
return (ABORT); |
return (ABORT); |
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
|
|
if (stat(dir, &sb) == -1) { |
if (stat(dir, &sb) == -1) { |
dobeep(); |
dobeep(); |
ewprintf("stat: %s", strerror(errno)); |
ewprintf("stat: %s", strerror(errno)); |
|
|
ewprintf("%s: Not a directory", dir); |
ewprintf("%s: Not a directory", dir); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
if (csexists("cscope-indexer") == FALSE) { |
if (csexists("cscope-indexer") == FALSE) { |
dobeep(); |
dobeep(); |
ewprintf("no such file or directory, cscope-indexer"); |
ewprintf("no such file or directory, cscope-indexer"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
clen = snprintf(cmd, sizeof(cmd), "cscope-indexer -v %s", dir); |
clen = snprintf(cmd, sizeof(cmd), "cscope-indexer -v %s", dir); |
if (clen < 0 || clen >= sizeof(cmd)) |
if (clen < 0 || clen >= sizeof(cmd)) |
return (FALSE); |
return (FALSE); |
|
|
ewprintf("problem opening pipe"); |
ewprintf("problem opening pipe"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
bp = bfind("*cscope*", TRUE); |
bp = bfind("*cscope*", TRUE); |
if (bclear(bp) != TRUE) { |
if (bclear(bp) != TRUE) { |
pclose(fpipe); |
pclose(fpipe); |
|
|
addline(bp, line); |
addline(bp, line); |
} |
} |
pclose(fpipe); |
pclose(fpipe); |
return (popbuftop(bp, WNONE)); |
return (popbuftop(bp, WNONE)); |
} |
} |
|
|
/* |
/* |
|
|
{ |
{ |
struct csrecord *r; |
struct csrecord *r; |
struct csmatch *m; |
struct csmatch *m; |
|
|
if (curmatch == NULL) { |
if (curmatch == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
dobeep(); |
dobeep(); |
|
|
csnextfile(int f, int n) |
csnextfile(int f, int n) |
{ |
{ |
struct csrecord *r; |
struct csrecord *r; |
|
|
if (curmatch == NULL) { |
if (curmatch == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
dobeep(); |
dobeep(); |
|
|
} |
} |
currecord = r; |
currecord = r; |
curmatch = TAILQ_FIRST(&currecord->matches); |
curmatch = TAILQ_FIRST(&currecord->matches); |
return (jumptomatch()); |
return (jumptomatch()); |
} |
} |
|
|
/* |
/* |
|
|
csprevfile(int f, int n) |
csprevfile(int f, int n) |
{ |
{ |
struct csrecord *r; |
struct csrecord *r; |
|
|
if (curmatch == NULL) { |
if (curmatch == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
if ((r = TAILQ_FIRST(&csrecords)) == NULL) { |
dobeep(); |
dobeep(); |
|
|
} |
} |
currecord = r; |
currecord = r; |
curmatch = TAILQ_FIRST(&currecord->matches); |
curmatch = TAILQ_FIRST(&currecord->matches); |
return (jumptomatch()); |
return (jumptomatch()); |
} |
} |
|
|
/* |
/* |
* The current symbol location is extracted from currecord->filename and |
* The current symbol location is extracted from currecord->filename and |
* curmatch->lineno. Load the file similar to filevisit and goto the |
* curmatch->lineno. Load the file similar to filevisit and goto the |
* lineno recorded. |
* lineno recorded. |
*/ |
*/ |
int |
int |
|
|
{ |
{ |
struct buffer *bp; |
struct buffer *bp; |
char *adjf; |
char *adjf; |
|
|
if (curmatch == NULL || currecord == NULL) |
if (curmatch == NULL || currecord == NULL) |
return (FALSE); |
return (FALSE); |
adjf = adjustname(currecord->filename, TRUE); |
adjf = adjustname(currecord->filename, TRUE); |
|
|
} |
} |
gotoline(FFARG, curmatch->lineno); |
gotoline(FFARG, curmatch->lineno); |
return (TRUE); |
return (TRUE); |
|
|
} |
} |
|
|
/* |
/* |
* Ask for the symbol, construct cscope commandline with the symbol |
* Ask for the symbol, construct cscope commandline with the symbol |
* and passed in index. Popen cscope, read the output into *cscope* |
* and passed in index. Popen cscope, read the output into *cscope* |
* buffer and pop it. |
* buffer and pop it. |
*/ |
*/ |
int |
int |
|
|
ewprintf("C-c s not defined"); |
ewprintf("C-c s not defined"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
if (curtoken(0, 1, pattern) == FALSE) |
if (curtoken(0, 1, pattern) == FALSE) |
return (FALSE); |
return (FALSE); |
p = eread(csprompt[i], pattern, MAX_TOKEN, EFNEW | EFCR | EFDEF); |
p = eread(csprompt[i], pattern, MAX_TOKEN, EFNEW | EFCR | EFDEF); |
if (p == NULL) |
if (p == NULL) |
return (ABORT); |
return (ABORT); |
|
|
ewprintf("no such file or directory, cscope"); |
ewprintf("no such file or directory, cscope"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
csflush(); |
csflush(); |
clen = snprintf(cmd, sizeof(cmd), "cscope -L -%d %s 2>/dev/null", |
clen = snprintf(cmd, sizeof(cmd), "cscope -L -%d %s 2>/dev/null", |
i, pattern); |
i, pattern); |
|
|
ewprintf("problem opening pipe"); |
ewprintf("problem opening pipe"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
bp = bfind("*cscope*", TRUE); |
bp = bfind("*cscope*", TRUE); |
if (bclear(bp) != TRUE) { |
if (bclear(bp) != TRUE) { |
pclose(fpipe); |
pclose(fpipe); |
|
|
if (addentry(bp, buf) != TRUE) |
if (addentry(bp, buf) != TRUE) |
return (FALSE); |
return (FALSE); |
nores = 1; |
nores = 1; |
}; |
}; |
pclose(fpipe); |
pclose(fpipe); |
addline(bp, "-------------------------------------------------------------------------------"); |
addline(bp, "-------------------------------------------------------------------------------"); |
if (nores == 0) |
if (nores == 0) |
|
|
lineno = strtonum(t.lineno, INT_MIN, INT_MAX, &errstr); |
lineno = strtonum(t.lineno, INT_MIN, INT_MAX, &errstr); |
if (errstr) |
if (errstr) |
return (FALSE); |
return (FALSE); |
|
|
if (addentryfn == NULL || strcmp(addentryfn, t.fname) != 0) { |
if (addentryfn == NULL || strcmp(addentryfn, t.fname) != 0) { |
if ((r = malloc(sizeof(struct csrecord))) == NULL) |
if ((r = malloc(sizeof(struct csrecord))) == NULL) |
return (FALSE); |
return (FALSE); |
|
|
{ |
{ |
struct csrecord *r; |
struct csrecord *r; |
struct csmatch *m; |
struct csmatch *m; |
|
|
while ((r = TAILQ_FIRST(&csrecords)) != NULL) { |
while ((r = TAILQ_FIRST(&csrecords)) != NULL) { |
free(r->filename); |
free(r->filename); |
while ((m = TAILQ_FIRST(&r->matches)) != NULL) { |
while ((m = TAILQ_FIRST(&r->matches)) != NULL) { |