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

Diff for /src/usr.bin/xstr/Attic/xstr.c between version 1.7 and 1.8

version 1.7, 2002/02/23 21:47:32 version 1.8, 2002/02/23 22:09:37
Line 68 
Line 68 
   
 off_t   tellpt;  off_t   tellpt;
 off_t   mesgpt;  off_t   mesgpt;
 char    *strings =      "strings";  char    *strings = "strings";
 char    *array =        0;  char    *array = 0;
   
 int     cflg;  int     cflg;
 int     vflg;  int     vflg;
Line 118 
Line 118 
                         array = optarg;                          array = optarg;
                         break;                          break;
                 default:                  default:
                         fprintf(stderr, "usage: xstr [ -v ] [ -c ] [ -l array ] [ - ] [ name ... ]\n");                          fprintf(stderr,
                         exit (1);                              "usage: xstr [-vc] [-l array] [-] [name ...]\n");
                           exit(1);
                 }                  }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
Line 147 
Line 148 
         }          }
   
         while (readstd || argc > 0) {          while (readstd || argc > 0) {
                 if (freopen("x.c", "w", stdout) == NULL)                  if (freopen("x.c", "w", stdout) == NULL) {
                         perror("x.c"), exit(1);                          perror("x.c");
                 if (!readstd && freopen(argv[0], "r", stdin) == NULL)                          exit(1);
                         perror(argv[0]), exit(2);                  }
                   if (!readstd && freopen(argv[0], "r", stdin) == NULL) {
                           perror(argv[0]);
                           exit(2);
                   }
                 process("x.c");                  process("x.c");
                 if (readstd == 0)                  if (readstd == 0)
                         argc--, argv++;                          argc--, argv++;
                 else                  else
                         readstd = 0;                          readstd = 0;
         };          }
         flushsh();          flushsh();
         if (cflg == 0)          if (cflg == 0)
                 xsdotc();                  xsdotc();
Line 252 
Line 257 
                         if (c == 0)                          if (c == 0)
                                 break;                                  break;
                         if (c == '\n') {                          if (c == '\n') {
                                 if (fgets(linebuf, sizeof linebuf, stdin)                                  if (fgets(linebuf, sizeof linebuf, stdin)
                                     == NULL) {                                      == NULL) {
                                         if (ferror(stdin)) {                                          if (ferror(stdin)) {
                                                 perror("x.c");                                                  perror("x.c");
Line 381 
Line 386 
         if (new == 0 && old != 0)          if (new == 0 && old != 0)
                 return;                  return;
         mesgwrit = fopen(strings, old ? "r+" : "w");          mesgwrit = fopen(strings, old ? "r+" : "w");
         if (mesgwrit == NULL)          if (mesgwrit == NULL) {
                 perror(strings), exit(4);                  perror(strings);
                   exit(4);
           }
         for (i = 0; i < BUCKETS; i++)          for (i = 0; i < BUCKETS; i++)
                 for (hp = bucket[i].hnext; hp != NULL; hp = hp->hnext) {                  for (hp = bucket[i].hnext; hp != NULL; hp = hp->hnext) {
                         found(hp->hnew, hp->hpt, hp->hstr);                          found(hp->hnew, hp->hpt, hp->hstr);
                         if (hp->hnew) {                          if (hp->hnew) {
                                 fseek(mesgwrit, hp->hpt, 0);                                  fseek(mesgwrit, hp->hpt, 0);
                                 fwrite(hp->hstr, strlen(hp->hstr) + 1, 1, mesgwrit);                                  fwrite(hp->hstr, strlen(hp->hstr) + 1, 1, mesgwrit);
                                 if (ferror(mesgwrit))                                  if (ferror(mesgwrit)) {
                                         perror(strings), exit(4);                                          perror(strings);
                                           exit(4);
                                   }
                         }                          }
                 }                  }
         if (fclose(mesgwrit) == EOF)          if (fclose(mesgwrit) == EOF) {
                 perror(strings), exit(4);                  perror(strings);
                   exit(4);
           }
 }  }
   
 void  void
Line 432 
Line 443 
         FILE *strf = fopen(strings, "r");          FILE *strf = fopen(strings, "r");
         FILE *xdotcf;          FILE *xdotcf;
   
         if (strf == NULL)          if (strf == NULL) {
                 perror(strings), exit(5);                  perror(strings);
                   exit(5);
           }
         xdotcf = fopen("xs.c", "w");          xdotcf = fopen("xs.c", "w");
         if (xdotcf == NULL)          if (xdotcf == NULL) {
                 perror("xs.c"), exit(6);                  perror("xs.c");
                   exit(6);
           }
         fprintf(xdotcf, "char\t%s[] = {\n", array);          fprintf(xdotcf, "char\t%s[] = {\n", array);
         for (;;) {          for (;;) {
                 int i, c;                  int i, c;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8