do_rewrite:
/* Driver for profile rewrite sub-command. */
static int do_rewrite (int argc, char **argv) { int opt; int ret; const char *output_dir = 0; #ifdef HAVE_LONG_LONG long long normalize_val = 0; #else int64_t normalize_val = 0; #endif float scale = 0.0; int numerator = 1; int denominator = 1; int do_scaling = 0;
optind = 0; while ((opt = getopt_long (argc, argv, "vo:s:n:", rewrite_options, NULL)) != -1) { switch (opt) { case 'v': verbose = true; gcov_set_verbose (); break; case 'o': output_dir = optarg; break; case 'n': if (!do_scaling) #if defined(HAVE_LONG_LONG) normalize_val = strtoll (optarg, (char **)NULL, 10); #elif defined(INT64_T_IS_LONG) normalize_val = strtol (optarg, (char **)NULL, 10); #else sscanf (optarg, "%" SCNd64, &normalize_val); #endif else fnotice (stderr, "scaling cannot co-exist with normalization," " skipping\n"); break; case 's': ret = 0; do_scaling = 1; if (strstr (optarg, "/")) { ret = sscanf (optarg, "%d/%d", &numerator, &denominator); if (ret == 2) { if (numerator < 0 || denominator <= 0) { fnotice (stderr, "incorrect format in scaling, using 1/1\n"); denominator = 1; numerator = 1; } } } if (ret != 2) { ret = sscanf (optarg, "%f", &scale); if (ret != 1) fnotice (stderr, "incorrect format in scaling, using 1/1\n"); else denominator = 0; }
if (scale < 0.0) fatal_error (input_location, "scale needs to be non-negative\n");
if (normalize_val != 0) { fnotice (stderr, "normalization cannot co-exist with scaling\n"); normalize_val = 0; } break; default: rewrite_usage (); } }
if (output_dir == NULL) output_dir = "rewrite_profile";
if (argc - optind == 1) { if (denominator > 0) ret = profile_rewrite (argv[optind], output_dir, 0, 0.0, numerator, denominator); else ret = profile_rewrite (argv[optind], output_dir, normalize_val, scale, 0, 0); } else rewrite_usage ();
return ret; }