diff options
author | wlestes <wlestes> | 2012-02-03 22:16:30 +0000 |
---|---|---|
committer | wlestes <wlestes> | 2012-02-03 22:16:30 +0000 |
commit | 0fba1571f33d4cc7b4c4fdde2a1e2ec0e7f8568f (patch) | |
tree | adfa6245ccd5fc0fc8748a1b0eb757a566b7517b | |
parent | a47a8e5c21db687d142804abfd47f2ff7ec523aa (diff) | |
download | flex-0fba1571f33d4cc7b4c4fdde2a1e2ec0e7f8568f.tar.gz |
more careful memory allocation in option processing
-rw-r--r-- | scanopt.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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; |