home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0084 < prev    next >
Encoding:
Text File  |  1982-02-25  |  1.5 KB  |  51 lines

  1. Autzoo.1430
  2. net.bugs.v7
  3. utcsrgv!utzoo!henry
  4. Wed Feb 24 21:37:58 1982
  5. wc verbosity
  6. The wc program is not half as useful as it should be, because it runs
  7. off at the mouth.  It insists on printing a filename even if it was
  8. given only one argument;  moreover, it inserts blanks to make its
  9. output look nice, and insists on inserting them even if only a
  10. partial output is requested.  The result is that a shell program which
  11. simply wants to count the lines in a file cannot use wc directly;  it
  12. must process the output through a sed filter or the equivalent to strip
  13. out the babble and get a single clean number.
  14.  
  15. It is easy to fix wc so that (a) it prints filenames only if there is
  16. more than one file, and (b) it uses tabs rather than fixed fields for
  17. output formatting, and suppresses them when they are not needed.  The
  18. resulting program doesn't yield quite as elegant an output format, but
  19. is much more useful as a TOOL.  (And if I want elegant output, I'll
  20. run it through tbl anyway...).  Here are the changes (line numbers may
  21. be off a bit from the V7 distribution version):
  22.  
  23. 53,54c55,56
  24. <         if(argc>1) {
  25. <             printf(" %s\n", argv[i]);
  26. ---
  27. >         if(argc>2) {
  28. >             printf("\t%s\n", argv[i]);
  29. 64c66
  30. <         printf(" total\n");
  31. ---
  32. >         printf("\ttotal\n");
  33. 75c77,79
  34. <         printf("%7ld", linect);
  35. ---
  36. >         printf("%ld", linect);
  37. >         if (*wd != '\0')
  38. >             putchar('\t');
  39. 79c83,85
  40. <         printf("%7ld ", wordct);
  41. ---
  42. >         printf("%ld", wordct);
  43. >         if (*wd != '\0')
  44. >             putchar('\t');
  45. 83c89,91
  46. <         printf("%7ld", charct);
  47. ---
  48. >         printf("%ld", charct);
  49. >         if (*wd != '\0')
  50. >             putchar('\t');
  51.