From 7d19cbd54ad60474aded4b9fe587c7f53a14d488 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 19 Aug 2013 20:47:49 +0300 Subject: Changes to ENVIRON reflect into the environment. --- main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 7438ee3a..76fd5652 100644 --- a/main.c +++ b/main.c @@ -1096,6 +1096,10 @@ load_environ() */ path_environ("AWKPATH", defpath); path_environ("AWKLIBPATH", deflibpath); + + /* set up array functions */ + init_env_array(ENVIRON_node); + return ENVIRON_node; } -- cgit v1.2.3 From c3f03fe1d5a7c1b2c7b8ff843afc506ce2a45811 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 16 Oct 2013 20:58:44 +0300 Subject: Fix -O option. --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7438ee3a..79508c7d 100644 --- a/main.c +++ b/main.c @@ -133,7 +133,7 @@ static bool disallow_var_assigns = false; /* true for --exec */ static void add_preassign(enum assign_type type, char *val); int do_flags = false; -bool do_optimize = true; /* apply default optimizations */ +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 */ @@ -438,7 +438,7 @@ main(int argc, char **argv) break; case 'O': - do_optimize++; + do_optimize = true; break; case 'p': -- cgit v1.2.3 From eb152bbe507aef92ece4a301863263818fb50a04 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 17 Oct 2013 22:04:42 +0300 Subject: Catch SIGPIPE. --- main.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 79508c7d..d765a43b 100644 --- a/main.c +++ b/main.c @@ -284,6 +284,14 @@ main(int argc, char **argv) #ifdef SIGBUS (void) signal(SIGBUS, catchsig); #endif +#ifdef SIGPIPE + /* + * Ignore SIGPIPE so that writes to pipes that fail don't + * kill the process but instead return -1 and set errno. + * That lets us print a fatal message instead of dieing suddenly. + */ + signal(SIGPIPE, SIG_IGN); +#endif (void) sigsegv_install_handler(catchsegv); #define STACK_SIZE (16*1024) -- cgit v1.2.3 From 25520aab6144927a20d501c0396e9597f36fc871 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 24 Oct 2013 22:03:09 +0300 Subject: Improve handling of writes to dead pipes. --- main.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index d765a43b..6d99c247 100644 --- a/main.c +++ b/main.c @@ -157,7 +157,7 @@ GETGROUPS_T *groupset; /* current group set */ int ngroups; /* size of said set */ #endif -void (*lintfunc)(const char *mesg, ...) = warning; +void (*lintfunc)(const char *mesg, ...) = r_warning; static const struct option optab[] = { { "traditional", no_argument, NULL, 'c' }, @@ -289,6 +289,14 @@ main(int argc, char **argv) * Ignore SIGPIPE so that writes to pipes that fail don't * kill the process but instead return -1 and set errno. * That lets us print a fatal message instead of dieing suddenly. + * + * Note that this requires ignoring EPIPE when writing and + * flushing stdout/stderr in other parts of the program. E.g., + * + * gawk 'BEGIN { print "hi" }' | exit + * + * should not give us "broken pipe" messages --- mainly because + * it did not do so in the past and people would complain. */ signal(SIGPIPE, SIG_IGN); #endif @@ -849,8 +857,13 @@ By default it reads standard input and writes standard output.\n\n"), fp); fflush(fp); if (ferror(fp)) { - if (fp == stdout) - warning(_("error writing standard output (%s)"), strerror(errno)); + /* don't warn about stdout/stderr if EPIPE, but do error exit */ + if (errno != EPIPE) { + if (fp == stdout) + warning(_("error writing standard output (%s)"), strerror(errno)); + else if (fp == stderr) + warning(_("error writing standard error (%s)"), strerror(errno)); + } exit(EXIT_FAILURE); } @@ -887,7 +900,9 @@ along with this program. If not, see http://www.gnu.org/licenses/.\n"); fflush(stdout); if (ferror(stdout)) { - warning(_("error writing standard output (%s)"), strerror(errno)); + /* don't warn about stdout if EPIPE, but do error exit */ + if (errno != EPIPE) + warning(_("error writing standard output (%s)"), strerror(errno)); exit(EXIT_FAILURE); } -- cgit v1.2.3 From 92d3554b0865ada14d1914842dbc5c7eaa3b01a8 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Wed, 27 Nov 2013 15:54:29 -0500 Subject: Add --include long option and tests to make sure that --load and --include work. --- main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'main.c') diff --git a/main.c b/main.c index 6d99c247..d18a8e3b 100644 --- a/main.c +++ b/main.c @@ -176,6 +176,7 @@ static const struct option optab[] = { { "file", required_argument, NULL, 'f' }, { "re-interval", no_argument, NULL, 'r' }, { "source", required_argument, NULL, 'e' }, + { "include", required_argument, NULL, 'i' }, { "load", required_argument, NULL, 'l' }, { "dump-variables", optional_argument, NULL, 'd' }, { "assign", required_argument, NULL, 'v' }, -- cgit v1.2.3 From bb878ebb4fe7162b22de5d9439549e35940de5ec Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sun, 1 Dec 2013 09:36:37 -0500 Subject: Sort option table by long option name for ease of maintenance. --- main.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index d18a8e3b..e0bc1954 100644 --- a/main.c +++ b/main.c @@ -159,37 +159,38 @@ int ngroups; /* size of said set */ void (*lintfunc)(const char *mesg, ...) = r_warning; +/* Sorted by long option name! */ static const struct option optab[] = { - { "traditional", no_argument, NULL, 'c' }, + { "assign", required_argument, NULL, 'v' }, + { "bignum", no_argument, NULL, 'M' }, + { "characters-as-bytes", no_argument, & do_binary, 'b' }, + { "copyright", no_argument, NULL, 'C' }, + { "debug", optional_argument, NULL, 'D' }, + { "dump-variables", optional_argument, NULL, 'd' }, + { "exec", required_argument, NULL, 'E' }, + { "field-separator", required_argument, NULL, 'F' }, + { "file", required_argument, NULL, 'f' }, + { "gen-pot", no_argument, NULL, 'g' }, + { "help", no_argument, NULL, 'h' }, + { "include", required_argument, NULL, 'i' }, { "lint", optional_argument, NULL, 'L' }, { "lint-old", no_argument, NULL, 't' }, + { "load", required_argument, NULL, 'l' }, + { "non-decimal-data", no_argument, NULL, 'n' }, + { "nostalgia", no_argument, & do_nostalgia, 1 }, { "optimize", no_argument, NULL, 'O' }, +#if defined(YYDEBUG) || defined(GAWKDEBUG) + { "parsedebug", no_argument, NULL, 'Y' }, +#endif { "posix", no_argument, NULL, 'P' }, - { "nostalgia", no_argument, & do_nostalgia, 1 }, - { "gen-pot", no_argument, NULL, 'g' }, - { "non-decimal-data", no_argument, NULL, 'n' }, { "pretty-print", optional_argument, NULL, 'o' }, { "profile", optional_argument, NULL, 'p' }, - { "debug", optional_argument, NULL, 'D' }, - { "copyright", no_argument, NULL, 'C' }, - { "field-separator", required_argument, NULL, 'F' }, - { "file", required_argument, NULL, 'f' }, { "re-interval", no_argument, NULL, 'r' }, + { "sandbox", no_argument, NULL, 'S' }, { "source", required_argument, NULL, 'e' }, - { "include", required_argument, NULL, 'i' }, - { "load", required_argument, NULL, 'l' }, - { "dump-variables", optional_argument, NULL, 'd' }, - { "assign", required_argument, NULL, 'v' }, - { "version", no_argument, & do_version, 'V' }, - { "help", no_argument, NULL, 'h' }, - { "exec", required_argument, NULL, 'E' }, + { "traditional", no_argument, NULL, 'c' }, { "use-lc-numeric", no_argument, & use_lc_numeric, 1 }, - { "characters-as-bytes", no_argument, & do_binary, 'b' }, - { "sandbox", no_argument, NULL, 'S' }, - { "bignum", no_argument, NULL, 'M' }, -#if defined(YYDEBUG) || defined(GAWKDEBUG) - { "parsedebug", no_argument, NULL, 'Y' }, -#endif + { "version", no_argument, & do_version, 'V' }, { NULL, 0, NULL, '\0' } }; -- cgit v1.2.3 From 9953f4cee02f2781ee5da2e42bcb837c1a849cb0 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 12 Dec 2013 20:45:59 +0200 Subject: First round of VMS changes. --- main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index e0bc1954..a47b025e 100644 --- a/main.c +++ b/main.c @@ -194,6 +194,10 @@ static const struct option optab[] = { { NULL, 0, NULL, '\0' } }; +/* VMS needs some special fix-ups for the program name */ +#ifdef __VMS +#include "vms_gawk_main_wrapper.c" +#endif /* main --- process args, parse program, run it, clean up */ -- cgit v1.2.3 From 07296693d0b748f6e6040f988099177d877f1229 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 12 Dec 2013 21:00:00 +0200 Subject: Further changes. --- main.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index a47b025e..4f77510f 100644 --- a/main.c +++ b/main.c @@ -194,11 +194,6 @@ static const struct option optab[] = { { NULL, 0, NULL, '\0' } }; -/* VMS needs some special fix-ups for the program name */ -#ifdef __VMS -#include "vms_gawk_main_wrapper.c" -#endif - /* main --- process args, parse program, run it, clean up */ int -- cgit v1.2.3 From ac1f9a6de76def07e6966f7701d5af2cfdb661f0 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 21 Mar 2014 14:40:00 +0200 Subject: Bump UPDATE_YEAR in main.c. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 4f77510f..dad39f4d 100644 --- a/main.c +++ b/main.c @@ -24,7 +24,7 @@ */ /* FIX THIS BEFORE EVERY RELEASE: */ -#define UPDATE_YEAR 2013 +#define UPDATE_YEAR 2014 #include "awk.h" #include "getopt.h" -- cgit v1.2.3 From 69d85d51dfd0f2e3b464585633d270f06fa1e846 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 31 Mar 2014 22:17:13 +0300 Subject: Update copyright years on files changed in 2014. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index dad39f4d..47fd51c9 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2013 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2014 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. -- cgit v1.2.3