| 312 | } |
| 313 | |
| 314 | int |
| 315 | main (int argc, char **argv) |
| 316 | { |
| 317 | int c; |
| 318 | |
| 319 | initialize_main (&argc, &argv); |
| 320 | set_program_name (argv[0]); |
| 321 | setlocale (LC_ALL, ""); |
| 322 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 323 | textdomain (PACKAGE); |
| 324 | |
| 325 | initialize_exit_failure (EXIT_CANCELED); |
| 326 | atexit (close_stdout); |
| 327 | |
| 328 | while ((c = getopt_long (argc, argv, "+i:o:e:", longopts, NULL)) != -1) |
| 329 | { |
| 330 | int opt_fileno; |
| 331 | |
| 332 | switch (c) |
| 333 | { |
| 334 | /* Old McDonald had a farm ei... */ |
| 335 | case 'e': |
| 336 | case 'i': |
| 337 | case 'o': |
| 338 | opt_fileno = optc_to_fileno (c); |
| 339 | affirm (0 <= opt_fileno && opt_fileno < countof (stdbuf)); |
| 340 | stdbuf[opt_fileno].optc = c; |
| 341 | while (c_isspace (*optarg)) |
| 342 | optarg++; |
| 343 | stdbuf[opt_fileno].optarg = optarg; |
| 344 | if (c == 'i' && *optarg == 'L') |
| 345 | { |
| 346 | /* -oL will be by far the most common use of this utility, |
| 347 | but one could easily think -iL might have the same affect, |
| 348 | so disallow it as it could be confusing. */ |
| 349 | error (0, 0, _("line buffering standard input is meaningless")); |
| 350 | usage (EXIT_CANCELED); |
| 351 | } |
| 352 | |
| 353 | if (!streq (optarg, "L") |
| 354 | && parse_size (optarg, &stdbuf[opt_fileno].size) == -1) |
| 355 | error (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg)); |
| 356 | |
| 357 | break; |
| 358 | |
| 359 | case_GETOPT_HELP_CHAR; |
| 360 | |
| 361 | case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); |
| 362 | |
| 363 | default: |
| 364 | usage (EXIT_CANCELED); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | argv += optind; |
| 369 | argc -= optind; |
| 370 | |
| 371 | /* must specify at least 1 command. */ |
nothing calls this directly
no test coverage detected