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

Diff for /src/usr.bin/paste/paste.c between version 1.5 and 1.6

version 1.5, 1998/11/16 06:09:12 version 1.6, 1999/08/23 23:58:23
Line 48 
Line 48 
 #endif /* not lint */  #endif /* not lint */
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <unistd.h>  
 #include <errno.h>  #include <errno.h>
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <unistd.h>
   
 char *delim;  char *delim;
 int delimcnt;  int delimcnt;
Line 115 
Line 116 
         register char ch, *p;          register char ch, *p;
         LIST *head, *tmp;          LIST *head, *tmp;
         int opencnt, output;          int opencnt, output;
         char buf[_POSIX2_LINE_MAX + 1], *malloc();          size_t len;
   
         for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) {          for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) {
                 if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) {                  if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) {
Line 148 
Line 149 
                                         putchar(ch);                                          putchar(ch);
                                 continue;                                  continue;
                         }                          }
                         if (!fgets(buf, sizeof(buf), lp->fp)) {                          if (!(p = fgetln(lp->fp, &len))) {
                                 if (!--opencnt)                                  if (!--opencnt)
                                         break;                                          break;
                                 lp->fp = NULL;                                  lp->fp = NULL;
Line 157 
Line 158 
                                         putchar(ch);                                          putchar(ch);
                                 continue;                                  continue;
                         }                          }
                         if (!(p = strchr(buf, '\n'))) {                          if (*(p + len - 1) == '\n')
                                   *(p + len - 1) = '\0';
                           else {
                                 (void)fprintf(stderr,                                  (void)fprintf(stderr,
                                     "paste: %s: input line too long.\n",                                      "paste: %s: incomplete line.\n",
                                     lp->name);                                      lp->name);
                                 exit(1);                                  exit(1);
                         }                          }
                         *p = '\0';  
                         /*                          /*
                          * make sure that we don't print any delimiters                           * make sure that we don't print any delimiters
                          * unless there's a non-empty file.                           * unless there's a non-empty file.
Line 175 
Line 177 
                                                 putchar(ch);                                                  putchar(ch);
                         } else if ((ch = delim[(lp->cnt - 1) % delimcnt]))                          } else if ((ch = delim[(lp->cnt - 1) % delimcnt]))
                                 putchar(ch);                                  putchar(ch);
                         (void)printf("%s", buf);                          (void)printf("%s", p);
                 }                  }
                 if (output)                  if (output)
                         putchar('\n');                          putchar('\n');

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6