GCC:gcc/gcov-tool.c
/* Process args, return index to first non-arg. */
static int process_args (int argc, char **argv) { int opt;
while ((opt = getopt_long (argc, argv, "+hv", options, NULL)) != -1) { switch (opt) { case 'h': print_usage (false); /* Print_usage will exit. */ case 'v': print_version (); /* Print_version will exit. */ default: print_usage (true); /* Print_usage will exit. */ } }
return optind; }
/* Print a usage message and exit. If ERROR_P is nonzero, this is an error, otherwise the output of --help. */
static void print_usage (int error_p) { FILE *file = error_p ? stderr : stdout; int status = error_p ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;
fnotice (file, "Usage: %s [OPTION]... SUB_COMMAND [OPTION]...\n\n", progname); fnotice (file, "Offline tool to handle gcda counts\n\n"); fnotice (file, " -h, --help Print this help, then exit\n"); fnotice (file, " -v, --version Print version number, then exit\n"); print_merge_usage_message (error_p); print_rewrite_usage_message (error_p); print_overlap_usage_message (error_p); fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n", bug_report_url); exit (status); }
/* Print version information and exit. */
static void print_version (void) { fnotice (stdout, "%s %s%s\n", progname, pkgversion_string, version_string); fnotice (stdout, "Copyright %s 2014-2016 Free Software Foundation, Inc.\n", _("(C)")); fnotice (stdout, _("This is free software; see the source for copying conditions.\n" "There is NO warranty; not even for MERCHANTABILITY or \n" "FITNESS FOR A PARTICULAR PURPOSE.\n\n")); exit (SUCCESS_EXIT_CODE); }
static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { 0, 0, 0, 0 } };