scanopt_init:
  140|    177|{
  141|    177|	int     i;
  142|    177|	struct _scanopt_t *s;
  143|    177|	s = malloc(sizeof (struct _scanopt_t));
  144|       |
  145|    177|	s->options = options;
  146|    177|	s->optc = 0;
  147|    177|	s->argc = argc;
  148|    177|	s->argv = (char **) argv;
  149|    177|	s->index = 1;
  150|    177|	s->subscript = 0;
  151|    177|	s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
  152|    177|	s->has_long = 0;
  153|    177|	s->has_short = 0;
  154|       |
  155|       |	/* Determine option count. (Find entry with all zeros). */
  156|    177|	s->optc = 0;
  157|  22.1k|	while (options[s->optc].opt_fmt
  ------------------
  |  Branch (157:9): [True: 21.9k, False: 177]
  ------------------
  158|    177|	       || options[s->optc].r_val || options[s->optc].desc)
  ------------------
  |  Branch (158:12): [True: 0, False: 177]
  |  Branch (158:38): [True: 0, False: 177]
  ------------------
  159|  21.9k|		s->optc++;
  160|       |
  161|       |	/* Build auxiliary data */
  162|    177|	s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
  163|       |
  164|  22.1k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (164:14): [True: 21.9k, False: 177]
  ------------------
  165|  21.9k|		const unsigned char *p, *pname;
  166|  21.9k|		const struct optspec_t *opt;
  167|  21.9k|		struct _aux *aux;
  168|       |
  169|  21.9k|		opt = s->options + i;
  170|  21.9k|		aux = s->aux + i;
  171|       |
  172|  21.9k|		aux->flags = ARG_NONE;
  ------------------
  |  |   42|  21.9k|#define ARG_NONE 0x01
  ------------------
  173|       |
  174|  21.9k|		if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
  ------------------
  |  Branch (174:7): [True: 21.9k, False: 0]
  |  Branch (174:33): [True: 16.4k, False: 5.48k]
  ------------------
  175|  16.4k|			aux->flags |= IS_LONG;
  ------------------
  |  |   45|  16.4k|#define IS_LONG  0x08
  ------------------
  176|  16.4k|			pname = (const unsigned char *)(opt->opt_fmt + 2);
  177|  16.4k|			s->has_long = 1;
  178|  16.4k|		}
  179|  5.48k|		else {
  180|  5.48k|			pname = (const unsigned char *)(opt->opt_fmt + 1);
  181|  5.48k|			s->has_short = 1;
  182|  5.48k|		}
  183|  21.9k|		aux->printlen = (int) strlen (opt->opt_fmt);
  184|       |
  185|  21.9k|		aux->namelen = 0;
  186|   167k|		for (p = pname + 1; *p; p++) {
  ------------------
  |  Branch (186:23): [True: 145k, False: 21.4k]
  ------------------
  187|       |			/* detect required arg */
  188|   145k|			if (*p == '=' || isspace ((unsigned char)*p)
  ------------------
  |  Branch (188:8): [True: 1.23k, False: 144k]
  |  Branch (188:21): [True: 708, False: 143k]
  ------------------
  189|   143k|			    || !(aux->flags & IS_LONG)) {
  ------------------
  |  |   45|   143k|#define IS_LONG  0x08
  ------------------
  |  Branch (189:11): [True: 4.24k, False: 139k]
  ------------------
  190|  6.19k|				if (aux->namelen == 0)
  ------------------
  |  Branch (190:9): [True: 2.30k, False: 3.89k]
  ------------------
  191|  2.30k|					aux->namelen = (int) (p - pname);
  192|  6.19k|				aux->flags |= ARG_REQ;
  ------------------
  |  |   43|  6.19k|#define ARG_REQ  0x02
  ------------------
  193|  6.19k|				aux->flags &= ~ARG_NONE;
  ------------------
  |  |   42|  6.19k|#define ARG_NONE 0x01
  ------------------
  194|  6.19k|			}
  195|       |			/* detect optional arg. This overrides required arg. */
  196|   145k|			if (*p == '[') {
  ------------------
  |  Branch (196:8): [True: 531, False: 145k]
  ------------------
  197|    531|				if (aux->namelen == 0)
  ------------------
  |  Branch (197:9): [True: 354, False: 177]
  ------------------
  198|    354|					aux->namelen = (int) (p - pname);
  199|    531|				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   43|    531|#define ARG_REQ  0x02
  ------------------
              				aux->flags &= ~(ARG_REQ | ARG_NONE);
  ------------------
  |  |   42|    531|#define ARG_NONE 0x01
  ------------------
  200|    531|				aux->flags |= ARG_OPT;
  ------------------
  |  |   44|    531|#define ARG_OPT  0x04
  ------------------
  201|    531|				break;
  202|    531|			}
  203|   145k|		}
  204|  21.9k|		if (aux->namelen == 0)
  ------------------
  |  Branch (204:7): [True: 19.2k, False: 2.65k]
  ------------------
  205|  19.2k|			aux->namelen = (int) (p - pname);
  206|  21.9k|	}
  207|    177|	return (scanopt_t *) s;
  208|    177|}
scanopt:
  617|    177|{
  618|    177|	char   *optname = NULL, *optarg = NULL, *pstart;
  619|    177|	int     namelen = 0, arglen = 0;
  620|    177|	int     errcode = 0, has_next;
  621|    177|	const optspec_t *optp;
  622|    177|	struct _scanopt_t *s;
  623|    177|	struct _aux *auxp;
  624|    177|	int     is_short;
  625|    177|	int     opt_offset = -1;
  626|       |
  627|    177|	s = (struct _scanopt_t *) svoid;
  628|       |
  629|       |	/* Normalize return-parameters. */
  630|    177|	SAFE_ASSIGN (arg, NULL);
  ------------------
  |  |  127|    177|    do{                      \
  |  |  128|    177|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 177, False: 0]
  |  |  ------------------
  |  |  129|    177|            *(ptr) = val;    \
  |  |  130|    177|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 177]
  |  |  ------------------
  ------------------
  631|    177|	SAFE_ASSIGN (optindex, s->index);
  ------------------
  |  |  127|    177|    do{                      \
  |  |  128|    177|        if((ptr)!=NULL)      \
  |  |  ------------------
  |  |  |  Branch (128:12): [True: 177, False: 0]
  |  |  ------------------
  |  |  129|    177|            *(ptr) = val;    \
  |  |  130|    177|    }while(0)
  |  |  ------------------
  |  |  |  Branch (130:12): [Folded, False: 177]
  |  |  ------------------
  ------------------
  632|       |
  633|    177|	if (s->index >= s->argc)
  ------------------
  |  Branch (633:6): [True: 0, False: 177]
  ------------------
  634|      0|		return 0;
  635|       |
  636|       |	/* pstart always points to the start of our current scan. */
  637|    177|	pstart = s->argv[s->index] + s->subscript;
  638|    177|	if (!pstart)
  ------------------
  |  Branch (638:6): [True: 0, False: 177]
  ------------------
  639|      0|		return 0;
  640|       |
  641|    177|	if (s->subscript == 0) {
  ------------------
  |  Branch (641:6): [True: 177, False: 0]
  ------------------
  642|       |
  643|       |		/* test for exact match of "--" */
  644|    177|		if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
  ------------------
  |  Branch (644:7): [True: 164, False: 13]
  |  Branch (644:27): [True: 139, False: 25]
  |  Branch (644:47): [True: 1, False: 138]
  ------------------
  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|    176|		if (matchlongopt
  ------------------
  |  Branch (651:7): [True: 138, False: 38]
  ------------------
  652|    176|		    (pstart, &optname, &namelen, &optarg, &arglen)) {
  653|       |
  654|       |			/* it LOOKS like an opt, but is it one?! */
  655|    138|			if (!find_opt
  ------------------
  |  Branch (655:8): [True: 128, False: 10]
  ------------------
  656|    138|			    (s, 1, optname, namelen, &errcode,
  657|    138|			     &opt_offset)) {
  658|    128|				scanopt_err (s, 0, errcode);
  659|    128|				return errcode;
  660|    128|			}
  661|       |			/* We handle this below. */
  662|     10|			is_short = 0;
  663|       |
  664|       |			/* Check for short opt.  */
  665|     10|		}
  666|     38|		else if (pstart[0] == '-' && pstart[1]) {
  ------------------
  |  Branch (666:12): [True: 25, False: 13]
  |  Branch (666:32): [True: 23, False: 2]
  ------------------
  667|       |			/* Pass through to below. */
  668|     23|			is_short = 1;
  669|     23|			s->subscript++;
  670|     23|			pstart++;
  671|     23|		}
  672|       |
  673|     15|		else {
  674|       |			/* It's not an option. We're done. */
  675|     15|			return 0;
  676|     15|		}
  677|    176|	}
  678|       |
  679|       |	/* We have to re-check the subscript status because it
  680|       |	 * may have changed above. */
  681|       |
  682|     33|	if (s->subscript != 0) {
  ------------------
  |  Branch (682:6): [True: 23, False: 10]
  ------------------
  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: 3, False: 8]
  ------------------
  699|      3|			optarg = NULL;
  700|      3|			arglen = 0;
  701|      3|		}
  702|      8|		else
  703|      8|			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: 15, False: 6]
  ------------------
  720|     15|		if (optarg && !is_short) {
  ------------------
  |  Branch (720:7): [True: 8, False: 7]
  |  Branch (720:17): [True: 1, False: 7]
  ------------------
  721|      1|			scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_ALLOWED);
  722|      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]
  |  |  ------------------
  ------------------
  723|      1|			return SCANOPT_ERR_ARG_NOT_ALLOWED;
  724|      1|		}
  725|     14|		else if (!optarg)
  ------------------
  |  Branch (725:12): [True: 7, False: 7]
  ------------------
  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|      7|		else
  728|      7|			s->subscript++;
  729|     14|		return optp->r_val;
  730|     15|	}
  731|       |
  732|       |	/* case: required */
  733|      6|	if (auxp->flags & ARG_REQ) {
  ------------------
  |  |   43|      6|#define ARG_REQ  0x02
  ------------------
  |  Branch (733:6): [True: 4, False: 2]
  ------------------
  734|      4|		if (!optarg && !has_next) {
  ------------------
  |  Branch (734:7): [True: 2, False: 2]
  |  Branch (734:18): [True: 0, False: 2]
  ------------------
  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: 2, False: 2]
  ------------------
  740|       |			/* Let the next argv element become the argument. */
  741|      2|			SAFE_ASSIGN (arg, s->argv[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]
  |  |  ------------------
  ------------------
  742|      2|			INC_INDEX (s, 2);
  ------------------
  |  |  134|      2|    do{                    \
  |  |  135|      2|       (s)->index += (n);  \
  |  |  136|      2|       (s)->subscript= 0;  \
  |  |  137|      2|    }while(0)
  |  |  ------------------
  |  |  |  Branch (137:12): [Folded, False: 2]
  |  |  ------------------
  ------------------
  743|      2|		}
  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|      4|		return optp->r_val;
  749|      4|	}
  750|       |
  751|       |	/* case: optional */
  752|      2|	if (auxp->flags & ARG_OPT) {
  ------------------
  |  |   44|      2|#define ARG_OPT  0x04
  ------------------
  |  Branch (752:6): [True: 2, False: 0]
  ------------------
  753|      2|		SAFE_ASSIGN (arg, 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]
  |  |  ------------------
  ------------------
  754|      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]
  |  |  ------------------
  ------------------
  755|      2|		return optp->r_val;
  756|      2|	}
  757|       |
  758|       |
  759|       |	/* Should not reach here. */
  760|      0|	return 0;
  761|      2|}
scanopt_destroy:
  765|    177|{
  766|    177|	struct _scanopt_t *s;
  767|       |
  768|    177|	s = (struct _scanopt_t *) svoid;
  769|    177|	if (s != NULL) {
  ------------------
  |  Branch (769:6): [True: 177, False: 0]
  ------------------
  770|    177|		free(s->aux);
  771|    177|		free(s);
  772|    177|	}
  773|    177|	return 0;
  774|    177|}
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: 13, False: 163]
  |  Branch (525:21): [True: 25, False: 138]
  |  Branch (525:36): [True: 0, False: 138]
  ------------------
  526|     38|		return 0;
  527|       |
  528|    138|	p += 2;
  529|    138|	*optname = p;
  530|       |
  531|       |	/* find the end of optname */
  532|  1.92k|	while (*p && *p != '=')
  ------------------
  |  Branch (532:9): [True: 1.80k, False: 122]
  |  Branch (532:15): [True: 1.78k, False: 16]
  ------------------
  533|  1.78k|		++p;
  534|       |
  535|    138|	*optlen = (int) (p - *optname);
  536|       |
  537|    138|	if (!*p)
  ------------------
  |  Branch (537:6): [True: 122, False: 16]
  ------------------
  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|     16|	p++;
  544|     16|	*arg = p;
  545|    109|	while (*p)
  ------------------
  |  Branch (545:9): [True: 93, False: 16]
  ------------------
  546|     93|		++p;
  547|     16|	*arglen = (int) (p - *arg);
  548|       |
  549|     16|	return 1;
  550|    138|}
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.3k|	for (i = 0; i < s->optc; i++) {
  ------------------
  |  Branch (569:14): [True: 19.1k, False: 153]
  ------------------
  570|  19.1k|		const char   *optname;
  571|       |
  572|  19.1k|		optname = s->options[i].opt_fmt + (lookup_long ? 2 : 1);
  ------------------
  |  Branch (572:38): [True: 16.3k, False: 2.85k]
  ------------------
  573|       |
  574|  19.1k|		if (lookup_long && (s->aux[i].flags & IS_LONG)) {
  ------------------
  |  |   45|  16.3k|#define IS_LONG  0x08
  ------------------
  |  Branch (574:7): [True: 16.3k, False: 2.85k]
  |  Branch (574:22): [True: 12.2k, False: 4.09k]
  ------------------
  575|  12.2k|			if (len > s->aux[i].namelen)
  ------------------
  |  Branch (575:8): [True: 8.36k, False: 3.87k]
  ------------------
  576|  8.36k|				continue;
  577|       |
  578|  3.87k|			if (strncmp (optname, optstart, (size_t) len) == 0) {
  ------------------
  |  Branch (578:8): [True: 212, False: 3.65k]
  ------------------
  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: 8, False: 204]
  ------------------
  584|      8|					nmatch = 1;
  585|      8|					break;
  586|      8|				}
  587|       |
  588|       |				/* ambiguity is ok between aliases. */
  589|    204|				if (lastr_val
  ------------------
  |  Branch (589:9): [True: 192, False: 12]
  ------------------
  590|    192|				    && lastr_val ==
  ------------------
  |  Branch (590:12): [True: 4, False: 188]
  ------------------
  591|    192|				    s->options[i].r_val) nmatch--;
  592|    204|				lastr_val = s->options[i].r_val;
  593|    204|			}
  594|  3.87k|		}
  595|  6.95k|		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.09k]
  |  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.1k|	}
  602|       |
  603|    161|	if (nmatch == 0) {
  ------------------
  |  Branch (603:6): [True: 130, False: 31]
  ------------------
  604|    130|		*err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
  605|    130|		*opt_offset = -1;
  606|    130|	}
  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|    161|	return *err_code ? 0 : 1;
  ------------------
  |  Branch (612:9): [True: 140, False: 21]
  ------------------
  613|    161|}
scanopt.c:scanopt_err:
  463|    141|{
  464|    141|	const char *optname = "";
  465|    141|	char    optchar[2];
  466|       |
  467|    141|	if (!s->no_err_msg) {
  ------------------
  |  Branch (467:6): [True: 141, False: 0]
  ------------------
  468|       |
  469|    141|		if (s->index > 0 && s->index < s->argc) {
  ------------------
  |  Branch (469:7): [True: 141, False: 0]
  |  Branch (469:23): [True: 141, False: 0]
  ------------------
  470|    141|			if (is_short) {
  ------------------
  |  Branch (470:8): [True: 12, False: 129]
  ------------------
  471|     12|				optchar[0] =
  472|     12|					s->argv[s->index][s->subscript];
  473|     12|				optchar[1] = '\0';
  474|     12|				optname = optchar;
  475|     12|			}
  476|    129|			else {
  477|    129|				optname = s->argv[s->index];
  478|    129|			}
  479|    141|		}
  480|       |
  481|    141|		fprintf (stderr, "%s: ", s->argv[0]);
  482|    141|		switch (err) {
  483|      1|		case SCANOPT_ERR_ARG_NOT_ALLOWED:
  ------------------
  |  Branch (483:3): [True: 1, False: 140]
  ------------------
  484|      1|			fprintf (stderr,
  485|      1|				 _
  ------------------
  |  |  100|      1|#define _(String) gettext (String)
  ------------------
  486|      1|				 ("option `%s' doesn't allow an argument\n"),
  487|      1|				 optname);
  488|      1|			break;
  489|      0|		case SCANOPT_ERR_ARG_NOT_FOUND:
  ------------------
  |  Branch (489:3): [True: 0, False: 141]
  ------------------
  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: 131]
  ------------------
  495|     10|			fprintf (stderr, _("option `%s' is ambiguous\n"),
  ------------------
  |  |  100|     10|#define _(String) gettext (String)
  ------------------
  496|     10|				 optname);
  497|     10|			break;
  498|    130|		case SCANOPT_ERR_OPT_UNRECOGNIZED:
  ------------------
  |  Branch (498:3): [True: 130, False: 11]
  ------------------
  499|    130|			fprintf (stderr, _("Unrecognized option `%s'\n"),
  ------------------
  |  |  100|    130|#define _(String) gettext (String)
  ------------------
  500|    130|				 optname);
  501|    130|			break;
  502|      0|		default:
  ------------------
  |  Branch (502:3): [True: 0, False: 141]
  ------------------
  503|      0|			fprintf (stderr, _("Unknown error=(%d)\n"), err);
  ------------------
  |  |  100|      0|#define _(String) gettext (String)
  ------------------
  504|      0|			break;
  505|    141|		}
  506|    141|	}
  507|    141|}

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

