MCPcopy Create free account
hub / github.com/coreutils/coreutils / main

Function main

src/uniq.c:484–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482 };
483
484int
485main (int argc, char **argv)
486{
487 int optc = 0;
488 bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
489 enum Skip_field_option_type skip_field_option_type = SFO_NONE;
490 int nfiles = 0;
491 char const *file[2];
492 char delimiter = '\n'; /* change with --zero-terminated, -z */
493 bool output_option_used = false; /* if true, one of -u/-d/-D/-c was used */
494
495 file[0] = file[1] = "-";
496 initialize_main (&argc, &argv);
497 set_program_name (argv[0]);
498 setlocale (LC_ALL, "");
499 bindtextdomain (PACKAGE, LOCALEDIR);
500 textdomain (PACKAGE);
501
502 atexit (close_stdout);
503
504 while (true)
505 {
506 /* Parse an operand with leading "+" as a file after "--" was
507 seen; or if pedantic and a file was seen; or if not
508 obsolete. */
509
510 if (optc == -1
511 || (posixly_correct && nfiles != 0)
512 || ((optc = getopt_long (argc, argv,
513 "-0123456789Dcdf:is:uw:z",
514 longopts, NULL))
515 == -1))
516 {
517 if (argc <= optind)
518 break;
519 if (nfiles == 2)
520 {
521 error (0, 0, _("extra operand %s"), quote (argv[optind]));
522 usage (EXIT_FAILURE);
523 }
524 file[nfiles++] = argv[optind++];
525 }
526 else switch (optc)
527 {
528 case 1:
529 {
530 intmax_t size;
531 if (optarg[0] == '+'
532 && ! strict_posix2 ()
533 && (xstrtoimax (optarg, NULL, 10, &size, "")
534 <= LONGINT_OVERFLOW))
535 skip_chars = MIN (size, IDX_MAX);
536 else if (nfiles == 2)
537 {
538 error (0, 0, _("extra operand %s"), quote (optarg));
539 usage (EXIT_FAILURE);
540 }
541 else

Callers

nothing calls this directly

Calls 4

strict_posix2Function · 0.85
size_optFunction · 0.85
check_fileFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected