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

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

