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

Diff for /src/usr.bin/patch/inp.c between version 1.23 and 1.24

version 1.23, 2003/08/05 18:13:43 version 1.24, 2003/08/05 18:20:33
Line 194 
Line 194 
         }          }
         if (i_size > SIZE_MAX) {          if (i_size > SIZE_MAX) {
                 say("block too large to mmap\n");                  say("block too large to mmap\n");
                 return false;                  return false;
         }          }
         if ((ifd = open(filename, O_RDONLY)) < 0)          if ((ifd = open(filename, O_RDONLY)) < 0)
                 pfatal("can't open file %s", filename);                  pfatal("can't open file %s", filename);
Line 214 
Line 214 
         /* test for NUL too, to maintain the behavior of the original code */          /* test for NUL too, to maintain the behavior of the original code */
         for (i = 0; i < i_size && i_womp[i] != '\0'; i++) {          for (i = 0; i < i_size && i_womp[i] != '\0'; i++) {
                 if (i_womp[i] == '\n')                  if (i_womp[i] == '\n')
                         iline++;                          iline++;
         }          }
         if (i_size > 0 && i_womp[i_size - 1] != '\n')          if (i_size > 0 && i_womp[i_size - 1] != '\n')
                 iline++;                  iline++;
Line 222 
Line 222 
   
         i_ptr = (char **) malloc((iline + 2) * sizeof(char *));          i_ptr = (char **) malloc((iline + 2) * sizeof(char *));
   
         if (i_ptr == NULL) {    /* shucks, it was a near thing */          if (i_ptr == NULL) {    /* shucks, it was a near thing */
                 munmap(i_womp, i_size);                  munmap(i_womp, i_size);
                 i_womp = NULL;                  i_womp = NULL;
                 return false;                  return false;
         }          }
   
         /* now scan the buffer and build pointer array */          /* now scan the buffer and build pointer array */
         iline = 1;          iline = 1;
Line 248 
Line 248 
                         i_womp = NULL;                          i_womp = NULL;
                         return false;                          return false;
                 }                  }
   
                 memcpy(p, i_ptr[iline], sz);                  memcpy(p, i_ptr[iline], sz);
                 p[sz] = '\n';                  p[sz] = '\n';
                 i_ptr[iline] = p;                  i_ptr[iline] = p;

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24