]> granicus.if.org Git - flex/commitdiff
more careful memory allocation in option processing
authorWill Estes <wlestes@users.sourceforge.net>
Fri, 3 Feb 2012 22:16:30 +0000 (22:16 +0000)
committerWill Estes <wlestes@users.sourceforge.net>
Fri, 3 Feb 2012 22:16:30 +0000 (22:16 +0000)
scanopt.c

index 2c8d59319dbf184a2f7191b0c8647de1fc44a0e0..f76ecd34dac07b9cc6d0682f2bfa1ca75c8ef664 100644 (file)
--- 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;