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

Diff for /src/usr.bin/patch/pch.c between version 1.40 and 1.41

version 1.40, 2013/07/11 12:39:31 version 1.41, 2013/11/26 13:19:07
Line 283 
Line 283 
                         else                          else
                                 indent++;                                  indent++;
                 }                  }
                 for (t = s; isdigit(*t) || *t == ','; t++)                  for (t = s; isdigit((unsigned char)*t) || *t == ','; t++)
                         ;                          ;
                 this_is_a_command = (isdigit(*s) &&                  this_is_a_command = (isdigit((unsigned char)*s) &&
                     (*t == 'd' || *t == 'c' || *t == 'a'));                      (*t == 'd' || *t == 'c' || *t == 'a'));
                 if (first_command_line < 0L && this_is_a_command) {                  if (first_command_line < 0L && this_is_a_command) {
                         first_command_line = this_line;                          first_command_line = this_line;
Line 306 
Line 306 
                         names[INDEX_FILE].path = fetchname(s + 6,                          names[INDEX_FILE].path = fetchname(s + 6,
                             &names[INDEX_FILE].exists, strippath);                              &names[INDEX_FILE].exists, strippath);
                 else if (strnEQ(s, "Prereq:", 7)) {                  else if (strnEQ(s, "Prereq:", 7)) {
                         for (t = s + 7; isspace(*t); t++)                          for (t = s + 7; isspace((unsigned char)*t); t++)
                                 ;                                  ;
                         revision = savestr(t);                          revision = savestr(t);
                         for (t = revision; *t && !isspace(*t); t++)                          for (t = revision;
                               *t && !isspace((unsigned char)*t); t++)
                                 ;                                  ;
                         *t = '\0';                          *t = '\0';
                         if (*revision == '\0') {                          if (*revision == '\0') {
Line 567 
Line 568 
                                         p_end--;                                          p_end--;
                                         return false;                                          return false;
                                 }                                  }
                                 for (s = buf; *s && !isdigit(*s); s++)                                  for (s = buf;
                                       *s && !isdigit((unsigned char)*s); s++)
                                         ;                                          ;
                                 if (!*s)                                  if (!*s)
                                         malformed();                                          malformed();
                                 if (strnEQ(s, "0,0", 3))                                  if (strnEQ(s, "0,0", 3))
                                         memmove(s, s + 2, strlen(s + 2) + 1);                                          memmove(s, s + 2, strlen(s + 2) + 1);
                                 p_first = (LINENUM) atol(s);                                  p_first = (LINENUM) atol(s);
                                 while (isdigit(*s))                                  while (isdigit((unsigned char)*s))
                                         s++;                                          s++;
                                 if (*s == ',') {                                  if (*s == ',') {
                                         for (; *s && !isdigit(*s); s++)                                          for (; *s && !isdigit((unsigned char)*s); s++)
                                                 ;                                                  ;
                                         if (!*s)                                          if (!*s)
                                                 malformed();                                                  malformed();
Line 636 
Line 638 
                                                 return false;                                                  return false;
                                         }                                          }
                                         p_char[p_end] = '=';                                          p_char[p_end] = '=';
                                         for (s = buf; *s && !isdigit(*s); s++)                                          for (s = buf;
                                               *s && !isdigit((unsigned char)*s); s++)
                                                 ;                                                  ;
                                         if (!*s)                                          if (!*s)
                                                 malformed();                                                  malformed();
                                         p_newfirst = (LINENUM) atol(s);                                          p_newfirst = (LINENUM) atol(s);
                                         while (isdigit(*s))                                          while (isdigit((unsigned char)*s))
                                                 s++;                                                  s++;
                                         if (*s == ',') {                                          if (*s == ',') {
                                                 for (; *s && !isdigit(*s); s++)                                                  for (; *s && !isdigit((unsigned char)*s); s++)
                                                         ;                                                          ;
                                                 if (!*s)                                                  if (!*s)
                                                         malformed();                                                          malformed();
Line 674 
Line 677 
                 change_line:                  change_line:
                                 if (buf[1] == '\n' && canonicalize)                                  if (buf[1] == '\n' && canonicalize)
                                         strlcpy(buf + 1, " \n", sizeof buf - 1);                                          strlcpy(buf + 1, " \n", sizeof buf - 1);
                                 if (!isspace(buf[1]) && buf[1] != '>' &&                                  if (!isspace((unsigned char)buf[1]) &&
                                     buf[1] != '<' &&                                      buf[1] != '>' && buf[1] != '<' &&
                                     repl_beginning && repl_could_be_missing) {                                      repl_beginning && repl_could_be_missing) {
                                         repl_missing = true;                                          repl_missing = true;
                                         goto hunk_done;                                          goto hunk_done;
Line 721 
Line 724 
                                 }                                  }
                                 break;                                  break;
                         case ' ':                          case ' ':
                                 if (!isspace(buf[1]) &&                                  if (!isspace((unsigned char)buf[1]) &&
                                     repl_beginning && repl_could_be_missing) {                                      repl_beginning && repl_could_be_missing) {
                                         repl_missing = true;                                          repl_missing = true;
                                         goto hunk_done;                                          goto hunk_done;
Line 849 
Line 852 
                 if (!*s)                  if (!*s)
                         malformed();                          malformed();
                 p_first = (LINENUM) atol(s);                  p_first = (LINENUM) atol(s);
                 while (isdigit(*s))                  while (isdigit((unsigned char)*s))
                         s++;                          s++;
                 if (*s == ',') {                  if (*s == ',') {
                         p_ptrn_lines = (LINENUM) atol(++s);                          p_ptrn_lines = (LINENUM) atol(++s);
                         while (isdigit(*s))                          while (isdigit((unsigned char)*s))
                                 s++;                                  s++;
                 } else                  } else
                         p_ptrn_lines = 1;                          p_ptrn_lines = 1;
Line 862 
Line 865 
                 if (*s != '+' || !*++s)                  if (*s != '+' || !*++s)
                         malformed();                          malformed();
                 p_newfirst = (LINENUM) atol(s);                  p_newfirst = (LINENUM) atol(s);
                 while (isdigit(*s))                  while (isdigit((unsigned char)*s))
                         s++;                          s++;
                 if (*s == ',') {                  if (*s == ',') {
                         p_repl_lines = (LINENUM) atol(++s);                          p_repl_lines = (LINENUM) atol(++s);
                         while (isdigit(*s))                          while (isdigit((unsigned char)*s))
                                 s++;                                  s++;
                 } else                  } else
                         p_repl_lines = 1;                          p_repl_lines = 1;
Line 1009 
Line 1012 
                 p_context = 0;                  p_context = 0;
                 ret = pgets(buf, sizeof buf, pfp);                  ret = pgets(buf, sizeof buf, pfp);
                 p_input_line++;                  p_input_line++;
                 if (ret == NULL || !isdigit(*buf)) {                  if (ret == NULL || !isdigit((unsigned char)*buf)) {
                         next_intuit_at(line_beginning, p_input_line);                          next_intuit_at(line_beginning, p_input_line);
                         return false;                          return false;
                 }                  }
                 p_first = (LINENUM) atol(buf);                  p_first = (LINENUM) atol(buf);
                 for (s = buf; isdigit(*s); s++)                  for (s = buf; isdigit((unsigned char)*s); s++)
                         ;                          ;
                 if (*s == ',') {                  if (*s == ',') {
                         p_ptrn_lines = (LINENUM) atol(++s) - p_first + 1;                          p_ptrn_lines = (LINENUM) atol(++s) - p_first + 1;
                         while (isdigit(*s))                          while (isdigit((unsigned char)*s))
                                 s++;                                  s++;
                 } else                  } else
                         p_ptrn_lines = (*s != 'a');                          p_ptrn_lines = (*s != 'a');
Line 1026 
Line 1029 
                 if (hunk_type == 'a')                  if (hunk_type == 'a')
                         p_first++;      /* do append rather than insert */                          p_first++;      /* do append rather than insert */
                 min = (LINENUM) atol(++s);                  min = (LINENUM) atol(++s);
                 for (; isdigit(*s); s++)                  for (; isdigit((unsigned char)*s); s++)
                         ;                          ;
                 if (*s == ',')                  if (*s == ',')
                         max = (LINENUM) atol(++s);                          max = (LINENUM) atol(++s);
Line 1383 
Line 1386 
                         break;                          break;
                 }                  }
                 p_input_line++;                  p_input_line++;
                 for (t = buf; isdigit(*t) || *t == ','; t++)                  for (t = buf; isdigit((unsigned char)*t) || *t == ','; t++)
                         ;                          ;
                 /* POSIX defines allowed commands as {a,c,d,i,s} */                  /* POSIX defines allowed commands as {a,c,d,i,s} */
                 if (isdigit(*buf) && (*t == 'a' || *t == 'c' || *t == 'd' ||                  if (isdigit((unsigned char)*buf) &&
                     *t == 'i' || *t == 's')) {                      (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 's')) {
                         if (pipefp != NULL)                          if (pipefp != NULL)
                                 fputs(buf, pipefp);                                  fputs(buf, pipefp);
                         if (*t != 'd') {                          if (*t != 'd') {

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41