[BACK]Return to miscbltin.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / bin / sh

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/bin/sh/miscbltin.c between version 1.44 and 1.44.2.1

version 1.44, 2017/05/13 15:03:34 version 1.44.2.1, 2022/10/27 16:16:50
Line 99  readcmd(int argc, char **argv)
Line 99  readcmd(int argc, char **argv)
         int i;          int i;
         int is_ifs;          int is_ifs;
         int saveall = 0;          int saveall = 0;
           ptrdiff_t wordlen = 0;
   
         rflag = 0;          rflag = 0;
         prompt = NULL;          prompt = NULL;
Line 109  readcmd(int argc, char **argv)
Line 110  readcmd(int argc, char **argv)
                         rflag = 1;                          rflag = 1;
         }          }
   
           if (*(ap = argptr) == NULL)
                   error("variable name required\n"
                           "Usage: read [-r] [-p prompt] var...");
   
         if (prompt && isatty(0)) {          if (prompt && isatty(0)) {
                 out2str(prompt);                  out2str(prompt);
                 flushall();                  flushall();
         }          }
   
         if (*(ap = argptr) == NULL)  
                 error("arg count");  
   
         if ((ifs = bltinlookup("IFS", 1)) == NULL)          if ((ifs = bltinlookup("IFS", 1)) == NULL)
                 ifs = " \t\n";                  ifs = " \t\n";
   
Line 136  readcmd(int argc, char **argv)
Line 138  readcmd(int argc, char **argv)
                                 break;                                  break;
                         }                          }
                         if (c != '\n')                          if (c != '\n')
                                 STPUTC(c, p);                                  goto wdch;
                         continue;                          continue;
                 }                  }
                 if (c == '\n')                  if (c == '\n')
Line 163  readcmd(int argc, char **argv)
Line 165  readcmd(int argc, char **argv)
                 }                  }
   
                 if (is_ifs == 0) {                  if (is_ifs == 0) {
     wdch:;
                         /* append this character to the current variable */                          /* append this character to the current variable */
                         startword = 0;                          startword = 0;
                         if (saveall)                          if (saveall)
                                 /* Not just a spare terminator */                                  /* Not just a spare terminator */
                                 saveall++;                                  saveall++;
                         STPUTC(c, p);                          STPUTC(c, p);
                           wordlen = p - stackblock();
                         continue;                          continue;
                 }                  }
   
Line 186  readcmd(int argc, char **argv)
Line 190  readcmd(int argc, char **argv)
                 setvar(*ap, stackblock(), 0);                  setvar(*ap, stackblock(), 0);
                 ap++;                  ap++;
                 STARTSTACKSTR(p);                  STARTSTACKSTR(p);
                   wordlen = 0;
         }          }
         STACKSTRNUL(p);          STACKSTRNUL(p);
   
         /* Remove trailing IFS chars */          /* Remove trailing IFS chars */
         for (; stackblock() <= --p; *p = 0) {          for (; stackblock() + wordlen <= --p; *p = 0) {
                 if (!strchr(ifs, *p))                  if (!strchr(ifs, *p))
                         break;                          break;
                 if (strchr(" \t\n", *p))                  if (strchr(" \t\n", *p))

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.44.2.1

CVSweb <webmaster@jp.NetBSD.org>