gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-477


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-477-gb549d43
Date: Mon, 10 Nov 2014 21:03:19 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-4.1-stable has been updated
       via  b549d4314c75c5136bfc5ede78df5ecdfbd85690 (commit)
      from  a9d4cec96e6e37f470ef5bf8ca7b5a6af6a722bc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=b549d4314c75c5136bfc5ede78df5ecdfbd85690

commit b549d4314c75c5136bfc5ede78df5ecdfbd85690
Author: Arnold D. Robbins <address@hidden>
Date:   Mon Nov 10 23:02:56 2014 +0200

    Add undocumented -Z option to set locale.

diff --git a/ChangeLog b/ChangeLog
index 99aee7a..4f21f0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-10         Arnold D. Robbins     <address@hidden>
+
+       Reorder main.c activities so that we can set a locale on the
+       command line with the new, for now undocumented, -Z option.
+
+       * main.c (parse_args, set_locale_stuff): New functions.
+       (stopped_early): Made file level static.
+       (optlist, optab): Add new argument.
+       (main): Adjust ordering and move inline code into new functions.
+
 2014-11-09         Andrew J. Schorr     <address@hidden>
 
        * gawkapi.c (node_to_awk_value): When the type wanted is AWK_UNDEFINED
diff --git a/configure b/configure
index d98aeb1..555cba2 100755
--- a/configure
+++ b/configure
@@ -5675,7 +5675,7 @@ $as_echo_n "checking for special development options... " 
>&6; }
 if test -f $srcdir/.developing
 then
        # add other debug flags as appropriate, save GAWKDEBUG for emergencies
-       CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG"
+       CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG"
        if grep dbug $srcdir/.developing
        then
                CFLAGS="$CFLAGS -DDBUG"
diff --git a/configure.ac b/configure.ac
index 55ca72d..ed7e3cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,7 +87,7 @@ AC_MSG_CHECKING([for special development options])
 if test -f $srcdir/.developing
 then
        # add other debug flags as appropriate, save GAWKDEBUG for emergencies
-       CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG"
+       CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG"
        if grep dbug $srcdir/.developing
        then
                CFLAGS="$CFLAGS -DDBUG"
diff --git a/main.c b/main.c
index 3bee048..e3440b8 100644
--- a/main.c
+++ b/main.c
@@ -142,11 +142,16 @@ static bool disallow_var_assigns = false; /* true for 
--exec */
 
 static void add_preassign(enum assign_type type, char *val);
 
+static void parse_args(int argc, char **argv);
+static void set_locale_stuff(void);
+static bool stopped_early = false;
+
 int do_flags = false;
 bool do_optimize = false;              /* apply default optimizations */
 static int do_nostalgia = false;       /* provide a blast from the past */
 static int do_binary = false;          /* hands off my data! */
 static int do_version = false;         /* print version info */
+static const char *locale = "";                /* default value to setlocale */
 
 int use_lc_numeric = false;    /* obey locale for decimal point */
 
@@ -186,6 +191,9 @@ static const struct option optab[] = {
        { "lint",               optional_argument,      NULL,   'L' },
        { "lint-old",           no_argument,            NULL,   't' },
        { "load",               required_argument,      NULL,   'l' },
+#if defined(LOCALEDEBUG)
+       { "locale",             required_argument,      NULL,   'Z' },
+#endif
        { "non-decimal-data",   no_argument,            NULL,   'n' },
        { "nostalgia",          no_argument,            & do_nostalgia, 1 },
        { "optimize",           no_argument,            NULL,   'O' },
@@ -209,15 +217,7 @@ static const struct option optab[] = {
 int
 main(int argc, char **argv)
 {
-       /*
-        * The + on the front tells GNU getopt not to rearrange argv.
-        */
-       const char *optlist = "+F:f:v:W;bcCd::D::e:E:ghi:l:L:nNo::Op::MPrStVY";
-       bool stopped_early = false;
-       int old_optind;
        int i;
-       int c;
-       char *scan, *src;
        char *extra_stack;
        int have_srcfile = 0;
        SRCFILE *s;
@@ -233,60 +233,11 @@ main(int argc, char **argv)
 #endif /* HAVE_MTRACE */
 #endif /* HAVE_MCHECK_H */
 
-#if defined(LC_CTYPE)
-       setlocale(LC_CTYPE, "");
-#endif
-#if defined(LC_COLLATE)
-       setlocale(LC_COLLATE, "");
-#endif
-#if defined(LC_MESSAGES)
-       setlocale(LC_MESSAGES, "");
-#endif
-#if defined(LC_NUMERIC) && defined(HAVE_LOCALE_H)
-       /*
-        * Force the issue here.  According to POSIX 2001, decimal
-        * point is used for parsing source code and for command-line
-        * assignments and the locale value for processing input,
-        * number to string conversion, and printing output.
-        *
-        * 10/2005 --- see below also; we now only use the locale's
-        * decimal point if do_posix in effect.
-        *
-        * 9/2007:
-        * This is a mess. We need to get the locale's numeric info for
-        * the thousands separator for the %'d flag.
-        */
-       setlocale(LC_NUMERIC, "");
-       init_locale(& loc);
-       setlocale(LC_NUMERIC, "C");
-#endif
-#if defined(LC_TIME)
-       setlocale(LC_TIME, "");
-#endif
-
-#if MBS_SUPPORT
-       /*
-        * In glibc, MB_CUR_MAX is actually a function.  This value is
-        * tested *a lot* in many speed-critical places in gawk. Caching
-        * this value once makes a speed difference.
-        */
-       gawk_mb_cur_max = MB_CUR_MAX;
-       /* Without MBS_SUPPORT, gawk_mb_cur_max is 1. */
-#ifdef LIBC_IS_BORKED
-{
-       const char *env_lc;
-
-       env_lc = getenv("LC_ALL");
-       if (env_lc == NULL)
-               env_lc = getenv("LANG");
-       if (env_lc != NULL && env_lc[1] == '\0' && tolower(env_lc[0]) == 'c')
-               gawk_mb_cur_max = 1;
-}
-#endif
+       myname = gawk_name(argv[0]);
+       os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */
 
-       /* init the cache for checking bytes if they're characters */
-       init_btowc_cache();
-#endif
+       if (argc < 2)
+               usage(EXIT_FAILURE, stderr);
 
        (void) bindtextdomain(PACKAGE, LOCALEDIR);
        (void) textdomain(PACKAGE);
@@ -318,12 +269,6 @@ main(int argc, char **argv)
        (void) stackoverflow_install_handler(catchstackoverflow, extra_stack, 
STACK_SIZE);
 #undef STACK_SIZE
 
-       myname = gawk_name(argv[0]);
-       os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */
-
-       if (argc < 2)
-               usage(EXIT_FAILURE, stderr);
-
        /* initialize the null string */
        Nnull_string = make_string("", 0);
 
@@ -338,306 +283,113 @@ main(int argc, char **argv)
 
        output_fp = stdout;
 
-       /* we do error messages ourselves on invalid options */
-       opterr = false;
-
-       /* copy argv before getopt gets to it; used to restart the debugger */  
-       save_argv(argc, argv);
-
        /* initialize global (main) execution context */
        push_context(new_context());
 
-       /* option processing. ready, set, go! */
-       for (optopt = 0, old_optind = 1;
-            (c = getopt_long(argc, argv, optlist, optab, NULL)) != EOF;
-            optopt = 0, old_optind = optind) {
-               if (do_posix)
-                       opterr = true;
-
-               switch (c) {
-               case 'F':
-                       add_preassign(PRE_ASSIGN_FS, optarg);
-                       break;
+       parse_args(argc, argv);
 
-               case 'E':
-                       disallow_var_assigns = true;
-                       /* fall through */
-               case 'f':
-                       /*
-                        * Allow multiple -f options.
-                        * This makes function libraries real easy.
-                        * Most of the magic is in the scanner.
-                        *
-                        * The following is to allow for whitespace at the end
-                        * of a #! /bin/gawk line in an executable file
-                        */
-                       scan = optarg;
-                       if (argv[optind-1] != optarg)
-                               while (isspace((unsigned char) *scan))
-                                       scan++;
-                       src = (*scan == '\0' ? argv[optind++] : optarg);
-                       (void) add_srcfile((src && src[0] == '-' && src[1] == 
'\0') ?
-                                       SRC_STDIN : SRC_FILE,
-                                       src, srcfiles, NULL, NULL);
+       set_locale_stuff();
 
-                       break;
+#if MBS_SUPPORT
+       /*
+        * In glibc, MB_CUR_MAX is actually a function.  This value is
+        * tested *a lot* in many speed-critical places in gawk. Caching
+        * this value once makes a speed difference.
+        */
+       gawk_mb_cur_max = MB_CUR_MAX;
+       /* Without MBS_SUPPORT, gawk_mb_cur_max is 1. */
+#ifdef LIBC_IS_BORKED
+{
+       const char *env_lc;
 
-               case 'v':
-                       add_preassign(PRE_ASSIGN, optarg);
-                       break;
+       env_lc = getenv("LC_ALL");
+       if (env_lc == NULL)
+               env_lc = getenv("LANG");
+       if (env_lc != NULL && env_lc[1] == '\0' && tolower(env_lc[0]) == 'c')
+               gawk_mb_cur_max = 1;
+}
+#endif
 
-               case 'b':
-                       do_binary = true;
-                       break;
+       /* init the cache for checking bytes if they're characters */
+       init_btowc_cache();
+#endif
 
-               case 'c':
-                       do_flags |= DO_TRADITIONAL;
-                       break;
 
-               case 'C':
-                       copyleft();
-                       break;
+       if (do_nostalgia)
+               nostalgia();
 
-               case 'd':
-                       do_flags |= DO_DUMP_VARS;
-                       if (optarg != NULL && optarg[0] != '\0')
-                               varfile = optarg;
-                       break;
+       /* check for POSIXLY_CORRECT environment variable */
+       if (! do_posix && getenv("POSIXLY_CORRECT") != NULL) {
+               do_flags |= DO_POSIX;
+               if (do_lint)
+                       lintwarn(
+       _("environment variable `POSIXLY_CORRECT' set: turning on `--posix'"));
+       }
 
-               case 'D':
-                       do_flags |= DO_DEBUG;
-                       if (optarg != NULL && optarg[0] != '\0')
-                               command_file = optarg;
-                       break;
+       if (do_posix) {
+               use_lc_numeric = true;
+               if (do_traditional)     /* both on command line */
+                       warning(_("`--posix' overrides `--traditional'"));
+               else
+                       do_flags |= DO_TRADITIONAL;
+                       /*
+                        * POSIX compliance also implies
+                        * no GNU extensions either.
+                        */
+       }
 
-               case 'e':
-                       if (optarg[0] == '\0')
-                               warning(_("empty argument to `-e/--source' 
ignored"));
-                       else
-                               (void) add_srcfile(SRC_CMDLINE, optarg, 
srcfiles, NULL, NULL);
-                       break;
+       if (do_traditional && do_non_decimal_data) {
+               do_flags &= ~DO_NON_DEC_DATA;
+               warning(_("`--posix'/`--traditional' overrides 
`--non-decimal-data'"));
+       }
 
-               case 'g':
-                       do_flags |= DO_INTL;
-                       break;
+       if (do_lint && os_is_setuid())
+               warning(_("running %s setuid root may be a security problem"), 
myname);
 
-               case 'h':
-                       /* write usage to stdout, per GNU coding stds */
-                       usage(EXIT_SUCCESS, stdout);
-                       break;
+#if MBS_SUPPORT
+       if (do_binary) {
+               if (do_posix)
+                       warning(_("`--posix' overrides 
`--characters-as-bytes'"));
+               else
+                       gawk_mb_cur_max = 1;    /* hands off my data! */
+#if defined(LC_ALL)
+               setlocale(LC_ALL, "C");
+#endif
+       }
+#endif
 
-               case 'i':
-                       (void) add_srcfile(SRC_INC, optarg, srcfiles, NULL, 
NULL);
-                       break;
+       if (do_debug)   /* Need to register the debugger pre-exec hook before 
any other */
+               init_debug();
 
-               case 'l':
-                       (void) add_srcfile(SRC_EXTLIB, optarg, srcfiles, NULL, 
NULL);
-                       break;
+#ifdef HAVE_MPFR
+       /* Set up MPFR defaults, and register pre-exec hook to process 
arithmetic opcodes */ 
+       if (do_mpfr)
+               init_mpfr(DEFAULT_PREC, DEFAULT_ROUNDMODE);
+#endif
 
-#ifndef NO_LINT
-               case 'L':
-                       do_flags |= DO_LINT_ALL;
-                       if (optarg != NULL) {
-                               if (strcmp(optarg, "fatal") == 0)
-                                       lintfunc = r_fatal;
-                               else if (strcmp(optarg, "invalid") == 0) {
-                                       do_flags &= ~DO_LINT_ALL;
-                                       do_flags |= DO_LINT_INVALID;
-                               }
-                       }
-                       break;
+       /* load group set */
+       init_groupset();
 
-               case 't':
-                       do_flags |= DO_LINT_OLD;
-                       break;
-#else
-               case 'L':
-               case 't':
-                       break;
+#ifdef HAVE_MPFR
+       if (do_mpfr) {
+               mpz_init(Nnull_string->mpg_i);
+               Nnull_string->flags = (MALLOC|STRCUR|STRING|MPZN|NUMCUR|NUMBER);
+       } else
 #endif
+       {
+               Nnull_string->numbr = 0.0;
+               Nnull_string->flags = (MALLOC|STRCUR|STRING|NUMCUR|NUMBER);
+       }
 
-               case 'n':
-                       do_flags |= DO_NON_DEC_DATA;
-                       break;
+       /*
+        * Tell the regex routines how they should work.
+        * Do this before initializing variables, since
+        * they could want to do a regexp compile.
+        */
+       resetup();
 
-               case 'N':
-                       use_lc_numeric = true;
-                       break;
-
-               case 'O':
-                       do_optimize = true;
-                       break;
-
-               case 'p':
-                       do_flags |= DO_PROFILE;
-                       /* fall through */
-               case 'o':
-                       do_flags |= DO_PRETTY_PRINT;
-                       if (optarg != NULL)
-                               set_prof_file(optarg);
-                       else
-                               set_prof_file(DEFAULT_PROFILE);
-                       break;
-
-               case 'M':
-#ifdef HAVE_MPFR
-                       do_flags |= DO_MPFR;
-#else
-                       warning(_("-M ignored: MPFR/GMP support not compiled 
in"));
-#endif
-                       break;
-
-               case 'P':
-                       do_flags |= DO_POSIX;
-                       break;
-
-               case 'r':
-                       do_flags |= DO_INTERVALS;
-                       break;
- 
-               case 'S':
-                       do_flags |= DO_SANDBOX;
-                       break;
-
-               case 'V':
-                       do_version = true;
-                       break;
-
-               case 'W':       /* gawk specific options - now in getopt_long */
-                       fprintf(stderr, _("%s: option `-W %s' unrecognized, 
ignored\n"),
-                               argv[0], optarg);
-                       break;
-
-               case 0:
-                       /*
-                        * getopt_long found an option that sets a variable
-                        * instead of returning a letter. Do nothing, just
-                        * cycle around for the next one.
-                        */
-                       break;
-
-               case 'Y':
-#if defined(YYDEBUG) || defined(GAWKDEBUG)
-                       if (c == 'Y') {
-                               yydebug = 2;
-                               break;
-                       }
-#endif
-                       /* if not debugging, fall through */
-               case '?':
-               default:
-                       /*
-                        * If not posix, an unrecognized option stops argument
-                        * processing so that it can go into ARGV for the awk
-                        * program to see. This makes use of ``#! /bin/gawk -f''
-                        * easier.
-                        *
-                        * However, it's never simple. If optopt is set,
-                        * an option that requires an argument didn't get the
-                        * argument. We care because if opterr is 0, then
-                        * getopt_long won't print the error message for us.
-                        */
-                       if (! do_posix
-                           && (optopt == '\0' || strchr(optlist, optopt) == 
NULL)) {
-                               /*
-                                * can't just do optind--. In case of an
-                                * option with >= 2 letters, getopt_long
-                                * won't have incremented optind.
-                                */
-                               optind = old_optind;
-                               stopped_early = true;
-                               goto out;
-                       } else if (optopt != '\0') {
-                               /* Use POSIX required message format */
-                               fprintf(stderr,
-                                       _("%s: option requires an argument -- 
%c\n"),
-                                       myname, optopt);
-                               usage(EXIT_FAILURE, stderr);
-                       }
-                       /* else
-                               let getopt print error message for us */
-                       break;
-               }
-               if (c == 'E')   /* --exec ends option processing */
-                       break;
-       }
-out:
-
-       if (do_nostalgia)
-               nostalgia();
-
-       /* check for POSIXLY_CORRECT environment variable */
-       if (! do_posix && getenv("POSIXLY_CORRECT") != NULL) {
-               do_flags |= DO_POSIX;
-               if (do_lint)
-                       lintwarn(
-       _("environment variable `POSIXLY_CORRECT' set: turning on `--posix'"));
-       }
-
-       if (do_posix) {
-               use_lc_numeric = true;
-               if (do_traditional)     /* both on command line */
-                       warning(_("`--posix' overrides `--traditional'"));
-               else
-                       do_flags |= DO_TRADITIONAL;
-                       /*
-                        * POSIX compliance also implies
-                        * no GNU extensions either.
-                        */
-       }
-
-       if (do_traditional && do_non_decimal_data) {
-               do_flags &= ~DO_NON_DEC_DATA;
-               warning(_("`--posix'/`--traditional' overrides 
`--non-decimal-data'"));
-       }
-
-       if (do_lint && os_is_setuid())
-               warning(_("running %s setuid root may be a security problem"), 
myname);
-
-#if MBS_SUPPORT
-       if (do_binary) {
-               if (do_posix)
-                       warning(_("`--posix' overrides 
`--characters-as-bytes'"));
-               else
-                       gawk_mb_cur_max = 1;    /* hands off my data! */
-#if defined(LC_ALL)
-               setlocale(LC_ALL, "C");
-#endif
-       }
-#endif
-
-       if (do_debug)   /* Need to register the debugger pre-exec hook before 
any other */
-               init_debug();
-
-#ifdef HAVE_MPFR
-       /* Set up MPFR defaults, and register pre-exec hook to process 
arithmetic opcodes */ 
-       if (do_mpfr)
-               init_mpfr(DEFAULT_PREC, DEFAULT_ROUNDMODE);
-#endif
-
-       /* load group set */
-       init_groupset();
-
-#ifdef HAVE_MPFR
-       if (do_mpfr) {
-               mpz_init(Nnull_string->mpg_i);
-               Nnull_string->flags = (MALLOC|STRCUR|STRING|MPZN|NUMCUR|NUMBER);
-       } else
-#endif
-       {
-               Nnull_string->numbr = 0.0;
-               Nnull_string->flags = (MALLOC|STRCUR|STRING|NUMCUR|NUMBER);
-       }
-
-       /*
-        * Tell the regex routines how they should work.
-        * Do this before initializing variables, since
-        * they could want to do a regexp compile.
-        */
-       resetup();
-
-       /* Set up the special variables */
-       init_vars();
+       /* Set up the special variables */
+       init_vars();
 
        /* Set up the field variables */
        init_fields();
@@ -745,8 +497,9 @@ out:
         * data using the local decimal point.
         */
        if (use_lc_numeric)
-               setlocale(LC_NUMERIC, "");
+               setlocale(LC_NUMERIC, locale);
 #endif
+// fprintf(stderr, "locale is <%s>\n", locale); fflush(stderr);
        
        init_io();
        output_fp = stdout;
@@ -856,6 +609,9 @@ usage(int exitval, FILE *fp)
 #ifdef GAWKDEBUG
        fputs(_("\t-Y\t\t--parsedebug\n"), fp);
 #endif
+#if defined(LOCALEDEBUG)
+       fputs(_("\t-Z\t\t--locale\n"), fp);
+#endif
 
        /* This is one string to make things easier on translators. */
        /* TRANSLATORS: --help output 5 (end)
@@ -1387,7 +1143,7 @@ arg_assign(char *arg, bool initing)
                        setlocale(LC_NUMERIC, "C");
                (void) force_number(it);
                if (do_posix)
-                       setlocale(LC_NUMERIC, "");
+                       setlocale(LC_NUMERIC, locale);
 #endif /* LC_NUMERIC */
 
                /*
@@ -1651,3 +1407,285 @@ getenv_long(const char *name)
        }
        return -1;
 }
+
+/* parse_args --- do the getopt_long thing */
+
+static void
+parse_args(int argc, char **argv)
+{
+       /*
+        * The + on the front tells GNU getopt not to rearrange argv.
+        */
+       const char *optlist = 
"+F:f:v:W;bcCd::D::e:E:ghi:l:L:nNo::Op::MPrStVYZ:";
+       int old_optind;
+       int c;
+       char *scan;
+       char *src;
+
+       /* we do error messages ourselves on invalid options */
+       opterr = false;
+
+       /* copy argv before getopt gets to it; used to restart the debugger */  
+       save_argv(argc, argv);
+
+       /* option processing. ready, set, go! */
+       for (optopt = 0, old_optind = 1;
+            (c = getopt_long(argc, argv, optlist, optab, NULL)) != EOF;
+            optopt = 0, old_optind = optind) {
+               if (do_posix)
+                       opterr = true;
+
+               switch (c) {
+               case 'F':
+                       add_preassign(PRE_ASSIGN_FS, optarg);
+                       break;
+
+               case 'E':
+                       disallow_var_assigns = true;
+                       /* fall through */
+               case 'f':
+                       /*
+                        * Allow multiple -f options.
+                        * This makes function libraries real easy.
+                        * Most of the magic is in the scanner.
+                        *
+                        * The following is to allow for whitespace at the end
+                        * of a #! /bin/gawk line in an executable file
+                        */
+                       scan = optarg;
+                       if (argv[optind-1] != optarg)
+                               while (isspace((unsigned char) *scan))
+                                       scan++;
+                       src = (*scan == '\0' ? argv[optind++] : optarg);
+                       (void) add_srcfile((src && src[0] == '-' && src[1] == 
'\0') ?
+                                       SRC_STDIN : SRC_FILE,
+                                       src, srcfiles, NULL, NULL);
+
+                       break;
+
+               case 'v':
+                       add_preassign(PRE_ASSIGN, optarg);
+                       break;
+
+               case 'b':
+                       do_binary = true;
+                       break;
+
+               case 'c':
+                       do_flags |= DO_TRADITIONAL;
+                       break;
+
+               case 'C':
+                       copyleft();
+                       break;
+
+               case 'd':
+                       do_flags |= DO_DUMP_VARS;
+                       if (optarg != NULL && optarg[0] != '\0')
+                               varfile = optarg;
+                       break;
+
+               case 'D':
+                       do_flags |= DO_DEBUG;
+                       if (optarg != NULL && optarg[0] != '\0')
+                               command_file = optarg;
+                       break;
+
+               case 'e':
+                       if (optarg[0] == '\0')
+                               warning(_("empty argument to `-e/--source' 
ignored"));
+                       else
+                               (void) add_srcfile(SRC_CMDLINE, optarg, 
srcfiles, NULL, NULL);
+                       break;
+
+               case 'g':
+                       do_flags |= DO_INTL;
+                       break;
+
+               case 'h':
+                       /* write usage to stdout, per GNU coding stds */
+                       usage(EXIT_SUCCESS, stdout);
+                       break;
+
+               case 'i':
+                       (void) add_srcfile(SRC_INC, optarg, srcfiles, NULL, 
NULL);
+                       break;
+
+               case 'l':
+                       (void) add_srcfile(SRC_EXTLIB, optarg, srcfiles, NULL, 
NULL);
+                       break;
+
+#ifndef NO_LINT
+               case 'L':
+                       do_flags |= DO_LINT_ALL;
+                       if (optarg != NULL) {
+                               if (strcmp(optarg, "fatal") == 0)
+                                       lintfunc = r_fatal;
+                               else if (strcmp(optarg, "invalid") == 0) {
+                                       do_flags &= ~DO_LINT_ALL;
+                                       do_flags |= DO_LINT_INVALID;
+                               }
+                       }
+                       break;
+
+               case 't':
+                       do_flags |= DO_LINT_OLD;
+                       break;
+#else
+               case 'L':
+               case 't':
+                       break;
+#endif
+
+               case 'n':
+                       do_flags |= DO_NON_DEC_DATA;
+                       break;
+
+               case 'N':
+                       use_lc_numeric = true;
+                       break;
+
+               case 'O':
+                       do_optimize = true;
+                       break;
+
+               case 'p':
+                       do_flags |= DO_PROFILE;
+                       /* fall through */
+               case 'o':
+                       do_flags |= DO_PRETTY_PRINT;
+                       if (optarg != NULL)
+                               set_prof_file(optarg);
+                       else
+                               set_prof_file(DEFAULT_PROFILE);
+                       break;
+
+               case 'M':
+#ifdef HAVE_MPFR
+                       do_flags |= DO_MPFR;
+#else
+                       warning(_("-M ignored: MPFR/GMP support not compiled 
in"));
+#endif
+                       break;
+
+               case 'P':
+                       do_flags |= DO_POSIX;
+                       break;
+
+               case 'r':
+                       do_flags |= DO_INTERVALS;
+                       break;
+ 
+               case 'S':
+                       do_flags |= DO_SANDBOX;
+                       break;
+
+               case 'V':
+                       do_version = true;
+                       break;
+
+               case 'W':       /* gawk specific options - now in getopt_long */
+                       fprintf(stderr, _("%s: option `-W %s' unrecognized, 
ignored\n"),
+                               argv[0], optarg);
+                       break;
+
+               case 0:
+                       /*
+                        * getopt_long found an option that sets a variable
+                        * instead of returning a letter. Do nothing, just
+                        * cycle around for the next one.
+                        */
+                       break;
+
+               case 'Y':
+               case 'Z':
+#if defined(YYDEBUG) || defined(GAWKDEBUG)
+                       if (c == 'Y') {
+                               yydebug = 2;
+                               break;
+                       }
+#endif
+#if defined(LOCALEDEBUG)
+                       if (c == 'Z') {
+                               locale = optarg;
+                               break;
+                       }
+#endif
+                       /* if not debugging, fall through */
+               case '?':
+               default:
+                       /*
+                        * If not posix, an unrecognized option stops argument
+                        * processing so that it can go into ARGV for the awk
+                        * program to see. This makes use of ``#! /bin/gawk -f''
+                        * easier.
+                        *
+                        * However, it's never simple. If optopt is set,
+                        * an option that requires an argument didn't get the
+                        * argument. We care because if opterr is 0, then
+                        * getopt_long won't print the error message for us.
+                        */
+                       if (! do_posix
+                           && (optopt == '\0' || strchr(optlist, optopt) == 
NULL)) {
+                               /*
+                                * can't just do optind--. In case of an
+                                * option with >= 2 letters, getopt_long
+                                * won't have incremented optind.
+                                */
+                               optind = old_optind;
+                               stopped_early = true;
+                               goto out;
+                       } else if (optopt != '\0') {
+                               /* Use POSIX required message format */
+                               fprintf(stderr,
+                                       _("%s: option requires an argument -- 
%c\n"),
+                                       myname, optopt);
+                               usage(EXIT_FAILURE, stderr);
+                       }
+                       /* else
+                               let getopt print error message for us */
+                       break;
+               }
+               if (c == 'E')   /* --exec ends option processing */
+                       break;
+       }
+out:
+       return;
+}
+
+/* set_locale_stuff --- setup the locale stuff */
+
+static void
+set_locale_stuff(void)
+{
+#if defined(LC_CTYPE)
+       setlocale(LC_CTYPE, locale);
+#endif
+#if defined(LC_COLLATE)
+       setlocale(LC_COLLATE, locale);
+#endif
+#if defined(LC_MESSAGES)
+       setlocale(LC_MESSAGES, locale);
+#endif
+#if defined(LC_NUMERIC) && defined(HAVE_LOCALE_H)
+       /*
+        * Force the issue here.  According to POSIX 2001, decimal
+        * point is used for parsing source code and for command-line
+        * assignments and the locale value for processing input,
+        * number to string conversion, and printing output.
+        *
+        * 10/2005 --- see below also; we now only use the locale's
+        * decimal point if do_posix in effect.
+        *
+        * 9/2007:
+        * This is a mess. We need to get the locale's numeric info for
+        * the thousands separator for the %'d flag.
+        */
+       setlocale(LC_NUMERIC, locale);
+       init_locale(& loc);
+       setlocale(LC_NUMERIC, "C");
+#endif
+#if defined(LC_TIME)
+       setlocale(LC_TIME, locale);
+#endif
+}

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog    |   10 +
 configure    |    2 +-
 configure.ac |    2 +-
 main.c       |  734 ++++++++++++++++++++++++++++++---------------------------
 4 files changed, 398 insertions(+), 350 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]