2013-09-24 Arnold D. Robbins * debug.c (find_rule): Handle case where lineno is zero. Can happen if break is given without a line number on a current line. Thanks to Ray Song for the report. 2013-09-19 Arnold D. Robbins * dfa.c (parse_bracket_exp): Use code from grep to keep things within range (updates change of 2013-09-08). Fix whitespace in one of the gawk-only additions. 2013-09-13 Arnold D. Robbins Fix use of NF after it's extended, e.g. see test/nfloop.awk. * awk.h (NULL_FIELD): New flag * builtin.c (do_print_rec): Check f0->flags instead of if equal to Nnull_string. * eval.c (r_get_field): Check (*lhs)->flags instead of if equal to Nnull_string or Null_field. * field.c (init_fields): Init field zero and Null_field with NULL_FIELD flag. (set_NF): Set parse_high_water = NF in case NF extended past the end. This is the actual bug fix. 2013-09-08 Arnold D. Robbins Fixes based on reports from a static code checker. Thanks to Anders Wallin for sending in the list. * array.c (asort_actual): Free list if it's not NULL. * builtin.c (do_sub): Set buf to NULL and assert on it before using it. * cint_array.c (cint_array_init): Clamp any value of NHAT from the environment such that it won't overflow power_two_table when used as an index. * dfa.c (parse_bracket_exp): Check that len is in range before using it to index buf. * getopt.c (_getopt_internal_r): Change call to alloca to use malloc. * io.c (socket_open): Init read_len to zero. (two_way_open): Upon failure to fork, close the slave fd also. * re.c (research): Init try_backref to false. * regcomp.c (build_range_exp): Free any items that were allocated in the case where not all items were. (build_charclass_op): Same. Init br_token to zero with memset. (create_tree): Init token t to zero with memset. * regex_internal.c (re_dfa_add_node): Free any items that were allocated in the case where not all items were. * symbol.c (destroy_symbol): On default, break, to fall into releasing of resources. 2013-08-29 Arnold D. Robbins * debug.c (HAVE_HISTORY_LIST): Move checks and defines to the top. (do_save, serialize): Adjust #if checks to depend on having both readline and the history functions. Needed for Mac OS X whose native readline is a very old version. Sigh. * configh.in, configure: Regenerated due to change in m4/readline.m4. Issue reported by Hermann Peifer and Larry Baker. Unrelated: * getopt.c: Sync with GLIBC, changes are minor. Unrelated: * dfa.c: Sync with version in grep. Primarily whitespace / comment wording changes. 2013-08-26 Arnold D. Robbins * regcomp.c (parse_dup_op): Remove RE_TOKEN_INIT_BUG code (change of Feb 19 2005) since it's no longer needed. * regcomp.c (re_fastmap_iter): Undo addition of volatile from Jan 18 2007; no longer needed and is one less change to have to maintain aginst the upstream. * regcomp.c, regex.h, regex_internal.h: Sync with GLIBC. 2013-08-20 Arnold D. Robbins * nonposix.h: New file. Contains FAKE_FD_VALUE. * awk.h: Include it if MinGW or EMX. * Makefile.am (base_sources): Add nonposix.h. 2013-08-18 Arnold D. Robbins * 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. 2013-08-15 Arnold D. Robbins * debug.c (print_memory): Fix whitespace / indentation. 2013-07-24 Arnold D. Robbins * io.c (FAKE_FD_VALUE): Move definition from here ... * awk.h (FAKE_FD_VALUE): ... to here. Fixes compilation on MinGW. 2013-07-08 Arnold D. Robbins * io.c (get_a_record): Change `min' to `MIN' for consistency with other files and general practice. 2013-07-04 Andrew J. Schorr * gawkapi.h (awk_element_t): Add comment indicating that the array element index will always be a string! * gawkapi.c (api_flatten_array): When converting the index to an awk value, request a string conversion, since we want the indices to appear as strings to the extensions. This makes the call to force_string redundant, since node_to_awk_value does that internally when we request a string. 2013-07-04 Arnold D. Robbins * builtin.c (format_tree): Fixes for %c with multibyte characters and field width > 1. Bugs reported by Nethox . 2013-07-02 Arnold D. Robbins * profile.c (pp_string): Add a call to chksize and fix another. Avoids valgrind errors on profile5 test. Thanks to Andrew Schorr for the report. 2013-06-27 Arnold D. Robbins * awkgram.y: Minor whitespace cleanup, remove redundant ifdef. 2013-06-24 Arnold D. Robbins * dfa.c (copytoks): Rewrite to call addtok_mb() directly. Avoids problems with multibyte characters inside character sets. Thanks to Steven Daniels for reporting the problem. Much thanks to Mike Haertel for the analysis and fix. 2013-06-24 Eli Zaretskii * io.c: Move #include "popen.h" out of the HAVE_SOCKETS condition, as this is needed for non-sockets builds as well. See http://lists.gnu.org/archive/html/bug-gawk/2013-06/msg00014.html for the details of the problem this caused. 2013-06-15 Arnold D. Robbins * io.c: Add ifdefs for VMS so that it will compile again. Thanks to Anders Wallin. 2013-06-11 Arnold D. Robbins * debug.c (print_lines): Move setting of binary mode to after all the messing with the fd. Simplifies code some. * io.c (srcopen): Rearrange so that can add call to setbinmode here too. This fixes the debugger and makes reading source files a little faster. Thanks again to Corinna Vinschen. 2013-06-10 Arnold D. Robbins * debug.c (print_lines): Set binary mode so that calculation of the byte offsets will be right. Thanks to Corinna Vinschen for the direction. 2013-06-10 Arnold D. Robbins * re.c (check_bracket_exp): Remove warning about ranges being locale dependent, since they aren't anymore. 2013-06-09 Arnold D. Robbins * io.c (iop_finish): Change fstat call to fcntl/F_GETFL per Eli Z., for Windows. 2013-06-03 Arnold D. Robbins * eval.c (unwind_stack): If exiting, don't worry about strange stuff on the stack. Unrelated: * awk.h (init_sockets): Declare. * io.c (init_io): Remove ifdef around call. 2013-06-01 Eli Zaretskii * io.c (SHUT_RD) [SD_RECEIVE]: Define to SD_RECEIVE. (SHUT_WR) [SD_SEND]: Define to SD_SEND. (SHUT_RDWR) [SD_BOTH]: Define to SD_BOTH. (FD_TO_SOCKET, closemaybesocket) [!FD_TO_SOCKET]: New macros. (SOCKET_TO_FD, SOCKET) [!SOCKET_TO_FD]: New macros. (PIPES_SIMULATED): Define only for DJGPP. (pipe) [__MINGW32__]: Define to call _pipe, unless PIPES_SIMULATED is defined. (init_io) [HAVE_SOCKETS]: Call init_sockets. (iop_close, socketopen): Call closemaybesocket instead of close. (redirect) [__MINGW32__]: Call wait_any with a non-zero argument. (devopen) [__EMX__ || __MINGW32__]: Don't call stat on network pseudo-filenames. (two_way_open) [HAVE_SOCKETS]: Switch input and output to binary mode if appropriate. (two_way_open) [!PIPES_SIMULATED]: Use the __EMX__ code for MinGW as well. [__MINGW32__] Call spawnl to invoke $ComSpec and pass it a suitably quoted command line. (two_way_open) [__MINGW32__]: Wait only for a specified process ID. If successful, update the exit status of the exited process. Don't use signals that are undefined on MinGW. (two_way_open) [!PIPES_SIMULATED]: Use the __EMX__ code for MinGW as well. (min): Define only if not already defined. (read_with_timeout) [__MINGW32__]: Allow reading from sockets with timeout. (gawk_fclose) [__MINGW32__]: Close the underlying socket as well. * getopt.c: Include stdlib.h for MinGW as well. 2013-05-30 Arnold D. Robbins More profiling fixes: * profile.c (pprint): For Op_in_array, parenthesize subscript if the precedence is lower. E.g.: (c = tolower(foo)) in ARRAY. (prec_level): Merge cases for precedence of 5. (parenthesize): Simplify, as in 3.1.8. Avoids stuff like `(x == 1 && (z ==2 && (q == 4 && w == 7)))'. Unrelated: * io.c (iop_finish): fstat the fd before closing it to avoid errors on some operating systems. Thanks to Eli Zaretskii for the report. 2013-05-29 Arnold D. Robbins * profile.c (pp_group3): Renamed from pp_concat. Change all calls. (is_binary): Change return type to bool. (is_scalar): New function. (pp_concat): New function to handle concatenation operator better. (pprint): Call it at case Op_concat. Fix Op_K_delete if multiple indexes to separate with "][". General: Add leading comments as needed. 2013-05-28 Arnold D. Robbins * main.c (main): Add minor hack to not run code if pretty printing and undocumented env var GAWK_NO_PP_RUN exists. * profile.c (pp_string): Explicitly print NUL chars as \000. 2013-05-27 Arnold D. Robbins * configure.ac (AM_INIT_AUTOMAKE): Add dist-lzip to quiet outside maintainer warnings. Unrelated: * configure.ac (AC_STRUCT_ST_BLKSIZE): Replaced with call to AC_CHECK_MEMBERS. Unrelated: * array.c (null_array): Remove the assert and just clear symbol->xarray. 2013-05-26 Arnold D. Robbins * getopt.c: For Mac OS X, also include to avoid some compiler warnings. 2013-05-20 Arnold D. Robbins * gawkapi.h [FAKE_FD_VALUE]: Moved from here to ... * io.c [FAKE_FD_VALAUE]: here. 2013-05-14 Eli Zaretskii * io.c (devopen) [__EMX__ || __MINGW32__]: Produce EISDIR on MinGW when an attempt to open() a directory fails. (two_way_open) [__EMX__ || __MINGW32__]: When trying to open() a directory fails with EISDIR, assign FAKE_FD_VALUE to the file descriptor and attributes of a directory to its mode bits. This is needed to support the readdir extension. * gawkapi.h (FAKE_FD_VALUE): New macro, used in io.h and in extension/gawkdirfd.h. 2013-05-09 Arnold D. Robbins * 4.1.0: Release tar ball made. 2013-05-09 Arnold D. Robbins * awkgram.y (snode): Make it a fatal error to use a regexp constant as the second argument of index(). Thanks to Christopher Durant and Brian Kernighan for the report and the advice. 2013-04-28 Eli Zaretskii * io.c (redirect): Remove the HACK that called close_one when errno was zero in the MinGW build. This prevents failure in several tests in the test suite, e.g., closebad. 2013-04-28 Arnold D. Robbins * bootstrap.sh: Fix a comment. 2013-04-24 Arnold D. Robbins * io.c (do_getline_redir): Fix the leading comment. 2013-04-23 Arnold D. Robbins * main.c (load_procinfo): Add PROCINFO entries for API major and minor versions. 2013-04-21 Arnold D. Robbins * missing: Update from Automake 1.13.1. 2013-04-18 Arnold D. Robbins * configure.ac: Fix a typo. 2013-04-17 Corinna Vinschen * configure.ac: Remove special casing for cygwin for libiconv and libintl. 2013-04-16 Arnold D. Robbins * bootstrap.sh: Touch gawk.texi too. Update copyright. 2013-04-16 Arnold D. Robbins * awkgram.c: Regenerated from bison 2.7.1. * command.c: Ditto. * dfa.h, dfa.c: Minor edits to sync with GNU grep. * gettext.h: Sync with gettext 0.18.2.1. * random.h: Remove obsolete __P macro and use. Update copyright year. * Makefile.am, array.c, builtin.c, cint_array.c, cmd.h, debug.c, eval.c, ext.c, field.c, gawkapi.c, gawkapi.h, gettext.h, int_array.c, interpret.h, msg.c, node.c, profile.c, re.c, replace.c, str_array.c, symbol.c: Update copyright year. Update to automake 1.13.1: * configure.ac (AM_INIT_AUTOMAKE): Update version. * configure, Makefile.in, aclocal.m4, awklib/Makefile.in, doc/Makefile.in, test/Makefile.in: Regenerated. * getopt.c, getopt.h, getopt1.c, getopt_int.h: Sync with GLIBC. 2013-04-14 Arnold D. Robbins * awkgram.y (check_funcs): Fix logic of test for called but not defined warning. Thanks to Scott Deifik for the bug report. 2013-04-02 Arnold D. Robbins * profile.c (print_lib_list): Send final newline to prof_fp instead of stdout. Thanks to Hermann Peifer for the bug report. 2013-03-27 Arnold D. Robbins * Makefile.am (SUBDIRS): Move extension back into the middle of the list so that `make check' without a prior `make' works. Unrelated: * main.c (main): Move env_lc into ifdef for LIBC_IS_BORKED. 2013-03-20 Arnold D. Robbins For systems where libc is borked (MirBSD, maybe others). * dfa.c: Force use of gawk_mb_cur_max instead of MB_CUR_MAX and make mbrtowc a macro that always fails. (using_utf8): Force utf8 to be 0 if libc borked and gawk_mb_cur_max is one. * main.c (main): If libc is borked and LC_ALL or LANG exist in the environment and are set to "C" or "c", force gawk_mb_cur_max to one. 2013-03-11 Arnold D. Robbins * re.c (check_bracket_exp): Make handling of embedded ] in regexp smarter. Thanks to Ed Morton for reporting the bug. 2013-03-01 Arnold D. Robbins Don't build extensions if API isn't supported: * Makefile.am (SUBDIRS): Move extension directory to last in case building the extensions is not supported. * configure.ac: Add check for MirBSD and don't even try to run the checks for DYNAMIC if so. Check for systems (MirBSD) where libc doesn't understand not to use UTF-8 for LC_ALL=C. * configure.ac (LIBC_IS_BORKED): AC_DEFINE if needed. * regcomp.c (init_dfa): Change logic as needed if LIBC_IS_BORKED. 2013-02-28 Arnold D. Robbins Cause profiling / pretty printing to include a list of loaded extensions. Thanks to Hermann Peifer for the bug report. * awk.h (srcfiles): Add declaration. * profile.c (print_lib_list): New function. (dump_prog): Call it. 2013-02-26 Arnold D. Robbins * awkgram.y (expression_list): In case of error return the list instead of NULL so that snode gets something it can count. 2013-02-12 Arnold D. Robbins * bisonfix.awk: Comment out code for fixing contined #if statements. It is likely not needed anymore. Leave it there in case I'm wrong. 2013-02-06 Arnold D. Robbins * builtin.c (printf_common): Move nargs > 0 check into assert. (do_sprintf): Add nargs check and fatal message to here. 2013-02-04 Arnold D. Robbins * main.c (main): Remove undocumented -m option which was for compatibility with BWK awk. His awk dropped it back in 2007. 2013-02-03 Arnold D. Robbins * configure.ac: Add Automake test for cross compiling. 2013-01-31 Arnold D. Robbins * regcomp.c, regex.c, regex_internal.c, regexec.c: Update copyright years to sync with GLIBC. From: http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html, by Andreas Schwab : * regexec.c (extend_buffers): Add parameter min_len. (check_matching): Pass minimum needed length. (clean_state_log_if_needed): Likewise. (get_subexp): Likewise.` 2013-01-31 Arnold D. Robbins * dfa.c: Include "dfa.h" which includes regex.h after limits.h so that RE_DUP_MAX gets the correct value. Especially needed on OpenVMS. Thanks to Anders Wallin. * main.c (version): Print out API version numbers if DYNAMIC. Helpful also for knowing if to run the shlib tests. * configure: Regenerated after change in m4/readline.m4. 2013-01-31 Arnold D. Robbins * PROBLEMS: Removed. It is no longer needed. * Makefile.am (EXTRA_DIST): Remove PROBLEMS from list. 2013-01-31 Andrew J. Schorr * configure.ac: Remove TEST_MPFR conditional added in last patch. We will instead test for MPFR capability by looking at the output from gawk --version. 2013-01-27 Andrew J. Schorr * configure.ac: Add MPFR test for use in test/Makefile.am. 2013-01-25 Arnold D. Robbins * awkgram.y (parms_shadow): Change int param to bool. * cmd.h (output_is_tty): Sync type with rest of code (is bool). * dfa.c (MALLOC): Undef first, for Irix. * Makefile.am (LDADD): Use LIBREADLINE and LIBMPFR instead of automake substitutions. * configure.ac (AC_INIT): Version bump. (GAWK_CHECK_READLINE): Renamed from GNUPG_CHECK_READLINE. 2013-01-23 Arnold D. Robbins * awk.h (list_functions): Change parameter to bool. * symbol.c (list_functions): Ditto. (get_symbols): Change sort parameter to bool. Additional code cleanup. 2013-01-22 Arnold D. Robbins * symbol.c (get_symbols): Reset count after each loop to only sort the actual items retrieved. Thanks to Hermann Peifer (by way of Andrew Schorr) for reporting the bug. Also add some commentary and fix function name in emalloc calls. 2013-01-20 Arnold D. Robbins * re.c (regexflags2str): New routine. (resetup): If do_intervals, also turn on RE_NO_BK_BRACES. Thanks to Yan Lei for the bug report. 2013-01-18 Arnold D. Robbins Fix a problem with include ordering to get ptrdiff_t definition, showed up on Debian Lenny. Reported by Manuel Collado. Fix brought over from grep. * dfa.h: Include regex.h and stddef.h directly. * dfa.c: Adjust includes. 2013-01-11 John Haque * awk.h (do_mpfr_rshift): Renamed from do_mpfr_rhift. * awkgram.y (do_mpfr_rshift): Renamed from do_mpfr_rhift. * mpfr.c (_tz1, _tz2, _mpz1, _mpz2, mpz1, mpz2, get_bit_ops, free_bit_ops): Removed. (init_mpfr): Remove calls to mpz_init. (get_intval, free_intval): New functions. (do_mpfr_rshift, do_mpfr_lshift): Rework code. (do_mpfr_and, do_mpfr_or, do_mpfr_xor): Accept two or more arguments to match regular functions. 2013-01-11 Arnold D. Robbins * bisonfix.awk: Adjust ARGV / ARGC to force reading of standard input; apparently needed for Mac OS X. Thanks to Akim Demaille for the report. 2013-01-06 Arnold D. Robbins * io.c (redirect, two_way_open): Set the name field in the awk_input_buf_t and awk_output_buf_t structures, as needed. Thanks to Manuel Collado for the report. 2013-01-05 Arnold D. Robbins * regex_internal.h (struct re_dfa_t): Restore ifdefs around __libc_lock_define, they really were needed. Bleah. 2013-01-01 Arnold D. Robbins Sync with GLIBC regex files. * regex_internal.h (struct re_dfa_t): Remove ifdefs around __libc_lock_define since it's already defined to empty in non-LIBC case. * regexec.c (check_node_accept_bytes): Restore decl with use from GLIBC code since this is LIBC case. 2012-12-27 Arnold D. Robbins * builtin.c (do_print, do_printf): Use output_fp as default output for print/printf only if running under the debugger. Otherwise use stdout as Brian, Peter, and Al intended. 2012-12-25 Arnold D. Robbins Remove sym-constant from API after discussions with John Haque and Andy Schorr. * gawkapi.h (api_sym_constant): Removed field in API struct. (sym_constant): Remove macro. * gawkapi.c (set_constant, api_sym_update, api_sym_constant): Removed. (sym_update_real): Renamed to api_sym_update(). is_const parameter removed and code adjusted. 2012-12-24 Arnold D. Robbins * 4.0.2: Release tar ball made. 2012-12-23 John Haque * eval.c (r_get_lhs): Node_array_ref. If original is Node_var, don't assign null-string as value. * ext.c (get_argument): Node_array_ref. Check if already a scalar. 2011-12-23 John Haque * awkgram.y (is_deferred_variable): New function. (func_install): Call it. * eval.c (r_interpret): Op_push_arg. Check for uninitialized scalar. 2012-12-23 Arnold D. Robbins * awkgram.y (tokentab): Whitespace fix for "include". * builtin.c (printf_common): Do a fatal error if no args to printf() or sprintf(). 2012-12-19 Arnold D. Robbins * bootstrap.sh: Touch extension/aclocal.m4 also. Unrelated: Extend input parser API: * awk.h (IOBUF): Remove read_func pointer. * gawkapi.h (awk_input_buf_t): Move it to here. * io.c (iop_alloc, get_a_record, get_read_timeout): Adjust code. Unrelated: Make sure that variables like NF, NR, FNR are accessable correctly both through SYMTAB and through API. * gawkapi.c (api_sym_lookup): Call update_global_values(). (api_sym_lookup_scalar): Ditto. * interpret.h (Op_subscript, Op_subscript_lhs): Ditto. * main.c (update_global_values): Adjust comment. Unrelated: Fix --disable-lint so that everything compiles. * main.c (main): Move case lable inside ifdef. * awkgram.y (isnoeffect): Add ifdefs around declaration, use, and function body. Unrelated: Restore building with tcc. * awk.h (AFUNC): Move to array.c which is the only place its used. (ainit_ind, atypeof_ind, etc.): New macros for use in array.c * array.c (AFUNC): Change to use F##_ind. Works with tcc and other compilers. * configure.ac: Only add -export-dynamic flag if compiling with gcc. 2012-12-18 Andrew J. Schorr * gawkapi.c (sym_update_real): If setting a scalar variable that exists already in an undefined state with type set to Node_var_new, we must update the type to Node_var if the new value is not undefined. 2012-12-18 Arnold D. Robbins * awkgram.y (tokentab): "extension" needs to be inside ifdef DYNAMIC. Thanks to Anders Wallin for finding this. 2012-12-16 Arnold D. Robbins * debug.c (do_set_var): Fix last remaining `*assoc_lookup() = x'. 2012-12-15 Arnold D. Robbins Infrastructure Updates: * awkgram.c, command.c: Regenerated with bison 2.7. * config.guess, config.sub, depcomp: Updated from automake 1.12.6. 2012-12-09 Arnold D. Robbins Clean up BINMODE to use symbolic values. * awk.h (enum binmode_values): New enum. * eval.c (set_BINMODE): Use them. * io.c (binmode, close_rp, gawk_popen): Ditto. * main.c (main): Ditto. * builtin.c (do_system): Ditto. Unrelated: * configure.ac: Look for posix_openpt * io.c (two_way_open): Use posix_openpt if it's available. Thanks to Christian Weisgerber for the changes. Also unrelated: * regex.c: Don't include on VMS. Thanks to Anders Wallin. Also unrelated: * ext.c (is_letter, is_identifier_char): New functions. Don't use functions since those could rely on the locale. (make_builtin): Adjust test for valid name to call the new functions and return false instead of throwing a fatal error. (make_old_builtin): Adjust test for valid name to call the new function. * awk.h (is_identchar): Move from here, ... * awkgram.y (is_identchar): ... to here. This is safe, since the locale is C during parsing the program. Also unrelated: Make all checks for bitflags being set consistent in case we should wish to switch them to macro calls: * awkgram.y, builtin.c, cint_array.c, debug.c, eval.c, gawkapi.c, int_array.c, io.c, mpfr.c, node.c, profile.c, str_array.c: Fix as needed. 2012-12-07 Arnold D. Robbins * awkgram.y (tokentab): `fflush()' is now in POSIX, remove the RESX flag. This was the last use, so delete the flag. (yylex): Don't check RESX. Thanks to Nathan Weeks for helping make this happen. 2012-12-01 Arnold D. Robbins * interpret.h: For op_assign_concat, if both strings have WSTRCUR, then do the realloc() and append for the wide string too. Thanks to Janis Papanagnou for the discussion in comp.lang.awk. 2012-11-30 Arnold D. Robbins * regcomp.c, regex.c, regex_internal.h, regexec.c: Sync with GLIBC. Why not. * gawkapi.c (awk_bool_t): Change into an enum with awk_false and awk_true values. 2012-01-30 Andrew J. Schorr Further cleanups of macros in awk.h * awk.h (_r, _t): Remove declarations. (unref, m_force_string): Remove macros. (r_unref): Move declaration. (r_force_string): Remove declaration. (DEREF, force_string, force_number, unref): Now inline functions. (POP_STRING, TOP_STRING): Back to macros. * eval.c (_t): Remove definition. * main.c (_r): Remove definition. * node.c (r_force_string): Remove. 2012-11-27 Arnold D. Robbins * builtin.c (do_fflush): Make fflush() and fflush("") both flush everything. See the comment in the code. 2012-11-26 Arnold D. Robbins * awk.h (Node_old_ext_func, Op_old_ext_func): New enum values. * configure.ac: Use -export-dynamic if supported for old extension mechanism. * eval.c (nodeytpes): Add Node_old_ext_func. (optypetab): Add Op_old_ext_func. * ext.c (make_old_ext_builtin): "New" function. * interpret.h: Special case Op_old_ext_builtin. Add checks for Node_old_ext_func. * msg.c: Adjust placement of a comment. 2012-05-02 John Haque * str_array.c (str_copy): Initialize next pointer in the linked list to avoid memory corruption. * int_array.c (int_copy): Ditto. 2012-04-21 John Haque Shutdown routine for a dynamic extension. * awk.h (SRCFILE): New field fini_func. * ext.c (load_ext): Takes an additional argument to look up and save the clean up routine in SRCFILE struct. (INIT_FUNC, FINI_FUNC): Defines for default init and fini routine names. (do_ext): Use default for the name of the init or fini routine if one is not supplied. Adjust call to load_ext(). (close_extensions): Execute fini routines. * interpret.h (Op_at_exit): Call close_extensions(). * msg.c (gawk_exit): Ditto. * debug.c (close_all): Ditto. * main.c (main): Adjust call to load_ext(). * awkgram.y (tokentab): Specify 2nd and 3rd optional arguments for the extension() built-in. Unrelated: * interpret.h (Op_arrayfor_init): Use assoc_length for array size. 2012-04-19 John Haque Enhanced array interface to support transparent implementation using external storage and ... * awk.h (astore): Optional post-assignment store routine for array subscripts. (Op_subscript_assign): New opcode to support the store routine. (alength): New array interface routine for array length. (assoc_length): New macro. (assoc_empty): Renamed from array_empty. * awkgram.y (snode): Append Op_subscript_assign opcode if (g)sub variable is an array element. (mk_getline): Same for getline variable. (mk_assignment): Same if assigning to an array element. * field.c (set_element): Call store routine if needed. * builtin.c (do_match): Ditto. (do_length): Use length routine for array size. * symbol.c (print_vars): Ditto. * array.c (null_length): Default function for array length interface. (asort_actual): Call store routine if defined. (asort_actual, assoc_list): Use length routine for array size. (null_array_func): Add length and store routine entries. * str_array.c (str_array_func): Same. * cint_array.c (cint_array_func): Same. * int_array.c (int_array_func): Same. * eval.c (optypetab): Add Op_subscript_assign. * profile.c (pprint): Add case Op_subscript_assign. * interpret.h (set_array, set_idx): New variables to keep track of an array element with store routine. (Op_sub_array, Op_subscript_lhs, Op_store_sub, Op_subscript_assign): Add code to handle array store routine. * debug.c (print_symbol, print_array, cmp_val, watchpoint_triggered, initialize_watch_item): Use length routine for array size. * awk.h (assoc_kind_t): New typedef for enum assoc_list_flags. (sort_context_t): Renamed from SORT_CONTEXT. * array.c (asort_actual, assoc_sort): Adjust. * cint_array.c (cint_list, tree_list, leaf_list): Adjust. * int_array.c (int_list): Adjust. * str_array.c (str_list): Adjust. 2012-04-18 John Haque * awk.h (atypeof, AFUNC): New macros. (afunc_t): Renamed typedef from array_ptr. * array.c (register_array_func, null_lookup): Use AFUNC macro instead of hard-coded index for array functions. (asort_actual): Unref null array elements before overwriting. (force_array): Renamed from get_array. (null_array): Renamed from init_array. Also initialize flags to 0. (array_types): Renamed from atypes. (num_array_types): Renamed from num_atypes. * interpret.h (r_interpret): In case Op_sub_array, unref null array element. * str_array.c (str_array_init): Reworked for (re)initialization of array. * int_array.c (int_array_init): Ditto. * cint_array.c (cint_array_init): Ditto. 2012-11-24 Arnold D. Robbins Directory cleanup. * TODO.xgawk, FUTURES: Merged into TODO. * TODO: More stuff added. * Makefile.am (EXTRA_DIST): Updated. 2012-11-22 Arnold D. Robbins Cleanup of awk.h. * array.c (r_in_array): Removed. * awk.h (MALLOC_ARG_T): Replaced with size_t everywhere. (S_ISREG, setsid): Moved to io.c. (__extension__): Removed. (INT32_BIT): Moved to cint_array.c. (_t): Always declare. (DO_LINT_INVALID, et al): Moved into an enum. (POP_ARRAY, POP_PARAM, POP_SCALAR, TOP_SCALAR, dupnode, in_array): Moved into inline functions. (force_number, force_string): Simplified. (ZOS_USS): Remove undef of DYNAMIC, it's handled in configure.ac. * io.c (S_ISREG, setsid): Moved to here. * cint_array.c (INT32_BIT): Moved to here. * eval.c (_t): Always define. * protos.h: Use size_t directly instead of MALLOC_ARG_T. Unrelated: * gawkapi.h: Add `awk_' prefix to structure tags where they were missing. Document the full list of include files needed. 2012-11-14 Arnold D. Robbins * io.c (do_find_source): On VMS, don't add the `/' separater. Thanks to Anders Wallin. MPFR minor cleanup: * awk.h (mpfr_unset): Declare new function. * mpfr.c (mpfr_unset): New function. * node.c (r_unref): Call it instead of inline code. * gawk_api.c (api_sym_update_scalar): Call it instead of inline code. 2012-11-13 Arnold D. Robbins * symbol.c (get_symbols): Check type, not vname. Keeps valgrind happy. Thanks to Andrew Schorr for noticing the problem. 2012-11-10 Arnold D. Robbins * Update to bison 2.6.5. Various files regenerated. * io.c (find_source): Add a default value for SHLIBEXT. (read_with_timeout): For VMS also, just use read(). 2012-11-10 John Haque * int_array.c (int_copy): Initialize next pointer of newchain to null. * eval.c (eval_condition): Force string context for an integer used as array index. 2012-11-10 Arnold D. Robbins * gawkapi.c (api_add_ext_func, api_awk_atexit, api_clear_array, api_create_array, api_create_value, api_register_ext_version, api_release_value, api_update_ERRNO_string, node_to_awk_value, remove_element, run_ext_exit_handlers): Add null pointer checks. Everywhere: Add / fixup leading comments. * interpret.h (Op_store_sub): If assigning to an unitialized variable through SYMTAB, change it to Node_var. Add explanatory comments. * symbol.c (get_symbol): Rationalized. Skip non-variables in SYMTAB. 2012-11-04 Arnold D. Robbins * gawkapi.h: Minor documentation edit. 2012-10-31 Arnold D. Robbins * awkgram.y (want_regexp): Use as a bool, not as an int. * field.c: Fix a comment. * gawkapi.h: Add comment to include . * symbol.c (load_symbols): ``No automatic aggregate initialization.'' Here too. Sigh again. * gawkapi.h: Minor documentation edits. 2012-11-27 Arnold D. Robbins * builtin.c (do_fflush): Make fflush() and fflush("") both flush everything. See the comment in the code. 2012-10-28 Arnold D. Robbins * Update to bison 2.6.4. Various files regenerated. 2012-10-27 Arnold D. Robbins * gawkapi.h: Continuing the minor formatting / doc cleanups. 2012-10-26 Arnold D. Robbins * gawkapi.h: Continuing the minor formatting / doc cleanups. 2012-10-24 Arnold D. Robbins * gawkapi.h: Still more minor formatting / doc cleanups. 2012-10-23 Arnold D. Robbins * gawkapi.h: More minor formatting / doc cleanups. 2012-10-21 Arnold D. Robbins Fixes for z/OS from Dave Pitts. * awk.h (assoc_list_flags): No trailing comma on last enum value. * gawkapi.h (awk_valtype_t): Ditto. * symbol.c (lookup): ``No automatic aggregate initialization.'' Sigh. Unrelated: * gawkapi.h: Minor formatting / doc cleanups. 2012-10-19 Arnold D. Robbins If SYMTAB is used, make sure ENVIRON and PROCINFO get loaded too. * awkgram.y (process_deferred): New function. Call it when program is completely parsed. (symtab_used): New variable. (variable): Set it to true if SYMTAB is looked up. * main.c (load_environ, load_procinfo): Make sure the routines are only called once. Unrelated fixes: * awkgram.y (yylex): Check continue_allowed and break_allowed as soon as they are seen in the scanner; the rules that check them can not be reduced until after a token that allows them is seen, leading to errors at execution time. * interpret.h (Op_K_break, Op_K_continue, Op_jmp): Add asssertion that pc->target_jmp is not NULL. * symbol.c (lookup): Correct a comment. 2012-10-14 Arnold D. Robbins * gawkapi.h (IOBUF_PUBLIC): Renamed awk_input_buf_t. (struct iobuf_public): Renamed struct awk_input. * awk.h: Adjust. 2012-10-13 Arnold D. Robbins * Update to Automake 1.12.4. Various files regenerated. 2012-10-11 Arnold D. Robbins * awk.h (dup_ent): New member for Node_param_list. * symbol.c (install): For parameters, if this is a duplicate, chain it off the original using the dup_ent pointer. (remove_params): If there's a duplicate, remove it from the list. * awk.h: Fix flags to have unique numeric values. Oops. 2012-10-10 Arnold D. Robbins * gawkapi.h: Add considerably more documentation. Rearrange order of functions in the struct to make more sense, grouping related functions together in a more logical order. * gawkapi.c: Adjust as needed. * ext.c (make_builtin): Adjust for name change in struct member. 2012-10-05 Arnold D. Robbins * mbsupport.h: Add a bunch of undefs for z/OS. 2012-10-04 Arnold D. Robbins * TODO.xgawk: Update. * awk.h (make_str_node): Removed macro. (make_string): Modified to call make_str_node. (r_make_str_node): Renamed to make_str_node. * gawkapi.c: Changed r_make_str_node to make_str_node everywhere. * node.c (make_str_node): Renamed from make_str_node. Update to automake 1.12.4. * Makefile.in, aclocal.m4, awklib/Makefile.in, doc/Makefile.in, extension/Makefile.in, extension/aclocal.m4, test/Makefile.in: Regenerated. * interpret.h (Op_Subscript): Added lint warnings for FUNCTAB and SYMTAB. 2012-10-02 Arnold D. Robbins * awk.h (func_table): Declare. * awkgram.y: If do_posix or do_traditional, then check for delete on SYMTAB. Add check for delete on FUNCTAB, also. * interpret.h (Op_Subscript): For FUNCTAB, return the element name as its value too. Avoids lots of weirdness and allows indirect calls after assignment from FUNCTAB["foo"] to work. (Op_store_sub): Disallow assignment to elements of FUNCTAB. (Op_indirect_func_all): Turn assert into check and fatal error. * symbol.c (func_table): No longer static. (lookup): If do_posix or do_traditional, skip the global table. (release_all_vars): Clear func_table too. 2012-09-25 Arnold D. Robbins First cut at SYMTAB and FUNCTAB. This does the following: - Change symbol table handling to use gawk arrays. - Store symbols in SYMTAB array and allow indirect access through SYMTAB to variables, both getting and setting. - List function names in FUNCTAB indexes; Values cannot be used at the moment. - No documentation yet. * awk.h (Node_hashnode, hnext, hname, hlength, hcode, hvalue): Removed, not needed any more. (init_symbol_table, symbol_table): Add declarations. * awkgram.y: Disallow delete on SYMTAB, fix warning for tawk extension if traditional. * eval.c (nodetypes): Remove Node_hashnode element. * interpret.h (Op_subscript, Op_store_sub): Handle SYMTAB and go through to the actual value. * main.c (main): Init Nnull_string earlier. Add call to init_symbol_table(). * profile.c (pp_str, pp_len): Change definitions. (pp_next): New macro. (pp_push, pp_pop): Adjust uses. * symbol.c (variables): Removed. (global_table, param_table, func_table, symbol_table, installing_specials): New variables. (lookup, make_params, install_params, remove_params, remove_symbol, make_symbol, install, get_symbols, release_all_vars, append_symbol, release_symbols, load_symbols): Rework logic considerably. (init_symbol_table): New function. 2012-09-23 Arnold D. Robbins `delete array' and `nextfile' are now in POSIX. Thanks to Nathan Weeks for the initiative and letting us know about it. * awkgram.y: Make the right code changes for `delete array' and `nextfile'. (tokentab): Set flags to zero for nextfile. 2012-09-19 Arnold D. Robbins * symbol.c (load_symbols): Zero out the new node. Prevents assertion failure on PPC Mac OS X. 2012-09-14 Arnold D. Robbins Allow read-only access to built-in variables from extensions. * awk.h (NO_EXT_SET): New flag. * gawkapi.c (api_sym_lookup, api_sym_update_real): Set flag if off limits variable instead of failing. Adjust logic. (api_sym_update_scalar, api_set_array_element, api_del_array_element, api_release_flattened_array): Adjust logic. * gawkapi.h: Adjust documentation. Provide PROCINFO["identifiers"]. Undocumented for now. * awk.h (load_symbols): Add declaration. * awkgram.y (variable): Adjust comment formatting. * main.c (main): Call load_symbols(). * symbol.c (load_symbols): New function. 2012-09-13 Arnold D. Robbins * configure.ac: Determination of DYNAMIC adjusted. Hopefully is smarter for z/OS. 2012-09-13 Dave Pitts * awk.h: Add defines for z/OS for newer types. 2012-08-31 Arnold D. Robbins * gawkapi.c: Wrap various bits in #ifdef DYNAMIC so that gawk will compile on systems without dynamic loading. 2012-08-24 Arnold D. Robbins Add version facility to API. Thanks to Manuel Collado for the idea. * awk.h (print_ext_versions): Declare. Rearrange includes and decls to make more sense. * gawkapi.h (register_ext_version): New API. (dl_load_func): Add code for ext_version. * gawkapi.c (api_register_ext_version, print_ext_versions): New functions. * main.c (do_version): New variable. (optab): Set it for -v / --version. (main): Set it in arg parsing switch. Call version() after the extensions have been loaded. 2012-08-22 Arnold D. Robbins Add output wrapper and two-way processor to extension API. * awk.h (struct redirect): Replace output FILE * with awk_output_buf_t. (register_output_wrapper, register_two_way_processor): Declare. * builtin.c (efwrite): Adjust logic to use rp->output data and functions if rp is not NULL. Remove redundant declaration of function. (do_fflush, do_printf, do_print, do_print_rec): Same adjustment. * ext.c (make_builtin): Adjust error messages. * gawkapi.c (api_register_output_wrapper, api_register_two_way_processor): New functions. (sym_update_real): Adjust code formatting. * gawkapi.h (awk_input_parser_t): Make next pointer awk_const. (awk_output_buf_t, awk_two_way_processor_t): New structs. (api_register_output_wrapper, api_register_two_way_processor): New APIs. (dl_load_func): Allow for empty function table (NULL elements). * io.c (find_output_wrapper, init_output_wrapper, find_two_processor, gawk_fwrite, gawk_ferror, gawk_fflush, gawk_fclose): New functions. (redirect): Call init_output_wrapper, find_output_wrapper as needed. Adjust use of rp->fp to rp->output.fp and also function calls. (close_rp, close_redir, flush_io): Same adjustment. (two_way_open): Same adjustment. Call find_two_way_processor, and find_output_wrapper, as needed. 2012-08-17 Arnold D. Robbins * Update infrastructure: Automake 1.12.3 and bison 2.6.2. 2012-08-15 Arnold D. Robbins * dfa.c: Sync w/GNU grep. 2012-08-12 Arnold D. Robbins * gawkapi.h: Make the versions enum constants instead of defines. 2012-08-11 Andrew J. Schorr * awkgram.y (add_srcfile): It is now a fatal error to load the same file with -f and -i (or @include). * TODO.xgawk: Update to reflect this change. 2012-08-10 Arnold D. Robbins * FUTURES, TODO.xgawk: Updates. 2012-08-08 Arnold D. Robbins * configure.ac: Add -DNDEBUG to remove asserts if not developing. * gawkapi.h: Document how to build up arrays. * gawkapi.c (api_sym_update): For an array, pass the new cookie back out to the extension. * awk.h (IOBUF): Move struct stat into IOBUF_PUBLIC. (os_isreadable): Change to take an IOBUF_PUBLIC. * gawkapi.h (IOBUF_PUBLIC): Received struct stat. (INVALID_HANDLE): Moves to here. * io.c (iop_alloc): Stat the fd and fill in stat buf. (iop_finish): Use passed in stat info. 2012-08-05 Arnold D. Robbins * README.git: More stuff added. 2012-08-01 Arnold D. Robbins * io.c (iop_finish): New function. (iop_alloc): Add errno_val parameter. Move code into iop_finish. Add large explanatory leading comment. (after_beginfile): Rework logic. Check for input parser first, then check for invalid iop. (nextfile): Organize code better. Call iop_alloc then iop_finish. (redirect): Call iop_alloc, find_input_parser, iop_finish. (two_way_open): Call iop_alloc, find_input_parser, iop_finish. (gawk_popen): Call iop_alloc, find_input_parser, iop_finish. (find_input_parser): Set iop->valid if input parser takes control. (get_a_record): Rework setting RT to use macros. 2012-07-29 Andrew J. Schorr * awk.h (set_RT_to_null, set_RT): Removed. * gawkapi.h (api_set_RT): Removed. (get_record): Signature changed in input parser struct. * gawkapi.c (api_set_RT): Removed. * io.c (set_RT_to_null, set_RT): Removed. (get_a_record): Adjustments for new API for input parser. 2012-07-29 Arnold D. Robbins * awk.h (os_isreadable): Adjust declaration. (struct iobuf): Add new member `valid'. * io.c (iop_alloc): Remove do_input_parsers parameter, it's always true. Adjust logic to set things to invalid if could not find an input parser. (after_beginfile): Use valid member to check if iobuf is valid. Don't clear iop->errcode. (nextfile): Adjust logic to clear errcode if valid is true and also to update ERRNO. (redirect): Check iop->valid and cleanup as necessary, including setting ERRNO. (two_way_open): Ditto. (gawk_popen): Ditto. (devopen): Remove check for directory. 2012-07-27 Andrew J. Schorr * io.c (find_input_parser): Issue a warning if take_control_of fails. 2012-07-27 Arnold D. Robbins * awk.h (set_RT): Change to take a NODE * parameter. * io.c (set_RT): Change to take a NODE * parameter. * gawkapi.h: Change open hook to input parser in comment. * gawkapi.c (api_set_RT): Adjust call to set_RT. 2012-07-26 Arnold D. Robbins * awk.h (set_RT_to_null, set_RT): Declare functions. (os_isreadable): Declare function. * io.c (set_RT_to_null, set_RT): New functions. (iop_close): Init ret to zero. * gawkapi.c (api_register_input_parser): Check for null pointer. (api_set_RT): New function. * gawkapi.h (api_set_RT): New function. 2012-07-26 Andrew J. Schorr * gawkapi.h (IOBUF_PUBLIC): Document the get_record and close_func API. (awk_input_parser_t) Change can_take_file argument to const, and document the API. * io.c (get_a_record): Document that the caller initializes *errcode to 0, and remote the test for non-NULL errcode. 2012-07-26 Andrew J. Schorr * gawkapi.c (api_sym_update_scalar): Fix some minor bugs. Was not updating AWK_NUMBER when valref != 1. And strings were not freeing MPFR values. 2012-07-25 Arnold D. Robbins Start refactoring of IOBUF handling and turn "open hooks" into "input parsers". * awk.h (IOP_NOFREE_OBJ): Flag removed. (register_input_parser): Renamed from register_open_hook. * ext.c (load_ext): Make sure lib_name is not NULL. * gawk_api.c (api_register_input_parser): Renamed from api_register_open_hook. * gawk_api.h (api_register_input_parser): Renamed from api_register_open_hook. Rework structure to have "do you want it" and "take control of it" functions. * io.c (iop_alloc): Remove third argument which is IOBUF pointer. Always malloc it. Remove use of IOP_NOFREE_OBJ everywhere. (find_input_parser): Renamed from find_open_hook. (nextfile): Don't use static IOBUF. (iop_close): Call close_func first. Then close fd or remap it if it's still not INVALID_HANDLE. (register_input_parser): Renamed from register_open_hook. Use a FIFO list and check if more than one parser will accept the file. If so, fatal error. 2012-07-25 Andrew J. Schorr * configure.ac: Instead of using acl_shlibext for the shared library extension, define our own variable GAWKLIBEXT with a hack to work correctly on Mac OS X. * Makefile.am (SHLIBEXT): Use the value of GAWKLIBEXT instead of acl_shlibext. 2012-07-24 Arnold D. Robbins * configure.ac: Add crude but small hack to make plug-ins work on Mac OS X. 2012-07-20 Arnold D. Robbins * gawkapi.h: Rework table to not take up so much space. * gawkapi.c (api_sym_update_scalar): Rework optimization code to clean up the function. 2012-07-17 Andrew J. Schorr * gawkapi.h: Add comments explaining new api_create_value and api_release_value functions. * gawkapi.c (sym_update_real): Allow updates with AWK_SCALAR and AWK_VALUE_COOKIE types. After creating a regular variable, remove the call to unref(node->var_value), since this is not done elsewhere in the code (see, for example, main.c:init_vars). If the update is for an existing variable, allow any val_type except AWK_ARRAY (was previously disallowing AWK_SCALAR and AWK_VALUE_COOKIE for no apparent reason). (api_sym_update_scalar): The switch should return false for an invalid val_type value, so change the AWK_ARRAY case to default. (valid_subscript_type): Any scalar value is good, so accept any valid type except AWK_ARRAY. (api_create_value): Accept only AWK_NUMBER and AWK_STRING values. Anything else should fail. 2012-07-17 Arnold D. Robbins Speedup: * awk.h (r_free_wstr): Renamed from free_wstr. (free_wstr): Macro to test the WSTRCUR flag first. * node.c (r_free_wstr): Renamed from free_wstr. Support value cookies: * gawkapi.h (awk_val_type_t): Add AWK_VALUE_COOKIE. (awk_value_cookie_t): New type. (awk_value_t): Support AWK_VALUE_COOKIE. (api_create_value, api_release_value): New function pointers. * gawkapi.c (awk_value_to_node, api_sym_update_scalar, valid_subscript_type): Handle AWK_VALUE_COOKIE. (api_create_value, api_release_value): New functions. 2012-07-16 Arnold D. Robbins * gawkapi.c (awk_value_to_node): Support AWK_SCALAR. (api_sym_update_scalar): Performance improvements. 2012-07-12 Arnold D. Robbins Allow creation of constants. Thanks to John Haque for the implementation concept. * gawk_api.h (api_sym_constant): Create a constant. * gawk_api.h (api_sym_update_real): Renamed from api_sym_update. Add is_const paramater and do the right thing if true. (api_sym_update, api_sym_constant): Call api_sym_update_real in the correct way. (set_constant): New function. 2012-07-11 Andrew J. Schorr * gawkapi.h: Fix typo in comment. (awk_value_t): Type for scalar_cookie should be awk_scalar_t, not awk_array_t. (gawk_api): Add new api_sym_lookup_scalar function. (sym_lookup_scalar): New wrapper macro for api_sym_lookup_scalar hook. * gawkapi.c (api_sym_lookup_scalar): New function for faster scalar lookup. (api_impl): Add entry for api_sym_lookup_scalar. 2012-07-11 Andrew J. Schorr * gawkapi.c (awk_value_to_node): Change to a switch statement so AWK_SCALAR or other invalid type is handled properly. (valid_subscript_type): Test whether a value type is acceptable for use as an array subscript (any scalar value will do). (api_get_array_element, api_set_array_element, api_del_array_element): Use new valid_subscript_type instead of restricting to string values. 2012-07-11 Arnold D. Robbins Lots of API work. * gawkapi.h: Function pointer members renamed api_XXXX and macros adjusted. More documentation. (awk_valtype_t): New AWK_SCALAR enum for scalar cookies. (awk_scalar_t): New type. (awk_value_t): New member scalar_cookie. (api_sym_update_scalar): New API function. (erealloc): New macro. (make_const_string): New macro, renamed from dup_string. (make_malloced_string): New macro, renamed from make_string. (make_null_string): New inline function. (dl_load_func): Add call to init routine through pointer if not NULL. * gawkapi.c (awk_value_to_node): Assume that string values came from malloc. (node_to_awk_value): Handle AWK_SCALAR. (api_sym_update): Ditto. (api_sym_update_scalar): New routine. (api_get_array_element): Return false if the element doesn't exist. Always unref the subscript. (remove_element): New helper routine. (api_del_array_element): Use it. (api_release_flattened_array): Ditto. (api_impl): Add the new routine. 2012-07-11 Andrew J. Schorr * gawkapi.c (api_sym_update): Allow val_type to be AWK_UNDEFINED for setting a variable to "", i.e. dupnode(Nnull_string). 2012-07-10 Andrew J. Schorr * awkgram.y (add_srcfile): Lint warning message for a previously loaded shared library should say "already loaded shared library" instead of "already included source file". 2012-07-08 Arnold D. Robbins * gawkapi.h (set_array_element): Use index + value instead of element structure. Matches get_array_element. (set_array_element_by_elem): New macro to use an element. * gawkapi.c (api_set_array_element): Make the necessary adjustments. 2012-07-04 Arnold D. Robbins * awkgram.y (tokentab): Remove limit on number of arguments for "and", "or", and "xor". * builtin.c (do_and, do_or, do_xor): Modify code to perform the respective operation on any number of arguments. There must be at least two. 2012-06-29 Arnold D. Robbins * gawkapi.h: Improve the documentation of the return values per Andrew Schorr. 2012-06-25 Arnold D. Robbins * TODO.xgawk: Updated. * awk.h (track_ext_func): Declared. * awkgram.y (enum defref): Add option for extension function. (struct fdesc): Add member for extension function. (func_use): Handle extension function, mark as extension and defined. (track_ext_func): New function. (check_funcs): Update logic for extension functions. * ext.c (make_builtin): Call track_ext_func. 2012-06-24 Andrew J. Schorr * TODO.xgawk: Most of IOBUF has been hidden. * gawkapi.h (IOBUF): Remove declaration (now back in awk.h). (IOBUF_PUBLIC): Declare new structure defining subset of IOBUF fields that should be exposed to extensions. (gawk_api): Update register_open_hook argument from IOBUF to IOBUF_PUBLIC. * awk.h (IOBUF): Restore declaration with 5 fields moved to new IOBUF_PUBLIC structure. (register_open_hook): Update open_func argument from IOBUF to IOBUF_PUBLIC. * gawkapi.c (api_register_open_hook): Ditto. * io.c (after_beginfile, nextfile, iop_close, gawk_pclose): Some fields such as fd and name are now inside the IOBUF public structure. (struct open_hook): Update open_func argument from IOBUF to (register_open_hook): Ditto. (find_open_hook): opaque now inside IOBUF_PUBLIC. (iop_alloc): fd and name now in IOBUF_PUBLIC. (get_a_record): If the get_record hook returns EOF, set the IOP_AT_EOF flag. Access fd inside IOBUF_PUBLIC. (get_read_timeout): File name now inside IOBUF_PUBLIC. * interpret.h (r_interpret): File name now inside IOBUF_PUBLIC. * ext.c (load_ext): No need to call return at the end of a void function. 2012-06-24 Arnold D. Robbins * ext.c (load_ext): Don't retun a value from a void function. * gawkapi.c (api_set_array_element): Set up vname and parent_array. 2012-06-21 Arnold D. Robbins More API and cleanup: * awk.h (stopme): Make signature match other built-ins. * awkgram.y (stopme): Make signature match other built-ins. (regexp): Minor edit. * gawkapi.c (api_set_argument): Remove unused variable. Set parent_array field of array value. * TODO.xgawk: Update some. Remove extension() builtin. * awk.h (do_ext): Removed. (load_ext): Signature changed. * awkgram.y (tokentab): Remove do_ext. Change calls to do_ext. * ext.c (load_ext): Make init function a constant. * main.c (main): Change calls to do_ext. 2012-06-20 Arnold D. Robbins Restore lost debugging function: * awkgram.y (stopme): Restore long lost debugging function. * awk.h (stopme): Add declaration. API work: * ext.c (get_argument): Make extern. * awk.h (get_argument): Declare it. * gawkapi.c (api_set_argument): Call it. Finish off the logic. (api_get_argument): Refine logic to use get_argument. * gawkapi.h (set_argument): New API. 2012-06-19 Arnold D. Robbins Remove code duplication in gawkapi.c from msg.c: * awk.h (err): Add `isfatal' first parameter. * awkgram.y (err): Adjust all calls. * msg.c (err): Adjust all calls. Move fatal code to here ... (r_fatal): From here. * gawkapi.c: Remove code duplication and adjust calls to `err'. Handle deleting elements of flattened array: * awk.h (get_argument): Remove declaration. * ext.c (get_argument): Make static. * gawkapi.h (awk_flat_array_t): Make opaque fields const. Add more descriptive comments. * gawkapi.c (release_flattened_array): Delete elements flagged for deletion. Free the flattened array also. Add additional debugging when developing: * configure.ac: Add additional debugging flags. * configure: Regenerated. 2012-06-18 Arnold D. Robbins * gawkapi.h (get_array_element): Restore `wanted' paramater. (awk_element_t): Use awk_value_t for index. Add awk_flat_array_t. (flatten_array): Change signature to use awk_flat_array_t; (release_flattened_array): Change signature to use awk_flat_array_t; * gawkapi.c (api_sym_update): Handle case where variable exists already. (api_get_array_element): Restore `wanted' paramater and pass it on to node_to_awk_value. (api_set_array_element): Revisse to match changed element type. (api_flatten_array): Revise signature, implement. (api_release_flattened_array): Revise signature, implement. 2012-06-17 Arnold D. Robbins API Work: * gawkapi.h (get_array_element): Remove `wanted' parameter. (r_make_string): Comment the need for `api' and `ext_id' parameters. * gawkapi.c (api_sym_update): Move checks to front. Initial code for handling arrays. Still needs work. (api_get_array_element): Implemented. (api_set_array_element): Additional checking code. (api_del_array_element): Implemented. (api_create_array): Implemented. (init_ext_api): Force do_xxx values to be 1 or 0. (update_ext_api): Ditto. 2012-06-12 Arnold D. Robbins API Work: * gawkapi.h (awk_value_t): Restore union. (get_curfunc_param): Renamed to get_argument. Return type changed to awk_bool_t. Semantics better thought out and documented. (awk_atexit, get_array_element): Return type now void. (sym_lookup): Return type now void. Argument order rationalized. * gawkapi.c (node_to_awk_value): Return type is now awk_bool_t. Semantics now match table in gawkawpi.h. (api_awk_atexit): Return type now void. (api_sym_lookup): Return type is now awk_bool_t. Change parameter order. (api_get_array_element): Return type is now awk_bool_t. Further API implementations and fixes for extension/testext.c: * awk.h (final_exit): Add declaration. * ext.c (load_ext): Change `func' to install_func. * gawkapi.c: Add casts to void for id param in all functions. (api_sym_update): Finish implementation. (api_get_array_element): Start implementation. (api_set_array_element): Add error checking. (api_get_element_count): Add error checking, return the right value. * main.c (main): Call final_exit instead of exit. (arg_assign): Ditto. * msg.c (final_exit): New routine to run the exit handlers and exit. (gawk_exit): Call it. * profile.c (dump_and_exit): Ditto. 2012-06-10 Andrew J. Schorr * TODO.xgawk: Addition of time extension moved to "done" section. 2012-06-10 Andrew J. Schorr * gawkapi.c (api_update_ERRNO_string): Treat boolean true as a request for TRANSLATE, and false as DONT_TRANSLATE. 2012-06-06 Arnold D. Robbins * cint_array.c (tree_print, leaf_print): Add additional casts for printf warnings. * awk.h (update_ext_api): Add declaration. * gawkapi.c (update_ext_api): New function. * eval.c (set_LINT): Call update_ext_api() at the end. * gawkapi.h: Document that do_XXX could change on the fly. * awk.h (run_ext_exit_handlers): Add declaration. * msg.c (gawk_exit): Call it. 2012-06-05 Arnold D. Robbins * ext.c (load_ext): Remove use of RTLD_GLOBAL. Not needed in new scheme. Clean up error messages. 2012-06-04 Arnold D. Robbins * configure.ac: Remove use of -export-dynamic for GCC. * configure: Regenerated. 2012-05-30 Arnold D. Robbins * main.c (is_off_limits_var): Minor coding style edit. * gawkapi.c (awk_value_to_node): More cleanup. (node_to_awk_value): Use `wanted' for decision making. (api_sym_update): Start implementation. Needs more work. General: More cleanup, comments. * gawkapi.h (api_sym_update): Add additional comments. 2012-05-29 Arnold D. Robbins * gawkapi.c (node_to_awk_value): Add third parameter indicating type of value desired. Based on that, do force_string or force_number to get the "other" type. (awk_value_to_node): Clean up the code a bit. (get_curfunc_param): Move forcing of values into node_to_awk_value. (api_sym_lookup): Add third parameter indicating type of value wanted. (api_get_array_element): Ditto. * gawk_api.h: Additional comments and clarifications. Revise APIs to take third 'wanted' argument as above. (awk_value_t): No longer a union so that both values may be accessed. All macros: Parenthesized the bodies. * bootstrap.sh: Rationalize a bit. 2012-05-26 Andrew J. Schorr * Makefile.am (include_HEADERS): Add so gawkapi.h will be installed. (base_sources): Add gawkapi.h so that it is in dist tarball. * TODO.xgawk: Update. * main.c (is_off_limits_var): Stop returning true for everything except PROCINFO. 2012-05-25 Arnold D. Robbins * main.c (is_off_limits_var): New function to check if a variable is one that an extension function may not change. * awk.h (is_off_limits_var): Declare it. * gawkapi.c (api_sym_lookup): Use it. * bootstrap.sh: Touch various files in the extension directory also. 2012-05-24 Andrew J. Schorr * gawkapi.h (awk_param_type_t): Remove (use awk_valtype_t instead). (awk_ext_func_t): Pass a result argument, and return an awk_value_t *. (gawk_api.get_curfunc_param): Add a result argument. (gawk_api.set_return_value): Remove obsolete function. (gawk_api.sym_lookup, gawk_api.get_array_element): Add a result argument. (gawk_api.api_make_string, gawk_api.api_make_number): Remove hooks, since access to gawk internal state is not required to do this. (set_return_value): Remove obsolete macro. (get_curfunc_param, sym_lookup, get_array_element): Add result argument. (r_make_string, make_number): New static inline functions. (make_string, dup_string): Revise macro definitions. (dl_load_func): Remove global_api_p and global_ext_id args, and fix SEGV by setting api prior to checking its version members. (GAWK): Expand ifdef to include more stuff. * gawkapi.c (node_to_awk_value): Add result argument. (api_get_curfunc_param): Add result argument, and use awk_valtype_t. (api_set_return_value): Remove obsolete function. (awk_value_to_node): New global function to convert back into internal format. (api_add_ext_func): Simply call make_builtin. (node_to_awk_value): Add result argument, and handle Node_val case. (api_sym_lookup, api_get_array_element): Add result argument. (api_set_array_element): Implement. (api_make_string, api_make_number): Remove functions that belong on client side. (api_impl): Remove 3 obsolete entries. * TODO.xgawk: Update to reflect progress. * Makefile.am (base_sources): Add gawkapi.c. * awk.h: Include gawkapi.h earlier. (api_impl, init_ext_api, awk_value_to_node): Add declarations so we can hook in new API. (INSTRUCTION): Add new union type efptr for external functions. (extfunc): New define for d.efptr. (load_ext): Remove 3rd obj argument that was never used for anything. (make_builtin): Change signature for new API. * awkgram.y (load_library): Change 2nd argument to load_ext from dlload to dl_load, and remove pointless 3rd argument. * main.c (main): Call init_ext_api() before loading shared libraries. Change 2nd argument to load_ext from dlload to dl_load, and remove pointless 3rd argument. * ext.c (do_ext): Remove pointless 3rd argument to load_ext. (load_ext): Remove 3rd argument. Port to new API (change initialization function signature). If initialization function fails, issue a warning and return -1, else return 0. (make_builtin): Port to new API. * interpret.h (r_interpret): For Op_ext_builtin, call external functions with an awk_value_t result buffer, and convert the returned value to a NODE *. For Node_ext_func, code now in extfunc instead of builtin. 2012-05-21 Andrew J. Schorr * configure.ac: Remove libtool, and call configure in the extension subdirectory. Change pkgextensiondir to remove the version number, since the new API has builtin version checks. * TODO.xgawk: Update. * ltmain.sh: Removed, since libtool no longer used here. 2012-05-19 Andrew J. Schorr * TODO.xgawk: Update to reflect progress and new issues. * main.c (main): Add -i (--include) option. (usage): Ditto. * awkgram.y (add_srcfile): Eliminate duplicates only for SRC_INC and SRC_EXTLIB sources (i.e. -f duplicates should not be removed). * io.c (find_source): Set DEFAULT_FILETYPE to ".awk" if not defined elsewhere. 2012-05-15 Arnold D. Robbins * awk.h: Include "gawkapi.h" to get IOBUF. * gawkapi.h: Considerable updates. * gawkapi.c: New file. Start at implementing the APIs. 2012-05-13 Andrew J. Schorr * TODO.xgawk: Update to reflect recent discussions and deletion of extension/xreadlink.[ch]. 2012-05-11 Arnold D. Robbins Sweeping change: Use `bool', `true', and `false' everywhere. 2012-04-09 Andrew J. Schorr * eval.c (unset_ERRNO): Fix memory management bug -- need to use dupnode with Nnull_string. 2012-04-08 Andrew J. Schorr * Makefile.am (valgrind): Define VALGRIND instead of redefining AWK. This allows test/Makefile.am to set up the command environment as desired. (valgrind-noleak): Ditto, plus set --leak-check=no instead of the default summary setting. 2012-04-07 Andrew J. Schorr * TODO.xgawk: Update to reflect progress. 2012-04-01 Andrew J. Schorr * TODO.xgawk: Move valgrind-noleak item into "done" section. * Makefile.am (valgrind-noleak): Add new valgrind rule that omits the "--leak-check=full" option to help spot more serious problems. 2012-04-01 Andrew J. Schorr * TODO.xgawk: Move ERRNO item into "done" section. * awk.h (update_ERRNO, update_ERRNO_saved): Remove declarations. (update_ERRNO_int, enum errno_translate, update_ERRNO_string, unset_ERRNO): Add new declarations. * eval.c (update_ERRNO_saved): Renamed to update_ERRNO_int. (update_ERRNO_string, unset_ERRNO): New functions. * ext.c (do_ext): Use new update_ERRNO_string function. * io.c (ERRNO_node): Remove redundant extern declaration (in awk.h). (after_beginfile, nextfile): Replace update_ERRNO() with update_ERRNO_int(errno). (inrec): Replace update_ERRNO_saved with update_ERRNO_int. (do_close): Use new function update_ERRNO_string. (close_redir, do_getline_redir, do_getline): Replace update_ERRNO_saved with update_ERRNO_int. 2012-03-27 Andrew J. Schorr * TODO.xgawk: Update to reflect debate about how to support Cygwin and other platforms that cannot link shared libraries with unresolved references. * awkgram.y (add_srcfile): Minor bug fix: reverse sense of test added by Arnold in last patch. * configure.ac: AC_DISABLE_STATIC must come before AC_PROG_LIBTOOL. 2012-03-26 Arnold D. Robbins Some cleanups. * awkgram.y (add_srcfile): Use whole messages, better for translations. * io.c (init_awkpath): Small style tweak. * main.c (path_environ): Straighten out initial comment, fix compiler warning by making `val' const char *. 2012-03-25 Andrew J. Schorr * configure.ac (AC_DISABLE_STATIC): Add this to avoid building useless static extension libraries. 2012-03-25 Andrew J. Schorr * TODO.xgawk: New file listing completed and pending xgawk enhancements. 2012-03-24 Andrew J. Schorr * io.c (path_info): Fix white space. (pi_awkpath, pi_awklibpath): Avoid structure initializers. (do_find_source): Eliminate pointless parentheses. (find_source): Leave a space after "&". * main.c (load_environ): Fix typo in comment. 2012-03-21 Andrew J. Schorr * awkgram.y (LEX_LOAD): New token to support @load. (grammar): Add rules to support @load. (tokentab): Add "load". (add_srcfile): Improve error message to distinguish between source files and shared libraries. (load_library): New function to load libraries specified with @load. (yylex): Add support for LEX_LOAD (treated the same way as LEX_INCLUDE). 2012-03-20 Andrew J. Schorr * Makefile.am (EXTRA_DIST): Remove extension. (SUBDIRS): Add extension so libraries will be built. (DEFS): Define DEFLIBPATH and SHLIBEXT so we can find shared libraries. * awk.h (deflibpath): New extern declaration. * configure.ac: Add support for building shared libraries by adding AC_PROG_LIBTOOL and AC_SUBST for acl_shlibext and pkgextensiondir. (AC_CONFIG_FILES): Add extension/Makefile. * io.c (pi_awkpath, pi_awklibpath): New static structures to contain path information. (awkpath, max_pathlen): Remove static variables now inside pi_awkpath. (init_awkpath): Operate on path_info structure to support both AWKPATH and AWKLIBPATH. No need for max_path to be static, since this should be called only once for each environment variable. (do_find_source): Add a path_info arg to specify which path to search. Check the try_cwd parameter to decide whether to search the current directory (not desirable for AWKLIBPATH). (find_source): Choose appropriate path_info structure based on value of the is_extlib argument. Set EXTLIB_SUFFIX using SHLIBEXT define instead of hardcoding ".so". * main.c (path_environ): New function to add AWKPATH or AWKLIBPATH to the ENVIRON array. (load_environ): Call path_environ for AWKPATH and AWKLIBPATH. 2012-06-19 Arnold D. Robbins * main.c (main): Do setlocale to "C" if --characters-as-bytes. Thanks to "SP" for the bug report. 2012-05-09 Arnold D. Robbins * configure.ac: Added AC_HEADER_STDBOOL * awk.h, dfa.c, regex.c: Reworked to use results of test and include missing_d/gawkbool.h. 2012-05-07 Arnold D. Robbins * array.c (prnode): Add casts to void* for %p format. * debug.c (print_instruction): Ditto. * builtin.c: Fix %lf format to be %f everywhere. Unrelated: * replace.c: Don't include "config.h", awk.h gets it for us. 2012-05-04 Arnold D. Robbins * getopt.c [DJGPP]: Change to __DJGPP__. * mbsupport.h [DJGPP]: Change to __DJGPP__. Unrelated: * awk.h: Workarounds for _TANDEM_SOURCE. 2012-05-01 Arnold D. Robbins * dfa.c: Sync with GNU grep. RRI code now there, needed additional change for gawk. * configure.ac: Add check for stdbool.h. * regex.c: Add check for if not have stdbool.h, then define the bool stuff. 2012-04-27 Arnold D. Robbins * dfa.c: Sync with GNU grep. * xalloc.h (xmemdup): Added, from grep, for dfa.c. Sigh. 2012-04-27 Arnold D. Robbins Update to autoconf 2.69, automake 1.12. * INSTALL, aclocal.m4, configh.in, depcomp, install-sh, missing, mkinstalldirs, ylwrap: Updated. * configure.ac (AC_TYPE_LONG_LONG_INT, AC_TYPE_UNSIGNED_LONG_LONG_INT, AC_TYPE_INTMAX_T, AC_TYPE_UINTMAX_T): Renamed from gl_* versions. * configure: Regenerated. 2012-04-24 Arnold D. Robbins * cmd.h (dPrompt, commands_Prompt, eval_Prompt, dgawk_Prompt): Changed to dbg_prompt, commands_prompt, eval_prompt, dgawk_prompt. * debug.c: Ditto. * command.y: Ditto. Some minor whitespace and comments cleanup. 2012-04-24 Arnold D. Robbins io.c cleanup and some speedup for RS as regexp parsing. * awk.h (Regexp): New members has_meta and maybe_long. (enum redirval): Add redirect_none as value 0. (remaybelong): Remove function declaration. * awkgram.y: Use redirect_none instead of 0 for no redirect cases. * io.c (go_getline_redir): Second arg now of type enum redirval. Changed intovar into into_variable. (comments and whitespace): Lots of general cleanup. (socket_open): readle changed to read_len. (two_way_open): Add additional calls to os_close_on_exec. (rsrescan): Simplify code a bit and use RS->maybe_long. * re.c (make_regexp): Set up new members in Regexp struct. (remaybelong): Remove function. (reisstring): Simplified code. 2012-04-16 Eli Zaretskii * io.c (read_with_timeout) [__MINGW32__]: Just call the blocking 'read', as 'select' is only available for sockets. * mpfr.c (set_ROUNDMODE) [!HAVE_MPFR]: Renamed from set_RNDMODE. * main.c (load_procinfo): Declare name[] also when HAVE_MPFR is defined even though HAVE_GETGROUPS etc. are not. 2012-04-12 John Haque * array.c, awk.h, awkgram.y, builtin.c, command.y, debug.c, field.c, mpfr.c, profile.c: Change RND_MODE to ROUND_MODE. 2012-04-11 John Haque * main.c (varinit): Change RNDMODE to ROUNDMODE. 2012-04-11 Arnold D. Robbins * main.c: Change --arbitrary-precision to --bignum. 2012-04-02 John Haque Add support for arbitrary-precision arithmetic. * mpfr.c: New file. * awk.h (struct exp_node): Add union to handle different number types. (MPFN, MPZN): New flag values. (DO_MPFR, do_mpfr): New defines. (PREC_node, RNDMODE_node): Add declarations. (PRECISION, RND_MODE, MNR, MFNR, mpzval, do_ieee_fmt): Add declarations. (make_number, str2number, format_val, cmp_numbers): Ditto. (force_number): Change definition. (Func_pre_exec, Func_post_exec): New typedefs. (POP_NUMBER, TOP_NUMBER): Change definitions. (get_number_ui, get_number_si, get_number_d, get_number_uj, iszero, IEEE_FMT, mpg_float, mpg_integer, mpg_float, mpg_integer): New defines. * awkgram.y (tokentab): Add alternate function entries for MPFR/GMP. (snode): Choose the appropriate function. (negate_num): New function to negate a number. (grammar): Use it. (yylex): Adjust number handling code. * array.c (value_info, asort_actual, sort_user_func): Adjust for MPFR/GMP numbers. (do_adump, indent): Minor changes. (sort_up_index_number, sort_up_value_number, sort_up_value_type): Use cmp_numbers() for numeric comparisons. * builtin.c (mpz2mpfr): New function. (format_tree): Adjust to handle MPFR and GMP numbers. * eval.c (register_exec_hook): New function to manage interpreter hooks. (num_exec_hook, pre_execute, post_execute): New and adjusted definitions. (h_interpret): Renamed from debug_interpret. (init_interpret): Changed to use the new name. (flags2str): New entries for MPFN and MPZN. (cmp_nodes): Reworked to use seperate routine for numeric comparisons. (set_IGNORECASE, set_BINMODE, set_LINT, update_NR, update_FNR, update_NF): Adjust code and some cleanup. * field.c (rebuild_record): Field copying code reworked to handle MPFR/GMP numbers. (set_NF): Minor adjustment. * io.c (INCREMENT_REC): New macro. (inrec, do_getline): Use the new macro. (nextfile, set_NR, set_FNR, get_read_timeout, pty_vs_pipe): Adjust code to handle MPFR/GMP numbers. * interpret.h (r_interpret): Adjust TOP_NUMBER/POP_NUMBER usage. (EXEC_HOOK): New macro and definition. (DEBUGGING): Removed. * main.c (DEFAULT_PREC, DEFAULT_RNDMODE): New defines. (opttab): New entry for option arbitrary-precision. (main): Handle the new option. (usage): Add to usage message. (varinit): Add PREC and RNDMODE. (load_procinfo): Install MPFR and GMP related items. (version): Append MPFR and GMP versions to message. * msg.c (err) : Adjust FNR handling with MPFR/GMP. * node.c (r_format_val): Renamed from format_val. (r_force_number): Return NODE * instead of AWKNUM. (make_number, str2number, format_val, cmp_numpers: Defined and initialized. (r_unref): Free MPFR/MPZ numbers. (get_numbase): Renamed from isnondecimal and return the base. (cmp_awknums): New function to compare two AWKNUMs. * command.y (yylex): Adjust number handling code. (grammar): Minor adjustments to handle negative numbers. * debug.c (init_debug): New function. (do_info, do_set_var, watchpoint_triggered, serialize, initialize_watch_item, do_watch, print_watch_item): Minor adjustments. (debug_pre_execute): Adjusted to handle MPFR and GMP numbers. 2012-04-09 Arnold D. Robbins * INSTALL, config.guess, config.sub, depcomp, install-sh, missing, mkinstalldirs, ylwrap: Update to latest from automake 1.11.4. 2012-04-08 Arnold D. Robbins * Update various files to automake 1.11.4. 2012-03-30 Arnold D. Robbins * configure.ac (GAWK_AC_NORETURN): Do as macro instead of inline. 2012-03-29 Arnold D. Robbins * dfa.h, dfa.c: Sync with grep. Major cleanups and some changes there. * re.c (research): Pass size_t* to dfaexec to match type change. * configure.ac (AH_VERBATIM[_Noreturn]): Added from Paul Eggert to ease compiling. (AC_INIT): Bump version. * configure, configh.in, version.c: Regenerated. 2012-03-28 Arnold D. Robbins * 4.0.1: Release tar ball made. 2012-03-28 Arnold D. Robbins * getopt.c: Add DJGPP to list of platforms where it's ok to include . * awkgram.y, builtin.c, ext.c, mbsupport.h, re.c: Update copyright year. 2012-03-21 Corinna Vinschen * getopt.c: Add Cygwin to list of platforms where it's ok to include . 2012-03-20 Arnold D. Robbins Get new getopt to work on Linux and C90 compilers: * getopt.c: Undef ELIDE_CODE for gawk. (_getopt_internal_r): Init first.needs_free to 0. In test for -W move executable code to after declarations for C90 compilers. * getopt1.c: Undef ELIDE_CODE for gawk. Minor bug fix with printf, thanks to John Haque: * builtin.c (format_tree): Initialize base to zero at the top of the while loop. Getting next tar ball ready: * configure.ac: Remove duplicate check for wcscoll. Thanks to Stepan Kasal. 2012-03-16 Arnold D. Robbins * getopt.c, getopt.h, getopt1.c, getopt_int.h, regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, regexec.c: Sync with GLIBC, what the heck. 2012-03-14 Eli Zaretskii * mbsupport.h (btowc): Change for non-DJGPP. * re.c (dfaerror): Add call to exit for DJGPP. 2012-03-14 Arnold D. Robbins * regex_internal.c (re_string_skip_chars): Fix calculation of remain_len with m.b. chars. Thanks to Stanislav Brabec . 2012-02-28 Arnold D. Robbins * main.c (init_groupset): Make `getgroups' failing a non-fatal error. After all, what's the big deal? Should help on Plan 9. 2012-02-27 Arnold D. Robbins * dfa.c (parse_bracket_exp): Revert changes 2012-02-15 to stay in sync with grep. * dfa.h (dfarerror): Add __attribute__ from grep. 2012-02-15 Arnold D. Robbins Fix warnings from GCC 4.6.2 -Wall option. * awkgram.y (newline_eof): New function to replace body of NEWLINE_EOF macro. (yylex): Replace body of NEWLINE_EOF macro. * dfa.c (parse_bracket_exp): Init variables to zero. * ext.c (dummy, junk): Remove. * regex_internal.c (re_string_reconstruct): Remove buf array. It was set but not used. 2012-02-10 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2012-02-07 Arnold D. Robbins * main.c (main): Move init of `output_fp' to before parsing of program so that error messages from msg.c don't dump core. Thanks to Michael Haardt . 2012-01-13 Arnold D. Robbins * dfa.c [is_valid_unibtye_character]: Fix from GNU grep to bug reported by me from Scott Deifik for DJGPP. 2012-01-03 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2012-01-02 Arnold D. Robbins * io.c (Read_can_timeout, Read_timeout, Read_default_timeout): Renamed to use lower case. Other minor stylistic edits. 2012-01-01 John Haque * awk.h (struct iobuf): New entry read_func. * io.c (Read_can_timeout, Read_timeout, Read_default_timeout): New variables. (init_io): New routine to initialize the variables. (in_PROCINFO): New "clever" routine to parse elements with indices seperated by a SUPSEP. (get_read_timeout): New routine to read timeout value for an IOBUF. (read_with_timeout): New routine to read from a fd with a timeout. (pty_vs_pipe): Use in_PROCINFO(). (get_a_record): Set the timeout value and the read routine as necessary. * main.c (main): Call init_io(). 2011-12-31 Arnold D. Robbins * profile_p.c: Remove the file. * msg.c (err): Remove check for name being dgawk. 2011-12-31 Arnold D. Robbins * awk.h [STREQ, STREQN]: Remove macros. * awkgram.y, builtin.c, command.y, debug.c, eval.c, io.c, msg.c: Change all uses to call strcmp, strncmp. 2011-12-28 Arnold D. Robbins * int_array.c, str_array.c: Fix some compiler warnings 32/64 bit system differences. 2011-12-26 John Haque Merge gawk, pgawk and dgawk into a single executable gawk. * awk.h (DO_PRETTY_PRINT, DO_PROFILE, DO_DEBUG, do_pretty_print, do_debug): New defines. (interpret): New variable, a pointer to an interpreter routine. (enum exe_mode): Nuked. * main.c (opttab): New options --pretty-print and --debug; Remove option --command. (usage): Update usage messages. * interpret.h: New file. * eval.c (r_interpret): Move to the new file. (debug_interpret): New interpreter routine when debugging. (init_interpret): New routine to initialize interpreter related variables. * eval_d.c, eval_p.c: Delete files. * debug.c (interpret): Renamed to debug_prog. (DEFAULT_PROMPT, DEFAULT_HISTFILE, DEFAULT_OPTFILE): Remove prefix 'd'. * profile.c (init_profiling): Nuked. * Makefile.am: Adjusted. Add command line option --load for loading extensions. * awk.h (srctype): Add new source type SRC_EXTLIB. * ext.c(load_ext): New routine to load extension. (do_ext): Adjust to use load_ext(). * main.c (opttab): Add new option --load. (main): Call load_ext() to load extensions. (usage): Add usage message for the new option. * io.c (get_cwd): New routine. (do_find_source): Use the new routine. (find_source): Handle new type SRC_EXTLIB. * awkgram.y (parse_program, next_sourcefile): Skip type SRC_EXTLIB. (add_srcfile): Adjust call to find_source. * debug.c (source_find): Same. Unrelated: * ext.c (get_argument): Fixed argument parsing. * array.c (null_array_func): Reworked array routines for an empty array. * str_array.c, int_array.c: Make GCC happy, use %u instead of %lu printf formats. * eval.c (node_Boolean): New array for TRUE and FALSE nodes. (init_interpret): Create the new nodes. (eval_condition): Add test for the new nodes. (setup_frame): Disable tail-recursion optimization when profiling. * interpret.h (r_interpret): Use the boolean nodes instead of making new ones when needed. 2011-12-26 Arnold D. Robbins Finish Rational Range Interpretation (!) * dfa.c (match_mb_charset): Compare wide characters directly instead of using wcscoll(). * regexec.c (check_node_accept_byte): Ditto. Thanks to Paolo Bonzini for pointing these out. 2011-12-06 John Haque * debug.c (source_find): Fix misplaced call to efree. * profile.c (redir2str): Add a missing comma in the redirtab array. * eval.c (r_interpret): Disallow call to exit if currule is undefined. This avoids the possiblity of running END blocks more than once when used in a user-defined sorted-in comparision function. * array.c (sort_user_func): Adjust appropriately. 2011-12-06 Arnold D. Robbins * awk.h, mbsupport.h: Changes for MBS support on DJGPP and z/OS. * io.c: Disable pty support on z/OS. 2011-11-27 Arnold D. Robbins * dfa.c: Sync with GNU grep. * dfa.h: Add _GL_ATTRIBUTE_PURE macro. Bleah. 2011-11-14 John Haque * debug.c (set_breakpoint_at): Fix problem with setting breakpoints in a switch statement. Thanks to Giorgio Palandri for the bug report. 2011-11-14 Arnold D. Robbins * mbsupport.h: Add check for HAVE_BTOWC, per Pat Rankin. 2011-11-12 Eli Zaretskii * mbsupport.h: Additional glop for dfa.c in Windows environment. 2011-11-01 Arnold D. Robbins * dfa.c: Move glop for ! MBS_SUPPORT to ... * mbsupport.h: ... here. * replace.c: Include missing_d/wcmisc.c if ! MBS_SUPPORT. * regex_internal.h: Move include of mbsupport.h up and add additional checks to avoid inclusion of wctype.h and wchar.h. 2011-10-27 Arnold D. Robbins * builtin.c (do_strftime): Per Pat Rankin, instead of casting fclock, use a long variable and check for negative or overflow. 2011-10-25 Arnold D. Robbins Merge with gawk_performance branch done. Additionally: * cint_array.c, int_array.c, str_array.c: Fix compiler complaints about printf formats (signed / unsigned vs. %d / %u). * eval.c (setup_frame): Add a missing return value. 2011-10-25 Arnold D. Robbins * Makefile.am (dist-hook): Use `cd $(srcdir)/pc' so that `make distcheck' works completely. * builtin.c (do_strftime): Add cast to long int in check for fclock < 0 for systems where time_t is unsigned (e.g., VMS). 2011-10-25 Stefano Lattarini dist: generated file `version.c' is not removed by "make distclean" * Makefile.am (distcleancheck_listfiles): Define to ignore the generated `version.c' file. 2011-10-24 Arnold D. Robbins * dfa.c (wcscoll): Create for VMS. * Makefile.am (dist-hook): Run sed scripts to make pc/config.h. 2011-10-24 Eli Zaretskii * builtin.c [HAVE_POPEN_H]: Include "popen.h". * README.git: Update for pc/ systems. 2011-10-21 Arnold D. Robbins * Makefile.am (distcleancheck_listfiles): Added, per advice from Stefano Lattarini . * dfa.c: Additional faking of mbsupport for systems without it; mainly VMS. 2011-10-21 Stefano Lattarini * configure.ac (AM_C_PROTOTYPES): Remove call to this macro. The comments in configure.ac said that the call to AM_C_PROTOTYPES was needed for dfa.h, synced from GNU grep; but this statement is not true anymore in grep since commit v2.5.4-24-g9b5e7d4 "replace AC_CHECK_* with gnulib modules", dating back to 2009-11-26. Also, the support for automatic de-ANSI-fication has been deprecated in automake 1.11.2, and will be removed altogether in automake 1.12. * vms/vms-conf.h (PROTOTYPES, __PROTOTYPES): Remove these #define, they are not used anymore. * pc/config.h (PROTOTYPES): Likewise. 2011-10-18 Dave Pitts * dfa.c: Move some decls to the top of their functions for C90 compilers. 2011-10-18 Arnold D. Robbins * builtin.c (do_strftime): Add check for negative / overflowed time_t value with fatal error. Thanks to Hermann Peifer for the bug report. * dfa.c (setbit_wc): Non-MBS version. Add a return false since VMS compiler doesn't understand that abort doesn't return. 2011-10-10 Arnold D. Robbins * builtin.c (do_sub): Init textlen to zero to avoid "may be used unitialized" warning. Thanks to Corinna Vinschen for pointing this out. * eval.c (unwind_stack): Add parentheses around condition in while to avoid overzealous warning from GCC. 2011-09-30 Eli Zaretskii * io.c (remap_std_file): Fix non-portable code that caused redirected "print" to fail if a previous read from standard input returned EOF. Reported by David Millis . (remap_std_file): Per Eli's suggestion, removed the leading close of oldfd and will let dup2 do the close for us. 2011-10-11 John Haque * symbol.c: Add licence notice. * array.c (PREC_NUM, PREC_STR): Define as macros. 2011-10-09 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2011-10-07 John Haque Tail recursion optimization. * awkgram.y (grammar, mk_function): Recognize tail-recursive calls. * awk.h (tail_call, num_tail_calls): New defines. * eval.c (setup_frame): Reuse function call stack for tail-recursive calls. (dump_fcall_stack): Reworked. 2011-10-04 Arnold D. Robbins * awk.h, main.c (gawk_mb_cur_max): Make it a constant 1 when MBS_SUPPORT isn't available to allow GCC dead code constant expression computation and dead code elimination to help out. 2011-10-02 Arnold D. Robbins * io.c (rsnullscan, get_a_record): Fix the cases where terminators are incomplete when RS == "". Also fix the case where the new value is shorter than the old one. Based on patch from Rogier as submitted by Jeroen Schot . 2011-09-24 Arnold D. Robbins * eval.c, io.c, re.c: Fix some spelling errors. Thanks to Jeroen Schot . 2011-09-21 Arnold D. Robbins * dfa.c, mbsupport.h: Sync with GNU grep. Large amount of changes that remove many ifdefs, moving many conditions for multibyte support into regular C code and relying GCC's dead code optimization to elimnate code that won't be needed. * dfa.c: For gawk, add a number of additional defines so that things will compile if MBS_SUPPORT is 0. * array.c, awk.h, awkgram.y, builtin.c, eval.c, field.c, main.c, node.c, re.c: Change `#ifdef MBS_SUPPORT' to `#if MBS_SUPPORT'. * awk.h, regex_internal.h: Move NO_MBSUPPORT handling to ... * mbsupport.h: ...here. 2011-09-16 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2011-09-08 John Haque Optimization for compound assignment, increment and decrement operators; Avoid unref and make_number calls when there is no extra references to the value NODE. 2011-09-03 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2011-08-31 John Haque Grammar related changes: Simplify grammar for user-defined functions and general cleanups. * symbol.c: New file. * awkgram.y: Move symbol table related routines to the new file. (rule, func_name, function_prologue, param_list): Reworked. (install_function, check_params): Do all error checkings for the function name and parameters before installing in the symbol table. (mk_function): Finalize function definition. (func_install, append_param, dup_params): Nuked. * symbol.c (make_params): allocate function parameter nodes for the symbol table. Use the hash node as Node_param_list; Saves a NODE for each parameter. (install_params): Install function parameters into the symbol table. (remove_params): Remove parameters out of the symbol table. * awk.h (parmlist, FUNC): Nuked. (fparms): New define. Dynamically loaded function parameters are now handled like those for a builtin. * awk.h (Node_ext_func, Op_ext_builtin): New types. (Op_ext_func): Nuked. * ext.c (make_builtin): Simplified. (get_curfunc_arg_count): Nuked; Use the argument 'nargs' of the extension function instead. (get_argument, get_actual_argument): Adjust. * eval.c (r_interpret): Update case Op_func_call for a dynamic extension function. Handle the new opcode Op_ext_builtin. * pprint (profile.c): Adjust. Use a single variable to process gawk options. * awk.h (do_flags): New variable. (DO_LINT_INVALID, DO_LINT_ALL, DO_LINT_OLD, DO_TRADITIONAL, DO_POSIX, DO_INTL, DO_NON_DEC_DATA, DO_INTERVALS, DO_PROFILING, DO_DUMP_VARS, DO_TIDY_MEM, DO_SANDBOX): New defines. (do_traditional, do_posix, do_intervals, do_intl, do_non_decimal_data, do_profiling, do_dump_vars, do_tidy_mem, do_sandbox, do_lint, do_lint_old): Defined as macros. * main.c: Remove definitions of the do_XX variables. Add do_flags definition. * debug.c (execute_code, do_eval, parse_condition): Save do_flags before executing/parsing and restore afterwards. Nuke PERM flag. Always increment/decrement the reference count for a Node_val. Simplifies macros and avoids occassional memory leaks, specially in the debugger. * awk.h (UPREF, DEREF, dupnode, unref): Simplified. (mk_number): Nuked. * (*.c): Increment the reference count of Nnull_string before assigning as a value. Revamped array handling mechanism for more speed and less memory consumption. * awk.h (union bucket_item, BUCKET): New definitions. Used as bucket elements for the hash table implementations of arrays; 40% space saving in 32 bit x86. (buckets, nodes, array_funcs, array_base, array_capacity, xarray, alookup, aexists, aclear, aremove, alist, acopy, adump, NUM_AFUNCS): New defines. (array_empty): New macro to test for an empty array. (assoc_lookup, in_array): Defined as macros. (enum assoc_list_flags): New declaration. (Node_ahash, NUMIND): Nuked. * eval.c (r_interpret): Adjust cases Op_subscript, Op_subscript_lhs, Op_store_var and Op_arrayfor_incr. * node.c (dupnode, unref): Removed code related to Node_ahash. * str_array.c: New file to handle array with string indices. * int_array.c: New file to handle array with integer indices. * cint_array.c: New file. Special handling of arrays with (mostly) consecutive integer indices. Memory pool management reworked to handle NODE and BUCKET. * awk.h (struct block_item, BLOCK, block_id): New definitions. (getblock, freeblock): New macros. (getbucket, freebucket): New macros to allocate and deallocate a BUCKET. (getnode, freenode): Adjusted. * node.c (more_nodes): Nuked. (more_blocks): New routine to allocate blocks of memory. 2011-08-24 Arnold D. Robbins Fix pty co-process communication on Ubuntu GNU/Linux. * io.c: Add include of to get definition of TIOCSCTTY. (two_way_open): Move call for this ioctl to after setsid() call. 2011-08-23 Arnold D. Robbins * regex_internal.c (re_string_fetch_byte_case ): Remove __attribute((pure)) since it causes failures with gcc -O2 -fno-inline. Thanks to Neil Cahill for reporting the bug. 2011-08-10 John Haque BEGINFILE/ENDFILE related code redone. * awk.h (prev_frame_size, has_endfile, target_get_record, target_newfile): New defines. * awkgram.y (mk_program): Initialize has_endfile appropriately for Op_get_record. (parse_program): Initialize new jump targets for Op_get_record and Op_newfile. * eval.c (unwind_stack): Change argument to number of items to be left in the stack. Adjust code. (pop_fcall, pop_stack): New defines. (setup_frame): Initialize prev_frame_size. (exec_state, EXEC_STATE): New structure and typedef. (exec_state_stack): New variable. (push_exec_state, pop_exec_state): New functions to save and later retrieve an execution state. (r_interpret): Use the new functions and the defines in cases Op_K_getline, Op_after_beginfile, Op_after_endfile, Op_newfile and Op_K_exit. * io.c (after_beginfile): When skipping a file using nextfile, return zero in case there was an error opening the file. (has_endfile): Nuke global variable. (inrec): Add a second argument to pass errno to the calling routine. * debug.c (print_instruction): Update cases. 2011-08-10 Arnold D. Robbins Fix (apparently long-standing) problem with FIELDWIDTHS. Thanks to Johannes Meixner . * field.c (set_FIELDWIDTHS): Adjust calculations. Fix problem with FPAT, reported by "T. X. G." * awk.h (Regexp): Add new member 'non_empty'. * field.c (fpat_parse_field): Save/restore local variable non_empty from member in Regexp struct. 2011-08-09 Arnold D. Robbins Fix pty issue reported by "T. X. G." * configure.ac: Check for setsid. * awk.h: If not HAVE_SETSID define it as an empty macro. * io.c (two_way_open): Call setsid if using pty's. 2011-07-29 Eli Zaretskii * builtin.c (format_tree): Rename small -> small_flag, big -> big_flag, bigbig -> bigbig_flag. Solves compilation errors when building Gawk with libsigsegv on MS-Windows, see https://lists.gnu.org/archive/html/bug-gawk/2011-07/msg00029.html. 2011-07-28 Arnold D. Robbins * builtin.c (do_sub): Revert to gawk 3.1 behavior for backslash handling. It was stupid to think I could break compatibility. Thanks to John Ellson for raising the issue. 2011-07-26 John Haque * eval.c (r_interpret): In cases Op_var_assign and Op_field_assign, include Op_K_getline_redir in the test for skipping the routine. 2011-07-26 John Haque Fix handling of assign routines for 'getline var'. Rework the previous fix for (g)sub. * awk.h: New define assign_ctxt for use in Op_var_assign and Op_field_assign opcodes. Remove define AFTER_ASSIGN. * awkgram.y (snode, mk_getline): Initialize assign_ctxt. * builtin.c (do_sub): Adjust to take only the first two arguments. * eval.c (r_interpret): In cases Op_var_assign and Op_field_assign, skip the routine as appropriate. Adjust case Op_sub_builtin. * main.c (get_spec_varname): New function. * debug.c (print_instruction): Use the new function to get special variable name. 2011-07-17 Arnold D. Robbins * main.c (varinit): Mark FPAT as NON_STANDARD. Thanks to Wolfgang Seeberg for the report. * Makefile.am (EXTRA_DIST): Add po/README, per advice from Bruno Haible. * dfa.c: Sync with GNU grep. * xalloc.h (xzalloc): New function, from GNU grep, for dfa.c. * README: Note that bug list is really a real mailing list. 2011-07-16 Arnold D. Robbins * Makefile.am (AUTOMAKE_OPTIONS): Removed. * configure.ac (AM_INIT_AUTOMAKE): Removed dist-bzip2 option, on advice from Karl Berry. 2011-07-15 John Haque * awk.h (Op_sub_builtin): New opcode. (GSUB, GENSUB, AFTER_ASSIGN, LITERAL): New flags for Op_sub_builtin. * awkgram.y (struct tokentab): Change opcode to Op_sub_builtin for sub, gsub and gensub. (snode): Update processing of sub, gsub and gensub. * builtin.c (do_sub, do_gsub, do_gensub): Nuke. (sub_common): Renamed to do_sub. Relocate gensub argument handling code from do_gensub to here; Simplify the code a little bit. * eval.c (r_interpret): Handle Op_sub_builtin. Avoid field re-splitting or $0 rebuilding if (g)sub target string is a field and no substitutions were done. * pprint (profile.c): Add case for the new opcode. * print_instruction (debug.c): Ditto. Take out translation for errno strings; extensions will need to use their own domain. * awk.h (enum errno_translate): Removed. (update_ERRNO_string): Remove second translate paramater. * eval.c (update_ERRNO_string): Remove second translate paramater and code that used it. * gawkapi.h (api_update_ERRNO_string): Remove third translate parameter. * gawkapi.c (api_update_ERRNO_string): Remove third translate paramater and change call to update_ERRNO_string. * io.c (do_close): Fix call to update_ERRNO_string. 2011-07-15 Arnold D. Robbins * awk.h: Typo fix: "loner" --> longer. Thanks to Nelson Beebe. * builtin.c (efwrite): Fix flushing test back to what it was in 3.1.8. Thanks to Strefil for the problem report. * configure.ac: Bump version to 4.0.0a for stable branch. 2011-06-24 Arnold D. Robbins * Makefile.am (EXTRA_DIST): Add ChangeLog.0. * 4.0.0: Remake the tar ball. 2011-06-23 Arnold D. Robbins * configure.ac: Update version to 4.0.0. * configure: Regenerated. * ChangeLog.0: Rotated ChangeLog into this file. * ChangeLog: Created anew for gawk 4.0.0 and on. * README: Bump version to 4.0.0. * 4.0.0: Release tar ball made.