[BACK]Return to cscope.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/cscope.c between version 1.9 and 1.10

version 1.9, 2015/03/19 21:22:15 version 1.10, 2015/09/26 21:51:58
Line 168 
Line 168 
         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));
Line 189 
Line 189 
                 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);
Line 205 
Line 205 
                 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);
Line 227 
Line 227 
                 addline(bp, line);                  addline(bp, line);
         }          }
         pclose(fpipe);          pclose(fpipe);
         return (popbuftop(bp, WNONE));          return (popbuftop(bp, WNONE));
 }  }
   
 /*  /*
Line 239 
Line 239 
 {  {
         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();
Line 307 
Line 307 
 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();
Line 324 
Line 324 
         }          }
         currecord = r;          currecord = r;
         curmatch = TAILQ_FIRST(&currecord->matches);          curmatch = TAILQ_FIRST(&currecord->matches);
         return (jumptomatch());          return (jumptomatch());
 }  }
   
 /*  /*
Line 334 
Line 334 
 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();
Line 352 
Line 352 
         }          }
         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
Line 365 
Line 365 
 {  {
         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);
Line 382 
Line 382 
         }          }
         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
Line 406 
Line 405 
                 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);
Line 420 
Line 419 
                 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);
Line 432 
Line 431 
                 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);
Line 454 
Line 453 
                 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)
Line 483 
Line 482 
         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);
Line 570 
Line 569 
 {  {
         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) {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10