diff options
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | NEWS | 12 | ||||
-rw-r--r-- | TODO | 210 | ||||
-rw-r--r-- | awk.h | 1 | ||||
-rw-r--r-- | builtin.c | 63 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/ChangeLog | 7 | ||||
-rw-r--r-- | doc/gawk.1 | 8 | ||||
-rw-r--r-- | doc/gawk.info | 798 | ||||
-rw-r--r-- | doc/gawk.texi | 26 | ||||
-rw-r--r-- | doc/gawktexi.in | 26 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | pc/config.h | 6 | ||||
-rw-r--r-- | str_array.c | 79 | ||||
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/Makefile.am | 10 | ||||
-rw-r--r-- | test/Makefile.in | 9 | ||||
-rw-r--r-- | test/rand.ok | 2 | ||||
-rw-r--r-- | test/randtest.ok | 0 | ||||
-rwxr-xr-x | test/randtest.sh | 113 |
22 files changed, 1012 insertions, 432 deletions
@@ -108,6 +108,13 @@ been moved into the inetfile() function. (two_way_open): Update args to inetfile(). +2014-04-20 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_rand): Make calls to random() in predictable + order to avoid order of evaluation differences amongst compilers. + Thanks to Anders Magnusson <ragge@ludd.ltu.se> (of the PCC team) + for the suggestion. + 2014-04-18 Arnold D. Robbins <arnold@skeeve.com> * configure.ac: Change adding of -export-dynamic for GCC to be @@ -474,6 +481,11 @@ * main.c (main): Ignore SIGPIPE. See the comment in the code. Thanks to Alan Broder for reporting the issue. + Unrelated: + + * rand.c (do_rand): Fix computation and loop checking against + 1.0 to use do..while. + 2013-10-16 Arnold D. Robbins <arnold@skeeve.com> Make -O work again. Turns out that C99 bool variables @@ -491,6 +503,11 @@ * re.c (resetup): Add a comment about the joy of syntax bits. + Unrelated: + + * builtin.c (do_rand): If result is exactly 1.0, keep trying. + Thanks to Nelson Beebe. + 2013-10-10 Arnold D. Robbins <arnold@skeeve.com> * dfa.c (lex): Sync with GNU grep. Handle multibyte \s and \S. @@ -510,6 +527,13 @@ * dfa.c: Sync with GNU grep. +2013-09-25 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_rand): Make the result more random by calling + random() twice. See the comment in the code. Thanks to + Bob Jewett <jewett@bill.scs.agilent.com> for the report and + the fix. + 2013-09-24 Arnold D. Robbins <arnold@skeeve.com> * debug.c (find_rule): Handle case where lineno is zero. Can happen @@ -591,6 +615,12 @@ * regcomp.c, regex.h, regex_internal.h: Sync with GLIBC. +2013-08-22 Arnold D. Robbins <arnold@skeeve.com> + + * str_array.c (env_store): If the new value being stored is NULL, + pass in "" instead. Avoids core dump on Mac OS X. + Thanks to Hermann Peifer for the bug report. + 2013-08-20 Arnold D. Robbins <arnold@skeeve.com> * nonposix.h: New file. Contains FAKE_FD_VALUE. @@ -599,6 +629,16 @@ 2013-08-18 Arnold D. Robbins <arnold@skeeve.com> + Reflect updates to ENVIRON into the real environment. + + * awk.h (init_env_array): Add declaration. + * main.c (load_environ): Call init_env_array. + * str_array.c (env_remove, env_store, env_clear, init_env_array): + New functions. + (env_array_func): New array vtable. + +2013-08-18 Arnold D. Robbins <arnold@skeeve.com> + * array.c (force_array): Set symbol->xarray to NULL before initing the array if it was Node_var_new. (null_array): Restore assert, undoing change of 2013-05-27. diff --git a/Makefile.in b/Makefile.in index d243df5b..2abf5b46 100644 --- a/Makefile.in +++ b/Makefile.in @@ -107,7 +107,7 @@ DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/configh.in mkinstalldirs ABOUT-NLS awkgram.c \ - command.c depcomp ylwrap $(include_HEADERS) COPYING \ + command.c depcomp ylwrap $(include_HEADERS) COPYING TODO \ config.guess config.rpath config.sub install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ @@ -4,6 +4,18 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. +Changes from 4.1.x to 4.2.0 +--------------------------- + +1. If not in POSIX mode, changes to ENVIRON are reflected into + gawk's environment, affecting any programs run by system() + or for piped redirections. + +2. The series of numbers returned by rand() should now be "more + random" than previously. Gawk's rand() remains repeatable; you will + get the same series of numbers each time you call rand() repeatedly, + but this will be a different series than previously. + Changes from 4.1.1 to 4.1.2 --------------------------- @@ -0,0 +1,210 @@ +Thu Apr 17 11:31:24 IDT 2014 +============================ + +There were too many files tracking different thoughts and ideas for +things to do, or consider doing. This file merges them into one. As +tasks are completed, they should be moved to the DONE section, below, +or simply removed. + +Upon creation of a release (major or patch release), items from the +previous release should be removed. + +This file should exist only in the master branch or branches based off +of it for development, but not in the stable branch. This may require some +careful work with Git. + +TODO +==== + +Minor Cleanups and Code Improvements +------------------------------------ + + Nuke installing the igawk script and the igawk.1 man page. Just + remove them from the dist. + + Review the bash source script for working with shared libraries in + order to nuke the use of libtool. [ Partially started in the + nolibtool branch. ] + + Enhance profiling to save comments in a byte-code that does nothing + but that can be used when pretty printing the program. + + API: + ??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS) + + ?? Add debugger commands to reference card + + Look at function order within files. + + regex.h - remove underscores in param names + + Consider removing use of and/or need for the protos.h file. + + Recheck if gnulib regex can be dropped in + + Fully synchronize whitespaces tests (for \s, \S in Unicode + environment) with those of GNU grep. + +Minor New Features +------------------ + + Add a div() function to do integer division result. Needed + esp for MPFR with large ints. + + Enhance extension/fork.c waitpid to allow the caller to specify + the options. And add an optional array argument to wait and + waitpid in which to return exit status information. + + Consider relaxing the strictness of --posix. + + Make it possible to put print/printf + redirections into + an expression. + + Have pretty printing not run the program and nuke the + undocumented GAWK_NO_PP_RUN env var. Requires test suite + adjustments. + + ? Add an optional base to strtonum, allowing 2-36. + + ? Optional third argument for index indicating where to start the + search. + +Major New Features +------------------ + + Think about how to generalize indirect access. Manuel Collado + suggests things like + + foo = 5 + @"foo" += 4 + + Also needed: + + Indirect calls of built-ins + Indirect calls of extension functions + Indirect through array elements, not just scalar variables + + Some way to make regexp constants first class citizens: + - Assign to variables + - Pass to functions + Tawk has this and it would also make indirect calling of builtins + work more reasonably. Probably would use a special syntax like + @/.../ for such objects. + + Consider a typeof() function that returns a string (scalar, array, + regexp). + + Fix the early chapters in the doc with more up-to-date examples. + No-one uses Bulletin Board Systems anymore. + + Add ability to do decimal arithmetic. + + Rework management of array index storage. (Partially DONE.) + + Consider using an atom table for all string array indices. + + DBM storage of awk arrays. Try to allow multiple dbm packages. + + ?? A RECLEN variable for fixed-length record input. PROCINFO["RS"] + would be "RS" or "RECLEN" depending upon what's in use. + *** Could this be done as an extension? + + ?? Use a new or improved dfa and/or regex library. + + Rewrite in C++. + +Things To Think About That May Never Happen +------------------------------------------- + + Consider making shadowed variables a warning and not + a fatal warning when --lint=fatal. + + Similar for extra parameters in a function call. + + Look at code coverage tools, like S2E: https://s2e.epfl.ch/ + + Try running with diehard. See http://www.diehard-software.org, + https://github.com/emeryberger/DieHard + + Implement namespaces. Arnold suggested the following in an email: + - Extend the definition of an 'identifier' to include "." as a valid character + although an identifier can't start with it. + - Extension libraries install functions and global variables with names + that have a "." in them: XML.parse(), XML.name, whatever. + - Awk code can read/write such variables and call such functions, but they + cannot define such functions + function XML.foo() { .. } # error + or create a variable with such a name if it doesn't exist. This would + be a run-time error, not a parse-time error. + - This last rule may be too restrictive. + I don't want to get into fancy rules a la perl and file-scope visibility + etc, I'd like to keep things simple. But how we design this is going + to be very important. + + Include a sample rpm spec file in a new packaging subdirectory. + + Patch lexer for @include and @load to make quotes optional. + + ? Have strftime() pay attention to the value of ENVIRON["TZ"] + + Add a lint check if the return value of a function is used but + the function did not supply a value. + + Consider making gawk output +nan for NaN values so that it + will accept its own output as input. + NOTE: Investigated this. GLIBC formats NaN as '-nan' + and -NaN as 'nan'. Dealing with this is not simple. + + Enhance FIELDWIDTHS with some way to indicate "the rest of the record". + E.g., a length of 0 or -1 or something. Maybe "n"? + + +DONE +==== + +Minor Cleanups and Code Improvements +------------------------------------ + +Minor New Features +------------------ + +Major New Features +------------------ + +Things That We Decided We Will Never Do +======================================= + + Consider moving var_value info into Node_var itself to reduce + memory usage. This would break all uses of get_lhs in the + code. It's too sweeping a change. + + Add macros for working with flags instead of using & and | + directly. + + FIX regular field splitting to use FPAT algorithm. + Note: Looked at this. Not sure it's with the trouble: + If it ain't broke... + + Scope IDs for IPv6 addresses + + Gnulib + + Make FIELDWIDTHS be an array? + + "Do an optimization pass over parse tree?" + This isn't relevant now that we are using a byte code engine. + + "Consider integrating Fred Fish's DBUG library into gawk." + I did this once as an experiment. But I don't see a lot of value + to this at this stage of the development. Stepping through things + in a debugger is generally enough. Also, I would have to try to + track down the latest version of this. + + "Make awk '/foo/' files... run at egrep speeds (how?)" + This has been on the list since the early days (gawk 1.x or early + 2.x). But I am not sure how to really do this, nor have I done + timings, nor does there seem to be any real demand for this. + + Change from dlopen to using the libltdl library (i.e. lt_dlopen). + This may support more platforms. If we move off of libtool + then this is the wrong direction. @@ -1361,6 +1361,7 @@ extern NODE *do_aoption(int nargs); extern NODE *do_asort(int nargs); extern NODE *do_asorti(int nargs); extern unsigned long (*hash)(const char *s, size_t len, unsigned long hsize, size_t *code); +extern void init_env_array(NODE *env_node); /* awkgram.c */ extern NODE *variable(int location, char *name, NODETYPE type); extern int parse_program(INSTRUCTION **pcode); @@ -2393,6 +2393,8 @@ static char *const state = (char *const) istate; NODE * do_rand(int nargs ATTRIBUTE_UNUSED) { + double tmprand; +#define RAND_DIVISOR ((double)GAWK_RANDOM_MAX+1.0) if (firstrand) { (void) initstate((unsigned) 1, state, SIZEOF_STATE); /* don't need to srandom(1), initstate() does it for us. */ @@ -2404,7 +2406,66 @@ do_rand(int nargs ATTRIBUTE_UNUSED) * * 0 <= n < 1 */ - return make_number((AWKNUM) (random() % GAWK_RANDOM_MAX) / GAWK_RANDOM_MAX); + /* + * Date: Wed, 28 Aug 2013 17:52:46 -0700 + * From: Bob Jewett <jewett@bill.scs.agilent.com> + * + * Call random() twice to fill in more bits in the value + * of the double. Also, there is a bug in random() such + * that when the values of successive values are combined + * like (rand1*rand2)^2, (rand3*rand4)^2, ... the + * resulting time series is not white noise. The + * following also seems to fix that bug. + * + * The add/subtract 0.5 keeps small bits from filling + * below 2^-53 in the double, not that anyone should be + * looking down there. + * + * Date: Wed, 25 Sep 2013 10:45:38 -0600 (MDT) + * From: "Nelson H. F. Beebe" <beebe@math.utah.edu> + * (4) The code is typical of many published fragments for converting + * from integer to floating-point, and I discuss the serious pitfalls + * in my book, because it leads to platform-dependent behavior at the + * end points of the interval [0,1] + * + * (5) the documentation in the gawk info node says + * + * `rand()' + * Return a random number. The values of `rand()' are uniformly + * distributed between zero and one. The value could be zero but is + * never one.(1) + * + * The division by RAND_DIVISOR may not guarantee that 1.0 is never + * returned: the programmer forgot the platform-dependent issue of + * rounding. + * + * For points 4 and 5, the safe way is a loop: + * + * double + * rand(void) // return value in [0.0, 1.0) + * { + * value = internal_rand(); + * + * while (value == 1.0) + * value = internal_rand(); + * + * return (value); + * } + */ + + do { + long d1, d2; + /* + * Do the calls in predictable order to avoid + * compiler differences in order of evaluation. + */ + d1 = random(); + d2 = random(); + tmprand = 0.5 + ( (d1/RAND_DIVISOR + d2) / RAND_DIVISOR ); + tmprand -= 0.5; + } while (tmprand == 1.0); + + return make_number((AWKNUM) tmprand); } /* do_srand --- seed the random number generator */ @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for GNU Awk 4.1.1a. +# Generated by GNU Autoconf 2.69 for GNU Awk 4.1.60. # # Report bugs to <bug-gawk@gnu.org>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU Awk' PACKAGE_TARNAME='gawk' -PACKAGE_VERSION='4.1.1a' -PACKAGE_STRING='GNU Awk 4.1.1a' +PACKAGE_VERSION='4.1.60' +PACKAGE_STRING='GNU Awk 4.1.60' PACKAGE_BUGREPORT='bug-gawk@gnu.org' PACKAGE_URL='http://www.gnu.org/software/gawk/' @@ -1324,7 +1324,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU Awk 4.1.1a to adapt to many kinds of systems. +\`configure' configures GNU Awk 4.1.60 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1394,7 +1394,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Awk 4.1.1a:";; + short | recursive ) echo "Configuration of GNU Awk 4.1.60:";; esac cat <<\_ACEOF @@ -1512,7 +1512,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU Awk configure 4.1.1a +GNU Awk configure 4.1.60 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2221,7 +2221,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU Awk $as_me 4.1.1a, which was +It was created by GNU Awk $as_me 4.1.60, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3104,7 +3104,7 @@ fi # Define the identity of the package. PACKAGE='gawk' - VERSION='4.1.1a' + VERSION='4.1.60' cat >>confdefs.h <<_ACEOF @@ -11506,7 +11506,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU Awk $as_me 4.1.1a, which was +This file was extended by GNU Awk $as_me 4.1.60, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11574,7 +11574,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -GNU Awk config.status 4.1.1a +GNU Awk config.status 4.1.60 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index b0817ba3..e7e2d5f6 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT([GNU Awk], 4.1.1a, bug-gawk@gnu.org, gawk) +AC_INIT([GNU Awk], 4.1.60, bug-gawk@gnu.org, gawk) # This is a hack. Different versions of install on different systems # are just too different. Chuck it and use install-sh. diff --git a/doc/ChangeLog b/doc/ChangeLog index 298ebbcf..83c7ae70 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -290,7 +290,7 @@ 2013-12-26 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: More minor additions / fixes. - (Bugs): Add John Malmberg for VMS. + (Bugs): Add John Malmberg for VMS. Other minor edits. 2013-12-25 Arnold D. Robbins <arnold@skeeve.com> @@ -364,6 +364,11 @@ * gawktexi.in (FN, FFN, DF,DDF, PVERSION, CTL): Remove macros. They have no alternate versions and are just in the way. +2013-08-15 Arnold D. Robbins <arnold@skeeve.com> + + * gawk.1: Document that ENVIRON updates affect the environment. + * gawktexi.in: Ditto. + 2013-06-27 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Update from Karl, fixes a formating problem. @@ -917,11 +917,17 @@ An array containing the values of the current environment. The array is indexed by the environment variables, each element being the value of that variable (e.g., \fBENVIRON["HOME"]\fP might be \fB"/home/arnold"\fR). -Changing this array does not affect the environment seen by programs which +.sp +In POSIX mode, +changing this array does not affect the environment seen by programs which .I gawk spawns via redirection or the .B system() function. +Otherwise, +.I gawk +updates its real environment so that programs it spawns see +the changes. .TP .B ERRNO If a system error occurs either doing a redirection for diff --git a/doc/gawk.info b/doc/gawk.info index 95d81e89..5d4aaa3c 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -10161,10 +10161,18 @@ Options::), they are not special. An associative array containing the values of the environment. The array indices are the environment variable names; the elements are the values of the particular environment variables. For - example, `ENVIRON["HOME"]' might be `"/home/arnold"'. Changing - this array does not affect the environment passed on to any - programs that `awk' may spawn via redirection or the `system()' - function. (In a future version of `gawk', it may do so.) + example, `ENVIRON["HOME"]' might be `/home/arnold'. + + For POSIX `awk', changing this array does not affect the + environment passed on to any programs that `awk' may spawn via + redirection or the `system()' function. + + However, beginning with version 4.2, if not in POSIX compatibility + mode, `gawk' does update its own environment when `ENVIRON' is + changed, thus changing the environment seen by programs that it + creates. You should therefore be especially careful if you modify + `ENVIRON["PATH"]"', which is the search path for finding + executable programs. Some operating systems may not have environment variables. On such systems, the `ENVIRON' array is empty (except for @@ -31753,9 +31761,9 @@ Index * dark corner, exit statement: Exit Statement. (line 30) * dark corner, field separators: Field Splitting Summary. (line 46) -* dark corner, FILENAME variable <1>: Auto-set. (line 90) +* dark corner, FILENAME variable <1>: Auto-set. (line 98) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 301) +* dark corner, FNR/NR variables: Auto-set. (line 309) * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) @@ -31940,12 +31948,12 @@ Index (line 81) * differences in awk and gawk, command line directories: Command line directories. (line 6) -* differences in awk and gawk, ERRNO variable: Auto-set. (line 74) +* differences in awk and gawk, ERRNO variable: Auto-set. (line 82) * differences in awk and gawk, error messages: Special FD. (line 16) * differences in awk and gawk, FIELDWIDTHS variable: User-modified. (line 37) * differences in awk and gawk, FPAT variable: User-modified. (line 43) -* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 115) +* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 123) * differences in awk and gawk, function arguments (gawk): Calling Built-in. (line 16) * differences in awk and gawk, getline command: Getline. (line 19) @@ -31968,7 +31976,7 @@ Index (line 260) * differences in awk and gawk, print/printf statements: Format Modifiers. (line 13) -* differences in awk and gawk, PROCINFO array: Auto-set. (line 128) +* differences in awk and gawk, PROCINFO array: Auto-set. (line 136) * differences in awk and gawk, read timeouts: Read Timeout. (line 6) * differences in awk and gawk, record separators: awk split records. (line 124) @@ -31978,7 +31986,7 @@ Index (line 26) * differences in awk and gawk, RS/RT variables: gawk split records. (line 58) -* differences in awk and gawk, RT variable: Auto-set. (line 257) +* differences in awk and gawk, RT variable: Auto-set. (line 265) * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. @@ -31986,7 +31994,7 @@ Index * differences in awk and gawk, strings: Scalar Constants. (line 20) * differences in awk and gawk, strings, storing: gawk split records. (line 77) -* differences in awk and gawk, SYMTAB variable: Auto-set. (line 261) +* differences in awk and gawk, SYMTAB variable: Auto-set. (line 269) * differences in awk and gawk, TEXTDOMAIN variable: User-modified. (line 152) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. @@ -32026,8 +32034,8 @@ Index * dynamically loaded extensions: Dynamic Extensions. (line 6) * e debugger command (alias for enable): Breakpoint Control. (line 73) * EBCDIC: Ordinal Functions. (line 45) -* effective group ID of gawk user: Auto-set. (line 133) -* effective user ID of gawk user: Auto-set. (line 137) +* effective group ID of gawk user: Auto-set. (line 141) +* effective user ID of gawk user: Auto-set. (line 145) * egrep utility <1>: Egrep Program. (line 6) * egrep utility: Bracket Expressions. (line 24) * egrep.awk program: Egrep Program. (line 54) @@ -32083,13 +32091,13 @@ Index (line 11) * EREs (Extended Regular Expressions): Bracket Expressions. (line 24) * ERRNO variable <1>: TCP/IP Networking. (line 54) -* ERRNO variable: Auto-set. (line 74) +* ERRNO variable: Auto-set. (line 82) * ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26) * ERRNO variable, with close() function: Close Files And Pipes. (line 139) * ERRNO variable, with getline command: Getline. (line 19) * error handling: Special FD. (line 16) -* error handling, ERRNO variable and: Auto-set. (line 74) +* error handling, ERRNO variable and: Auto-set. (line 82) * error output: Special FD. (line 6) * escape processing, gsub()/gensub()/sub() functions: Gory Details. (line 6) @@ -32143,7 +32151,7 @@ Index (line 6) * extension API version: Extension Versioning. (line 6) -* extension API, version number: Auto-set. (line 224) +* extension API, version number: Auto-set. (line 232) * extension example: Extension Example. (line 6) * extension registration: Registration Functions. (line 6) @@ -32222,7 +32230,7 @@ Index * file names, distinguishing: Auto-set. (line 56) * file names, in compatibility mode: Special Caveats. (line 9) * file names, standard streams in gawk: Special FD. (line 46) -* FILENAME variable <1>: Auto-set. (line 90) +* FILENAME variable <1>: Auto-set. (line 98) * FILENAME variable: Reading Files. (line 6) * FILENAME variable, getline, setting with: Getline Notes. (line 19) * filenames, assignments as: Ignoring Assigns. (line 6) @@ -32290,9 +32298,9 @@ Index * flush buffered output: I/O Functions. (line 28) * fnmatch() extension function: Extension Sample Fnmatch. (line 12) -* FNR variable <1>: Auto-set. (line 99) +* FNR variable <1>: Auto-set. (line 107) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 301) +* FNR variable, changing: Auto-set. (line 309) * for statement: For Statement. (line 6) * for statement, looping over arrays: Scanning an Array. (line 20) * fork() extension function: Extension Sample Fork. @@ -32342,7 +32350,7 @@ Index * FSF (Free Software Foundation): Manual History. (line 6) * fts() extension function: Extension Sample File Functions. (line 61) -* FUNCTAB array: Auto-set. (line 115) +* FUNCTAB array: Auto-set. (line 123) * function calls: Function Calls. (line 6) * function calls, indirect: Indirect Calls. (line 6) * function definition example: Function Example. (line 6) @@ -32392,7 +32400,7 @@ Index * G-d: Acknowledgments. (line 82) * Garfinkle, Scott: Contributors. (line 34) * gawk program, dynamic profiling: Profiling. (line 179) -* gawk version: Auto-set. (line 199) +* gawk version: Auto-set. (line 207) * gawk, ARGIND variable in: Other Arguments. (line 12) * gawk, awk and <1>: This Manual. (line 14) * gawk, awk and: Preface. (line 23) @@ -32413,7 +32421,7 @@ Index * gawk, distribution: Distribution contents. (line 6) * gawk, ERRNO variable in <1>: TCP/IP Networking. (line 54) -* gawk, ERRNO variable in <2>: Auto-set. (line 74) +* gawk, ERRNO variable in <2>: Auto-set. (line 82) * gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26) * gawk, ERRNO variable in <4>: Close Files And Pipes. (line 139) @@ -32430,7 +32438,7 @@ Index * gawk, FPAT variable in <1>: User-modified. (line 43) * gawk, FPAT variable in: Splitting By Content. (line 27) -* gawk, FUNCTAB array in: Auto-set. (line 115) +* gawk, FUNCTAB array in: Auto-set. (line 123) * gawk, function arguments and: Calling Built-in. (line 16) * gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) * gawk, IGNORECASE variable in <1>: Array Sorting Functions. @@ -32461,7 +32469,7 @@ Index * gawk, OS/2 version of: PC Using. (line 16) * gawk, PROCINFO array in <1>: Two-way I/O. (line 117) * gawk, PROCINFO array in <2>: Time Functions. (line 47) -* gawk, PROCINFO array in: Auto-set. (line 128) +* gawk, PROCINFO array in: Auto-set. (line 136) * gawk, regexp constants and: Using Constant Regexps. (line 28) * gawk, regular expressions, case sensitivity: Case-sensitivity. @@ -32469,14 +32477,14 @@ Index * gawk, regular expressions, operators: GNU Regexp Operators. (line 6) * gawk, regular expressions, precedence: Regexp Operators. (line 162) -* gawk, RT variable in <1>: Auto-set. (line 257) +* gawk, RT variable in <1>: Auto-set. (line 265) * gawk, RT variable in <2>: Multiple Line. (line 129) * gawk, RT variable in: awk split records. (line 124) * gawk, See Also awk: Preface. (line 36) * gawk, source code, obtaining: Getting. (line 6) * gawk, splitting fields and: Constant Size. (line 88) * gawk, string-translation functions: I18N Functions. (line 6) -* gawk, SYMTAB array in: Auto-set. (line 261) +* gawk, SYMTAB array in: Auto-set. (line 269) * gawk, TEXTDOMAIN variable in: User-modified. (line 152) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 36) @@ -32562,7 +32570,7 @@ Index * Grigera, Juan: Contributors. (line 57) * group database, reading: Group Functions. (line 6) * group file: Group Functions. (line 6) -* group ID of gawk user: Auto-set. (line 172) +* group ID of gawk user: Auto-set. (line 180) * groups, information about: Group Functions. (line 6) * gsub <1>: String Functions. (line 139) * gsub: Using Constant Regexps. @@ -32853,7 +32861,7 @@ Index * mawk utility <3>: Concatenation. (line 36) * mawk utility <4>: Getline/Pipe. (line 62) * mawk utility: Escape Sequences. (line 124) -* maximum precision supported by MPFR library: Auto-set. (line 213) +* maximum precision supported by MPFR library: Auto-set. (line 221) * McIlroy, Doug: Glossary. (line 149) * McPhee, Patrick: Contributors. (line 100) * message object files: Explaining gettext. (line 42) @@ -32866,7 +32874,7 @@ Index * messages from extensions: Printing Messages. (line 6) * metacharacters in regular expressions: Regexp Operators. (line 6) * metacharacters, escape sequences for: Escape Sequences. (line 130) -* minimum precision supported by MPFR library: Auto-set. (line 216) +* minimum precision supported by MPFR library: Auto-set. (line 224) * mktime: Time Functions. (line 25) * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 104) @@ -32918,7 +32926,7 @@ Index (line 47) * nexti debugger command: Debugger Execution Control. (line 49) -* NF variable <1>: Auto-set. (line 104) +* NF variable <1>: Auto-set. (line 112) * NF variable: Fields. (line 33) * NF variable, decrementing: Changing Fields. (line 107) * ni debugger command (alias for nexti): Debugger Execution Control. @@ -32927,9 +32935,9 @@ Index * non-existent array elements: Reference to Elements. (line 23) * not Boolean-logic operator: Boolean Ops. (line 6) -* NR variable <1>: Auto-set. (line 123) +* NR variable <1>: Auto-set. (line 131) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 301) +* NR variable, changing: Auto-set. (line 309) * null strings <1>: Basic Data Typing. (line 26) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -33044,7 +33052,7 @@ Index * p debugger command (alias for print): Viewing And Changing Data. (line 36) * Papadopoulos, Panos: Contributors. (line 129) -* parent process ID of gawk process: Auto-set. (line 181) +* parent process ID of gawk process: Auto-set. (line 189) * parentheses (), in a profile: Profiling. (line 146) * parentheses (), regexp operator: Regexp Operators. (line 80) * password file: Passwd Functions. (line 16) @@ -33207,24 +33215,24 @@ Index * printing, unduplicated lines of text: Uniq Program. (line 6) * printing, user information: Id Program. (line 6) * private variables: Library Names. (line 11) -* process group idIDof gawk process: Auto-set. (line 175) -* process ID of gawk process: Auto-set. (line 178) +* process group idIDof gawk process: Auto-set. (line 183) +* process ID of gawk process: Auto-set. (line 186) * processes, two-way communications with: Two-way I/O. (line 23) * processing data: Basic High Level. (line 6) * PROCINFO array <1>: Passwd Functions. (line 6) * PROCINFO array <2>: Time Functions. (line 47) -* PROCINFO array: Auto-set. (line 128) +* PROCINFO array: Auto-set. (line 136) * PROCINFO array, and communications via ptys: Two-way I/O. (line 117) * PROCINFO array, and group membership: Group Functions. (line 6) * PROCINFO array, and user and group ID numbers: Id Program. (line 15) * PROCINFO array, testing the field splitting: Passwd Functions. (line 161) -* PROCINFO array, uses: Auto-set. (line 234) +* PROCINFO array, uses: Auto-set. (line 242) * PROCINFO, values of sorted_in: Controlling Scanning. (line 26) * profiling awk programs: Profiling. (line 6) * profiling awk programs, dynamically: Profiling. (line 179) -* program identifiers: Auto-set. (line 146) +* program identifiers: Auto-set. (line 154) * program, definition of: Getting Started. (line 21) * programmers, attractiveness of: Two-way I/O. (line 6) * programming conventions, --non-decimal-data option: Nondecimal Data. @@ -33384,7 +33392,7 @@ Index * right shift: Bitwise Functions. (line 52) * right shift, bitwise: Bitwise Functions. (line 32) * Ritchie, Dennis: Basic Data Typing. (line 54) -* RLENGTH variable: Auto-set. (line 244) +* RLENGTH variable: Auto-set. (line 252) * RLENGTH variable, match() function and: String Functions. (line 224) * Robbins, Arnold <1>: Future Extensions. (line 6) * Robbins, Arnold <2>: Bugs. (line 32) @@ -33410,9 +33418,9 @@ Index * RS variable: awk split records. (line 12) * RS variable, multiline records and: Multiple Line. (line 17) * rshift: Bitwise Functions. (line 52) -* RSTART variable: Auto-set. (line 250) +* RSTART variable: Auto-set. (line 258) * RSTART variable, match() function and: String Functions. (line 224) -* RT variable <1>: Auto-set. (line 257) +* RT variable <1>: Auto-set. (line 265) * RT variable <2>: Multiple Line. (line 129) * RT variable: awk split records. (line 124) * Rubin, Paul <1>: Contributors. (line 15) @@ -33432,7 +33440,7 @@ Index * scanning arrays: Scanning an Array. (line 6) * scanning multidimensional arrays: Multiscanning. (line 11) * Schorr, Andrew <1>: Contributors. (line 134) -* Schorr, Andrew <2>: Auto-set. (line 284) +* Schorr, Andrew <2>: Auto-set. (line 292) * Schorr, Andrew: Acknowledgments. (line 60) * Schreiber, Bert: Acknowledgments. (line 38) * Schreiber, Rita: Acknowledgments. (line 38) @@ -33517,7 +33525,7 @@ Index (line 110) * sidebar, Changing FS Does Not Affect the Fields: Field Splitting Summary. (line 38) -* sidebar, Changing NR and FNR: Auto-set. (line 299) +* sidebar, Changing NR and FNR: Auto-set. (line 307) * sidebar, Controlling Output Buffering with system(): I/O Functions. (line 138) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. @@ -33680,9 +33688,9 @@ Index * substr: String Functions. (line 479) * substring: String Functions. (line 479) * Sumner, Andrew: Other Versions. (line 64) -* supplementary groups of gawk process: Auto-set. (line 229) +* supplementary groups of gawk process: Auto-set. (line 237) * switch statement: Switch Statement. (line 6) -* SYMTAB array: Auto-set. (line 261) +* SYMTAB array: Auto-set. (line 269) * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) * system: I/O Functions. (line 75) @@ -33860,10 +33868,10 @@ Index * variables, uninitialized, as array subscripts: Uninitialized Subscripts. (line 6) * variables, user-defined: Variables. (line 6) -* version of gawk: Auto-set. (line 199) -* version of gawk extension API: Auto-set. (line 224) -* version of GNU MP library: Auto-set. (line 210) -* version of GNU MPFR library: Auto-set. (line 206) +* version of gawk: Auto-set. (line 207) +* version of gawk extension API: Auto-set. (line 232) +* version of GNU MP library: Auto-set. (line 218) +* version of GNU MPFR library: Auto-set. (line 214) * vertical bar (|): Regexp Operators. (line 70) * vertical bar (|), | operator (I/O) <1>: Precedence. (line 65) * vertical bar (|), | operator (I/O): Getline/Pipe. (line 9) @@ -34151,351 +34159,351 @@ Node: Built-in Variables423923 Node: User-modified425050 Ref: User-modified-Footnote-1432739 Node: Auto-set432801 -Ref: Auto-set-Footnote-1445383 -Ref: Auto-set-Footnote-2445588 -Node: ARGC and ARGV445644 -Node: Pattern Action Summary449498 -Node: Arrays451721 -Node: Array Basics453270 -Node: Array Intro454096 -Ref: figure-array-elements456069 -Node: Reference to Elements458476 -Node: Assigning Elements460749 -Node: Array Example461240 -Node: Scanning an Array462972 -Node: Controlling Scanning465987 -Ref: Controlling Scanning-Footnote-1471160 -Node: Delete471476 -Ref: Delete-Footnote-1474241 -Node: Numeric Array Subscripts474298 -Node: Uninitialized Subscripts476481 -Node: Multidimensional478106 -Node: Multiscanning481199 -Node: Arrays of Arrays482788 -Node: Arrays Summary487451 -Node: Functions489556 -Node: Built-in490429 -Node: Calling Built-in491507 -Node: Numeric Functions493495 -Ref: Numeric Functions-Footnote-1497329 -Ref: Numeric Functions-Footnote-2497686 -Ref: Numeric Functions-Footnote-3497734 -Node: String Functions498003 -Ref: String Functions-Footnote-1521014 -Ref: String Functions-Footnote-2521143 -Ref: String Functions-Footnote-3521391 -Node: Gory Details521478 -Ref: table-sub-escapes523147 -Ref: table-sub-posix-92524501 -Ref: table-sub-proposed525852 -Ref: table-posix-sub527206 -Ref: table-gensub-escapes528751 -Ref: Gory Details-Footnote-1529927 -Ref: Gory Details-Footnote-2529978 -Node: I/O Functions530129 -Ref: I/O Functions-Footnote-1537252 -Node: Time Functions537399 -Ref: Time Functions-Footnote-1547863 -Ref: Time Functions-Footnote-2547931 -Ref: Time Functions-Footnote-3548089 -Ref: Time Functions-Footnote-4548200 -Ref: Time Functions-Footnote-5548312 -Ref: Time Functions-Footnote-6548539 -Node: Bitwise Functions548805 -Ref: table-bitwise-ops549367 -Ref: Bitwise Functions-Footnote-1553612 -Node: Type Functions553796 -Node: I18N Functions554938 -Node: User-defined556583 -Node: Definition Syntax557387 -Ref: Definition Syntax-Footnote-1562566 -Node: Function Example562635 -Ref: Function Example-Footnote-1565279 -Node: Function Caveats565301 -Node: Calling A Function565819 -Node: Variable Scope566774 -Node: Pass By Value/Reference569762 -Node: Return Statement573270 -Node: Dynamic Typing576254 -Node: Indirect Calls577183 -Node: Functions Summary586896 -Node: Library Functions589435 -Ref: Library Functions-Footnote-1593053 -Ref: Library Functions-Footnote-2593196 -Node: Library Names593367 -Ref: Library Names-Footnote-1596840 -Ref: Library Names-Footnote-2597060 -Node: General Functions597146 -Node: Strtonum Function598174 -Node: Assert Function600954 -Node: Round Function604280 -Node: Cliff Random Function605821 -Node: Ordinal Functions606837 -Ref: Ordinal Functions-Footnote-1609914 -Ref: Ordinal Functions-Footnote-2610166 -Node: Join Function610377 -Ref: Join Function-Footnote-1612148 -Node: Getlocaltime Function612348 -Node: Readfile Function616084 -Node: Data File Management617923 -Node: Filetrans Function618555 -Node: Rewind Function622624 -Node: File Checking624011 -Ref: File Checking-Footnote-1625143 -Node: Empty Files625344 -Node: Ignoring Assigns627323 -Node: Getopt Function628877 -Ref: Getopt Function-Footnote-1640180 -Node: Passwd Functions640383 -Ref: Passwd Functions-Footnote-1649362 -Node: Group Functions649450 -Ref: Group Functions-Footnote-1657391 -Node: Walking Arrays657604 -Node: Library Functions Summary659207 -Node: Library exercises660595 -Node: Sample Programs661875 -Node: Running Examples662645 -Node: Clones663373 -Node: Cut Program664597 -Node: Egrep Program674465 -Ref: Egrep Program-Footnote-1682436 -Node: Id Program682546 -Node: Split Program686210 -Ref: Split Program-Footnote-1689748 -Node: Tee Program689876 -Node: Uniq Program692683 -Node: Wc Program700113 -Ref: Wc Program-Footnote-1704378 -Node: Miscellaneous Programs704470 -Node: Dupword Program705683 -Node: Alarm Program707714 -Node: Translate Program712528 -Ref: Translate Program-Footnote-1716919 -Ref: Translate Program-Footnote-2717189 -Node: Labels Program717323 -Ref: Labels Program-Footnote-1720694 -Node: Word Sorting720778 -Node: History Sorting724821 -Node: Extract Program726657 -Node: Simple Sed734193 -Node: Igawk Program737255 -Ref: Igawk Program-Footnote-1751566 -Ref: Igawk Program-Footnote-2751767 -Node: Anagram Program751905 -Node: Signature Program754973 -Node: Programs Summary756220 -Node: Programs Exercises757435 -Node: Advanced Features761086 -Node: Nondecimal Data763034 -Node: Array Sorting764611 -Node: Controlling Array Traversal765308 -Node: Array Sorting Functions773588 -Ref: Array Sorting Functions-Footnote-1777495 -Node: Two-way I/O777689 -Ref: Two-way I/O-Footnote-1783205 -Node: TCP/IP Networking783287 -Node: Profiling786131 -Node: Advanced Features Summary793673 -Node: Internationalization795537 -Node: I18N and L10N797017 -Node: Explaining gettext797703 -Ref: Explaining gettext-Footnote-1802843 -Ref: Explaining gettext-Footnote-2803027 -Node: Programmer i18n803192 -Node: Translator i18n807417 -Node: String Extraction808211 -Ref: String Extraction-Footnote-1809172 -Node: Printf Ordering809258 -Ref: Printf Ordering-Footnote-1812040 -Node: I18N Portability812104 -Ref: I18N Portability-Footnote-1814553 -Node: I18N Example814616 -Ref: I18N Example-Footnote-1817338 -Node: Gawk I18N817410 -Node: I18N Summary818048 -Node: Debugger819387 -Node: Debugging820409 -Node: Debugging Concepts820850 -Node: Debugging Terms822706 -Node: Awk Debugging825303 -Node: Sample Debugging Session826195 -Node: Debugger Invocation826715 -Node: Finding The Bug828048 -Node: List of Debugger Commands834530 -Node: Breakpoint Control835862 -Node: Debugger Execution Control839526 -Node: Viewing And Changing Data842886 -Node: Execution Stack846244 -Node: Debugger Info847757 -Node: Miscellaneous Debugger Commands851751 -Node: Readline Support856935 -Node: Limitations857827 -Node: Debugging Summary860101 -Node: Arbitrary Precision Arithmetic861265 -Node: Computer Arithmetic862594 -Ref: Computer Arithmetic-Footnote-1866981 -Node: Math Definitions867038 -Ref: table-ieee-formats869922 -Node: MPFR features870426 -Node: FP Math Caution872068 -Ref: FP Math Caution-Footnote-1873109 -Node: Inexactness of computations873478 -Node: Inexact representation874426 -Node: Comparing FP Values875781 -Node: Errors accumulate876745 -Node: Getting Accuracy878178 -Node: Try To Round880837 -Node: Setting precision881736 -Ref: table-predefined-precision-strings882418 -Node: Setting the rounding mode884211 -Ref: table-gawk-rounding-modes884575 -Ref: Setting the rounding mode-Footnote-1888029 -Node: Arbitrary Precision Integers888208 -Ref: Arbitrary Precision Integers-Footnote-1891211 -Node: POSIX Floating Point Problems891360 -Ref: POSIX Floating Point Problems-Footnote-1895236 -Node: Floating point summary895274 -Node: Dynamic Extensions897491 -Node: Extension Intro899043 -Node: Plugin License900308 -Node: Extension Mechanism Outline900993 -Ref: figure-load-extension901417 -Ref: figure-load-new-function902902 -Ref: figure-call-new-function903904 -Node: Extension API Description905888 -Node: Extension API Functions Introduction907338 -Node: General Data Types912203 -Ref: General Data Types-Footnote-1917896 -Node: Requesting Values918195 -Ref: table-value-types-returned918932 -Node: Memory Allocation Functions919890 -Ref: Memory Allocation Functions-Footnote-1922637 -Node: Constructor Functions922733 -Node: Registration Functions924491 -Node: Extension Functions925176 -Node: Exit Callback Functions927478 -Node: Extension Version String928727 -Node: Input Parsers929377 -Node: Output Wrappers939180 -Node: Two-way processors943696 -Node: Printing Messages945900 -Ref: Printing Messages-Footnote-1946977 -Node: Updating `ERRNO'947129 -Node: Accessing Parameters947868 -Node: Symbol Table Access949098 -Node: Symbol table by name949612 -Node: Symbol table by cookie951588 -Ref: Symbol table by cookie-Footnote-1955721 -Node: Cached values955784 -Ref: Cached values-Footnote-1959288 -Node: Array Manipulation959379 -Ref: Array Manipulation-Footnote-1960477 -Node: Array Data Types960516 -Ref: Array Data Types-Footnote-1963219 -Node: Array Functions963311 -Node: Flattening Arrays967185 -Node: Creating Arrays974037 -Node: Extension API Variables978768 -Node: Extension Versioning979404 -Node: Extension API Informational Variables981305 -Node: Extension API Boilerplate982391 -Node: Finding Extensions986195 -Node: Extension Example986755 -Node: Internal File Description987485 -Node: Internal File Ops991576 -Ref: Internal File Ops-Footnote-11003008 -Node: Using Internal File Ops1003148 -Ref: Using Internal File Ops-Footnote-11005495 -Node: Extension Samples1005763 -Node: Extension Sample File Functions1007287 -Node: Extension Sample Fnmatch1014855 -Node: Extension Sample Fork1016336 -Node: Extension Sample Inplace1017549 -Node: Extension Sample Ord1019224 -Node: Extension Sample Readdir1020060 -Ref: table-readdir-file-types1020916 -Node: Extension Sample Revout1021715 -Node: Extension Sample Rev2way1022306 -Node: Extension Sample Read write array1023047 -Node: Extension Sample Readfile1024926 -Node: Extension Sample API Tests1026026 -Node: Extension Sample Time1026551 -Node: gawkextlib1027866 -Node: Extension summary1030679 -Node: Extension Exercises1034372 -Node: Language History1035094 -Node: V7/SVR3.11036737 -Node: SVR41039057 -Node: POSIX1040499 -Node: BTL1041885 -Node: POSIX/GNU1042619 -Node: Feature History1048218 -Node: Common Extensions1061348 -Node: Ranges and Locales1062660 -Ref: Ranges and Locales-Footnote-11067277 -Ref: Ranges and Locales-Footnote-21067304 -Ref: Ranges and Locales-Footnote-31067538 -Node: Contributors1067759 -Node: History summary1073221 -Node: Installation1074590 -Node: Gawk Distribution1075541 -Node: Getting1076025 -Node: Extracting1076849 -Node: Distribution contents1078491 -Node: Unix Installation1084208 -Node: Quick Installation1084825 -Node: Additional Configuration Options1087267 -Node: Configuration Philosophy1089005 -Node: Non-Unix Installation1091356 -Node: PC Installation1091814 -Node: PC Binary Installation1093125 -Node: PC Compiling1094973 -Ref: PC Compiling-Footnote-11097972 -Node: PC Testing1098077 -Node: PC Using1099253 -Node: Cygwin1103411 -Node: MSYS1104220 -Node: VMS Installation1104734 -Node: VMS Compilation1105530 -Ref: VMS Compilation-Footnote-11106752 -Node: VMS Dynamic Extensions1106810 -Node: VMS Installation Details1108183 -Node: VMS Running1110435 -Node: VMS GNV1113269 -Node: VMS Old Gawk1113992 -Node: Bugs1114462 -Node: Other Versions1118466 -Node: Installation summary1124721 -Node: Notes1125777 -Node: Compatibility Mode1126642 -Node: Additions1127424 -Node: Accessing The Source1128349 -Node: Adding Code1129785 -Node: New Ports1135963 -Node: Derived Files1140444 -Ref: Derived Files-Footnote-11145525 -Ref: Derived Files-Footnote-21145559 -Ref: Derived Files-Footnote-31146155 -Node: Future Extensions1146269 -Node: Implementation Limitations1146875 -Node: Extension Design1148123 -Node: Old Extension Problems1149277 -Ref: Old Extension Problems-Footnote-11150794 -Node: Extension New Mechanism Goals1150851 -Ref: Extension New Mechanism Goals-Footnote-11154211 -Node: Extension Other Design Decisions1154400 -Node: Extension Future Growth1156506 -Node: Old Extension Mechanism1157342 -Node: Notes summary1159104 -Node: Basic Concepts1160290 -Node: Basic High Level1160971 -Ref: figure-general-flow1161243 -Ref: figure-process-flow1161842 -Ref: Basic High Level-Footnote-11165071 -Node: Basic Data Typing1165256 -Node: Glossary1168584 -Node: Copying1193736 -Node: GNU Free Documentation License1231292 -Node: Index1256428 +Ref: Auto-set-Footnote-1445720 +Ref: Auto-set-Footnote-2445925 +Node: ARGC and ARGV445981 +Node: Pattern Action Summary449835 +Node: Arrays452058 +Node: Array Basics453607 +Node: Array Intro454433 +Ref: figure-array-elements456406 +Node: Reference to Elements458813 +Node: Assigning Elements461086 +Node: Array Example461577 +Node: Scanning an Array463309 +Node: Controlling Scanning466324 +Ref: Controlling Scanning-Footnote-1471497 +Node: Delete471813 +Ref: Delete-Footnote-1474578 +Node: Numeric Array Subscripts474635 +Node: Uninitialized Subscripts476818 +Node: Multidimensional478443 +Node: Multiscanning481536 +Node: Arrays of Arrays483125 +Node: Arrays Summary487788 +Node: Functions489893 +Node: Built-in490766 +Node: Calling Built-in491844 +Node: Numeric Functions493832 +Ref: Numeric Functions-Footnote-1497666 +Ref: Numeric Functions-Footnote-2498023 +Ref: Numeric Functions-Footnote-3498071 +Node: String Functions498340 +Ref: String Functions-Footnote-1521351 +Ref: String Functions-Footnote-2521480 +Ref: String Functions-Footnote-3521728 +Node: Gory Details521815 +Ref: table-sub-escapes523484 +Ref: table-sub-posix-92524838 +Ref: table-sub-proposed526189 +Ref: table-posix-sub527543 +Ref: table-gensub-escapes529088 +Ref: Gory Details-Footnote-1530264 +Ref: Gory Details-Footnote-2530315 +Node: I/O Functions530466 +Ref: I/O Functions-Footnote-1537589 +Node: Time Functions537736 +Ref: Time Functions-Footnote-1548200 +Ref: Time Functions-Footnote-2548268 +Ref: Time Functions-Footnote-3548426 +Ref: Time Functions-Footnote-4548537 +Ref: Time Functions-Footnote-5548649 +Ref: Time Functions-Footnote-6548876 +Node: Bitwise Functions549142 +Ref: table-bitwise-ops549704 +Ref: Bitwise Functions-Footnote-1553949 +Node: Type Functions554133 +Node: I18N Functions555275 +Node: User-defined556920 +Node: Definition Syntax557724 +Ref: Definition Syntax-Footnote-1562903 +Node: Function Example562972 +Ref: Function Example-Footnote-1565616 +Node: Function Caveats565638 +Node: Calling A Function566156 +Node: Variable Scope567111 +Node: Pass By Value/Reference570099 +Node: Return Statement573607 +Node: Dynamic Typing576591 +Node: Indirect Calls577520 +Node: Functions Summary587233 +Node: Library Functions589772 +Ref: Library Functions-Footnote-1593390 +Ref: Library Functions-Footnote-2593533 +Node: Library Names593704 +Ref: Library Names-Footnote-1597177 +Ref: Library Names-Footnote-2597397 +Node: General Functions597483 +Node: Strtonum Function598511 +Node: Assert Function601291 +Node: Round Function604617 +Node: Cliff Random Function606158 +Node: Ordinal Functions607174 +Ref: Ordinal Functions-Footnote-1610251 +Ref: Ordinal Functions-Footnote-2610503 +Node: Join Function610714 +Ref: Join Function-Footnote-1612485 +Node: Getlocaltime Function612685 +Node: Readfile Function616421 +Node: Data File Management618260 +Node: Filetrans Function618892 +Node: Rewind Function622961 +Node: File Checking624348 +Ref: File Checking-Footnote-1625480 +Node: Empty Files625681 +Node: Ignoring Assigns627660 +Node: Getopt Function629214 +Ref: Getopt Function-Footnote-1640517 +Node: Passwd Functions640720 +Ref: Passwd Functions-Footnote-1649699 +Node: Group Functions649787 +Ref: Group Functions-Footnote-1657728 +Node: Walking Arrays657941 +Node: Library Functions Summary659544 +Node: Library exercises660932 +Node: Sample Programs662212 +Node: Running Examples662982 +Node: Clones663710 +Node: Cut Program664934 +Node: Egrep Program674802 +Ref: Egrep Program-Footnote-1682773 +Node: Id Program682883 +Node: Split Program686547 +Ref: Split Program-Footnote-1690085 +Node: Tee Program690213 +Node: Uniq Program693020 +Node: Wc Program700450 +Ref: Wc Program-Footnote-1704715 +Node: Miscellaneous Programs704807 +Node: Dupword Program706020 +Node: Alarm Program708051 +Node: Translate Program712865 +Ref: Translate Program-Footnote-1717256 +Ref: Translate Program-Footnote-2717526 +Node: Labels Program717660 +Ref: Labels Program-Footnote-1721031 +Node: Word Sorting721115 +Node: History Sorting725158 +Node: Extract Program726994 +Node: Simple Sed734530 +Node: Igawk Program737592 +Ref: Igawk Program-Footnote-1751903 +Ref: Igawk Program-Footnote-2752104 +Node: Anagram Program752242 +Node: Signature Program755310 +Node: Programs Summary756557 +Node: Programs Exercises757772 +Node: Advanced Features761423 +Node: Nondecimal Data763371 +Node: Array Sorting764948 +Node: Controlling Array Traversal765645 +Node: Array Sorting Functions773925 +Ref: Array Sorting Functions-Footnote-1777832 +Node: Two-way I/O778026 +Ref: Two-way I/O-Footnote-1783542 +Node: TCP/IP Networking783624 +Node: Profiling786468 +Node: Advanced Features Summary794010 +Node: Internationalization795874 +Node: I18N and L10N797354 +Node: Explaining gettext798040 +Ref: Explaining gettext-Footnote-1803180 +Ref: Explaining gettext-Footnote-2803364 +Node: Programmer i18n803529 +Node: Translator i18n807754 +Node: String Extraction808548 +Ref: String Extraction-Footnote-1809509 +Node: Printf Ordering809595 +Ref: Printf Ordering-Footnote-1812377 +Node: I18N Portability812441 +Ref: I18N Portability-Footnote-1814890 +Node: I18N Example814953 +Ref: I18N Example-Footnote-1817675 +Node: Gawk I18N817747 +Node: I18N Summary818385 +Node: Debugger819724 +Node: Debugging820746 +Node: Debugging Concepts821187 +Node: Debugging Terms823043 +Node: Awk Debugging825640 +Node: Sample Debugging Session826532 +Node: Debugger Invocation827052 +Node: Finding The Bug828385 +Node: List of Debugger Commands834867 +Node: Breakpoint Control836199 +Node: Debugger Execution Control839863 +Node: Viewing And Changing Data843223 +Node: Execution Stack846581 +Node: Debugger Info848094 +Node: Miscellaneous Debugger Commands852088 +Node: Readline Support857272 +Node: Limitations858164 +Node: Debugging Summary860438 +Node: Arbitrary Precision Arithmetic861602 +Node: Computer Arithmetic862931 +Ref: Computer Arithmetic-Footnote-1867318 +Node: Math Definitions867375 +Ref: table-ieee-formats870259 +Node: MPFR features870763 +Node: FP Math Caution872405 +Ref: FP Math Caution-Footnote-1873446 +Node: Inexactness of computations873815 +Node: Inexact representation874763 +Node: Comparing FP Values876118 +Node: Errors accumulate877082 +Node: Getting Accuracy878515 +Node: Try To Round881174 +Node: Setting precision882073 +Ref: table-predefined-precision-strings882755 +Node: Setting the rounding mode884548 +Ref: table-gawk-rounding-modes884912 +Ref: Setting the rounding mode-Footnote-1888366 +Node: Arbitrary Precision Integers888545 +Ref: Arbitrary Precision Integers-Footnote-1891548 +Node: POSIX Floating Point Problems891697 +Ref: POSIX Floating Point Problems-Footnote-1895573 +Node: Floating point summary895611 +Node: Dynamic Extensions897828 +Node: Extension Intro899380 +Node: Plugin License900645 +Node: Extension Mechanism Outline901330 +Ref: figure-load-extension901754 +Ref: figure-load-new-function903239 +Ref: figure-call-new-function904241 +Node: Extension API Description906225 +Node: Extension API Functions Introduction907675 +Node: General Data Types912540 +Ref: General Data Types-Footnote-1918233 +Node: Requesting Values918532 +Ref: table-value-types-returned919269 +Node: Memory Allocation Functions920227 +Ref: Memory Allocation Functions-Footnote-1922974 +Node: Constructor Functions923070 +Node: Registration Functions924828 +Node: Extension Functions925513 +Node: Exit Callback Functions927815 +Node: Extension Version String929064 +Node: Input Parsers929714 +Node: Output Wrappers939517 +Node: Two-way processors944033 +Node: Printing Messages946237 +Ref: Printing Messages-Footnote-1947314 +Node: Updating `ERRNO'947466 +Node: Accessing Parameters948205 +Node: Symbol Table Access949435 +Node: Symbol table by name949949 +Node: Symbol table by cookie951925 +Ref: Symbol table by cookie-Footnote-1956058 +Node: Cached values956121 +Ref: Cached values-Footnote-1959625 +Node: Array Manipulation959716 +Ref: Array Manipulation-Footnote-1960814 +Node: Array Data Types960853 +Ref: Array Data Types-Footnote-1963556 +Node: Array Functions963648 +Node: Flattening Arrays967522 +Node: Creating Arrays974374 +Node: Extension API Variables979105 +Node: Extension Versioning979741 +Node: Extension API Informational Variables981642 +Node: Extension API Boilerplate982728 +Node: Finding Extensions986532 +Node: Extension Example987092 +Node: Internal File Description987822 +Node: Internal File Ops991913 +Ref: Internal File Ops-Footnote-11003345 +Node: Using Internal File Ops1003485 +Ref: Using Internal File Ops-Footnote-11005832 +Node: Extension Samples1006100 +Node: Extension Sample File Functions1007624 +Node: Extension Sample Fnmatch1015192 +Node: Extension Sample Fork1016673 +Node: Extension Sample Inplace1017886 +Node: Extension Sample Ord1019561 +Node: Extension Sample Readdir1020397 +Ref: table-readdir-file-types1021253 +Node: Extension Sample Revout1022052 +Node: Extension Sample Rev2way1022643 +Node: Extension Sample Read write array1023384 +Node: Extension Sample Readfile1025263 +Node: Extension Sample API Tests1026363 +Node: Extension Sample Time1026888 +Node: gawkextlib1028203 +Node: Extension summary1031016 +Node: Extension Exercises1034709 +Node: Language History1035431 +Node: V7/SVR3.11037074 +Node: SVR41039394 +Node: POSIX1040836 +Node: BTL1042222 +Node: POSIX/GNU1042956 +Node: Feature History1048555 +Node: Common Extensions1061685 +Node: Ranges and Locales1062997 +Ref: Ranges and Locales-Footnote-11067614 +Ref: Ranges and Locales-Footnote-21067641 +Ref: Ranges and Locales-Footnote-31067875 +Node: Contributors1068096 +Node: History summary1073558 +Node: Installation1074927 +Node: Gawk Distribution1075878 +Node: Getting1076362 +Node: Extracting1077186 +Node: Distribution contents1078828 +Node: Unix Installation1084545 +Node: Quick Installation1085162 +Node: Additional Configuration Options1087604 +Node: Configuration Philosophy1089342 +Node: Non-Unix Installation1091693 +Node: PC Installation1092151 +Node: PC Binary Installation1093462 +Node: PC Compiling1095310 +Ref: PC Compiling-Footnote-11098309 +Node: PC Testing1098414 +Node: PC Using1099590 +Node: Cygwin1103748 +Node: MSYS1104557 +Node: VMS Installation1105071 +Node: VMS Compilation1105867 +Ref: VMS Compilation-Footnote-11107089 +Node: VMS Dynamic Extensions1107147 +Node: VMS Installation Details1108520 +Node: VMS Running1110772 +Node: VMS GNV1113606 +Node: VMS Old Gawk1114329 +Node: Bugs1114799 +Node: Other Versions1118803 +Node: Installation summary1125058 +Node: Notes1126114 +Node: Compatibility Mode1126979 +Node: Additions1127761 +Node: Accessing The Source1128686 +Node: Adding Code1130122 +Node: New Ports1136300 +Node: Derived Files1140781 +Ref: Derived Files-Footnote-11145862 +Ref: Derived Files-Footnote-21145896 +Ref: Derived Files-Footnote-31146492 +Node: Future Extensions1146606 +Node: Implementation Limitations1147212 +Node: Extension Design1148460 +Node: Old Extension Problems1149614 +Ref: Old Extension Problems-Footnote-11151131 +Node: Extension New Mechanism Goals1151188 +Ref: Extension New Mechanism Goals-Footnote-11154548 +Node: Extension Other Design Decisions1154737 +Node: Extension Future Growth1156843 +Node: Old Extension Mechanism1157679 +Node: Notes summary1159441 +Node: Basic Concepts1160627 +Node: Basic High Level1161308 +Ref: figure-general-flow1161580 +Ref: figure-process-flow1162179 +Ref: Basic High Level-Footnote-11165408 +Node: Basic Data Typing1165593 +Node: Glossary1168921 +Node: Copying1194073 +Node: GNU Free Documentation License1231629 +Node: Index1256765 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index e12de779..85c6dab3 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -14504,10 +14504,18 @@ next file is opened. An associative array containing the values of the environment. The array indices are the environment variable names; the elements are the values of the particular environment variables. For example, -@code{ENVIRON["HOME"]} might be @code{"/home/arnold"}. Changing this array -does not affect the environment passed on to any programs that -@command{awk} may spawn via redirection or the @code{system()} function. -(In a future version of @command{gawk}, it may do so.) +@code{ENVIRON["HOME"]} might be @code{/home/arnold}. + +For POSIX @command{awk}, changing this array does not affect the +environment passed on to any programs that @command{awk} may spawn via +redirection or the @code{system()} function. + +However, beginning with version 4.2, if not in POSIX +compatibility mode, @command{gawk} does update its own environment when +@code{ENVIRON} is changed, thus changing the environment seen by programs +that it creates. You should therefore be especially careful if you +modify @code{ENVIRON["PATH"]"}, which is the search path for finding +executable programs. Some operating systems may not have environment variables. On such systems, the @code{ENVIRON} array is empty (except for @@ -37683,9 +37691,10 @@ mail at the Internet address noted previously. If you find bugs in one of the non-Unix ports of @command{gawk}, please send an electronic mail message to the person who maintains that port. They -are named in the following list, as well as in the @file{README} file in the @command{gawk} -distribution. Information in the @file{README} file should be considered -authoritative if it conflicts with this @value{DOCUMENT}. +are named in the following list, as well as in the @file{README} file +in the @command{gawk} distribution. Information in the @file{README} +file should be considered authoritative if it conflicts with this +@value{DOCUMENT}. The people maintaining the non-Unix ports of @command{gawk} are as follows: @@ -37713,7 +37722,8 @@ John Malmberg, @EMAIL{wb8tyw@@qsl.net,wb8tyw at qsl.net}. @end multitable If your bug is also reproducible under Unix, please send a copy of your -report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well. +report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email +list as well. @c ENDOFRANGE dbugg @c ENDOFRANGE tblgawb diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 8167da72..13e46315 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -13855,10 +13855,18 @@ next file is opened. An associative array containing the values of the environment. The array indices are the environment variable names; the elements are the values of the particular environment variables. For example, -@code{ENVIRON["HOME"]} might be @code{"/home/arnold"}. Changing this array -does not affect the environment passed on to any programs that -@command{awk} may spawn via redirection or the @code{system()} function. -(In a future version of @command{gawk}, it may do so.) +@code{ENVIRON["HOME"]} might be @code{/home/arnold}. + +For POSIX @command{awk}, changing this array does not affect the +environment passed on to any programs that @command{awk} may spawn via +redirection or the @code{system()} function. + +However, beginning with version 4.2, if not in POSIX +compatibility mode, @command{gawk} does update its own environment when +@code{ENVIRON} is changed, thus changing the environment seen by programs +that it creates. You should therefore be especially careful if you +modify @code{ENVIRON["PATH"]"}, which is the search path for finding +executable programs. Some operating systems may not have environment variables. On such systems, the @code{ENVIRON} array is empty (except for @@ -36798,9 +36806,10 @@ mail at the Internet address noted previously. If you find bugs in one of the non-Unix ports of @command{gawk}, please send an electronic mail message to the person who maintains that port. They -are named in the following list, as well as in the @file{README} file in the @command{gawk} -distribution. Information in the @file{README} file should be considered -authoritative if it conflicts with this @value{DOCUMENT}. +are named in the following list, as well as in the @file{README} file +in the @command{gawk} distribution. Information in the @file{README} +file should be considered authoritative if it conflicts with this +@value{DOCUMENT}. The people maintaining the non-Unix ports of @command{gawk} are as follows: @@ -36828,7 +36837,8 @@ John Malmberg, @EMAIL{wb8tyw@@qsl.net,wb8tyw at qsl.net}. @end multitable If your bug is also reproducible under Unix, please send a copy of your -report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well. +report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email +list as well. @c ENDOFRANGE dbugg @c ENDOFRANGE tblgawb @@ -1120,6 +1120,10 @@ load_environ() */ path_environ("AWKPATH", defpath); path_environ("AWKLIBPATH", deflibpath); + + /* set up array functions */ + init_env_array(ENVIRON_node); + return ENVIRON_node; } diff --git a/pc/config.h b/pc/config.h index 85389eb2..c5d78a96 100644 --- a/pc/config.h +++ b/pc/config.h @@ -423,7 +423,7 @@ #define PACKAGE_NAME "GNU Awk" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Awk 4.1.1a" +#define PACKAGE_STRING "GNU Awk 4.1.60" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gawk" @@ -432,7 +432,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/gawk/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.1.1a" +#define PACKAGE_VERSION "4.1.60" /* Define to 1 if *printf supports %F format */ #undef PRINTF_HAS_F_FORMAT @@ -494,7 +494,7 @@ /* Version number of package */ -#define VERSION "4.1.1a" +#define VERSION "4.1.60" /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE diff --git a/str_array.c b/str_array.c index aa82d71b..33c9ddcc 100644 --- a/str_array.c +++ b/str_array.c @@ -69,6 +69,25 @@ afunc_t str_array_func[] = { (afunc_t) 0, }; +static NODE **env_remove(NODE *symbol, NODE *subs); +static NODE **env_store(NODE *symbol, NODE *subs); +static NODE **env_clear(NODE *symbol, NODE *subs); + +/* special case for ENVIRON */ +afunc_t env_array_func[] = { + str_array_init, + (afunc_t) 0, + null_length, + str_lookup, + str_exists, + env_clear, + env_remove, + str_list, + str_copy, + str_dump, + env_store, +}; + static inline NODE **str_find(NODE *symbol, NODE *s1, size_t code1, unsigned long hash1); static void grow_table(NODE *symbol); @@ -737,3 +756,63 @@ scramble(unsigned long x) return x; } + +/* env_remove --- for ENVIRON, remove value from real environment */ + +static NODE ** +env_remove(NODE *symbol, NODE *subs) +{ + NODE **val = str_remove(symbol, subs); + + if (val != NULL) + (void) unsetenv(subs->stptr); + + return val; +} + +/* env_clear --- clear out the environment when ENVIRON is deleted */ + +static NODE ** +env_clear(NODE *symbol, NODE *subs) +{ + extern char **environ; + NODE **val = str_clear(symbol, subs); + + environ = NULL; /* ZAP! */ + + /* str_clear zaps the vtable, reset it */ + symbol->array_funcs = env_array_func; + + return val; +} + +/* env_store --- post assign function for ENVIRON, put new value into env */ + +static NODE ** +env_store(NODE *symbol, NODE *subs) +{ + NODE **val = str_exists(symbol, subs); + const char *newval; + + assert(val != NULL); + + newval = (*val)->stptr; + if (newval == NULL) + newval = ""; + + (void) setenv(subs->stptr, newval, 1); + + return val; +} + +/* init_env_array --- set up the pointers for ENVIRON. A bit hacky. */ + +void +init_env_array(NODE *env_node) +{ + /* If POSIX simply don't reset the vtable and things work as before */ + if (do_posix) + return; + + env_node->array_funcs = env_array_func; +} diff --git a/test/ChangeLog b/test/ChangeLog index 5674ec67..a337603b 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -214,6 +214,12 @@ * Makefile.am (badassign1): New test. * badassign1.awk, badassign1.ok: New files. +2013-09-25 Arnold D. Robbins <arnold@skeeve.com> + + * Makfile.am (randtest): New test. + * randtest.sh, randtest.ok: New files. + * rand.ok: Updated to reflect new results based on code change. + 2013-09-13 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am: Fix quoting for generation of Maketests file so diff --git a/test/Makefile.am b/test/Makefile.am index 904553b8..13069084 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -705,6 +705,8 @@ EXTRA_DIST = \ rand-mpfr.ok \ rand.awk \ rand.ok \ + randtest.sh \ + randtest.ok \ range1.awk \ range1.in \ range1.ok \ @@ -979,7 +981,7 @@ BASIC_TESTS = \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ - rand range1 rebt8b1 redfilnm regeq regexprange regrange reindops \ + rand randtest range1 rebt8b1 redfilnm regeq regexprange regrange reindops \ reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sortempty splitargv splitarr splitdef \ @@ -1916,6 +1918,12 @@ dfamb1: AWKPATH="$(srcdir)" $(AWK) -f $@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +randtest:: + @echo $@ + @GAWK="$(AWKPROG)" "$(srcdir)"/randtest.sh >_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + backbigs1: @echo $@ @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ diff --git a/test/Makefile.in b/test/Makefile.in index 15c95345..2632334b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -951,6 +951,8 @@ EXTRA_DIST = \ rand-mpfr.ok \ rand.awk \ rand.ok \ + randtest.sh \ + randtest.ok \ range1.awk \ range1.in \ range1.ok \ @@ -1224,7 +1226,7 @@ BASIC_TESTS = \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ - rand range1 rebt8b1 redfilnm regeq regexprange regrange reindops \ + rand randtest range1 rebt8b1 redfilnm regeq regexprange regrange reindops \ reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sortempty splitargv splitarr splitdef \ @@ -2340,6 +2342,11 @@ dfamb1: AWKPATH="$(srcdir)" $(AWK) -f $@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +randtest:: + @echo $@ + @GAWK="$(AWKPROG)" "$(srcdir)"/randtest.sh >_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + backbigs1: @echo $@ @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ diff --git a/test/rand.ok b/test/rand.ok index 60432b95..1df4ba39 100644 --- a/test/rand.ok +++ b/test/rand.ok @@ -1 +1 @@ - 62 67 88 6 35 77 3 68 30 96 90 26 35 8 88 93 49 53 37 + 67 6 77 68 96 26 8 93 53 74 53 95 78 74 96 77 33 58 91 diff --git a/test/randtest.ok b/test/randtest.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/randtest.ok diff --git a/test/randtest.sh b/test/randtest.sh new file mode 100755 index 00000000..b17fda73 --- /dev/null +++ b/test/randtest.sh @@ -0,0 +1,113 @@ +# THIS PURPOSELY DOES NOT HAVE A !# LINE !!!! +# +# Date: Mon, 9 Sep 2013 14:49:43 -0700 +# From: Bob Jewett <jewett@bill.scs.agilent.com> +# Message-Id: <201309092149.r89Lnh94010909@bill.scs.agilent.com> +# To: arnold@skeeve.com +# Subject: Re: [bug-gawk] Bug in random() in builtin.c +# +# Hi Arnold, +# +# Attached below is a script that tests gawk for this particular +# rand() problem. The pair-wise combinations show a strong +# autocorrelation for a delay of 31 pairs of rand() samples. +# +# The script prints out the measured autocorrelation for a record +# of NSAMPLES pairs. It also prints a fail message at the end if +# it fails. +# +# If you want to see the autocorrelation values, there is a print +# statement that if uncommented will save them to a file. +# +# Please let me know if the mailer screws up the transfer or +# if you have any questions about the test. +# +# Best regards, +# Bob +# +# -------------- test_pair_power_autocorrelation ----------------------- +# +#!/bin/ksh + +#GAWK=/bin/gawk + +# ADR: Get GAWK from the environment. +# Additional note: This wants ksh/bash for the use of $RANDOM below to +# seed the generator. However, shells that don't provide it won't be +# a problem since gawk will then seed the generator with the time of day, +# as srand() will be called without an argument. + +# large NSAMPLES and NRUNS will bring any correlation out of the noise better +NSAMPLES=1024; MAX_ALLOWED_SIGMA=5; NRUNS=50; + +$GAWK 'BEGIN{ + srand('$RANDOM'); + nsamples=('$NSAMPLES'); + max_allowed_sigma=('$MAX_ALLOWED_SIGMA'); + nruns=('$NRUNS'); + for(tau=0;tau<nsamples/2;tau++) corr[tau]=0; + + for(run=0;run<nruns;run++) { + sum=0; + + # Fill an array with a sequence of samples that are a + # function of pairs of rand() values. + + for(i=0;i<nsamples;i++) { + samp[i]=((rand()-0.5)*(rand()-0.5))^2; + sum=sum+samp[i]; + } + + # Subtract off the mean of the sequence: + + mean=sum/nsamples; + for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; + + # Calculate an autocorrelation function on the sequence. + # Because the values of rand() should be independent, there + # should be no peaks in the autocorrelation. + + for(tau=0;tau<nsamples/2;tau++) { + sum=0; + for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; + corr[tau]=corr[tau]+sum; + } + + } + # Normalize the autocorrelation to the tau=0 value. + + max_corr=corr[0]; + for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; + + # OPTIONALLY Print out the autocorrelation values: + + # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] > "pairpower_corr.data"; + + # Calculate the sigma for the non-zero tau values: + + power_sum=0; + + for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; + + sigma=sqrt(power_sum/(nsamples/2-1)); + + # See if any of the correlations exceed a reasonable number of sigma: + + passed=1; + for(tau=1;tau<nsamples/2;tau++) { + if ( abs(corr[tau])/sigma > max_allowed_sigma ) { + print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; + passed=0; + } + } + if(!passed) { + print "Test failed." + exit(1); + } + else exit (0); + } + +function abs(abs_input) { return(sqrt(abs_input^2)) ; } +' + +exit 0 |