scanopt_init:
  140|    181|{
  141|    181|	int     i;
  142|    181|	struct _scanopt_t *s;
  143|    181|	s = malloc(sizeof (struct _scanopt_t));
  144|       |
  145|    181|	s->options = options;
  146|    181|	s->optc = 0;
  147|    181|	s->argc = argc;
  148|    181|	s->argv = (char **) argv;
  149|    181|	s->index = 1;
  150|    181|	s->subscript = 0;
  151|    181|	s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
  152|    181|	s->has_long = 0;
  153|    181|	s->has_short = 0;
  154|       |
  155|       |	/* Determine option count. (Find entry with all zeros). */
  156|    181|	s->optc = 0;
  157|  22.6k|	while (options[s->optc].opt_fmt
  ------------------
  |  Branch (157:9): [True: 22.4k, False: 181]
  ------------------
  158|    181|	       || options[s->optc].r_val || options[s->optc].desc)
  ------------------
  |  Branch (158:12): [True: 0, False: 181]
  |  Branch (158:38): [True: 0, False: 181]
  ------------------
  159|  22.4k|		s->optc++;
  160|       |
  161|       |	/* Build auxiliary data */
  162|    181|	s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
  163|       |
  164|  22.6k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (164:14): [True: 22.4k, False: 181]
  ------------------
  165|  22.4k|		const unsigned char *p, *pname;
  166|  22.4k|		const struct optspec_t *opt;
  167|  22.4k|		struct _aux *aux;
  168|       |
  169|  22.4k|		opt = s->options + i;
  170|  22.4k|		aux = s->aux + i;
  171|       |
  172|  22.4k|		aux->flags = ARG_NONE;
  ------------------
  |  |   42|  22.4k|#define ARG_NONE 0x01
  ------------------
  173|       |
  174|  22.4k|		if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
  ------------------
  |  Branch (174:7): [True: 22.4k, False: 0]
  |  Branch (174:33): [True: 16.8k, False: 5.61k]
  ------------------
  175|  16.8k|			aux->flags |= IS_LONG;
  ------------------
  |  |   45|  16.8k|#define IS_LONG  0x08
  ------------------
  176|  16.8k|			pname = (const unsigned char *)(opt->opt_fmt + 2);
  177|  16.8k|			s->has_long = 1;
  178|  16.8k|		}
  179|  5.61k|		else {
  180|  5.61k|			pname = (const unsigned char *)(opt->opt_fmt + 1);
  181|  5.61k|			s->has_short = 1;
  182|  5.61k|		}
  183|  22.4k|		aux->printlen = (int) strlen (opt->opt_fmt);
  184|       |
  185|  22.4k|		aux->namelen = 0;
  186|   171k|		for (p = pname + 1; *p; p++) {
  ------------------
  |  Branch (186:23): [True: 149k, False: 21.9k]
  ------------------
  187|       |			/* detect required arg */
  188|   149k|			if (*p == '=' || isspace ((unsigned char)*p)
  ------------------
  |  Branch (188:8): [True: 1.26k, False: 147k]
  |  Branch (188:21): [True: 724, False: 147k]
  ------------------
  189|   147k|			    || !(aux->flags & IS_LONG)) {
  ------------------
  |  |   45|   147k|#define IS_LONG  0x08
  ------------------
  |  Branch (189:11): [True: 4.34k, False: 142k]
  ------------------
  190|  6.33k|				if (aux->namelen == 0)
  ------------------
  |  Branch (190:9): [True: 2.35k, False: 3.98k]
  ------------------
  191|  2.35k|					aux->namelen = (int) (p - pname);
  192|  6.33k|				aux->flags |= ARG_REQ;
  ------------------
  |  |   43|  6.33k|#define ARG_REQ  0x02
  ------------------
  193|  6.33k|				aux->flags &= ~ARG_NONE;
  ------------------
  |  |   42|  6.33k|#define ARG_NONE 0x01
  ------------------
  194|  6.33k|			}
  195|       |			/* detect optional arg. This overrides required arg. */
  196|   149k|			if (*p == '[') {
  ------------------
  |  Branch (196:8): [True: 543, False: 148k]
  ------------------
  197|    543|				if (aux->namelen == 0)
  ------------------
  |  Branch (197:9): [True: 362, False: 181]
  ------------------
  198|    362|					aux->namelen = (int) (p - pname);
  199|    543|				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   43|    543|#define ARG_REQ  0x02
  ------------------
              				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   42|    543|#define ARG_NONE 0x01
  ------------------
  200|    543|				aux->flags |= ARG_OPT;
  ------------------
  |  |   44|    543|#define ARG_OPT  0x04
  ------------------
  201|    543|				break;
  202|    543|			}
  203|   149k|		}
  204|  22.4k|		if (aux->namelen == 0)
  ------------------
  |  Branch (204:7): [True: 19.7k, False: 2.71k]
  ------------------
  205|  19.7k|			aux->namelen = (int) (p - pname);
  206|  22.4k|	}
  207|    181|	return (scanopt_t *) s;
  208|    181|}
scanopt:
  617|    181|{
  618|    181|	char   *optname = NULL, *optarg = NULL, *pstart;
  619|    181|	int     namelen = 0, arglen = 0;
  620|    181|	int     errcode = 0, has_next;
  621|    181|	const optspec_t *optp;
  622|    181|	struct _scanopt_t *s;
  623|    181|	struct _aux *auxp;
  624|    181|	int     is_short;
  625|    181|	int     opt_offset = -1;
  626|       |
  627|    181|	s = (struct _scanopt_t *) svoid;
  628|       |
  629|       |	/* Normalize return-parameters. */
  630|    181|	SAFE_ASSIGN (arg, NULL);
  ------------------
  |  |  127|    181|    do{                      \
  |  |  128|    181|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 181, False: 0]
  |  |  ------------------
  |  |  129|    181|            *(ptr) = val;    \
  |  |  130|    181|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 181]
  |  |  ------------------
  ------------------
  631|    181|	SAFE_ASSIGN (optindex, s->index);
  ------------------
  |  |  127|    181|    do{                      \
  |  |  128|    181|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 181, False: 0]
  |  |  ------------------
  |  |  129|    181|            *(ptr) = val;    \
  |  |  130|    181|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 181]
  |  |  ------------------
  ------------------
  632|       |
  633|    181|	if (s->index >= s->argc)
  ------------------
  |  Branch (633:6): [True: 0, False: 181]
  ------------------
  634|      0|		return 0;
  635|       |
  636|       |	/* pstart always points to the start of our current scan. */
  637|    181|	pstart = s->argv[s->index] + s->subscript;
  638|    181|	if (!pstart)
  ------------------
  |  Branch (638:6): [True: 0, False: 181]
  ------------------
  639|      0|		return 0;
  640|       |
  641|    181|	if (s->subscript == 0) {
  ------------------
  |  Branch (641:6): [True: 181, False: 0]
  ------------------
  642|       |
  643|       |		/* test for exact match of "--" */
  644|    181|		if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
  ------------------
  |  Branch (644:7): [True: 164, False: 17]
  |  Branch (644:27): [True: 135, False: 29]
  |  Branch (644:47): [True: 1, False: 134]
  ------------------
  645|      1|			SAFE_ASSIGN (optindex, 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]
  |  |  ------------------
  ------------------
  646|      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]
  |  |  ------------------
  ------------------
  647|      1|			return 0;
  648|      1|		}
  649|       |
  650|       |		/* Match an opt. */
  651|    180|		if (matchlongopt
  ------------------
  |  Branch (651:7): [True: 134, False: 46]
  ------------------
  652|    180|		    (pstart, &optname, &namelen, &optarg, &arglen)) {
  653|       |
  654|       |			/* it LOOKS like an opt, but is it one?! */
  655|    134|			if (!find_opt
  ------------------
  |  Branch (655:8): [True: 122, False: 12]
  ------------------
  656|    134|			    (s, 1, optname, namelen, &errcode,
  657|    134|			     &opt_offset)) {
  658|    122|				scanopt_err (s, 0, errcode);
  659|    122|				return errcode;
  660|    122|			}
  661|       |			/* We handle this below. */
  662|     12|			is_short = 0;
  663|       |
  664|       |			/* Check for short opt.  */
  665|     12|		}
  666|     46|		else if (pstart[0] == '-' && pstart[1]) {
  ------------------
  |  Branch (666:12): [True: 29, False: 17]
  |  Branch (666:32): [True: 27, False: 2]
  ------------------
  667|       |			/* Pass through to below. */
  668|     27|			is_short = 1;
  669|     27|			s->subscript++;
  670|     27|			pstart++;
  671|     27|		}
  672|       |
  673|     19|		else {
  674|       |			/* It's not an option. We're done. */
  675|     19|			return 0;
  676|     19|		}
  677|    180|	}
  678|       |
  679|       |	/* We have to re-check the subscript status because it
  680|       |	 * may have changed above. */
  681|       |
  682|     39|	if (s->subscript != 0) {
  ------------------
  |  Branch (682:6): [True: 27, False: 12]
  ------------------
  683|       |
  684|       |		/* we are somewhere in a run of short opts,
  685|       |		 * e.g., at the 'z' in `tar -xzf` */
  686|       |
  687|     27|		optname = pstart;
  688|     27|		namelen = 1;
  689|     27|		is_short = 1;
  690|       |
  691|     27|		if (!find_opt
  ------------------
  |  Branch (691:7): [True: 14, False: 13]
  ------------------
  692|     27|		    (s, 0, pstart, namelen, &errcode, &opt_offset)) {
  693|     14|			scanopt_err(s, 1, errcode);
  694|     14|			return errcode;
  695|     14|		}
  696|       |
  697|     13|		optarg = pstart + 1;
  698|     13|		if (!*optarg) {
  ------------------
  |  Branch (698:7): [True: 1, False: 12]
  ------------------
  699|      1|			optarg = NULL;
  700|      1|			arglen = 0;
  701|      1|		}
  702|     12|		else
  703|     12|			arglen = (int) strlen (optarg);
  704|     13|	}
  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|     25|	has_next = s->index + 1 < s->argc;
  714|       |
  715|     25|	optp = s->options + opt_offset;
  716|     25|	auxp = s->aux + opt_offset;
  717|       |
  718|       |	/* case: no args allowed */
  719|     25|	if (auxp->flags & ARG_NONE) {
  ------------------
  |  |   42|     25|#define ARG_NONE 0x01
  ------------------
  |  Branch (719:6): [True: 19, False: 6]
  ------------------
  720|     19|		if (optarg && !is_short) {
  ------------------
  |  Branch (720:7): [True: 12, False: 7]
  |  Branch (720:17): [True: 4, False: 8]
  ------------------
  721|      4|			scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_ALLOWED);
  722|      4|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      4|    do{                    \
  |  |  135|      4|       (s)->index += (n);  \
  |  |  136|      4|       (s)->subscript= 0;  \
  |  |  137|      4|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 4]
  |  |  ------------------
  ------------------
  723|      4|			return SCANOPT_ERR_ARG_NOT_ALLOWED;
  724|      4|		}
  725|     15|		else if (!optarg)
  ------------------
  |  Branch (725:12): [True: 7, False: 8]
  ------------------
  726|      7|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      7|    do{                    \
  |  |  135|      7|       (s)->index += (n);  \
  |  |  136|      7|       (s)->subscript= 0;  \
  |  |  137|      7|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 7]
  |  |  ------------------
  ------------------
  727|      8|		else
  728|      8|			s->subscript++;
  729|     15|		return optp->r_val;
  730|     19|	}
  731|       |
  732|       |	/* case: required */
  733|      6|	if (auxp->flags & ARG_REQ) {
  ------------------
  |  |   43|      6|#define ARG_REQ  0x02
  ------------------
  |  Branch (733:6): [True: 5, False: 1]
  ------------------
  734|      5|		if (!optarg && !has_next) {
  ------------------
  |  Branch (734:7): [True: 1, False: 4]
  |  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|      5|		if (!optarg) {
  ------------------
  |  Branch (739:7): [True: 1, False: 4]
  ------------------
  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|      4|		else {
  745|      4|			SAFE_ASSIGN (arg, (char *) optarg);
  ------------------
  |  |  127|      4|    do{                      \
  |  |  128|      4|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 4, False: 0]
  |  |  ------------------
  |  |  129|      4|            *(ptr) = val;    \
  |  |  130|      4|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 4]
  |  |  ------------------
  ------------------
  746|      4|			INC_INDEX (s, 1);
  ------------------
  |  |  134|      4|    do{                    \
  |  |  135|      4|       (s)->index += (n);  \
  |  |  136|      4|       (s)->subscript= 0;  \
  |  |  137|      4|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 4]
  |  |  ------------------
  ------------------
  747|      4|		}
  748|      5|		return optp->r_val;
  749|      5|	}
  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|    181|{
  766|    181|	struct _scanopt_t *s;
  767|       |
  768|    181|	s = (struct _scanopt_t *) svoid;
  769|    181|	if (s != NULL) {
  ------------------
  |  Branch (769:6): [True: 181, False: 0]
  ------------------
  770|    181|		free(s->aux);
  771|    181|		free(s);
  772|    181|	}
  773|    181|	return 0;
  774|    181|}
scanopt.c:matchlongopt:
  517|    180|{
  518|    180|	char   *p;
  519|       |
  520|    180|	*optname = *arg = NULL;
  521|    180|	*optlen = *arglen = 0;
  522|       |
  523|       |	/* Match regex /--./   */
  524|    180|	p = str;
  525|    180|	if (p[0] != '-' || p[1] != '-' || !p[2])
  ------------------
  |  Branch (525:6): [True: 17, False: 163]
  |  Branch (525:21): [True: 29, False: 134]
  |  Branch (525:36): [True: 0, False: 134]
  ------------------
  526|     46|		return 0;
  527|       |
  528|    134|	p += 2;
  529|    134|	*optname = p;
  530|       |
  531|       |	/* find the end of optname */
  532|  1.90k|	while (*p && *p != '=')
  ------------------
  |  Branch (532:9): [True: 1.78k, False: 122]
  |  Branch (532:15): [True: 1.77k, False: 12]
  ------------------
  533|  1.77k|		++p;
  534|       |
  535|    134|	*optlen = (int) (p - *optname);
  536|       |
  537|    134|	if (!*p)
  ------------------
  |  Branch (537:6): [True: 122, False: 12]
  ------------------
  538|       |		/* an option with no '=...' part. */
  539|    122|		return 1;
  540|       |
  541|       |
  542|       |	/* We saw an '=' char. The rest of p is the arg. */
  543|     12|	p++;
  544|     12|	*arg = p;
  545|     81|	while (*p)
  ------------------
  |  Branch (545:9): [True: 69, False: 12]
  ------------------
  546|     69|		++p;
  547|     12|	*arglen = (int) (p - *arg);
  548|       |
  549|     12|	return 1;
  550|    134|}
scanopt.c:find_opt:
  560|    161|{
  561|    161|	int     nmatch = 0, lastr_val = 0, i;
  562|       |
  563|    161|	*err_code = 0;
  564|    161|	*opt_offset = -1;
  565|       |
  566|    161|	if (!optstart)
  ------------------
  |  Branch (566:6): [True: 0, False: 161]
  ------------------
  567|      0|		return 0;
  568|       |
  569|  19.1k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (569:14): [True: 18.9k, False: 152]
  ------------------
  570|  18.9k|		const char   *optname;
  571|       |
  572|  18.9k|		optname = s->options[i].opt_fmt + (lookup_long ? 2 : 1);
  ------------------
  |  Branch (572:38): [True: 15.6k, False: 3.34k]
  ------------------
  573|       |
  574|  18.9k|		if (lookup_long && (s->aux[i].flags & IS_LONG)) {
  ------------------
  |  |   45|  15.6k|#define IS_LONG  0x08
  ------------------
  |  Branch (574:7): [True: 15.6k, False: 3.34k]
  |  Branch (574:22): [True: 11.6k, False: 3.91k]
  ------------------
  575|  11.6k|			if (len > s->aux[i].namelen)
  ------------------
  |  Branch (575:8): [True: 8.17k, False: 3.52k]
  ------------------
  576|  8.17k|				continue;
  577|       |
  578|  3.52k|			if (strncmp (optname, optstart, (size_t) len) == 0) {
  ------------------
  |  Branch (578:8): [True: 212, False: 3.31k]
  ------------------
  579|    212|				nmatch++;
  580|    212|				*opt_offset = i;
  581|       |
  582|       |				/* exact match overrides all. */
  583|    212|				if (len == s->aux[i].namelen) {
  ------------------
  |  Branch (583:9): [True: 9, False: 203]
  ------------------
  584|      9|					nmatch = 1;
  585|      9|					break;
  586|      9|				}
  587|       |
  588|       |				/* ambiguity is ok between aliases. */
  589|    203|				if (lastr_val
  ------------------
  |  Branch (589:9): [True: 191, False: 12]
  ------------------
  590|    191|				    && lastr_val ==
  ------------------
  |  Branch (590:12): [True: 4, False: 187]
  ------------------
  591|    191|				    s->options[i].r_val) nmatch--;
  592|    203|				lastr_val = s->options[i].r_val;
  593|    203|			}
  594|  3.52k|		}
  595|  7.26k|		else if (!lookup_long && !(s->aux[i].flags & IS_LONG)) {
  ------------------
  |  |   45|  3.34k|#define IS_LONG  0x08
  ------------------
  |  Branch (595:12): [True: 3.34k, False: 3.91k]
  |  Branch (595:28): [True: 837, False: 2.51k]
  ------------------
  596|    837|			if (optname[0] == optstart[0]) {
  ------------------
  |  Branch (596:8): [True: 13, False: 824]
  ------------------
  597|     13|				nmatch++;
  598|     13|				*opt_offset = i;
  599|     13|			}
  600|    837|		}
  601|  18.9k|	}
  602|       |
  603|    161|	if (nmatch == 0) {
  ------------------
  |  Branch (603:6): [True: 127, False: 34]
  ------------------
  604|    127|		*err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
  605|    127|		*opt_offset = -1;
  606|    127|	}
  607|     34|	else if (nmatch > 1) {
  ------------------
  |  Branch (607:11): [True: 9, False: 25]
  ------------------
  608|      9|		*err_code = SCANOPT_ERR_OPT_AMBIGUOUS;
  609|      9|		*opt_offset = -1;
  610|      9|	}
  611|       |
  612|    161|	return *err_code ? 0 : 1;
  ------------------
  |  Branch (612:9): [True: 136, False: 25]
  ------------------
  613|    161|}
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|      4|		case SCANOPT_ERR_ARG_NOT_ALLOWED:
  ------------------
  |  Branch (483:3): [True: 4, False: 136]
  ------------------
  484|      4|			fprintf (stderr,
  485|      4|				 _
  ------------------
  |  |  100|      4|#define _(String) gettext (String)
  ------------------
  486|      4|				 ("option `%s' doesn't allow an argument\n"),
  487|      4|				 optname);
  488|      4|			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|      9|		case SCANOPT_ERR_OPT_AMBIGUOUS:
  ------------------
  |  Branch (494:3): [True: 9, False: 131]
  ------------------
  495|      9|			fprintf (stderr, _("option `%s' is ambiguous\n"),
  ------------------
  |  |  100|      9|#define _(String) gettext (String)
  ------------------
  496|      9|				 optname);
  497|      9|			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|    189|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   24|    189|  if (size < 24) {
  ------------------
  |  Branch (24:7): [True: 8, False: 181]
  ------------------
   25|      8|    return 0;
   26|      8|  }
   27|    181|  char *opt_fuzz = malloc(24);
   28|       |
   29|    181|  memcpy(opt_fuzz, data, 23);
   30|    181|  opt_fuzz[23] = 0;
   31|    181|  data += 23;
   32|    181|  size -= 23;
   33|       |
   34|    181|  char *new_str = (char *)malloc(size + 1);
   35|    181|  if (new_str == NULL) {
  ------------------
  |  Branch (35:7): [True: 0, False: 181]
  ------------------
   36|      0|    return 0;
   37|      0|  }
   38|    181|  memcpy(new_str, data, size);
   39|    181|  new_str[size] = '\0';
   40|    181|  my_argv[0] = "/tmp/fuzz/";
   41|    181|  my_argv[1] = opt_fuzz;
   42|    181|  my_argv[2] = new_str;
   43|    181|  my_argv[3] = NULL;
   44|       |
   45|    181|  scanopt_t sopt;
   46|    181|  sopt = scanopt_init(flexopts, 3, my_argv, 0);
   47|    181|  if (!sopt) {
  ------------------
  |  Branch (47:7): [True: 0, False: 181]
  ------------------
   48|      0|    free(new_str);
   49|      0|    free(opt_fuzz);
   50|      0|    return 0;
   51|      0|  }
   52|    181|  int optind;
   53|    181|  char *arg;
   54|    181|  scanopt(sopt, &arg, &optind);
   55|    181|  scanopt_destroy(sopt);
   56|       |
   57|    181|  free(new_str);
   58|    181|  free(opt_fuzz);
   59|    181|  return 0;
   60|    181|}

