| 286 | } |
| 287 | |
| 288 | int |
| 289 | main (int argc, char **argv) |
| 290 | { |
| 291 | size_t width = 80; |
| 292 | int optc; |
| 293 | bool ok; |
| 294 | |
| 295 | initialize_main (&argc, &argv); |
| 296 | set_program_name (argv[0]); |
| 297 | setlocale (LC_ALL, ""); |
| 298 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 299 | textdomain (PACKAGE); |
| 300 | |
| 301 | atexit (close_stdout); |
| 302 | |
| 303 | while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) |
| 304 | { |
| 305 | char optargbuf[2]; |
| 306 | |
| 307 | switch (optc) |
| 308 | { |
| 309 | case 'b': /* Count bytes rather than columns. */ |
| 310 | counting_mode = COUNT_BYTES; |
| 311 | break; |
| 312 | |
| 313 | case 'c': /* Count characters rather than columns. */ |
| 314 | counting_mode = COUNT_CHARACTERS; |
| 315 | break; |
| 316 | |
| 317 | case 's': /* Break at word boundaries. */ |
| 318 | break_spaces = true; |
| 319 | break; |
| 320 | |
| 321 | case '0': case '1': case '2': case '3': case '4': |
| 322 | case '5': case '6': case '7': case '8': case '9': |
| 323 | if (optarg) |
| 324 | optarg--; |
| 325 | else |
| 326 | { |
| 327 | optargbuf[0] = optc; |
| 328 | optargbuf[1] = '\0'; |
| 329 | optarg = optargbuf; |
| 330 | } |
| 331 | FALLTHROUGH; |
| 332 | case 'w': /* Line width. */ |
| 333 | width = xnumtoumax (optarg, 10, 1, SIZE_MAX - TAB_WIDTH - 1, "", |
| 334 | _("invalid number of columns"), 0, |
| 335 | XTOINT_MIN_RANGE | XTOINT_MAX_RANGE); |
| 336 | break; |
| 337 | |
| 338 | case_GETOPT_HELP_CHAR; |
| 339 | |
| 340 | case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); |
| 341 | |
| 342 | default: |
| 343 | usage (EXIT_FAILURE); |
| 344 | } |
| 345 | } |