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

Diff for /src/usr.bin/mg/extend.c between version 1.73 and 1.74

version 1.73, 2021/03/21 12:56:16 version 1.74, 2021/03/25 12:46:11
Line 570 
Line 570 
   
 /*  /*
  * evalexpr - get one line from the user, and run it.   * evalexpr - get one line from the user, and run it.
    * Use strlen for length of line, assume user is not typing in a '\0' in the
    * modeline. llen only used for foundparen() so old-school will be ok.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 evalexpr(int f, int n)  evalexpr(int f, int n)
 {  {
         char     exbuf[BUFSIZE], *bufp;          char     exbuf[BUFSIZE], *bufp;
           int      llen;
   
         if ((bufp = eread("Eval: ", exbuf, sizeof(exbuf),          if ((bufp = eread("Eval: ", exbuf, sizeof(exbuf),
             EFNEW | EFCR)) == NULL)              EFNEW | EFCR)) == NULL)
                 return (ABORT);                  return (ABORT);
         else if (bufp[0] == '\0')          else if (bufp[0] == '\0')
                 return (FALSE);                  return (FALSE);
         return (excline(exbuf));          llen = strlen(bufp);
   
           return (excline(exbuf, llen));
 }  }
   
 /*  /*
Line 595 
Line 600 
 {  {
         struct line             *lp;          struct line             *lp;
         struct buffer           *bp = curbp;          struct buffer           *bp = curbp;
         int              s;          int              s, llen;
         static char      excbuf[BUFSIZE];          static char      excbuf[BUFSIZE];
   
         for (lp = bfirstlp(bp); lp != bp->b_headp; lp = lforw(lp)) {          for (lp = bfirstlp(bp); lp != bp->b_headp; lp = lforw(lp)) {
                 if (llength(lp) >= BUFSIZE)                  llen = llength(lp);
                   if (llen >= BUFSIZE)
                         return (FALSE);                          return (FALSE);
                 (void)strncpy(excbuf, ltext(lp), llength(lp));                  (void)strncpy(excbuf, ltext(lp), llen);
   
                 /* make sure it's terminated */                  /* make sure the line is terminated */
                 excbuf[llength(lp)] = '\0';                  excbuf[llen] = '\0';
                 if ((s = excline(excbuf)) != TRUE) {                  if ((s = excline(excbuf, llen)) != TRUE) {
                         cleanup();                          cleanup();
                         return (s);                          return (s);
                 }                  }
Line 661 
Line 667 
             == FIOSUC) {              == FIOSUC) {
                 line++;                  line++;
                 excbuf[nbytes] = '\0';                  excbuf[nbytes] = '\0';
                 if (excline(excbuf) != TRUE) {                  if (excline(excbuf, nbytes) != TRUE) {
                         s = FIOERR;                          s = FIOERR;
                         dobeep();                          dobeep();
                         ewprintf("Error loading file %s at line %d", fncpy, line);                          ewprintf("Error loading file %s at line %d", fncpy, line);
Line 670 
Line 676 
         }          }
         (void)ffclose(ffp, NULL);          (void)ffclose(ffp, NULL);
         excbuf[nbytes] = '\0';          excbuf[nbytes] = '\0';
         if (s != FIOEOF || (nbytes && excline(excbuf) != TRUE))          if (s != FIOEOF || (nbytes && excline(excbuf, nbytes) != TRUE))
                 return (FALSE);                  return (FALSE);
         return (TRUE);          return (TRUE);
 }  }
Line 679 
Line 685 
  * excline - run a line from a load file or eval-expression.   * excline - run a line from a load file or eval-expression.
  */   */
 int  int
 excline(char *line)  excline(char *line, int llen)
 {  {
         PF       fp;          PF       fp;
         struct line     *lp, *np;          struct line     *lp, *np;
Line 706 
Line 712 
         if (*funcp == '\0')          if (*funcp == '\0')
                 return (TRUE);  /* No error on blank lines */                  return (TRUE);  /* No error on blank lines */
         if (*funcp == '(')          if (*funcp == '(')
                 return (foundparen(funcp));                  return (foundparen(funcp, llen));
         line = parsetoken(funcp);          line = parsetoken(funcp);
         if (*line != '\0') {          if (*line != '\0') {
                 *line++ = '\0';                  *line++ = '\0';

Legend:
Removed from v.1.73  
changed lines
  Added in v.1.74