scanopt_init:
  140|    178|{
  141|    178|	int     i;
  142|    178|	struct _scanopt_t *s;
  143|    178|	s = malloc(sizeof (struct _scanopt_t));
  144|       |
  145|    178|	s->options = options;
  146|    178|	s->optc = 0;
  147|    178|	s->argc = argc;
  148|    178|	s->argv = (char **) argv;
  149|    178|	s->index = 1;
  150|    178|	s->subscript = 0;
  151|    178|	s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
  152|    178|	s->has_long = 0;
  153|    178|	s->has_short = 0;
  154|       |
  155|       |	/* Determine option count. (Find entry with all zeros). */
  156|    178|	s->optc = 0;
  157|  22.2k|	while (options[s->optc].opt_fmt
  ------------------
  |  Branch (157:9): [True: 22.0k, False: 178]
  ------------------
  158|    178|	       || options[s->optc].r_val || options[s->optc].desc)
  ------------------
  |  Branch (158:12): [True: 0, False: 178]
  |  Branch (158:38): [True: 0, False: 178]
  ------------------
  159|  22.0k|		s->optc++;
  160|       |
  161|       |	/* Build auxiliary data */
  162|    178|	s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
  163|       |
  164|  22.2k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (164:14): [True: 22.0k, False: 178]
  ------------------
  165|  22.0k|		const unsigned char *p, *pname;
  166|  22.0k|		const struct optspec_t *opt;
  167|  22.0k|		struct _aux *aux;
  168|       |
  169|  22.0k|		opt = s->options + i;
  170|  22.0k|		aux = s->aux + i;
  171|       |
  172|  22.0k|		aux->flags = ARG_NONE;
  ------------------
  |  |   42|  22.0k|#define ARG_NONE 0x01
  ------------------
  173|       |
  174|  22.0k|		if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
  ------------------
  |  Branch (174:7): [True: 22.0k, False: 0]
  |  Branch (174:33): [True: 16.5k, False: 5.51k]
  ------------------
  175|  16.5k|			aux->flags |= IS_LONG;
  ------------------
  |  |   45|  16.5k|#define IS_LONG  0x08
  ------------------
  176|  16.5k|			pname = (const unsigned char *)(opt->opt_fmt + 2);
  177|  16.5k|			s->has_long = 1;
  178|  16.5k|		}
  179|  5.51k|		else {
  180|  5.51k|			pname = (const unsigned char *)(opt->opt_fmt + 1);
  181|  5.51k|			s->has_short = 1;
  182|  5.51k|		}
  183|  22.0k|		aux->printlen = (int) strlen (opt->opt_fmt);
  184|       |
  185|  22.0k|		aux->namelen = 0;
  186|   168k|		for (p = pname + 1; *p; p++) {
  ------------------
  |  Branch (186:23): [True: 146k, False: 21.5k]
  ------------------
  187|       |			/* detect required arg */
  188|   146k|			if (*p == '=' || isspace ((unsigned char)*p)
  ------------------
  |  Branch (188:8): [True: 1.24k, False: 145k]
  |  Branch (188:21): [True: 712, False: 144k]
  ------------------
  189|   144k|			    || !(aux->flags & IS_LONG)) {
  ------------------
  |  |   45|   144k|#define IS_LONG  0x08
  ------------------
  |  Branch (189:11): [True: 4.27k, False: 140k]
  ------------------
  190|  6.23k|				if (aux->namelen == 0)
  ------------------
  |  Branch (190:9): [True: 2.31k, False: 3.91k]
  ------------------
  191|  2.31k|					aux->namelen = (int) (p - pname);
  192|  6.23k|				aux->flags |= ARG_REQ;
  ------------------
  |  |   43|  6.23k|#define ARG_REQ  0x02
  ------------------
  193|  6.23k|				aux->flags &= ~ARG_NONE;
  ------------------
  |  |   42|  6.23k|#define ARG_NONE 0x01
  ------------------
  194|  6.23k|			}
  195|       |			/* detect optional arg. This overrides required arg. */
  196|   146k|			if (*p == '[') {
  ------------------
  |  Branch (196:8): [True: 534, False: 146k]
  ------------------
  197|    534|				if (aux->namelen == 0)
  ------------------
  |  Branch (197:9): [True: 356, False: 178]
  ------------------
  198|    356|					aux->namelen = (int) (p - pname);
  199|    534|				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   43|    534|#define ARG_REQ  0x02
  ------------------
              				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   42|    534|#define ARG_NONE 0x01
  ------------------
  200|    534|				aux->flags |= ARG_OPT;
  ------------------
  |  |   44|    534|#define ARG_OPT  0x04
  ------------------
  201|    534|				break;
  202|    534|			}
  203|   146k|		}
  204|  22.0k|		if (aux->namelen == 0)
  ------------------
  |  Branch (204:7): [True: 19.4k, False: 2.67k]
  ------------------
  205|  19.4k|			aux->namelen = (int) (p - pname);
  206|  22.0k|	}
  207|    178|	return (scanopt_t *) s;
  208|    178|}
scanopt:
  617|    178|{
  618|    178|	char   *optname = NULL, *optarg = NULL, *pstart;
  619|    178|	int     namelen = 0, arglen = 0;
  620|    178|	int     errcode = 0, has_next;
  621|    178|	const optspec_t *optp;
  622|    178|	struct _scanopt_t *s;
  623|    178|	struct _aux *auxp;
  624|    178|	int     is_short;
  625|    178|	int     opt_offset = -1;
  626|       |
  627|    178|	s = (struct _scanopt_t *) svoid;
  628|       |
  629|       |	/* Normalize return-parameters. */
  630|    178|	SAFE_ASSIGN (arg, NULL);
  ------------------
  |  |  127|    178|    do{                      \
  |  |  128|    178|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 178, False: 0]
  |  |  ------------------
  |  |  129|    178|            *(ptr) = val;    \
  |  |  130|    178|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 178]
  |  |  ------------------
  ------------------
  631|    178|	SAFE_ASSIGN (optindex, s->index);
  ------------------
  |  |  127|    178|    do{                      \
  |  |  128|    178|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 178, False: 0]
  |  |  ------------------
  |  |  129|    178|            *(ptr) = val;    \
  |  |  130|    178|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 178]
  |  |  ------------------
  ------------------
  632|       |
  633|    178|	if (s->index >= s->argc)
  ------------------
  |  Branch (633:6): [True: 0, False: 178]
  ------------------
  634|      0|		return 0;
  635|       |
  636|       |	/* pstart always points to the start of our current scan. */
  637|    178|	pstart = s->argv[s->index] + s->subscript;
  638|    178|	if (!pstart)
  ------------------
  |  Branch (638:6): [True: 0, False: 178]
  ------------------
  639|      0|		return 0;
  640|       |
  641|    178|	if (s->subscript == 0) {
  ------------------
  |  Branch (641:6): [True: 178, False: 0]
  ------------------
  642|       |
  643|       |		/* test for exact match of "--" */
  644|    178|		if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
  ------------------
  |  Branch (644:7): [True: 162, False: 16]
  |  Branch (644:27): [True: 135, False: 27]
  |  Branch (644:47): [True: 2, False: 133]
  ------------------
  645|      2|			SAFE_ASSIGN (optindex, s->index + 1);
  ------------------
  |  |  127|      2|    do{                      \
  |  |  128|      2|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 2, False: 0]
  |  |  ------------------
  |  |  129|      2|            *(ptr) = val;    \
  |  |  130|      2|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 2]
  |  |  ------------------
  ------------------
  646|      2|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      2|    do{                    \
  |  |  135|      2|       (s)->index += (n);  \
  |  |  136|      2|       (s)->subscript= 0;  \
  |  |  137|      2|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 2]
  |  |  ------------------
  ------------------
  647|      2|			return 0;
  648|      2|		}
  649|       |
  650|       |		/* Match an opt. */
  651|    176|		if (matchlongopt
  ------------------
  |  Branch (651:7): [True: 133, False: 43]
  ------------------
  652|    176|		    (pstart, &optname, &namelen, &optarg, &arglen)) {
  653|       |
  654|       |			/* it LOOKS like an opt, but is it one?! */
  655|    133|			if (!find_opt
  ------------------
  |  Branch (655:8): [True: 123, False: 10]
  ------------------
  656|    133|			    (s, 1, optname, namelen, &errcode,
  657|    133|			     &opt_offset)) {
  658|    123|				scanopt_err (s, 0, errcode);
  659|    123|				return errcode;
  660|    123|			}
  661|       |			/* We handle this below. */
  662|     10|			is_short = 0;
  663|       |
  664|       |			/* Check for short opt.  */
  665|     10|		}
  666|     43|		else if (pstart[0] == '-' && pstart[1]) {
  ------------------
  |  Branch (666:12): [True: 27, False: 16]
  |  Branch (666:32): [True: 25, False: 2]
  ------------------
  667|       |			/* Pass through to below. */
  668|     25|			is_short = 1;
  669|     25|			s->subscript++;
  670|     25|			pstart++;
  671|     25|		}
  672|       |
  673|     18|		else {
  674|       |			/* It's not an option. We're done. */
  675|     18|			return 0;
  676|     18|		}
  677|    176|	}
  678|       |
  679|       |	/* We have to re-check the subscript status because it
  680|       |	 * may have changed above. */
  681|       |
  682|     35|	if (s->subscript != 0) {
  ------------------
  |  Branch (682:6): [True: 25, False: 10]
  ------------------
  683|       |
  684|       |		/* we are somewhere in a run of short opts,
  685|       |		 * e.g., at the 'z' in `tar -xzf` */
  686|       |
  687|     25|		optname = pstart;
  688|     25|		namelen = 1;
  689|     25|		is_short = 1;
  690|       |
  691|     25|		if (!find_opt
  ------------------
  |  Branch (691:7): [True: 14, False: 11]
  ------------------
  692|     25|		    (s, 0, pstart, namelen, &errcode, &opt_offset)) {
  693|     14|			scanopt_err(s, 1, errcode);
  694|     14|			return errcode;
  695|     14|		}
  696|       |
  697|     11|		optarg = pstart + 1;
  698|     11|		if (!*optarg) {
  ------------------
  |  Branch (698:7): [True: 2, False: 9]
  ------------------
  699|      2|			optarg = NULL;
  700|      2|			arglen = 0;
  701|      2|		}
  702|      9|		else
  703|      9|			arglen = (int) strlen (optarg);
  704|     11|	}
  705|       |
  706|       |	/* At this point, we have a long or short option matched at opt_offset into
  707|       |	 * the s->options array (and corresponding aux array).
  708|       |	 * A trailing argument is in {optarg,arglen}, if any.
  709|       |	 */
  710|       |
  711|       |	/* Look ahead in argv[] to see if there is something
  712|       |	 * that we can use as an argument (if needed). */
  713|     21|	has_next = s->index + 1 < s->argc;
  714|       |
  715|     21|	optp = s->options + opt_offset;
  716|     21|	auxp = s->aux + opt_offset;
  717|       |
  718|       |	/* case: no args allowed */
  719|     21|	if (auxp->flags & ARG_NONE) {
  ------------------
  |  |   42|     21|#define ARG_NONE 0x01
  ------------------
  |  Branch (719:6): [True: 17, False: 4]
  ------------------
  720|     17|		if (optarg && !is_short) {
  ------------------
  |  Branch (720:7): [True: 9, False: 8]
  |  Branch (720:17): [True: 3, False: 6]
  ------------------
  721|      3|			scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_ALLOWED);
  722|      3|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      3|    do{                    \
  |  |  135|      3|       (s)->index += (n);  \
  |  |  136|      3|       (s)->subscript= 0;  \
  |  |  137|      3|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 3]
  |  |  ------------------
  ------------------
  723|      3|			return SCANOPT_ERR_ARG_NOT_ALLOWED;
  724|      3|		}
  725|     14|		else if (!optarg)
  ------------------
  |  Branch (725:12): [True: 8, False: 6]
  ------------------
  726|      8|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      8|    do{                    \
  |  |  135|      8|       (s)->index += (n);  \
  |  |  136|      8|       (s)->subscript= 0;  \
  |  |  137|      8|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 8]
  |  |  ------------------
  ------------------
  727|      6|		else
  728|      6|			s->subscript++;
  729|     14|		return optp->r_val;
  730|     17|	}
  731|       |
  732|       |	/* case: required */
  733|      4|	if (auxp->flags & ARG_REQ) {
  ------------------
  |  |   43|      4|#define ARG_REQ  0x02
  ------------------
  |  Branch (733:6): [True: 3, False: 1]
  ------------------
  734|      3|		if (!optarg && !has_next) {
  ------------------
  |  Branch (734:7): [True: 1, False: 2]
  |  Branch (734:18): [True: 0, False: 1]
  ------------------
  735|      0|			scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_FOUND);
  736|      0|			return SCANOPT_ERR_ARG_NOT_FOUND;
  737|      0|		}
  738|       |
  739|      3|		if (!optarg) {
  ------------------
  |  Branch (739:7): [True: 1, False: 2]
  ------------------
  740|       |			/* Let the next argv element become the argument. */
  741|      1|			SAFE_ASSIGN (arg, s->argv[s->index + 1]);
  ------------------
  |  |  127|      1|    do{                      \
  |  |  128|      1|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 1, False: 0]
  |  |  ------------------
  |  |  129|      1|            *(ptr) = val;    \
  |  |  130|      1|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  742|      1|			INC_INDEX (s, 2);
  ------------------
  |  |  134|      1|    do{                    \
  |  |  135|      1|       (s)->index += (n);  \
  |  |  136|      1|       (s)->subscript= 0;  \
  |  |  137|      1|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  743|      1|		}
  744|      2|		else {
  745|      2|			SAFE_ASSIGN (arg, (char *) optarg);
  ------------------
  |  |  127|      2|    do{                      \
  |  |  128|      2|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 2, False: 0]
  |  |  ------------------
  |  |  129|      2|            *(ptr) = val;    \
  |  |  130|      2|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 2]
  |  |  ------------------
  ------------------
  746|      2|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      2|    do{                    \
  |  |  135|      2|       (s)->index += (n);  \
  |  |  136|      2|       (s)->subscript= 0;  \
  |  |  137|      2|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 2]
  |  |  ------------------
  ------------------
  747|      2|		}
  748|      3|		return optp->r_val;
  749|      3|	}
  750|       |
  751|       |	/* case: optional */
  752|      1|	if (auxp->flags & ARG_OPT) {
  ------------------
  |  |   44|      1|#define ARG_OPT  0x04
  ------------------
  |  Branch (752:6): [True: 1, False: 0]
  ------------------
  753|      1|		SAFE_ASSIGN (arg, optarg);
  ------------------
  |  |  127|      1|    do{                      \
  |  |  128|      1|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 1, False: 0]
  |  |  ------------------
  |  |  129|      1|            *(ptr) = val;    \
  |  |  130|      1|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  754|      1|		INC_INDEX (s, 1);
  ------------------
  |  |  134|      1|    do{                    \
  |  |  135|      1|       (s)->index += (n);  \
  |  |  136|      1|       (s)->subscript= 0;  \
  |  |  137|      1|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  755|      1|		return optp->r_val;
  756|      1|	}
  757|       |
  758|       |
  759|       |	/* Should not reach here. */
  760|      0|	return 0;
  761|      1|}
scanopt_destroy:
  765|    178|{
  766|    178|	struct _scanopt_t *s;
  767|       |
  768|    178|	s = (struct _scanopt_t *) svoid;
  769|    178|	if (s != NULL) {
  ------------------
  |  Branch (769:6): [True: 178, False: 0]
  ------------------
  770|    178|		free(s->aux);
  771|    178|		free(s);
  772|    178|	}
  773|    178|	return 0;
  774|    178|}
scanopt.c:matchlongopt:
  517|    176|{
  518|    176|	char   *p;
  519|       |
  520|    176|	*optname = *arg = NULL;
  521|    176|	*optlen = *arglen = 0;
  522|       |
  523|       |	/* Match regex /--./   */
  524|    176|	p = str;
  525|    176|	if (p[0] != '-' || p[1] != '-' || !p[2])
  ------------------
  |  Branch (525:6): [True: 16, False: 160]
  |  Branch (525:21): [True: 27, False: 133]
  |  Branch (525:36): [True: 0, False: 133]
  ------------------
  526|     43|		return 0;
  527|       |
  528|    133|	p += 2;
  529|    133|	*optname = p;
  530|       |
  531|       |	/* find the end of optname */
  532|  2.00k|	while (*p && *p != '=')
  ------------------
  |  Branch (532:9): [True: 1.88k, False: 123]
  |  Branch (532:15): [True: 1.87k, False: 10]
  ------------------
  533|  1.87k|		++p;
  534|       |
  535|    133|	*optlen = (int) (p - *optname);
  536|       |
  537|    133|	if (!*p)
  ------------------
  |  Branch (537:6): [True: 123, False: 10]
  ------------------
  538|       |		/* an option with no '=...' part. */
  539|    123|		return 1;
  540|       |
  541|       |
  542|       |	/* We saw an '=' char. The rest of p is the arg. */
  543|     10|	p++;
  544|     10|	*arg = p;
  545|     85|	while (*p)
  ------------------
  |  Branch (545:9): [True: 75, False: 10]
  ------------------
  546|     75|		++p;
  547|     10|	*arglen = (int) (p - *arg);
  548|       |
  549|     10|	return 1;
  550|    133|}
scanopt.c:find_opt:
  560|    158|{
  561|    158|	int     nmatch = 0, lastr_val = 0, i;
  562|       |
  563|    158|	*err_code = 0;
  564|    158|	*opt_offset = -1;
  565|       |
  566|    158|	if (!optstart)
  ------------------
  |  Branch (566:6): [True: 0, False: 158]
  ------------------
  567|      0|		return 0;
  568|       |
  569|  18.9k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (569:14): [True: 18.7k, False: 150]
  ------------------
  570|  18.7k|		const char   *optname;
  571|       |
  572|  18.7k|		optname = s->options[i].opt_fmt + (lookup_long ? 2 : 1);
  ------------------
  |  Branch (572:38): [True: 15.6k, False: 3.10k]
  ------------------
  573|       |
  574|  18.7k|		if (lookup_long && (s->aux[i].flags & IS_LONG)) {
  ------------------
  |  |   45|  15.6k|#define IS_LONG  0x08
  ------------------
  |  Branch (574:7): [True: 15.6k, False: 3.10k]
  |  Branch (574:22): [True: 11.7k, False: 3.92k]
  ------------------
  575|  11.7k|			if (len > s->aux[i].namelen)
  ------------------
  |  Branch (575:8): [True: 8.50k, False: 3.25k]
  ------------------
  576|  8.50k|				continue;
  577|       |
  578|  3.25k|			if (strncmp (optname, optstart, (size_t) len) == 0) {
  ------------------
  |  Branch (578:8): [True: 214, False: 3.03k]
  ------------------
  579|    214|				nmatch++;
  580|    214|				*opt_offset = i;
  581|       |
  582|       |				/* exact match overrides all. */
  583|    214|				if (len == s->aux[i].namelen) {
  ------------------
  |  Branch (583:9): [True: 8, False: 206]
  ------------------
  584|      8|					nmatch = 1;
  585|      8|					break;
  586|      8|				}
  587|       |
  588|       |				/* ambiguity is ok between aliases. */
  589|    206|				if (lastr_val
  ------------------
  |  Branch (589:9): [True: 194, False: 12]
  ------------------
  590|    194|				    && lastr_val ==
  ------------------
  |  Branch (590:12): [True: 4, False: 190]
  ------------------
  591|    194|				    s->options[i].r_val) nmatch--;
  592|    206|				lastr_val = s->options[i].r_val;
  593|    206|			}
  594|  3.25k|		}
  595|  7.02k|		else if (!lookup_long && !(s->aux[i].flags & IS_LONG)) {
  ------------------
  |  |   45|  3.10k|#define IS_LONG  0x08
  ------------------
  |  Branch (595:12): [True: 3.10k, False: 3.92k]
  |  Branch (595:28): [True: 775, False: 2.32k]
  ------------------
  596|    775|			if (optname[0] == optstart[0]) {
  ------------------
  |  Branch (596:8): [True: 11, False: 764]
  ------------------
  597|     11|				nmatch++;
  598|     11|				*opt_offset = i;
  599|     11|			}
  600|    775|		}
  601|  18.7k|	}
  602|       |
  603|    158|	if (nmatch == 0) {
  ------------------
  |  Branch (603:6): [True: 127, False: 31]
  ------------------
  604|    127|		*err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
  605|    127|		*opt_offset = -1;
  606|    127|	}
  607|     31|	else if (nmatch > 1) {
  ------------------
  |  Branch (607:11): [True: 10, False: 21]
  ------------------
  608|     10|		*err_code = SCANOPT_ERR_OPT_AMBIGUOUS;
  609|     10|		*opt_offset = -1;
  610|     10|	}
  611|       |
  612|    158|	return *err_code ? 0 : 1;
  ------------------
  |  Branch (612:9): [True: 137, False: 21]
  ------------------
  613|    158|}
scanopt.c:scanopt_err:
  463|    140|{
  464|    140|	const char *optname = "";
  465|    140|	char    optchar[2];
  466|       |
  467|    140|	if (!s->no_err_msg) {
  ------------------
  |  Branch (467:6): [True: 140, False: 0]
  ------------------
  468|       |
  469|    140|		if (s->index > 0 && s->index < s->argc) {
  ------------------
  |  Branch (469:7): [True: 140, False: 0]
  |  Branch (469:23): [True: 140, False: 0]
  ------------------
  470|    140|			if (is_short) {
  ------------------
  |  Branch (470:8): [True: 14, False: 126]
  ------------------
  471|     14|				optchar[0] =
  472|     14|					s->argv[s->index][s->subscript];
  473|     14|				optchar[1] = '\0';
  474|     14|				optname = optchar;
  475|     14|			}
  476|    126|			else {
  477|    126|				optname = s->argv[s->index];
  478|    126|			}
  479|    140|		}
  480|       |
  481|    140|		fprintf (stderr, "%s: ", s->argv[0]);
  482|    140|		switch (err) {
  483|      3|		case SCANOPT_ERR_ARG_NOT_ALLOWED:
  ------------------
  |  Branch (483:3): [True: 3, False: 137]
  ------------------
  484|      3|			fprintf (stderr,
  485|      3|				 _
  ------------------
  |  |  100|      3|#define _(String) gettext (String)
  ------------------
  486|      3|				 ("option `%s' doesn't allow an argument\n"),
  487|      3|				 optname);
  488|      3|			break;
  489|      0|		case SCANOPT_ERR_ARG_NOT_FOUND:
  ------------------
  |  Branch (489:3): [True: 0, False: 140]
  ------------------
  490|      0|			fprintf (stderr,
  491|      0|				 _("option `%s' requires an argument\n"),
  ------------------
  |  |  100|      0|#define _(String) gettext (String)
  ------------------
  492|      0|				 optname);
  493|      0|			break;
  494|     10|		case SCANOPT_ERR_OPT_AMBIGUOUS:
  ------------------
  |  Branch (494:3): [True: 10, False: 130]
  ------------------
  495|     10|			fprintf (stderr, _("option `%s' is ambiguous\n"),
  ------------------
  |  |  100|     10|#define _(String) gettext (String)
  ------------------
  496|     10|				 optname);
  497|     10|			break;
  498|    127|		case SCANOPT_ERR_OPT_UNRECOGNIZED:
  ------------------
  |  Branch (498:3): [True: 127, False: 13]
  ------------------
  499|    127|			fprintf (stderr, _("Unrecognized option `%s'\n"),
  ------------------
  |  |  100|    127|#define _(String) gettext (String)
  ------------------
  500|    127|				 optname);
  501|    127|			break;
  502|      0|		default:
  ------------------
  |  Branch (502:3): [True: 0, False: 140]
  ------------------
  503|      0|			fprintf (stderr, _("Unknown error=(%d)\n"), err);
  ------------------
  |  |  100|      0|#define _(String) gettext (String)
  ------------------
  504|      0|			break;
  505|    140|		}
  506|    140|	}
  507|    140|}

LLVMFuzzerTestOneInput:
   23|    186|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   24|    186|  if (size < 24) {
  ------------------
  |  Branch (24:7): [True: 8, False: 178]
  ------------------
   25|      8|    return 0;
   26|      8|  }
   27|    178|  char *opt_fuzz = malloc(24);
   28|       |
   29|    178|  memcpy(opt_fuzz, data, 23);
   30|    178|  opt_fuzz[23] = 0;
   31|    178|  data += 23;
   32|    178|  size -= 23;
   33|       |
   34|    178|  char *new_str = (char *)malloc(size + 1);
   35|    178|  if (new_str == NULL) {
  ------------------
  |  Branch (35:7): [True: 0, False: 178]
  ------------------
   36|      0|    return 0;
   37|      0|  }
   38|    178|  memcpy(new_str, data, size);
   39|    178|  new_str[size] = '\0';
   40|    178|  my_argv[0] = "/tmp/fuzz/";
   41|    178|  my_argv[1] = opt_fuzz;
   42|    178|  my_argv[2] = new_str;
   43|    178|  my_argv[3] = NULL;
   44|       |
   45|    178|  scanopt_t sopt;
   46|    178|  sopt = scanopt_init(flexopts, 3, my_argv, 0);
   47|    178|  if (!sopt) {
  ------------------
  |  Branch (47:7): [True: 0, False: 178]
  ------------------
   48|      0|    free(new_str);
   49|      0|    free(opt_fuzz);
   50|      0|    return 0;
   51|      0|  }
   52|    178|  int optind;
   53|    178|  char *arg;
   54|    178|  scanopt(sopt, &arg, &optind);
   55|    178|  scanopt_destroy(sopt);
   56|       |
   57|    178|  free(new_str);
   58|    178|  free(opt_fuzz);
   59|    178|  return 0;
   60|    178|}

