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

Diff for /src/usr.bin/fmt/fmt.c between version 1.15 and 1.16

version 1.15, 1999/12/30 18:00:42 version 1.16, 2000/06/25 15:35:42
Line 284 
Line 284 
   
   /* 1. Grok parameters. */    /* 1. Grok parameters. */
   
   while ((ch = getopt(argc, argv, "cd:hl:mpst:")) != -1) switch(ch) {    while ((ch = getopt(argc, argv, "0123456789cd:hl:mpst:w:")) != -1)
     switch(ch) {
     case 'c':      case 'c':
       centerP = 1;        centerP = 1;
       continue;        continue;
Line 308 
Line 309 
     case 't':      case 't':
       tab_width = get_positive(optarg, "tab width must be positive", 1);        tab_width = get_positive(optarg, "tab width must be positive", 1);
       continue;        continue;
       case 'w':
         goal_length = get_positive(optarg, "width must be positive", 1);
         max_length = goal_length;
         continue;
       case '0': case '1': case '2': case '3': case '4': case '5':
       case '6': case '7': case '8': case '9':
       /* XXX  this is not a stylistically approved use of getopt() */
         if (goal_length==0) {
           char *p;
           p = argv[optind - 1];
           if (p[0] == '-' && p[1] == ch && !p[2])
                goal_length = get_positive(++p, "width must be nonzero", 1);
           else
                goal_length = get_positive(argv[optind]+1,
                    "width must be nonzero", 1);
           max_length = goal_length;
         }
         continue;
     case 'h': default:      case 'h': default:
       fprintf(stderr,        fprintf(stderr,
 "Usage:   fmt [-cmps] [-d chars] [-l num] [-t num] [goal [maximum]] [file...]\n"  "Usage:   fmt [-cmps] [-d chars] [-l num] [-t num]\n"
   "             [-w width | -width | goal [maximum]] [file ...]\n"
 "Options: -c     " CENTER " each line instead of formatting\n"  "Options: -c     " CENTER " each line instead of formatting\n"
 "         -d <chars> double-space after <chars> at line end\n"  "         -d <chars> double-space after <chars> at line end\n"
 "         -l <n> turn each <n> spaces at start of line into a tab\n"  "         -l <n> turn each <n> spaces at start of line into a tab\n"
 "         -m     try to make sure mail header lines stay separate\n"  "         -m     try to make sure mail header lines stay separate\n"
 "         -p     allow indented paragraphs\n"  "         -p     allow indented paragraphs\n"
 "         -s     coalesce whitespace inside lines\n"  "         -s     coalesce whitespace inside lines\n"
 "         -t <n> have tabs every <n> columns\n");  "         -t <n> have tabs every <n> columns\n"
   "         -w <n> set maximum width to <n>\n"
   "         goal   set target width to goal\n");
       exit(ch=='h' ? 0 : EX_USAGE);        exit(ch=='h' ? 0 : EX_USAGE);
   }    }
   argc -= optind; argv += optind;    argc -= optind; argv += optind;
   
   /* [ goal [ maximum ] ] */    /* [ goal [ maximum ] ] */
   
   if (argc>0    if (argc>0 && goal_length==0
       && (goal_length=get_positive(*argv,"goal length must be positive", 0))        && (goal_length=get_positive(*argv,"goal length must be positive", 0))
          != 0) {           != 0) {
     --argc; ++argv;      --argc; ++argv;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16