From: Will Estes Date: Fri, 3 Feb 2012 22:16:30 +0000 (+0000) Subject: more careful memory allocation in option processing X-Git-Tag: flex-2-5-36~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=accb35a7ae87bdf95a67a904a05d85901192afa8;p=flex more careful memory allocation in option processing --- diff --git a/scanopt.c b/scanopt.c index 2c8d593..f76ecd3 100644 --- a/scanopt.c +++ b/scanopt.c @@ -189,7 +189,7 @@ scanopt_t *scanopt_init (options, argc, argv, flags) s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux)); for (i = 0; i < s->optc; i++) { - const char *p, *pname; + const Char *p, *pname; const struct optspec_t *opt; struct _aux *aux; @@ -200,11 +200,11 @@ scanopt_t *scanopt_init (options, argc, argv, flags) if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') { aux->flags |= IS_LONG; - pname = opt->opt_fmt + 2; + pname = (const Char *)(opt->opt_fmt + 2); s->has_long = 1; } else { - pname = opt->opt_fmt + 1; + pname = (const Char *)(opt->opt_fmt + 1); s->has_short = 1; } aux->printlen = strlen (opt->opt_fmt); @@ -481,7 +481,7 @@ int scanopt_usage (scanner, fp, usage) while (*p && n < maxlen[1] && *p != '\n') { - if (isspace (*p) + if (isspace ((Char)(*p)) || *p == '-') lastws = p; n++; @@ -504,8 +504,7 @@ int scanopt_usage (scanner, fp, usage) if (lastws) { fprintf (fp, "%.*s\n", - lastws - - pstart, + (int)(lastws - pstart), pstart); pstart = lastws + 1;