2017-08-04 Arnold D. Robbins * array.c, awk.h, awkgram.y, builtin.c, cint_array.c, cmd.h, debug.c, eval.c, ext.c, field.c, gawkapi.c, gawkmisc.c, gettext.h, int_array.c, main.c, mpfr.c, msg.c, node.c, profile.c, re.c, str_array.c, symbol.c: Update copyright years. 2017-08-04 Arnold D. Robbins * config.guess, mkinstalldirs: Updated from GNULIB. 2017-07-17 Arnold D. Robbins * awkgram.y [non_post_simp_exp]: Merge LEX_BUILTIN and LEX_LENGTH expansions. (lookup_builtin): Move MPFR test to after test for sub builtin. * awkgram.y [non_post_simp_exp]: Unmerge LEX_BUILTIN and LEX_LENGTH expansions. This introduced a reduce/reduce conflict, and those are bad. I don't know why I didn't notice this earlier. Sigh. 2017-07-15 Arnold D. Robbins Revert change of 2016-07-24 that always runs the dfa matcher. Based on a bug report from Alexandre Oliva , DFA can cause gawk to hang, even in the C locale. * re.c (research): Don't use dfa if need_start is true. 2017-07-11 Arnold D. Robbins * awk.h (is_letter): Add declaration. * ext.c (is_valid_identifier): New function. (make_builtin): Use is_valid_identifier instead of inline code. (is_letter): Moved from here ... * awkgram.y (is_letter): ... to here. (yylex): Use is_letter instead of a test. * command.y (yylex): Ditto. * main.c (arg_assign): Ditto. 2017-07-07 Arnold D. Robbins Remove warnings from GCC 7.1 compilation. * awk.h (fatal_tag_valid): Change type to int. * awkgram.y (yylex): Set did_newline to true instead of using ++. * builtin.c (format_tree): Set lj to true instead of using ++. * cmd.h (pager_quit_tag_valid): Change type to int. * debug.c (pager_quit_tag_valid): Change type to int. (do_clear): Make bp_found an int, change uses. (do_run): Treat fatal_tag_valid as an int. * msg.c (fatal_tag_valid): Change type to int. 2017-07-07 Arnold D. Robbins * gawapi.h: Bring descriptive comments up to date, minor edits. * io.c: Add some initial comments to functions where they were missing. 2017-07-03 Arnold D. Robbins * gawkapi.h, gawkapi.c: Typo fixes in comments. 2017-06-25 Andrew J. Schorr * gawkmisc.c (xmalloc): Remove function now in support/xalloc.h. 2017-06-22 Arnold D. Robbins Make pretty-printing include parentheses that were explicitly in the source code. Thanks to Hermann Peifer for the bug report. * awk.h (OPCODE): Add Op_parens. * awkgram.y [Grammar]: If pretty-printing, add Op_parens ot end of list for parenthesized expression. * eval.c (optypetab): Add Op_parens. * interpret.h (r_interpret): Ditto. * profile.c (pprint): Ditto. For ?:, don't parenthesize it. (pp_parenthesize): If string starts with left paren, return early. (parenthesize): Don't call div_on_left_mul_on_right. (div_on_left_mul_on_right): Remove function. (pp_concat): Don't add parentheses if expressions already have them. * NEWS: Updated. 2017-06-21 Andrew J. Schorr Replace malloc/memset combinations with calloc by using the new ezalloc macro. * awkgram.y (yyerror, do_add_srcfile, funcuse): Replace emalloc+memset with ezalloc. * cint_array.c (cint_lookup, cint_copy, tree_lookup, tree_copy, leaf_lookup, leaf_copy): Ditto. * command.y (mk_cmdarg): Ditto. * debug.c (add_item): Ditto. * eval.c (setup_frame): Ditto. * field.c (set_record): Ditto. * gawkapi.c (api_flatten_array_typed): Ditto. * int_array.c (int_copy, grow_int_table): Ditto. * io.c (init_awkpath, iop_alloc): Ditto. * node.c (str2wstr): Ditto. * re.c (make_regexp): Ditto. * str_array.c (str_copy, grow_table): Ditto. * symbol.c (make_params, new_context): Ditto. 2017-06-19 Andrew J. Schorr * awk.h (ezalloc): Add new macro to allocate memory initialized to zero. (ezalloc_real): New inline function to call calloc. * gawkapi.h (ezalloc): Add new API macro to allocate memory initialized to zero. 2017-06-18 Arnold D. Robbins * builtin.c (mbc_char_count): Fix code to correctly traverse the string. Thanks to Hermann Peifer for the bug report. * config.guess, config.sub: Update to latest from GNULIB. * gettext.h: Pull in a few nice changes from GNULIB version. 2017-05-30 Arnold D. Robbins * NEWS: Mention PROCINFO["argv"]. 2017-05-24 Andrew J. Schorr * field.c (set_FIELDWIDTHS): Add check to protect against blank characters after a `:' skip separator. Fix field number in error message, thanks to a bug report from Michal Jaegermann. 2017-05-23 Andrew J. Schorr * field.c (set_FIELDWIDTHS): Simplify the logic and consistentify use of UINT_MAX. Make sure that negative value after : is caught. 2017-05-23 Arnold D. Robbins * field.c (fw_parse_field): Stop upon hitting the end of the record; this enables correct counting of the number of fields. (set_FIELDWIDTHS): Add `*' at end as meaning ``all the rest of the data on the line.'' Allow skip:* as well. * NEWS: Update information about FIELDWIDTHS. 2017-05-20 Arnold D. Robbins * awkgram.y (add_lint): Make ``no effect'' check smarter about reporting line numbers. 2017-05-01 Arnold D. Robbins * awkgram.y (nextc): Fix to change of 2017-04-24 such that @include works in multibyte locales. Thanks to Hermann Peifer for the bug report. 2017-04-26 Andrew J. Schorr * awkgram.y (make_regnode): Fix bug -- we should not set valref to 1 when creating a node of type Node_regex, since valref is appropriate only for Node_val nodes. This fixes a bug introduced in commit 687e6594. Also, add an assert to make it clear that this function supports only Node_regex and Node_dynregex. * awk.h (NODE): Restore sref to the `val' subportion, since it is not really needed for Node_regex, now that the bug in make_regnode has been fixed. (valref): Restore macro definition. 2017-04-24 Arnold D. Robbins * awk.h (NODE): Additional cleanups. Removed `aq' and `param_list' elements from various unions and removed 'nextp' and `a_opaque' defines. None of these were in use. Rework the comment for valref, per suggestion from Andrew Schorr. 2017-04-23 Arnold D. Robbins * awkgram.y (nextc): Adjust so that 3.1.x behavior is restored whereby --source arguments are concatenated. Thanks to "Neil R. Ormos" for the report. 2017-04-21 Arnold D. Robbins * awk.h (NODE): Put the `val' subportion back the way it was and move valref (formerly sref) out of the unions entirely. This was the real problem. Rework the corresponding commentary. [valref]: Removed the macro definition. 2017-04-20 Arnold D. Robbins * configure.ac: Make letter case usage in the various AC_ARG_ENABLE messages consistent with the rest of configure output. (--disable-mpfr): Add this option to make it easier to check compiles without MPFR. Motivated by: * awk.h (NODE): Rearrange the layout of the 'val' subportion of the union to fix alignment problems when compiling without MPFR. The problem only happened on 64-bit compiles, not 32-bit compiles. 2017-04-16 Arnold D. Robbins * builtin.c (do_intdiv): Use DEREF on the arguments. Thanks to Andrew Schorr for finding the problem. * mpfr.c (do_mpfr_intdiv): Return -1 if numerator or denominator are not valid numbers. Unref various bits first. 2017-04-12 Arnold D. Robbins * mpfr.c (mpg_format_val): Set STRCUR flag when we're done. Fixes a memory leak. Thanks to valgrind for the report. * builtin.c (do_dcgettext): Move declaration of reslen to outside the ifdefs. Thanks to Hermann Peifer for the report. 2017-04-12 Manuel Collado Fix the FPAT bug reported by Ed Morton in the gawk-bug mailing list. * awk.h (Regexp): Remove the non_empty flag. * field.c (fpat_parse_field): Restructure the code to reduce complexity and document the new structure. * field.c (fpat_parse_field): Further restructuring to avoid invalid reads as reported by valgrind. 2017-04-10 Andrew J. Schorr * awk.h (enum opcodeval): For the avoidance of doubt, specify that Op_illegal must equal zero. * symbol.c (bcfree): Improve clarity by setting opcode to Op_illegal instead of 0. (free_bc_mempool): Improve clarity by comparing opcode to Op_illegal instead of to 0. * field.c (set_FIELDWIDTHS): Set use_chars to awk_true, since its type is awk_bool_t. 2017-04-10 Arnold D. Robbins * symbol.c (free_bc_mempool): Change `first' from int to bool. 2017-04-09 Andrew J. Schorr * field.c (fw_parse_field): Edit comment about resetting shift state. * gawkapi.h (awk_fieldwidth_info_t): Make white space more uniform. 2017-04-08 Eli Zaretskii * main.c (usage, copyleft) [__MINGW32__]: * io.c (non_fatal_flush_std_file, close_io) [__MINGW32__]: Call w32_maybe_set_errno to correctly set errno to EPIPE when appropriate. * awk.h (die_via_sigpipe) [__MINGW32__]: MinGW-specific definition. 2017-04-07 Andrew J. Schorr * awk.h (INSTRUCTION_POOL): Redefine as an array of structures so we can track allocated blocks. * symbol.c (pools): Make it a pointer to avoid copying. (struct instruction_block): Define structure to hold a block of allocated instructions. (bcfree): Update to use new INSTRUCTION_POOL definition. (bcalloc): Allocate an instruction by searching first on the free list, second for free space in the current block, or third by allocating a new block. (set_context): Update to reflect that pools is now a pointer. (free_bc_mempool): New helper function to free a pool of a certain size. (fre_bcpool): Call free_bc_mempool for each pool. 2017-04-04 Arnold D. Robbins * awk.h (INSTRUCTION): Add pool_size member. [MAX_INSTRUCTION_ALLOC]: New macro. (INSTRUCTION_POOL): New type. (struct context): Use INSTRUCTION_POOL. * array.c (assoc_list): Reorg the code a bit to make sure to alway free the INSTRUCTIONs allocated for calling a user-supplied sorting function. Based on code by Andrew Schorr. * symbol.c (free_bcpool): Rework to use an INSTRUCTION_POOL. (bcfree, bcalloc): Rework to use separate chains in the instruction pool. (set_context): Update appropriately. 2017-03-27 Arnold D. Robbins * field.c (parse_field_func_t): New typedef. Used as needed. (fw_parse_field): Edit comment about resetting shift state. (set_parser): Fix leading comment's style and type of argument. (set_FIELDWIDTHS): Improve the fatal error message. * gawkapi.h: Minor edits in some comments. 2017-03-27 Arnold D. Robbins Cause EPIPE errors to stdout to generate a real SIGPIPE. * awk.h (die_via_sigpipe): New macro. * builtin.c (efwrite): Use it. * io.c (non_fatal_flush_std_file): Ditto. * main.c (usage): Ditto. 2017-03-25 Arnold D. Robbins * io.c (flush_io): Use r_fatal and r_warning for messagefunc in the loop. 2017-03-24 Arnold D. Robbins * builtin.c (efwrite): Exit successfully upon EPIPE, as SIGPIPE done. Improve error messages upon failure to write. (do_fflush): Update ERRNO for non-fatal flush failures. * io.c (non_fatal_flush_std_file): Update ERRNO when flush is non-fatal. (flush_io): If a redirect is marked non-fatal, only warning, not fatal message. 2017-03-23 Arnold D. Robbins * config.sub: Updated again. 2017-03-22 Andrew J. Schorr * NEWS: Document new PROCINFO["FS"] value of "API". 2017-03-22 Andrew J. Schorr * NEWS: Document new FIELDWIDTHS skip capability and API input parser field parsing enhancement. 2017-03-22 Andrew J. Schorr * gawkapi.h (awk_input_buf_t): Update get_record comment regarding the new field_width argument. 2017-03-21 Andrew J. Schorr * gawkapi.h (awk_fieldwidth_info_t): Define new structure to contain API field parsing info, replacing the previous awk_input_field_info_t array. (awk_fieldwidth_info_size): Define macro to calculate size of the variable-length awk_fieldwidth_info_t structure. (awk_input_buf_t): Update get_record prototype to update the type of the final field_width argument from 'const awk_input_field_info_t **' to 'const awk_fieldwidth_info_t **'. * awk.h (set_record): Change 3rd argument from 'const awk_input_field_info_t *' to 'const awk_fieldwidth_info_t *'. * io.c (inrec, do_getline_redir, do_getline): Change field_width type from 'const awk_input_field_info_t *' to 'const awk_fieldwidth_info_t *'. (get_a_record): Change field_width argument type from 'const awk_input_field_info_t **' to 'const awk_fieldwidth_info_t **'. * field.c (api_parser_override): Define new boolean to track whether API parsing is currently overriding default parsing behavior. (api_fw): Change type from 'const awk_input_field_info_t *' to 'const awk_fieldwidth_info_t *'. (FIELDWIDTHS): Change type from 'int *' to 'awk_fieldwidth_info_t *'. (set_record): Use new boolean api_parser_override to track whether API parsing override is in effect, since we can no longer discern this from the value of parse_field -- FIELDWIDTHS parsing uses the same function. (calc_mbslen): New function to calculate the length of a multi-byte string. (fw_parse_field): Enhance to support the awk_fieldwidth_info_t structure instead of simply using an array of integer field widths. (api_parse_field): Remove function no longer needed since fw_parse_field now supports both FIELDWIDTHS and API parsing. (set_parser): Use api_parser_override instead of comparing parse_field to api_parse_field. (set_FIELDWIDTHS): Enhance to use new awk_fieldwidth_info_t structure and parse new skip prefix for each field. (current_field_sep): Use api_parser_override flag instead of comparing to api_parse_field. (current_field_sep_str): Ditto. 2017-03-20 Arnold D. Robbins Improve handling of EPIPE. Problems reported by Alexandre Ferrieux and David Kerns . * awk.h (ignore_sigpipe, set_sigpipe_to_default, non_fatal_flush_std): Declare new functions. (ignore_sigpipe, set_sigpipe_to_default, non_fatal_flush_std): New macros. * builtin.c (do_fflush): When nonfatal not in force, flush of stdout/stderr and EPIPE exits, simulating SIGPIPE, as in nawk/mawk. Flush of other redirections with EPIPE now also fatals. (do_system): Use ignore_sipipe and set_sigpipe_to_default instead of uglier inline ifdefed code. * main.c (main): Ditto. * io.c (redirect_string, two_way_open, gawk_popen): Ditto. (flush_io): Use non_fatal_flush_std for stdout and stderr. Unrelated: * config.guess, config.rpath, config.sub, install-sh: Sync with GNULIB. 2017-03-16 Arnold D. Robbins * configure.ac: Some cleanups. 2017-03-09 Andrew J. Schorr * gawkapi.h (awk_input_field_info_t): Define new structure to contain API field parsing info. (awk_input_buf_t): Update get_record prototype to use an array of awk_input_field_info_t instead of integers. * awk.h (set_record): Change 3rd argument from 'const int *' to 'const awk_input_field_info_t *'. * field.c (api_fw): Now points to an array of awk_input_field_info_t instead of integers. (set_record): Change 3rd argument to point to an array of awk_input_field_info_t. (api_parse_field): Update parsing logic to use awk_input_field_info_t structures instead of an array of integers. * io.c (inrec, do_getline_redir, do_getline): Change field_width type from 'const int *' to 'const awk_input_field_info_t *'. (get_a_record): Change field_width argument type from 'const int **' to 'const awk_input_field_info_t **'. 2017-03-09 Arnold D. Robbins * field.c: Minor style edits. 2017-03-06 Andrew J. Schorr * field.c (normal_parse_field): Renamed from save_parse_field to reflect better its purpose. Added a comment to explain more clearly what's going on. (set_record, set_parser): Rename save_parse_field to normal_parse_field. 2017-03-06 Andrew J. Schorr * gawkapi.h (awk_input_buf_t): Remove field_width array and instead add it as a 6th argument to the get_record function. This should not break existing code, since it's fine to ignore the additional argument. Document the behavior of the field_width argument. * io.c (inrec): Pass pointer to field_width array to get_a_record, and then hand it off to set_record. (do_getline_redir): If not reading into a variable, pass pointer to field_width array to get_a_record and then hand it off to set_record. (do_getline): Ditto. (get_a_record): Add a 4th field_width argument to pass through to the API get_record method. 2017-03-05 Andrew J. Schorr * awk.h (set_record): Add a new argument containing a field-width array returned by an API parser. (field_sep_type): Add new enum value Using_API. (current_field_sep_str): Declare new function. * field.c (save_parse_field): New static variable to save the parse_field value in cases where it's overridden by API parsing. (api_fw): New static variable to hold pointer to API parser fieldwidth array. (set_record): Add new field-width array argument. If present, API parsing will override the default parsing mechanism. (api_parse_field): New field parser using field widths supplied by the API. This is very similar to the existing fw_parse_field function. (get_field): Fix typo in comment. (set_parser): New function to set default parser and check whether there's an API parser override in effect. Update PROCINFO["FS"] if something has changed. (set_FIELDWIDTHS): Use set_parser and stop updating PROCINFO["FS"]. (set_FS): Ditto. (set_FPAT): Ditto. (current_field_sep): Return Using_API when using the API field parsing widths. (current_field_sep_str): New function to return the proper string value for PROCINFO["FS"]. * gawkapi.h (awk_input_buf_t): Add field_width array to enable the parser get_record function to supply field widths to override the default gawk field parsing mechanism. * io.c (inrec): Pass iop->public.field_width to set_record as the 3rd argument to enable API field parsing overrides. (do_getline_redir, do_getline): Ditto. * main.c (load_procinfo): Use new current_field_sep_str function instead of switching on the return value from current_field_sep. 2017-02-23 Arnold D. Robbins * awk.h (boolval): Return bool instead of int. * eval.c (eval_condition): Same. * io.c (pty_vs_pipe): Same Thanks to Andrew Schorr for pointing these out. 2017-02-21 Andrew J. Schorr * NEWS: Document that mktime now takes an optional utc-flag argument. * awkgram.y (tokentab): Modify mktime entry to indicate that it may accept two arguments. * builtin.c (mktime_tz): New function to run mktime in an arbitrary time zone. Code was copied from the Linux timegm man page. (do_mktime): Add support for new optional 2nd argument utc-flag by using the new mktime_tz function. (do_strftime): Change do_gmt type from int to bool. 2017-02-17 Arnold D. Robbins * builtin.c (do_typeof): Handle arguments that have the NULL_FIELD flag set. 2017-02-03 Andrew J. Schorr * awkgram.y (set_profile_text): Improve code clarity by using emalloc to allocate the string instead of abusing estrdup. 2017-02-02 Arnold D. Robbins * awkgram.y (set_profile_next): Allocate an extra byte at the end for the NUL in case we add a sign. Thanks to Andrew Schorr for making me look at this code. And later in the same day: * awkgram.y (set_profile_next): Undo previous change, since estrdup handles it, but updated the comments. 2017-02-01 Arnold D. Robbins * builtin.c (mbc_char_count): Remove spurious multiplies by gawk_mb_cur_max. Thanks to Andrew Schorr for making me look at this code. Unrelated: * awkgram.y (make_profile_number): Renamed to ... (set_profile_next): New function. All calls adjusted. Also improved use at MPFR number case. 2017-01-28 Andrew J. Schorr * io.c (inetfile): Replace strncmp with memcmp in a few places, now that we are checking string length beforehand. 2017-01-27 Andrew J. Schorr * io.c (redirect_string): Check explen positive before accessing *str. In lintwarn message, use explen string length. Pass length to inetfile. (devopen): Pass name length to inetfile. Stop assuming that remoteport is NUL-terminated. (two_way_open): Pass name length to inetfile. (inetfile): Stop assuming NUL string termination; add checks to avoid string overrun. 2017-01-27 Andrew J. Schorr * awk.h (str_terminate_f): New helper function for terminating a string NODE. (str_terminate): Macro wrapper to call str_terminate_f. (str_restore): New macro to restore the string. * builtin.c (do_strftime): Use str_terminate and str_restore. (do_dcgettext): Ditto, and remove saved_end flag since equivalent to testing (t2 != NULL). Fix overrun bug in calculating result length when !ENABLE_NLS. (do_dcngettext, do_bindtextdomain): Use str_terminate and str_restore. * interpret.h (Op_arrayfor_init, Op_indirect_func_call): Ditto. * str_array.c (env_remove): Ditto. 2017-01-27 Andrew J. Schorr * interpret.h [UNFIELD]: Fix condition for assignment from value with valref == 1. Fixes problems introduced at gawk 4.1.2. 2017-01-27 Arnold D. Robbins * interpret.h: Update copyright year. * debug.c (do_run): Rework error message to ease translation. Thanks to Rafael Fontenelle and to Eli Zaretskii . 2017-01-26 Andrew J. Schorr * builtin.c (do_dcgettext): First argument also needs protection from string overrun. (do_dcngettext): Need to terminate string1 and string2 also, and replace strlen(the_result), which could overrun. (do_bindtextdomain): Terminate both string args, and eliminate saved_end boolean which is redundant with (t2 != NULL). 2017-01-26 Andrew J. Schorr * interpret.h (Op_arrayfor_init): Protect against string overrun on sorting method. (Op_indirect_func_call): Terminate function name. 2017-01-26 Andrew J. Schorr * str_array.c (env_remove): Terminate string before calling unsetenv. 2017-01-26 Andrew J. Schorr * node.c (is_hex): Add a new argument pointing to the end of the string so we can check for string overrun. (r_force_number): Pass string end to is_hex. 2017-01-26 Andrew J. Schorr * awk.h (get_numbase): Add string length argument so we can operate on unterminated strings. * awkgram.y: Call get_numbase with string length, and fix off-by-one error in length passed to nondec2awknum: should be strlen(tokstart)-1 based on surrounding code. * builtin.c (do_strtonum): Pass string length to get_numbase. (nondec2awknum): Check string length before accessing characters. * mpfr.c (force_mpnum): Pass string length to get_numbase. * node.c (r_force_number): Pass string length to get_numbase. (get_numbase): Add string length argument and honor it. 2017-01-26 Andrew J. Schorr * builtin.c (do_strftime): If format argument is passed, we need to terminate it in case it's a field variable. 2017-01-26 Andrew J. Schorr * node.c (r_format_val): Before we free s->stptr, make sure that it was malloced. (wstr2str): Add comment explaining why it's safe to free n->stptr without doing any checks. * mpfr.c (mpg_format_val): Ditto. And no need to reset the STRCUR flag that we just checked. 2017-01-26 Andrew J. Schorr * awk.h (enum block_id): Remove BLOCK_INVALID, since it serves no useful purpose and seems to slow things down a bit. * node.c (nextfree): Remove first invalid entry. 2017-01-25 Andrew J. Schorr * awk.h (BLOCK): Remove typedef. BLOCK was used for 2 different purposes: to contain a block allocation list header, and to hold each individual allocated item. This was confusing, because the "size" field was set only in the header, but not in each element. (struct block_header): The block header contains a pointer to the first element and the element size. (struct block_item): Represent a single allocated item. This contains only a pointer to the next element. This reduces the minimum allocated item size from 2 pointers to 1 (16 bytes to 8 bytes on x86_64). (nextfree): Change array item type from BLOCK to struct block_header. (getblock, freeblock): Change cast from 'BLOCK' to 'struct block_item'. * node.c (nextfree): Now an array of 'struct block_header' instead of BLOCK. Switch the ordering to put the next pointer before the size. (more_blocks): Replace 'BLOCK' with 'struct block_item', and add an assert to ensure that the allocation size is at least as large as 'struct block_item', i.e. 1 pointer. 2017-01-22 Andrew J. Schorr * awk.h (numtype_choose): New backend macro used to implement various macros whose calculations depend on how a number is actually represented. This improves readability and should give a small performance improvement when not using extended precision. (get_number_ui, get_number_si, get_number_d, get_number_uj, iszero): Rewrite using new numtype_choose macro. 2017-01-04 Arnold Robbins Trade space for time for programs that toggle IGNORECASE a lot. Brings 25% to 39% speedup. NODE does not actually grow in size. * awk.h (NODE::preg): Now an array of size two. [CASE]: Flag no longer needed, so removed. (IGNORECASE): Change type from int to bool. * awkgram.y (make_regnode): Build two copies of the compiled regexp, one without ignorecase, and one with. * io.c (RS_re): Array replacing RS_re_yes_case and RS_re_no_case. (set_RS): Use RS_re[IGNORECASE] as appropriate. Free and recompute as needed. * main.c (IGNORECASE): Change type from int to bool. * re.c (re_update): Simplify the code. No need to check CASE flag any longer. Recompute only if text of regexp changed. * symbol.c (free_bc_internal): Adjust to free both elements of m_re_reg. 2017-01-18 Andrew J. Schorr * interpret.h (r_interpret): Increase robustness of the optimization logic in Op_assign_concat -- check that the node has MALLOC set, and make sure to wipe all flags other than MALLOC, STRING, STRCUR, and possibly WSTRCUR. Use STFMT_UNUSED define. 2017-01-15 Andrew J. Schorr * interpret.h (r_interpret): Fix bug in Op_assign_concat reported on Cygwin mailing list. The string concatenation optimization was not updating the node correctly by setting STRING and STRCUR flags and setting stfmt. 2017-01-04 Arnold Robbins * config.guess, config.sub, compile, depcomp: Sync from latest in GNULIB. 2016-12-27 Juergen Kahrs * CMakeLists.txt: Updated after adding support library. 2016-12-23 Arnold D. Robbins * configure.ac (GNUPG_CHECK_MPFR): Don't call on PowerPC Macintosh. C99 and the last version of MPFR that works on that platform don't get along. Sigh. 2016-12-22 Arnold D. Robbins * dfa.c: Sync with GNULIB. * intprops.h: New file. * Makefile.am (base_sources): Add intprops.h. Unrelated. Import GNULIB fix for regex: fix integer-overflow bug in never-used code. Problem reported by Clément Pit–Claudel in: http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00654.html Fix by Paul Eggert : * regex_internal.h: Include intprops.h. * regexec.c (re_search_2_stub): Use it to avoid undefined behavior on integer overflow. Unrelated. Set up a support directory for externally obtained support files. * Makefile.am (base_sources, EXTRA_DIST): Edit lists. (SUBDIRS): Get ordering right. (LDADD): Add support/libsupport.a. (DEFS): Add -I for support directory. * dfa.c, dfa.h, getopt.c, getopt.h, getopt1.c, getopt_int.h, intprops.h, localeinfo.c, localeinfo.h, random.c, random.h, regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, regexec.c, verify.h, xalloc.h: Moved to support. Unrelated: Totally break binary compatibility in the API after merging in API min/max changes and REGEX and STRNUM support in the API: * gawkapi.c (valtype2str): New function. (node_to_awk_value): Minor simplification in a switch. (api_flatten_array): Removed. (api_flatten_array_typed): Use valtype2str in error message. (api_impl): Reorder functions to group related ones together again. * gawkapi.h (awk_valtype_t): Reorder enum values. (struct gawk_api): Remove api_flatten_array field. Reorder functions to group related ones together again. 2016-12-17 Arnold D. Robbins * gawkapi.h (api_add_ext_func): Add comment about point to awk_ext_func_t not being const but gawk doesn't use it. * * interpret.h (Op_ext_builtin): Simplify code, check only if do_lint and ! f->suppress_lint and num_args > max_expected. 2016-12-16 Arnold D. Robbins * gawkapi.h (awk_ext_func_t): Put max back before min. Restores source compatibility, although there will be compile warnings because of the 3rd argument for the C function being missing. * interpret.h (Op_ext_builtin): Used size_t instead of int for the various variables. Add a check that max expected > 0. 2016-12-14 Arnold D. Robbins MAJOR BREAKING API CHANGE. * awk.h (INSTRUCTION): Update extension function pointer to take 3rd argument of pointer to struct awk_ext_func. * gawkapi.c (api_add_ext_func): Update third arg to not be const. * gawkapi.h (awk_ext_func_t): Put min before max. Add suppress_lint and data pointer. [gawk_api_major_version]: Update to 2. [gawk_api_minor_version]: Reset to 0. (api_add_ext_func): Update third arg to not be const. * interpret.h (Op_ext_symbol): Revise lint check. 2016-12-12 Arnold D. Robbins * awk.h (INSTRUCTION): Replace min_required and max_expected with a pointer to the extension functions awk_ext_func_t struct. * ext.c (make_builtin): Store a pointer to the extension function struct into the INSTRUCTION instead of the min and max. * gawkapi.h (awk_ext_func): Use size_t instead of unsigned short. Put min second, which preserves source code compatibility. * interpret.h (Op_ext_builtin): Use the pointer for the info directly. If lint and max_expected > 0 and args > max_expected print a message and set max_expected to zero so we only print once per function. Remove special case of both min and max being zero. (Op_ext_func): Adjust creation of the data structures. 2016-12-11 Arnold D. Robbins * dfa.c: Sync with GNULIB. 2016-12-05 Andrew J. Schorr Add API support for strnum values. * gawkapi.c (awk_value_to_node): Add AWK_STRNUM. (assign_string): Add a type argument so we can use this for AWK_STRING or AWK_STRNUM. (node_to_awk_value): When AWK_NUMBER is requested, a regex value should return false, as per the header file documentation. Add support for AWK_STRNUM requests. When AWK_REGEX is requested, implement the cases properly instead of always returning true. Fix AWK_SCALAR logic. For AWK_UNDEFINED, rewrite using a switch and support AWK_STRNUM. (api_sym_update): Add AWK_STRNUM. (api_sym_update_scalar): Add optimized support for updating AWK_STRNUM. (valid_subscript_type): Add AWK_STRNUM. (api_create_value): Add AWK_STRNUM. * gawkapi.h (awk_valtype_t): Add AWK_STRNUM. (strnum_value): New macro. (Value fetching table): Updated. 2016-12-04 Andrew J. Schorr * gawkapi.c (assign_regex): Do not call assign_string, since we know that a REGEX value is not an unterminated field string. * gawkapi.h (make_regex): Delete macro. (make_const_regex, make_malloced_regex): Add new macros to replace make_regex with necessary memory management support. 2016-12-04 Andrew J. Schorr * awk.h (fixtype): Remove conditional checking if the node type is Node_val. This is already covered by the assert, and if it's not true, we have serious bugs. * builtin.c (do_typeof): Do not treat Node_var the same way as Node_val, since they are different beasts. In reality, the argument to this function will never have type Node_var. 2016-12-04 Andrew J. Schorr * gawkapi.h (awk_element_t): Remove obsolete comment claiming that the index will always be a string. (gawk_api_t): Add new api_flatten_array_typed function and indicate that api_flatten_array has been superseded. (flatten_array_typed): New macro to call api_flatten_array_typed. (flatten_array): Redefine using the new flatten_array_typed macro. * gawkapi.c (api_flatten_array_typed): New function renamed from api_flatten_array to flatten an array with the types requested by the caller. Also update the comments and error messages. (api_flatten_array): Now a wrapper around api_flatten_array_typed. (api_impl): Add new api_flatten_array_typed hook. 2016-12-06 Arnold D. Robbins Add minimum required and maximum expected number of arguments to the API. * awk.h (INSTRUCTION): Add new members min_required and max_expected. * ext.c (make_builtin): Store values from extension function struct into the INSTRUCTION. * gawkapi.h (awk_ext_func): Add min_required args. Make both it and max_expected_args into unsigned short to match type in INSTRUCTION. * interpret.h (Op_ext_builtin): Store min_required and max_expected in instructions. Add checking code and lint checks. (Op_ext_func): Copy min_required and max_expected from function info. 2016-12-04 Andrew J. Schorr * gawkapi.h (r_make_string_type): New inline function to create strings of any type, currently AWK_STRING or AWK_REGEX. (r_make_string): Now a wrapper around r_make_string_type. (make_regex): Convert from an inline function to a macro that calls r_make_string_type. 2016-11-30 Arnold D. Robbins * dfa.c: Sync with fixes in GNULIB. Unrelated: * gawkapi.h (make_regex): New function. 2016-11-29 Arnold D. Robbins Add support for typed regex variables to the API. * awk.h (make_typed_regex): Declare function. * awkgram.y (typed_regexp): Call make_typed_regex instead of using inline code. * gawkapi.h (AWK_REGEX): New value type. (regex_value): New macro. (Value fetching table): Updated. * gawkapi.c (awk_value_to_node, node_to_awk_value, api_sym_update, api_sym_update_scalar, valid_subscript_type, api_create_value): Add support for AWK_REGEX. (assign_regex): New function. (api_flatten_array): Adjust comment. * node.c (make_typed_regex): New function; moved code from grammar. 2016-11-29 Arnold D. Robbins Remove redundant flag from dfa: * dfa.c (dfasyntax): Use RE_ICASE instead of DFA_CASE_FOLD. * dfa.h (DFA_CASE_FOLD): Removed. * re.c (make_regexp): Use RE_ICASE for regex and dfa. Yay! Unrelated: Don't have to recompute syntax stuff every time we compile a regexp. * dfa.c (dfacopysyntax): New function. (dfaalloc): Zero out the newly allocated memory. * dfa.h (dfacopysyntax): Declare it. * re.c (make_regexp): Declare two static dfaregs, one for with and without ignorecase. Compute the syntax once for each, then use dfacopysyntax to copy the settings when compiling a regexp. 2016-11-28 Arnold D. Robbins Make gawk compile on HP-UX 11.33. * debug.c (serialize_list): Renamed from `serialize'. (unserialize_list): Renamed from `unserialize', for consistency. Unrelated: * dfa.c: Sync with GNULIB. Twice in one day. 2016-11-21 Arnold D. Robbins * dfa.c: Sync with GNULIB. 2016-11-17 Arnold D. Robbins General cleanup for zero termination of strings. * array.c (do_delete): Use %.*s. (value_info): Get length and use %.*s. (asort_actual): Save and restore character after end. * awkgram.y (split_comment): Use make_string, not make_str_node. * builtin.c (do_fflush): Use %.*s. (locale_category_from_argument, do_dcgettext, do_dcngettext, do_bindtextdomain): Save and restore character after end. * debug.c (do_info, print_array, print_subscript, do_print_var, do_set_var, display, do_watch, print_watch_item, serialize_subscript, do_print_f): Use %.*s. * eval.c (cmp_nodes, fmt_index): Save and restore character after end. * interpret.h (r_interpret): Fix compuation for concatenation of wide strings. * io.c (is_non_fatal_redirect): Add length parameter; save and restore character after last. Adjust all other declarations and calls. (do_close): Save and restore character after end. * mpfr.c (ieee_fmts): Adjust table indentation. (do_mpfr_strtonum): Clear wide string members of the union. * msg.c (err): Use %.*s. 2016-11-07 Arnold D. Robbins * awk.h [USER_INPUT]: Renamed from MAYBE_NUM. * builtin.c, eval.c, field.c, int_array.c, io.c, main.c, mpfr.c, node.c: Change all uses. 2016-11-15 Arnold D. Robbins Finish reworking typed regexes. * awk.h (typed_re): Replaces tre_reg. * awkgram.y (typed_regexp production): Node_val points to a regular Node_regex and also has string value and length. (make_regnode): Simplified back to its original form. * builtin.c (call_sub, call_match, call_split_func): For REGEX, get n->typed_re. * field.c (do_split, do_patsplit): Ditto, for separator regexp. * profile.c (pprint): Op_match_rec, handle REGEX correctly. * re.c (re_update): If REGEX, get t->typed_re->re_reg. 2016-11-15 Arnold D. Robbins Start reworking typed regexes. * awk.h (Node_typedregex): Nuked. [REGEX]: New flag. (tre_reg): New member in val part of NODE union. (force_string, force_number, fixtype): Remove use of Node_typedregex. * awkgram.y (grammer): Use REGEX flag instead of node type. (valinfo); Ditto. (make_regnode): Adjust creation based on node type. * builtin.c (do_length, do_print, call_sub, call_match, call_split_func, do_typeof): Adjust code. * debug.c (watchpoint_triggered, initialize_watch_item, print_memory): Adjust code. * eval.c (nodetypes): Remove Node_typedregex. (flags2str): Add REGEX. (setup_frame): Adjust code after removal of Node_typedregex. * interpret.h (r_interpret): Adjust code after removal of Node_typedregex. * profile.c (pp_typed_regex): Renamed from pp_strong_regex. (pp_string_or_strong_regex): Renamed from pp_string_or_strong_regex. (pprint): Adjust code after removal of Node_typedregex. * re.c (re_update): Adjust code after removal of Node_typedregex. 2016-11-04 Eli Zaretskii * builtin.c (efwrite) [__MINGW32__]: Call w32_maybe_set_errno if errno is not set or set to EINVAL. * nonposix.h (w32_maybe_set_errno) [__MINGW32__]: Add prototype. 2016-11-01 Arnold D. Robbins * eval.c (flags2str): Add NO_EXT_SET and NUMCONSTSTR. 2016-10-31 Arnold D. Robbins Fix valgrind issues. * io.c (init_awkpath): Need to allocate max_path+3 pointers. * awkgram.y (make_profile_number): Need to add STRCUR flag and set n->stfmt to STFMT_UNUSED. See the comment in the code. 2016-10-26 Arnold D. Robbins * io.c (init_awkpath): Set max path len for leading separator. 2016-10-25 Arnold D. Robbins * io.c (init_awkpath): Restore documented behavior whereby null elements represent the current directory. Sheesh. Bug reported by "Jun T." . Disallow negative arguments to the bitwise functions. * NEWS: Document this. * builtin.c (do_lshift, do_rshift, do_and, do_or, do_xor, do_compl): Make negative arguments a fatal error. * mpfr.c (do_mpfr_compl, get_intval): Ditto. 2016-10-23 Arnold D. Robbins * General: Remove trailing whitespace from all relevant files. * mpfr.c: Replace Unicode sequences with ASCII. * cint_array.c: Ditto. 2016-10-16 Arnold D. Robbins * awkgram.y: Typo fix in call to add_sign_to_num. 2016-10-16 Arnold D. Robbins * awk.h (enum opcodeval): Add Op_unary_plus. * awkgram.y (add_sign_to_num): New routine to put in a sign on profiling constants. Call it as necessary. In unary plus production, use new opcode, or set up a constant as for unary minus. (negate_num): Call add_sign_to_num instead of doing it directly. * eval.c (optypetab): Add entry for Op_unary_plus. * interpret.h (r_interpret): Add case for Op_unary_plus. * profile.c (pprint, prec_level, is_scalar): Ditto. 2016-10-13 Arnold D. Robbins * dfa.c: Sync with GNULIB. 2016-10-12 Arnold D. Robbins * awkgram.y (make_profile_number): Allocate an extra byte for the string, so there's room for a minus if necessary. Store '\0' in the right place. (negate_num): Use memmove to shift the string up and then insert a minus, instead of doing a fresh alloc + copy + free. 2016-10-11 Arnold D. Robbins * awk.h (NUMCONSTSTR): New flag value. * awkgram.y (make_profile_number): New function. Use it wherever we make a number. This calls make_number and then, if pretty printing, save the original string value and sets NUMCONSTSTR. (negate_num): If NUNCONSTSTR set, update the saved string value. * profile.c (pp_number): Assert NUMCONSSTR set, use that value. Remove previous code. 2016-09-24 Eli Zaretskii * debug.c (restart) [__MINGW32__]: Cast 2nd argument of execvp to avoid compiler warnings about prototype mismatch. Reported by Marc de Bourget . 2016-09-09 Norihiro Tanaka * awk.h (struct Regexp): Remove member has_anchor. All uses removed. * re.c (make_regexp, research): Use dfa matcher for regex with anchor. 2016-09-09 Arnold D. Robbins * dfa.c: Sync with grep. 2016-09-08 Paul Eggert * dfa.c, dfa.h: Sync with grep. * re.c (make_regexp): Adjust to DFA API changes. 2016-09-08 Arnold D. Robbins * command.y: Update license text to version 3. Oops. 2016-09-07 Arnold D. Robbins * cmd.h, debug.c: Update license text to version citing GPLv3+ and with correct FSF address. Thanks to David Kaspar for pointing out the need. 2016-09-02 Arnold D. Robbins * dfa.c: Sync with grep. 2016-09-01 Arnold D. Robbins Merge grep's now thread-safe dfa. Wheee. * dfa.h, dfa.c: Sync with grep. * localeinfo.h, localeinfo.c, verify.h: New files. * Makefile.am (base_sources): Adjust. * awk.h (using_utf8): Declare new function. * node.c (str2wstr): Use using_utf8 instead of now-gone dfa function. * re.c: Include "localeinfo.h". (localeinfo): New static variable. (make_regexp): Adjust call to dfa_syntax. (resetup): Call init_localeinfo on localeinfo. Remove call to now-gone function dfa_init. (using_utf8): New function. 2016-08-29 Arnold D. Robbins * configure.ac (fwrite_unlocked): Check for it. * awk.h (fwrite): Define to fwrite_unlocked if we have it. * NEWS: Make note of speed improvement. 2016-08-25 Arnold D. Robbins POSIX now says use strcmp for == and !=. Thanks to Chet Ramey for pointing me at the change. Make it so: * awk.h (cmp_nodes): New 3rd param indicating strcmp, not strcoll. * debug.c (cmp_val): Update call to cmp_nodes. * eval.c (cmp_nodes): New 3rd param indicating strcmp, not strcoll. Adjust code and all callers. (scalar_cmp_t): New enum type. Used in ... (cmp_scalars): ... in order to call cmp_nodes correctly. * interpret.h: Use the enum type in calls to cmp_scalars. * re.c (re_update): Adjust call to cmp_nodes. 2016-08-25 Norihiro Tanaka * awk.h (struct Regexp): Remove dfa. Now dfareg instead of it. All referers changed. * re.c (research): Arrange caller of dfaexec and research. * (avoid_dfa): Removed. All callers changed. * awk.h (avoid_dfa): Removed. Other changes by Arnold Robbins: * awk.h (struct Regexp): Change various boolean members to bool. (RE_NO_FLAGS): New #define. * interpret.h: Use RE_NO_FLAGS instead of zero. * re.c (research): Prettify the logic a little bit. 2016-08-25 Arnold D. Robbins * dfa.c: Sync with grep. 2016-08-25 Arnold D. Robbins * 4.1.4: Release tar ball made. 2016-08-23 Arnold D. Robbins * dfa.h: Sync with grep. API changes. * dfa.c: Sync with grep. * re.c (make_regexp): Adjust for API changes, move call to dfasyntax into stanza that compiles the regex. (resetup): Call dfa_init. * node.c (str2wstr): using_utf8 is now called dfa_using_utf8. Unrelated: * Makefile.am: Quote all uses of $(srcdir) and $(distdir). (spell): New target. 2016-08-18 Arnold D. Robbins * dfa.c: Sync with grep. 2016-08-15 Andrew J. Schorr * int_array.c (is_integer): Fix merge of stable changes to remove obsolete string formatting check that has been superseded by the new standard_integer_string check. 2016-08-14 Arnold D. Robbins * re.c (make_regexp): Only call dfasyntax if actually using dfa. Gives a 14% speedup on this test: https://raw.githubusercontent.com/chadbrewbaker/awka/master/benchmark/regexp.awk. From blathering in comp.lang.awk. 2016-08-12 Arnold D. Robbins * dfa.c: Sync with GNU grep. Unrelated: * int_array.c: Minor text and formatting edits. 2016-08-09 Andrew J. Schorr * awk.h: Add a comment explaining the NUMINT flag in more detail. * int_array.c (standard_integer_string): New function to test whether a string matches what would be produced by sprintf("%ld", ). (is_integer): Fix bug -- if NUMBER was set, then the function was accepting strnum values with nonstandard string representations. We now call standard_integer_string to check that the string looks OK. Also added ifdef'ed code to simplify the function by relying upon force_number to parse the string, but this is disabled due to possible negative performance impact. 2016-08-03 Arnold D. Robbins Remove typed regexes until they can be done properly. * NEWS: Updated. * awk.h (enum nodevals): Remove Node_typedregex. (force_string, force_number): Remove check for Node_typedregex. * awkgram.y (TYPED_REGEXP): Remove token. (grammar): Remove productions related to typed regexps. (yylex): Don't find a typed regex or return it. (valinfo): Remove code for Node_typedregex. * builtin.c (do_length, do_print, call_sub, call_match, call_split_func, do_typeof): Remove code for Node_typedregex. * debug.c (watchpoint_triggered, print_memory): Remove code for Node_typedregex. * eval.c (nodetypes, setup_frame): Remove code for Node_typedregex. * interpret.h (r_interpret): Remove code for Node_typedregex. * profile.c (pprint): Remove code for Node_typedregex. (pp_strong_regex): Removed. (pp_string_or_strong_regex): Remove code for Node_typedregex. * re.c (re_update): Remove code for Node_typedregex. 2016-08-01 Arnold D. Robbins * README, NEWS: Mark DJGPP port as unsupported. 2016-08-01 Andrew J. Schorr * mpfr.c (mpg_tofloat): Always set precision to avoid hysteresis effects from previous calculations using the same temporary mpfr variables. 2016-08-01 Andrew J. Schorr * mpfr.c (default_prec): Add new static variable to show current PREC setting in effect. (init_mpfr, set_PREC): Save mpfr_set_default_prec argument in default_prec. (do_mpfr_func): If the argument's precision exceeds the default precision, boost the result's precision to match it. This fixes a bug where we used to copy the argument's precision, regardless of whether it was higher or lower than the PREC setting. 2016-07-24 Norihiro Tanaka * re.c (research): Now that the dfa matcher correctly runs even in multibyte locales, try it if even if need_start is true. However, if start > 0, avoid dfa matcher, since it can't handle the case where the search starts in the middle of a string. Unrelated: * eval.c (load_casetable): Reset casetable[i] to `i' if i should not be mapped to upper case. Fixes inconsistencies between dfa and regex in some single bytes locales; notably el_GR.iso88597. 2016-07-23 Arnold D. Robbins Make result of close on a pipe match result of system. Thanks to Mike Brennan for the encouragement. * awk.h (sanitize_exit_status): Declare routine. * builtin.c (sanitize_exit_status): New routine. (do_system): Use it. * io.c (close_rp): Use it on pclose result. (gawk_pclose): Use it. 2016-07-23 Andrew J. Schorr * builtin.c (do_print): Improve logic for formatting numeric values. 2016-07-19 Andrew J. Schorr * eval.c (set_LINT): Simplify the code considerably. 2016-07-19 Arnold D. Robbins * awkgram.y (shadow_funcs): Change test at end to be `lintfunc == r_fatal' instead of `lintfunc != warning'. Thank to Andrew Schorr for the suggestion. 2016-07-18 Arnold D. Robbins * main.c (locale_dir): New variable, init to LOCALEDIR (set by configure). (set_locale_stuff): Move calls to bindtextdomain and textdomain to here; they must be done after calling setlocale. Use locale_dir instead of LOCALEDIR. (main): Move call to set_locale_stuff() to before parsing arguments. Check for GAWK_LOCALE_DIR env var and use it if there. If doing locale debugging, call set_locale_stuff again if arg parsing changed the locale. Unrelated: * dfa.c: Sync with GNU grep. Unrelated: * config.sub: Updated from GNULIB. 2016-07-17 Arnold D. Robbins * eval.c (set_LINT): Reset lintfunc to `warning' for LINT="invalid". Thanks to Andy Schorr for the report. 2016-07-08 Andrew J. Schorr * awk.h: Restore previous comment about unterminated strings, since I am removing the string termination patches from field.c (free_api_string_copies): Declare new gawkapi function. * builtin.c (do_mktime, do_system): Restore temporary string termination to protect against unterminated field values. (nondec2awknum): Remove comment about unnecessary termination. * eval.c (posix_compare): Restore temporary string termination. * field.c (databuf): Remove struct, no longer needed. (set_field): Remove memcpy for string termination, since we will support unterminated field string values. (rebuild_record): Ditto. Also no need to allocate space for terminated string copies. (allocate_databuf): Remove function, since memory management can again be done inside set_record. (set_record): Restore inline buffer management logic. (reset_record): Remove calls to allocate_databuf, since we no longer need space for making terminated copies of field strings. * gawkapi.c (free_api_string_copies): New function to free strings that we made to provide terminated copies to API functions. (assign_string): New function to convert a string to an awk_value, making sure to copy it if we need to terminate it. (node_to_awk_value): Use assign_string to return string values with NUL termination protection. * int_array.c (is_integer): Restore temporary string termination. * interpret.h (Op_push_i): Ditto. (Op_ext_builtin): After external function returns, call free_api_string_copies to free temporary string copies. * mpfr.c (force_mpnum): Restore temporary string termination. * node.c (r_force_number, get_ieee_magic_val): Ditto. 2016-07-08 Arnold D. Robbins * dfa.c: Sync with GNU grep. Unrelated: * builtin.c (do_print): Coding style change. (This change obsoleted by earlier changes in the fixtype branch.) 2016-07-06 Andrew J. Schorr * awk.h: Modify comments to indicate that MAYBE_NUM will now be left enabled to indicate strnum values by the NUMBER|MAYBE_NUM combination, whereas STRING|MAYBE_NUM indicates a potential strnum. (fixtype): Modify MAYBE_NUM test to avoid calling force_number if NUMCUR is already set. * builtin.c (do_typeof): Call fixtype to resolve argument type. This forces parsing of numeric strings, so there's a performance penalty, but we must do this to give a correct result. The meaning of "strnum" changes from "potential strnum" to "actual strnum". * eval.c (set_TEXTDOMAIN): Remove some dead code left over from last patch. * int_array.c (is_integer): When a MAYBE_NUM is converted successfully to a NUMBER, leave the MAYBE_NUM flag enabled. * mpfr.c (mpg_force_number): Ditto. * node.c (r_force_number): Ditto. 2016-07-06 Andrew J. Schorr * awk.h: Modify stptr comment to indicate that all strings are now NUL-terminated. * builtin.c (do_mktime): Remove unnecessary logic to terminate the string with '\0' temporarily. (do_system) Ditto. (nondec2awknum): Add a comment about termination. * eval.c (posix_compare): Remove logic to terminate strings temporarily. (set_ORS): No need to terminate ORS, since the string node is already terminated. What gave us the right to modify that node anyway? (fmt_index): Remove code to terminate string. This seems to have been invalid anyway, since we don't own that memory. (set_TEXTDOMAIN): Do not terminate TEXTDOMAIN string, since the node is already terminated. We didn't have the right to modify that node anyway. * gawkapi.c (node_to_awk_value): Add assert checks to confirm that the string is NUL-terminated. * gawkapi.h: Modify awk_string comment to indicate that strings are always terminated with '\0'. * int_array.c (isinteger): Remove unnecessary logic to terminate string with '\0' temporarily. * interpret.h (Op_push_i): Ditto. * io.c (nextfile): Remove string termination. We didn't own that memory anyway. * mpfr.c (force_mpnum): Remove unnecessary logic to terminate the string with '\0' temporarily. * node.c (r_force_number): Remove NUL termination around strtod call, since we already know that there is either a white space or '\0' character there. Either one will stop strtod. (get_ieee_magic_val): Ditto. * profile.c (pp_number): No need to terminate string returned by r_format_val. 2016-07-06 Andrew J. Schorr * interpret.h (Op_field_spec): Now that all $n field values are NUL-terminated, there is no reason to call dupnode for $n where n > 0. This saves malloc and copying overhead, thereby more than offsetting the performance hit of the additional copying and NUL-termination in the last patch to field.c. It also eliminates repeated parsing in cases where $n, for n > 1, was accessed more than once in a numeric context, so the new approach should be a performance win. 2016-07-06 Andrew J. Schorr Make sure that all field values, and therefore all strings inside gawk, are terminated with a '\0' character! * field.c (databuf): New static struct to hold info about our buffer to contain the field string values. (allocate_databuf): New function to make sure the databuf is large enough to hold $0 and copies of $1 through $NF. (set_field): Copy $n into free space previously allocated in databuf and add a '\0' at the end. (rebuild_record): Call allocate_databuf to ensure sufficient space for copying non-malloced field values. When copying field values, use databuf to create a NUL-terminated copy. (purge_record): New function extracted from reset_record to initialize $1 through $NF to null values. (set_record): Buffer management moved to new allocate_databuf function. Call purge_record instead of reset_record, since reset_record contains some extra logic not needed in this case. (reset_record): Call purge_record to do most of the work, and call allocate_databuf to make sure we have a big enough buffer to contain copies of the $1 through $NF. 2016-07-06 Andrew J. Schorr * awk.h: Renumber flags to remove gap created when FIELD was removed. 2016-07-05 Andrew J. Schorr * field.c (rebuild_record): Need to set MALLOC flag if we allocate memory for a residual field node with valref > 1. 2016-07-05 Andrew J. Schorr * field.c (rebuild_record): Do not bother to create new field nodes to replace malloc'ed nodes when rebuilding $0. 2016-07-05 Andrew J. Schorr * awk.h (FIELD): Remove unnecessary flag. (MALLOC): Move definition to join the others, and improve the comment. * array.c (value_info): Replace FIELD test with MALLOC test. * eval.c (flags2str): Remove FIELD flag. * field.c (init_fields): Remove FIELD bit from Null_field->flags. (set_field): Remove FIELD bit from flags. (rebuild_record): Test against MALLOC instead of FIELD. If a field node has valref > 1, we should make a copy, although I don't think it is valid for this to happen. (set_record): Remove FIELD bit from flags. * interpret.h (UNFIELD): Add comment, and test MALLOC flag instead of FIELD. Remove probably buggy code to disable the FIELD flag when valref is 1; that would have created a node where neither the FIELD nor MALLOC flag was set, which seems invalid. * node.c (r_dupnode): Remove code disabling FIELD flag. 2016-07-04 Andrew J. Schorr * awk.h (force_string_fmt): New inline function to get the string representation in a requested format. (force_string): Reimplement as a macro using force_string_fmt function. (force_string_ofmt): New macro to get a value's OFMT representation. * builtin.c (do_print): Use new force_string_ofmt macro instead of duplicating the logic inline. 2016-07-04 Andrew J. Schorr * str_array.c (str_lookup): There is no need to worry about the MAYBE_NUM flag, since the code has been patched to make sure to preserve the string value of strnum values, and the integer array code should no longer mistakenly claim a strnum integer with a nonstandard string representation. 2016-07-03 Andrew J. Schorr * field.c (rebuild_record): Revert warning message regarding flags, since I'm not yet totally confident that it is invalid to have FIELD and MALLOC set at the same time. 2016-07-03 Andrew J. Schorr * field.c (rebuild_record): Do not turn off the STRING flag when copying a FIELD node, and issue a warning if MALLOC is enabled. 2016-07-01 Arnold D. Robbins * array.c (value_info): Print something reasonable when stfmt is -1. * mpfr.c (mpg_format_val): Don't cast index to char. * node.c (r_format_val): Ditto. Thanks to Andrew Schorr for pointing these out. Unrelated: * gawkapi.c (api_warning): Fix the comment header. (api_lintwarn): Factor out the call to va_end to after the if. Unrelated: * symbol.c (get_symbols): Add FUNCTAB and SYMTAB to the list for the -d option. * awkgram.y (dump_vars): Allow "-" to mean print to stdout. Thanks to Hermann Peifer for the reports. 2016-06-30 Arnold D. Robbins * node.c (r_force_number): Coding style change. 2016-06-30 Andrew J. Schorr * awk.h (STFMT_UNUSED): New define indicating that the string representation does not depend on CONVFMT or OFMT. (force_string): Use STFMT_UNUSED to improve code clarity. * array.c (value_info): Fix stfmt logic. * builtin.c (do_print): Use STFMT_UNUSED to improve code clarity. * field.c (set_record): Ditto. * gawkapi.c (api_sym_update_scalar): Ditto. * int_array.c (is_integer): Check stfmt equals STFMT_UNUSED before bothering to inspect the string. * mpfr.c (mpg_format_val): Use STFMT_UNUSED to improve code clarity. Remove buggy cast to char in stfmt assignment. * node.c (r_format_val): Ditto. * str_array.c (str_lookup): Use STFMT_UNUSED to improve code clarity. * symbol.c (check_param_names): Ditto. 2016-06-29 Andrew J. Schorr * node.c (r_force_number): Optimize by trimming leading and trailing white space before we inspect the string contents. (get_ieee_magic_val): Must terminate the string with '\0' before calling strtod. 2016-06-27 Andrew J. Schorr * gawkapi.h (awk_string): Add comment about the potential lack of NUL-termination. 2016-06-27 Andrew J. Schorr * awk.h: Add a comment regarding the potential lack of NUL-termination for Node_val strings. 2016-06-27 Andrew J. Schorr * node.c (r_format_val): Do not free stptr unless STRCUR is set. This is safer than testing for non-NULL stptr, since, for example, pp_number copies a node and calls r_format_val, but does not bother to set stptr to NULL beforehand. 2016-06-26 Andrew J. Schorr * node.c (r_force_number): When checking for trailing spaces, protect against running off the end of the string. * mpfr.c (force_mpnum): Ditto. 2016-06-26 Andrew J. Schorr * builtin.c (do_print): There's actually no reason to test whether a value is a number, since the STRCUR flag and stfmt value contain all the necessary info, as in awk.h:force_string. 2016-06-26 Andrew J. Schorr * builtin.c (do_print): Do not use OFMT to print strnum values. We accomplish this by calling format_val for a NUMBER only if there is no string currently available, or if stfmt equals neither -1 nor OFMTidx. 2016-06-26 Arnold D. Robbins * awk.h: Edit some comments. Add others. Minor coding style changes. * builtin.c (format_tree): Restore a comment. (do_mktime): Restore saving/restoring of byte after format string. (do_sub): Coding style. Use %.*s in warning message. (nondec2awknum): Restore saving/restoring of byte after string value being converted. * eval.c: Minor coding style edits. * int_array.c (is_integer): Fix order of checks for not updating string value: check length == 0 before testing values. Coding style edits. * mpfr.c (do_mpfr_strtonum): Coding style edits. * node.c (r_force_number): Restore saving/restoring of byte after string value being converted. Edit comments some. 2016-06-26 Arnold D. Robbins Repair change of 2015-08-25 to handling of MAYBE_NUM. * mpfr.c (mpg_force_number): Just clear MAYBE_NUM. * node.c (r_force_number): Clear STRING separately after setting NUMBER. Thanks to Andrew Schorr for reporting the problem. A test case will eventually be merged into master. Only in stable and master. 2016-06-20 Andrew J. Schorr * builtin.c (do_strftime): Call fixtype before checking flags for STRING type. (do_print): Call fixtype before checking whether argument is a NUMBER. * eval.c (set_BINMODE): Call fixtype before checking value type. No need to call force_number if the flags say it's a number. (r_get_field): Fix lint check for non-numeric argument. * io.c (redirect): Call fixtype before checking whether it's a string. 2016-06-18 Andrew J. Schorr * node.c (r_force_number): Fix typo in comment. 2016-06-16 Arnold D. Robbins * awk.h: Add comment headers for several functions. * builtin.c (nondec2awknum): Actually set a '\0' before calling to strtod() so that the save and restore do something. 2016-06-15 Arnold D. Robbins * config.sub: Update from GNULIB. 2016-06-14 Andrew J. Schorr * awk.h (boolval): New inline function to standardize testing whether a node's value is true. * builtin.c (do_strftime): Use boolval to handle 3rd argument. * eval.c (set_IGNORECASE, eval_condition): Use new boolval function. * io.c (pty_vs_pipe): Use new boolval function. 2016-06-14 Andrew J. Schorr * builtin.c (do_strftime): Fix handling of 3rd argument to work as a standard boolean: non-null or non-zero. 2016-06-14 Andrew J. Schorr * gawkapi.c (node_to_awk_value): When caller requests AWK_SCALAR or AWK_UNDEFINED, we need to call fixtype before we check the type. 2016-06-13 Andrew J. Schorr * awkgram.y: Eliminate STRCUR tests. Must use STRING to test whether a scalar is a string. 2016-06-12 Andrew J. Schorr * awk.h: Improve comment about STRING and NUMBER type assignment. (nondec2awknum): Add endptr argument. (fixtype): New inline function to clarify a scalar's type. * array.c (sort_up_value_type): Call fixtype before checking the value types. * awkgram.y (yylex): Pass NULL endptr argument to nondec2awknum. (valinfo): Remove dead tests: either STRING or NUMBER or both must be set, so there's no reason to continue with checks for NUMCUR or STRCUR. * builtin.c (do_exp, do_int, do_log, do_sqrt, do_sin, do_cos, do_srand): Fix lint check for non-numeric argument. (do_string): Fix lint check for 1st and 2nd args being strings. (do_length): Fix assert to allow for Node_typedregex. Fix lint check for non-string argument. (format_tree): Fix type detection for '%c' arguments. (do_strftime): Fix lint check for non-numeric 2nd argument and lint check for non-string 1st argument. (do_mktime): Fix lint check for non-string argument. Eliminate useless logic to save and restore terminating NUL. (do_system, do_tolower, do_toupper): Fix lint check for non-string argument. (do_atan2, do_lshift, do_rshift, do_and, do_or, do_xor, do_compl, do_intdiv): Fix lint checks for non-numeric args. (do_sub): Attempt to clean up treatment of 3rd argument to gensub despite vague documentation of expected behavior. (do_strnum): Fix bug in number detection logic, and pass new endptr arg to nondec2awknum. (nondec2awknum): Add endptr argument so caller can detect how much of the string was consumed. Eliminate unnecessary logic to save and restore terminating NUL char. (do_typeof): Use a switch to specify which cases are supported, and issue a warning message when a corrupt type is detected. * debug.c (print_memory): At least one of NUMBER and STRING should be set, so no need to check for NUMCUR or STRCUR in addition. * eval.c (cmp_nodes): Use fixtype function to fix arg types. (set_IGNORECASE): Fix logic for acting on value type. Note that setting IGNORECASE to a string value of "0" with NUMCUR set now enables ignorecase, so that's a subtle change in behavior that seems to match the docs. (set_LINT): Try to clean up configuration logic based on type. * ext.c (get_argument): Remove unused variable pcount. * gawkapi.c (node_to_awk_value): Remove pointless test for NUMCUR after calling force_number. Similarly, no need to test for STRCUR after calling force_string. * int_array.c (is_integer): Reject cases where a string value is present that will not be correctly regenerated from the integer; in particular, this could happen where blank space padding is present, leading zeroes are present, or for hex or octal values. Also fix some bugs where a strnum was converted to a NUMBER without turning off the STRING bit. * io.c (redirect_string): Make lint warning message more accurate. (redirect): Change not_string test to use STRING bit, not STRCUR. (pty_vs_pipe): Use fixtype to correct logic for detecting whether a value is anumber. * mpfr.c (mpg_force_number): If NUMCUR is set, there's no need to test is_mpg_number. If it's not, the NODE is corrupt and we've got bigger problems. Fix flag manipulation logic. Always set NUMCUR and clear MAYBE_NUM, (set_PREC): Fix logic using fixtype function. (do_mpfr_atan2, do_mpfr_intdiv): Fix lint check for non-numeric arguments. (do_mpfr_func, do_mpfr_int, do_mpfr_compl, get_intval, do_mpfr_srand): Fix lint check for non-numeric argument. (do_mpfr_strtonum): Use fixtype and stop testing for NUMCUR bit. * node.c (r_force_number): Eliminate pointless save and restore of terminating NUL char. Always set NUMCUR and clear MAYBE_NUM, and convert STRING to NUMBER if appropriate, fixing bugs in flag manipulations. For non-decimal data, need to consider whether there is trailing non-numeric data in deciding whether a MAYBE_NUM should be converted to a NUMBER, so take advantage of new endptr arg to nondec2awknum. 2016-06-14 Arnold D. Robbins * builtin.c (do_sub): Fix sub for long runs of backslashes. Thanks to Mike Brennan for the report. Unrelated: * ext.c (get_argument): Remove unused variable pcount. 2016-06-10 Arnold D. Robbins * config.guess, config.sub: Get latest from Gnulib master. * main.c (UPDATE_YEAR): Bump to 2016. 2016-06-09 Arnold D. Robbins * dfa.c: Sync with GNU grep. Unrelated: * configure.ac: Move AM_CONDITIONAL[ENABLE_EXTENSIONS] outside the enclosing if. Thanks to Assaf Gordon for the report. 2016-06-08 Arnold D. Robbins * symbol.c (lookup): If got Node_val, it's a non-variable in SYMTAB, return NULL. Can affect watchpoints in the debugger, maybe other places. Thanks to Hermann Peifer for the test case and report. 2016-06-05 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2016-06-01 Arnold D. Robbins * nonposix.h (getpgrp): Wrap declaration in ifdef so it doesn't mess things up on POSIX systems (like Solaris). Thanks to Nelson Beebe for the report. * node.c (is_hex): New function to check for 0x preceded by optional sign. (r_force_number): Use it. Thanks to Mike Brennan for the report. 2016-05-30 Andrew J. Schorr * gawkapi.h (awk_ext_func_t): Rename num_expected_args to max_expected_args, and explain in the comment that it doesn't really matter. * ext.c (make_builtin): Replace num_expected_args with max_expected_args. (get_argument): Do not check whether the argument number exceeds the maximum expected by the function. 2016-05-30 Arnold D. Robbins * main.c (arg_assign): Fully bracket ifdefs around call to force_number. Thanks to Andrew Schorr for pointing out that force_number was called only if LC_NUMERIC was defined. Lots of files: Update copyright date. * field.c (set_FS): Handle FS = "\0" if RS = "". Thanks to Janis Papanagnou for the report. * getopt.c, getopt.h, getopt1.c, getopt_int.h: Sync with GLIBC. 2016-05-26 Andrew J. Schorr * awk.h (get_actual_argument): Remove unused "optional" argument. (get_scalar_argument, get_array_argument): Change macro definition to remove 3rd "optional" argument. * ext.c (get_actual_argument): Remove unused "optional" argument. * gawkapi.c (api_get_argument, api_set_argument): Remove unused final argument to get_array_argument and get_scalar_argument. 2016-05-26 Arnold D. Robbins * awk.h [fatal]: Make parentheses and use of indirection consistent with warning and lintwarn. Thanks to Andrew Schorr for pointing this out. * str_array.c (str_lookup): Move test for MAYBE_NUM to where we duplicate the subscript. Removing it across the board is wrong if there are multiple references to the value. Thanks to Andrew Schorr for discussion and test case. 2016-05-26 Andrew J. Schorr * awk.h (get_actual_argument): Add an initial argument containing the (NODE *) previously returned by get_argument. This allows us to eliminate a call to get_argument from inside get_actual_argument. (get_scalar_argument, get_array_argument): Change macro definition to add an initial node argument to pass through to get_actual_argument. * ext.c (get_actual_argument): Add initial (NODE *) argument to contain the value previously returned by get_argument. This allows us to avoid repeating the call to get_argument. We can also eliminate the check for a NULL value, since the caller did that already. * gawkapi.c (api_get_argument): Pass (NODE *) returned by get_argument to get_array_argument and get_scalar_argument. (api_set_argument): Pass (NODE *) returned by get_argument to get_array_argument. 2016-05-25 Manuel Collado . * gawkapi.c (api_nonfatal): New function. (api_impl): Include it. * gawkapi.h (struct gawk_api): Add api_nonfatal member. (nonfatal): New macro. 2016-05-12 Arnold Robbins * str_array.c (str_lookup): Remove MAYBE_NUM from subscript flags. Bug reported by Andres Legarra . Unrelated: Fix issues with SIGPIPE. Reported by Ian Jackson . * builtin.c (do_system): Reset/restore SIGPIPE to/from default around call to system. * io.c (redirect, gawk_popen [PIPES_SIMULATED]): Same. 2016-05-12 Eli Zaretskii * nonposix.h: Add prototypes for Posix functions emulated in pc/* files. 2016-05-09 Andrew J. Schorr * interpret.h (r_interpret): Op_ext_builtin. No need to test whether op == Op_ext_builtin, since we wouldn't be here otherwise. 2016-05-03 Andrew J. Schorr * builtin.c (format_tree): Do not waste a byte at the end of a string. 2016-05-03 Andrew J. Schorr * builtin.c (format_tree): After the string has been rendered, use realloc to shrink the buffer to the needed size. Otherwise, the minimum buffer size of 512 bytes can result in lots of wasted memory if many sprintf results are stored in an array. 2016-05-02 Andrew J. Schorr * gawkapi.h (gawk_api_major_version, gawk_api_minor_version): Add CPP #define values to support conditional compilation. 2016-05-02 Arnold D. Robbins * dfa.h, dfa.c: Sync with grep. * re.c (research): Adjust type of try_backref. 2016-05-02 Arnold D. Robbins * awk.h (success_node): Declare. * array.c (success_node): Define. * cint_array.c, int_array.c, str_array.c: Use `& success_node' instead of `(NODE **) ! NULL' to indicate success throughout. Thanks to Pat Rankin for the cleanup suggestion. 2016-04-27 Arnold D. Robbins * io.c (set_RS): Use rs1scan if do_traditional, even if length of RS is > 1. Bug reported by Glauco Ciullini . 2016-04-24 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2016-04-11 Arnold D. Robbins * regex_internal.c: Replace _GL_ATTRIBUTE_PURE with __attribute__. 2016-04-11 Arnold D. Robbins * regexec.c: Stamp out last remaining use of __attribute. * regcomp.c: Undo change of 2016-01-24 when parsing single-byte ranges. Go back to treating them as bytes and not as characters. The change broke things on Windows in non-UTF-8 character sets. * mbsupport.h (mbstate_t): Define to int. Update copyright. 2016-04-10 John E. Malmberg * regex_internal.c: Use _GL_ATTRIBUTE_PURE macro 2016-04-07 Arnold D. Robbins * awk.h (two_way_close_type): Move here from io.c. (close_rp): Add declaration. * builtin.c (do_printf): Call close_rp before fatal message when attempting to write the closed write end of a two way pipe. (do_print): Ditto. (do_print_rec): Ditto. * io.c (do_getline_redir): Same, for reading closed read end. (close_rp): Make not static. 2016-04-07 Eli Zaretskii * nonposix.h (WEXITSTATUS, WIFEXITED, WIFSIGNALED, WTERMSIG) (WIFSTOPPED, WSTOPSIG) [__MINGW32__]: New macros to replace the missing header sys/wait.h. (w32_status_to_termsig): Add prototype. * builtin.c (do_system) [__MINGW32__]: Compute the exit status of 'system' differently under --traditional, as the low 8 bits are the most interesting. 2016-04-06 Arnold D. Robbins * builtin.c (do_printf): Allow a write to the closed write-end of a two-way pipe to be nonfatal if NONFATAL is set for it. (do_print): Ditto. (do_print_rec): Ditto. * io.c (do_getline_redir): Same thing for reading from a closed read end of a two-way pipe. Fatal error. 2016-04-04 Arnold D. Robbins * builtin.c (do_fflush): Add warning for flush to two-way pipe where write end was closed. * io.c (flush_io): Add some braces for the for loop. 2016-04-02 Arnold D. Robbins * builtin.c (do_printf): If the redirection is two way but the fp is NULL, it means we're writing to the closed write-end of a two-way pipe. Issue a fatal error message. (do_print): Ditto. (do_print_rec): Ditto. * io.c (do_getline_redir): Same thing for reading from a closed read end of a two-way pipe. Fatal error. * NEWS: Updated. 2016-03-27 Stephen Davies * awkgram.y (get_comment): Strip CRs from comment. Strip off trailing newlines. 2016-03-21 Arnold D. Robbins * profile.c (pprint): Improve handling of comment after and if statement without an else. 2016-03-19 Arnold D. Robbins Considerable improvements to handling of comments when pretty printing, particularly for end-of-line comments. * awkgram.y (prior_comment, comment_to_save): New variables. (add_pending_comment): New function. (grammar): Jump through lots more hoops to capture comments. Due to shift-reduce parsing, there can be up to two comments captured and waiting to be saved; be sure to get them both and at the right times. This is difficult since comments have no real syntactic exisitence. Call add_pending_comment on most of the simple statements. (get_comment): Save a pre-existing comment in prior_comment. (split_comment): Use comment_to_save instead of `comment'. * profile.c (end_line): Change to return the instruction after the comment that gets printed; adjust return type. (pprint): Add skip_comment static variable. Adjust logic for skipping an end-of-line comment; only do it if skip_comment is true. This is set to true in places where we can't use the return value from end_line(). Call end_line() in many more places. (pp_func): Handle end-of-line comments after a function header. 2016-03-17 Arnold D. Robbins * debug.c (print_instruction): For Op_comment, improve notation as to whether it's a full comment or an end of line comment. 2016-03-14 Arnold D. Robbins * io.c (socketopen): For SOCK_DGRAM, set read_len to sizeof remote_addr. Makes UDP more or less work again. Thanks to Juergen Kahrs for the fix. 2016-03-11 Arnold D. Robbins * debug.c (print_instruction): Normalize printing of comment dump. 2016-03-10 Arnold D. Robbins * builtin.c (do_system): Further improvements. Catch core dump flag. 2016-03-11 Arnold D. Robbins * builtin.c (do_system): Improve return values of system(). 2016-03-08 Arnold D. Robbins * profile.c (print_instruction): Fix duplicate case not caught by TinyCC. Grrr. 2016-03-07 Arnold D. Robbins * profile.c (print_instruction): Further improvements in instruction dump, especially for when pretty-printing. * builtin.c (do_system): Augment the logic for the return value so that death-by-signal info is available too. 2016-03-03 Arnold D. Robbins * profile.c (pp_list): Unconditionally compute delimlen. Avoids compiler warning. 2016-03-02 Arnold D. Robbins * debug.c (print_instruction): Improvements in instruction dump for if and else. 2016-03-01 Arnold D. Robbins * debug.c (print_instruction): For Op_comment, add notation as to whether it's a full comment or an end of line comment. 2016-02-29 Arnold D. Robbins * profile.c (pp_list): Handle the case of nargs equal to zero. Thanks to Hermann Peifer for the report. 2016-02-28 Arnold D. Robbins * profile.c (pprint): Fix copy-paste error in else handling. Thanks to Michal Jaegermann for the report. 2016-02-23 Arnold D. Robbins * config.guess, config.rpath, config.sub: Update to latest from GNULIB. 2016-02-23 Arnold D. Robbins * NEWS: Update full list of infrastructure tools. 2016-02-22 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.19.7. 2016-02-21 Nelson H.F. Beebe * random.c [SHUFFLE_BITS, SHUFFLE_MAX, SHUFFLE_MASK]: New macros. (shuffle_init, shuffle_buffer): New static variables. (random_old): Renamed from random. (random): New function wrapping random_old and providing a shuffle buffer to increase the period. See the literature citations and other notes in the code. 2016-02-21 Arnold D. Robbins * regexec.c (prune_impossible_nodes): Remove attribute that keeps it from compiling with 32 bit GCC. Who the heck knows why or how. Sigh. Double sigh. 2016-02-20 Arnold D. Robbins * regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, regexec.c: Sync with GLIBC, mostly prototype changes. 2016-02-18 Arnold D. Robbins Fix profile / pretty-printing to chain else-ifs. * profile.c (pprint): Change third argument into a set of flags for in the for header or in an else if. Adjust case Op_K_else to make the right checks and format the code properly. In Op_K_if clear the flag so that any following else gets indented properly. Adjust all calls. 2016-02-14 Arnold D. Robbins * README, NEWS: Updated to reflect use of Texinfo 6.1. Unrelated: * configure.ac: Switch to AC_PROG_CC_C99 to enable C99 compilation and features. * dfa.c: Sync with GNU grep, go back to C99 style declarations at point of use. 2016-02-05 Arnold D. Robbins Make optimization (constant folding and tail call recursion) be on by default. * awkgram.y (common_exp): Only do concatenation of two strings(!) * main.c (do_optimize): Init to true. (optab): Add new -s/--no-optimize option. (usage): Update message to include it. (parse_args): Parse it. Set do_optimize to false if pretty printing or profiling. * NEWS: Updated. 2016-01-28 Arnold D. Robbins * Makefile.am (SUBDIRS): Include extras. Otherwise dist does doesn't work. 2016-01-27 Arnold D. Robbins * configure.ac (GAWK_AC_AIX_TWEAK): Remove call. * configure: Regenerated. * io.c (GAWK_AIX): Check _AIX instead. * custom.h (_AIX): Add define of _XOPEN_SOURCE_EXTENDED. Unrelated: * configure.ac: Remove old stuff for ISC Unix, no longer needed. * configure: Regenerated. 2016-01-25 John E. Malmberg * io.c (redirect): Need to call close_one more than once after running out of file handles. 2016-01-25 Arnold D. Robbins * NEWS: Document VMS support updated. 2016-01-24 Arnold D. Robbins Regex: treat [x] as x if x is a unibyte encoding error. This change removes an ifdef GAWK. * regcomp.c (parse_byte) [ !_LIBC && RE_ENABLE_I18N]: New function. (build_range_exp) [ !_LIBC && RE_ENABLE_I18N]: Use it. From Paul Eggert . 2016-01-22 Arnold D. Robbins * regexec.c (prune_impossible_nodes): Remove all attributes, on both declaration and definition. Fixes a Linux Mint 17 compilation braino reported by Antonio Colombo. * regex_internal.h (test_malloc): Add cast to silence a warning on the same system. (test_realloc): Ditto. 2016-01-20 Arnold D. Robbins * regex_internal.h [attribute_hidden]: Remove definition. * regcomp.c [attribute_hidden]: Remove uses. Not needed since the variables are static. Thanks to Paul Eggert for pointing this out. 2016-01-18 Paul Eggert Diagnose ERE '()|\1' Problem reported by Hanno Boeck in: http://bugs.gnu.org/21513 * lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep track of the set of previously-completed subexpressions available before the first alternative, and restore this set just before parsing each subsequent alternative. This lets us diagnose the invalid back-reference in the ERE '()|\1'. Unrelated: General minor cleanups (spelling, code) from Gnulib: * regex.h, regex_internal.c, regex_internal.h, regexec.c: Minor cleanups. 2016-01-14 Arnold D. Robbins * eval.c (r_get_lhs): If original array was Node_var_new, assign value that is dupnode of Nnull_string and not Nnull_string directly. Fixes core dump reported by ruyk . Unrelated: * ChangeLog: Cleanup spurious extra whitespace. 2016-01-03 Arnold D. Robbins * configure.ac (GAWK_AC_LINUX_ALPHA): Remove call. * configure: Regenerated. * NEWS: Document removal of support for GNU/Linux on Alpha. 2016-01-02 Arnold D. Robbins * dfa.c (add_utf8_anychar): Minor change in declaration of utf8_classes to keep Tiny CC happy. Also syncs with grep. * dfa.h: Sync with grep (update copyright year). 2015-12-27 Arnold D. Robbins * awkgram.y (mk_condition): Revise to correctly handle empty else part for pretty printing. Bug report by ziyunfei <446240525@qq.com>. 2015-12-20 Arnold D. Robbins * io.c (nonfatal): New static constant string. * is_non_fatal, is_non_fatal_redirect: Use it. 2015-12-16 Arnold D. Robbins * io.c (two_way_open): Remove unneeded close of slave in the parent. 2015-12-16 Arnold D. Robbins * profile.c (pp_number): Move count into ifdef for MPFR. Avoids an unused variable warning if not compiling for MPFR. Unrelated: * io.c (two_way_open): If using a pty instead of pipes, open the slave in the child. Fixes AIX and doesn't seem to break GNU/Linux. 2015-11-26 Arnold D. Robbins * command.y (cmdtab): Add "exit" as synonym for "quit". Suggested by Joep van Delft . * NEWS: Document this. 2015-11-24 Arnold D. Robbins * debug.c (debug_pre_execute): Fix to check watchpoints before checking breakpoints. Gives more natural behavior for the user. * NEWS: Document this. Issue reported by Joep van Delft . 2015-10-28 Arnold D. Robbins * awkgram.y (nextc): Don't allow '\0' even if check_for_bad is false. Fixes a problem reported by Hanno Boeck . Unrelated: * dfa.c: Sync with GNU grep. 2015-10-25 Arnold D. Robbins * awkgram.y (yylex): Fix invalid write problems. Reported by Hanno Boeck . Only appeared in master. Harumph. 2015-10-16 Arnold D. Robbins * Makefile.am (SUBDIRS): Fix ordering so that make check directly after configure works properly. Thanks to Michal Jaegermann for the report. Unrelated: * dfa.c: Sync with GNU grep. 2015-10-11 Arnold D. Robbins * awkgram.y (yylex): Fix invalid read problems. Reported by Hanno Boeck . 2015-10-04 Arnold D. Robbins * configure.ac: Bump version to 4.1.3a. 2015-09-26 Arnold D. Robbins * awkgram.y (yylex): Diagnose multidimensional arrays for traditional/posix (fatal) or lint. Thanks to Ed Morton for the bug report. 2015-09-25 Arnold D. Robbins * config.guess, config.sub, config.rpath: Updated. 2015-09-18 Arnold D. Robbins * field.c (fpat_parse_field): Always use rp->non_empty instead of only if in_middle. The latter can be true even if we've already parsed part of the record. Thanks to Ed Morton for the bug report. 2015-09-11 Daniel Richard G. * regcomp.c: Include strings.h, wrapped in ifdef. Revise defines for BTOWC. * regex_internal.h: Remove ZOS_USS bracketing ifdefs. 2015-09-04 Arnold D. Robbins * profile.c (pp_num): Use format_val to print integral values as integers. Thanks to Hermann Peifer for the report. 2015-08-28 Daniel Richard G. * Makefile.am, configure.ac: Use an Automake conditional to enable/disable the "extensions" subdirectory instead of producing a stub Makefile therein from the configure script. * awk.h, custom.h, regex_internal.h: Removed z/OS-specific code that is no longer needed due to improvements in Gawk's general Autotools support. * awk.h: Allow to be #included together with as this is required on some systems (z/OS). * io.c, configure.ac: is needed for select() and related bits on z/OS. * awk.h: Handle the redefinition of EXIT_FAILURE on z/OS in a more elegant/general way. * awkgram.y, command.y, configure.ac, eval.c, helpers/testdfa.c: Define and use the USE_EBCDIC cpp symbol instead of checking the value of 'a' whenever we want to know if we're on an EBCDIC system. Also, don't assume that z/OS necessarily means EBCDIC, as the compiler does have an ASCII mode (-qascii). * awkgram.y, command.y, configure.ac: On EBCDIC systems, convert singleton EBCDIC characters in the input stream to ASCII on the fly so that the generated awkgram.c/command.c in the distributed sources can be used, i.e. we don't have to require the user to build Bison and re-generate those files themselves. This implementation uses a z/OS-specific function (__etoa_l()) to do the conversion, but support for other systems can be added in the future as necessary. * io.c: No need to protect this block of "#if defined(HAVE_TERMIOS_H)" code from z/OS; it works just fine there. * configure.ac: Check for the "struct passwd.pw_passwd" and "struct group.gr_passwd" fields and conditionalize their use, as they don't exist on z/OS. Needed for doc/gawktexi.in. 2015-08-25 Arnold D. Robbins * node.c (str2wstr): Upon finding an invalid character, if using UTF-8, use the replacement character instead of skipping it. Helps match() and other functions work better in the face of unexpected data. Make the lint warning an unconditional warning. Unrelated: * awk.h: Add explanatory comment on the flags related to types and values. * mpfr.c (mpg_force_number): If setting NUMBER, clear STRING also when clearing MAYBE_NUM. (set_PREC): Check STRCUR instead of STRING. * node.c (r_force_number): If setting NUMBER, clear STRING also when clearing MAYBE_NUM. 2015-08-15 Arnold D. Robbins * dfa.c (dfamust): Restore c90 compat by moving some variable declarations to the top of the routine. 2015-08-12 Arnold D. Robbins * dfa.c: Sync with GNU grep. Yet again, again. 2015-08-02 Arnold D. Robbins * dfa.c: Sync with GNU grep. Yet again. 2015-07-21 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2015-07-18 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2015-07-08 Arnold D. Robbins * dfa.h, dfa.c: Sync with GNU grep. 2015-06-29 Arnold D. Robbins * awkgram.y (yylex): If gawk extension function is found as a function in a user-defined function body, treat it normally. Makes eval "print and(a, 1)" work in the debugger again. Thanks, yet again, to Hermann Peifer. * interpret.h (r_interpret): Op_subscript. UPREF if the element value is a typed regexp. Thanks to Hermann Peifer. 2015-06-28 Arnold D. Robbins Improve memory tracking of typed regexps. * awkgram.y (make_regnode): Set valref to 1. * interpret.h (r_interpret): Have Op_push_re upref typed regexp. * builtin.c (do_typeof): OK to deref typed regex. * awk.h (force_string): Do dupnode on the regexp text. 2015-06-26 Arnold D. Robbins Remove support for old-style extensions. * awk.h (Node_old_ext_func, Op_old_ext_func): Removed. Remove all uses throughout the code. (load_old_ext, make_old_builtin): Remove declarations. * ext.c (load_old_ext, make_old_builtin): Removed. * awkgram.y (tokentab): Remove "extension" entry. * eval.c (Node_old_ext_funci, Op_old_ext_func): Remove from tables. * interpret.h (interpret): Remove stuff for old extensions. Unrelated: * builtin.c (do_typeof): Add support for strnum, distinguish untyped from unassigned, use "string" and "number". Thanks to Hermann Peifer for suggesting inclusion of strnum. 2015-06-25 Arnold D. Robbins Further work straightening out memory management for typeof. * awk.h (DEREF): Add an assert. * builtin.c (do_typeof): Add comments, cases where not to deref. * debug.c (print_instruction): Add Op_push_arg_untyped. * interpret.h (r_interpret): Additional comments / tweaks for Op_push_arg_untyped. Unrelated. Make `x = @/foo/ ; print x' print something. * builtin.c (do_print): Check for Node_typedregex and handle it. Needed for adding test code. Unrelated. Typo fix. * debug.c (initialize_watch_item): Dupnode the right thing. 2015-06-22 Arnold D. Robbins * awkgram.y (snode): Make isarray not scalarize untyped parameters also. * profile.c (pprint): Add Op_push_arg_untyped. Improve debugger support for typed regexps. Thanks to Hermann Peifer for the bug report. * awkgram.y (valinfo): Add support for Node_typedregex. * debug.c (watchpoint_triggerred): Handle Node_typedregex. (initialize_watch_item): Ditto. (print_memory): Ditto. Fix typeof to work on subarrays. Thanks, yet again, to Hermann Peifer for the bug report. * builtin.c (do_typeof): Don't deref Node_var_array. 2015-06-21 Arnold D. Robbins Fixes for typeof - Don't let typeof change an untyped variable into a scalar. * awk.h (opcodeval): Add Op_push_arg_untyped. * awkgram.y (snode): Separate out case for do_typeof, use Op_push_arg_untyped. * builtin.c (do_typeof): Arg will be equal to Nnull_string if it's untyped. * eval.c (optypes): Add Op_push_arg_untyped. * interpret.h (r_interpret): Add Op_push_arg_untyped handling. 2015-06-19 Arnold D. Robbins * builtin.c (do_isarray): Minor edit to lint warning. * TODO: Updated. 2015-06-14 Arnold D. Robbins * regcomp.c, regex_internal.h, regexec.c: Sync with GLIBC. Unrelated: * regex_internal.c, regexec.c: __attribute --> __attribute__. Related: * regex_internal.h: Clean up defines for non-GCC for attribute; essentially sync it with GLIBC. 2015-06-12 Arnold D. Robbins * awkgram.y: Finish converting "hard" regex to "typed" regex. 2015-05-31 Arnold D. Robbins * field.c (posix_def_parse_field): Removed. It's no longer needed after updates to the POSIX standard. Thanks to Michael Klement for pointing this out. 2015-05-26 Paul Eggert * floatcomp.c (count_trailing_zeros): New function. This compiles to a single TZCNT instruction on the x86-64. (adjust_uint): Use it to keep more high-order bits when some of the lowest-order bits are zero. This implements the documented behavior: "If the result cannot be represented exactly as a C 'double', leading nonzero bits are removed one by one until it can be represented exactly." 2015-05-26 Arnold D. Robbins * regcomp.c: Fix offsets so error messages come out correct once again. 2015-05-19 Arnold D. Robbins * 4.1.3: Release tar ball made. 2015-05-15 Andrew J. Schorr * symbol.c (load_symbols): Plug minor memory leak by calling unref(tmp) on "identifiers" string after assoc_lookup is done with it. 2015-05-15 Andrew J. Schorr * main.c (load_procinfo_argv): New function to save argv array values in PROCINFO["argv"][0..argc-1]. (load_procinfo): Call load_procinfo_argv. 2015-05-11 Arnold D. Robbins * awk.h, awkgram.y, builtin.c, eval.c profile.c, re.c: Change Node_hardregex to Node_typedregex everywhere. 2015-05-05 Arnold D. Robbins * awkgram.y (yylex): Yet Another Fix for parsing bracket expressions. Thanks yet again to Andrew Schorr. Maybe it's even finally nailed down now. Unrelated: * config.guess, config.sub: Get latest versions. Make profiling for hard regexes work. * profile.c (pp_string_or_hard_regex): Renamed from pp_string. Add bool param for hard regex and add @ if so. (pp_string): New function, calls pp_string_or_hard_regex. (pp_hard_regex): New function, calls pp_string_or_hard_regex. (pprint): Adjust to print a hard regex correctly. 2015-05-01 Arnold D. Robbins * awkgram.y: Make sure values are not null in param list. Avoids core dump for `function f(func, a) {}'. Thanks to Tibor Palinkas . 2015-04-30 Arnold D. Robbins * Makefile.am: Take --program-prefix into account when installing/uninstalling the symlinks, especially 'awk'. Thanks to Steffen Nurpmeso for the report. Unrelated: * awkgram.y (yylex): Yet Another Fix for parsing bracket expressions. Thanks again to Andrew Schorr. 2015-04-29 Arnold D. Robbins * 4.1.2: Release tar ball made. 2015-04-28 Arnold D. Robbins * builtin.c (isarray): Add lint warning that isarray() is deprecated. 2015-04-28 Arnold D. Robbins * awkgram.y (yylex): Rework the bracket handling from zero. Thanks to Michal Jaegermann for yet another test case. Unrelated: * eval.c (setup_frame): Restore call-by-value for $0. This was necessitated by the changes on 2014-11-11 for conserving memory use. Thanks to Andrew Schorr for the report and isolating the cause of the problem. 2015-04-27 Arnold D. Robbins * awkgram.y (yylex): Make change of Jan 7 for parsing regexps work better. Thanks to Nelson Beebe. 2015-04-26 Arnold D. Robbins * dfa.c: Sync with grep. 2015-04-16 Arnold D. Robbins * builtin.c (do_strftime): For bad time_t values, return "". 2015-04-16 Andrew J. Schorr * node.c (r_force_number): If strtod sets errno, then force the numeric value in node->numbr to zero. For subnormal values, strtod sets errno but does not return zero, and we don't want to retain those subnormal values. 2015-04-16 Arnold D. Robbins Let parameter names shadow the names of gawk additional built-ins. Make it actually work. * awkgram.y (want_param_names): Now an enum, there are three states. (grammar): Set states properly. (yylex): Improve checking logic. 2015-04-16 Arnold D. Robbins * configure.ac: Updated by autoupdate. * configure, aclocal.m4: Regenerated. * io.c, main.c, profile.c: Removed use of RETSIGTYPE. 2015-04-16 Arnold D. Robbins * builtin.c (do_strftime): Use a double for the timestamp and check that the value is within range for a time_t. Unrelated: * regex_internal.h (test_malloc, test_realloc): Use %lu in printf format for error messages. Thanks to Michal Jaegermann for pointing this out. Unrelated: * NEWS: Updated. 2015-04-15 Arnold D. Robbins Let parameter names shadow the names of gawk additional built-ins. * awkgram.y (want_param_names): New variable. (yylex): Check it before returning a built-in token. (grammar): Set and clear it in the right places. 2015-04-14 Arnold D. Robbins * builtin.c (do_strftime): Restore checking for negative result and add check that time_t is > 0 --- means we're assigning a negative value to an unsigned time_t. Thanks again to Glaudiston Gomes da Silva . If localtime() or gmtime() return NULL, return a null string. Thanks to Andrew Schorr. Unrelated: * builtin.c (call_sub): Fix for indirect gensub, 3 args now works. Unrelated: * builtin.c (do_sub): Improve some variable names for readability and add / expand some comments. Unrelated: * builtin.c (call_sub, call_match, call_split_func): Allow for regex to be Node_hardregex. 2015-04-14 Andrew J. Schorr Arnold D. Robbins * builtin.c (do_sub): Make computations smarter; initial len to malloc, test for final amount after all matches done and need to copy in the final part of the original string. 2015-04-13 Arnold D. Robbins * regcomp.c (analyze): Prevent malloc(0). * regex_internal.h (test_malloc, test_realloc): New functions that check for zero count. (re_malloc, re_realloc): Adjust to call the new functions for gawk. * regexec.c (buid_trtable, match_ctx_clean): Replace malloc/free with re_malloc/re_free. Unrelated: * builtin.c (do_strftime): Disable checking timestamp value for less than zero. Allows times before the epoch to work with strftime. Thanks to Glaudiston Gomes da Silva for raising the issue. 2015-04-12 Arnold D. Robbins * Makefile.am (efence): Make this link again. Thanks to Michal Jaegermann for pointing out the problem. 2015-04-09 Andrew J. Schorr * awkgram.y (yyerror): Rationalize buffer size computations. Remove old valgrind workarounds. * debug.c (gprintf): Rationalize buffer size computations. (serialize_subscript): Ditto. * io.c (iop_finish): Rationalize buffer size computations. * profile.c (pp_string): Correct space allocation computation. 2015-04-08 John E. Malmberg * custom.h: VMS shares some code paths with ZOS_USS in building gawkfts extension. 2015-04-08 Arnold D. Robbins Factor out opening of /dev/XXX files from /inet. Enable interpretation of special filenames for profiling output. * awk.h (devopen_simple): Add declaration. * io.c (devopen_simple): New routine. (devopen): Call devopen_simple as appropriate. * profile.c (set_prof_file): Call devopen_simple as appropriate, some additonal logic to hande fd to fp conversion. Unrelated: * main.c (usage): Add a comment for translators. 2015-04-08 Eli Zaretskii * profile.c (set_prof_file): Interpret a file name of "-" to mean standard output. 2015-04-06 Arnold D. Robbins * awk.h (force_number): Add `!= 0' check to bitwise operation. * awkgram.y: Same, many places. (check_special): Simplify code for checking extension flags. 2015-04-05 Arnold D. Robbins * awkgram.y (install_builtins): If do_traditional is true, do not install gawk extensions flagged with GAWKX. Similarly, if do_posix is true, do not install functions flagged with NOT_POSIX. This fixes a problem with spurious lint complaints about shadowing a global variable that is not valid in traditional or posix mode. Thanks to Andrew Schorr for finding the problem and supplying initial code; I did it slightly differently. 2015-04-03 Arnold D. Robbins * awk.h (force_string): If hard_regex, return string text of the regex. (force_string, force_number): If hard_regex, return Nnull_string. * awkgram.y: Fix ~ and !~ with @/.../. * eval.c (setup_frame): Handle a hard regex. * re.c (avoid_dfa): Ditto. 2015-04-02 Andrew J. Schorr * NEWS: Rename div to intdiv. 2015-04-02 Arnold D. Robbins Rename div() to intdiv(). * builtin.c (do_intdiv): Renamed from do_div. * mfpr.c (do_mpfr_intdiv): Renamed from do_mpfr_div. * awk.h: Update declarations. * awkgram.y (tokentab, snode): Revise accordingly. 2015-03-31 Arnold D. Robbins * awk.h (call_sub): Renamed from call_sub_func. (call_match, call_split_func): Declare. * builtin.c (call_sub): Renamed from call_sub_func. (call_match, call_split_func): New functions. * interpret.h (r_interpret): Call new functions as appropriate. * node.c (r_unref): Revert change to handle Node_regex, not needed. 2015-03-31 Arnold D. Robbins * awk.h (r_get_field): Declare. * builtin.c (call_sub_func): Rearrange the stack to be what the buitin function expects. * eval.c (r_get_field): Make extern. 2015-03-27 Arnold D. Robbins * io.c (redirect): Change not_string from int to bool. * gawkapi.c (api_get_file): Minor stylistic improvements. * NEWS: Updated for retryable I/O and new API function. 2015-03-24 Arnold D. Robbins * awkgram.y (make_regnode): Make extern. * awk.h (make_regnode): Declare. * builtin.c (call_sub_func): Start on reworking the stack to be what do_sub() expects. Still needs work. * interpret.h (r_interpret): Add a cast in comparison with do_sub(). * node.c (r_unref): Handle Node_regex nodes. 2015-03-24 Andrew J. Schorr * interpret.h (r_interpret): When Op_K_exit has an argument of Nnull_string, do not update exit_val, since no value was supplied. 2015-03-24 Arnold D. Robbins * awk.h, gawkapi.c, io.c: Minor code reformatting. 2015-03-20 Arnold D. Robbins Start on fixing indirect calls of builtins. * awk.h (call_sub_func): Add declaration. * awkgram.y (lookup_builtin): Handle length, sub functions. (install_builtin): Handle length function. * builtin.c (call_sub_func): New function. * interpret.h (r_interpret): If calling do_sub, do it through call_sub_func(). 2015-03-19 Arnold D. Robbins * re.c (re_update): Handle hard regex - for sub/gsub/gensub. * awkgram.y (grammar): Add support for hard_regex with ~ and !~; allowed only on the right hand side. (mk_rexp): Handle a hard regex. 2015-03-18 Arnold D. Robbins * builtin.c (do_typeof): Be smarter about checking for uninitialized values; can now detect and return "untyped" for such values. * awkgram.y (yylex): Collect @/.../ entirely in the lexer and return a new terminal (HARD_REGEX). (regexp): Reverted to just a regular awk regexp constant. (hard_regexp): New nonterminal, can be used only in direct assignment and as an argument in function call. New set of nonterminals for function call expression lists. More work still to do. 2015-03-18 Arnold D. Robbins * config.guess, config.sub: Updated, from libtool 2.4.6. 2015-03-17 Arnold D. Robbins * profile.c (pp_number): Allocate enough room to print the number in all cases. Was a problem mixing -M with profiling with a really big number. Thanks to Hermann Peifer for the bug report. 2015-03-08 Arnold D. Robbins * re.c (regexflags2str): Removed. It was redundant. * io.c (devopen): Change the logic such that if nonfatal is true for the socket, don't do retries. Also clean up the formatting some. At strictopen, check if errno is ENOENT and if so, propagate the error from getaddrinfo() up to the caller. Add explanatory comments. 2015-02-28 Andrew J. Schorr * io.c (pty_vs_pipe): Remove check for NULL PROCINFO_node, since this is now checked inside in_PROCINFO. 2015-02-27 Andrew J. Schorr * io.c (socketopen): New parameter hard_error; set it if getaddrinfo() fails. Change fatals to warnings. (devopen): Pass in address of boolean hard_error variable and stop trying to open the file if hard_error is true. Save and restore errno around call to socketopen() and use restored errno if open() fails at strictopen. 2015-02-27 Arnold D. Robbins * symbol.c (check_param_names): Fix argument order in memset() call. * configure.ac: Use AC_SEARCH_LIBS instead of AC_CHECK_LIB. This fixes a long-standing problem where `-lm' was used twice in the final compilation line. 2015-02-27 Arnold D. Robbins Start on making regexp a real type. * awk.h (Node_hardregex): New node type. (do_typeof): Add declaration. * awkgram.y: Make @/.../ a hard regex. (tokentab): New entry for typeof() function. (snode): Try to handle typeof(). (make_regnode): Handle Node_hardregex. * builtin.c (do_typeof): New function. * eval.c (nodetypes): Add Node_hardregex. * re.c (re_update): Check for hardregex too in assert. 2015-02-24 Arnold D. Robbins * POSIX.STD: Update copyright year. * awkgram.y (yylex): Allow \r after \\ line continuation everywhere. Thanks to Scott Rush for the report. 2015-02-13 Arnold D. Robbins * awkgram.y (yylex): Be more careful about passing true to nextc() when collecting a regexp. Some systems' iscntrl() are not as forgiving as GLIBC's. E.g., Solaris. Thanks to Dagobert Michelsen for the bug report and access to systems to check the fix. 2015-02-12 Arnold D. Robbins * POSIX.STD: Update with info about function parameters. * configure.ac: Remove test for / use of dbug library. 2015-02-11 Arnold D. Robbins * gawkapi.h: Fix spelling error in comment. 2015-02-10 Arnold D. Robbins * profile.c (pprint): Restore printing of count for rules. Bug report by Hermann Peifer. 2015-02-08 Arnold D. Robbins * io.c: Make it "NONFATAL" everywhere. 2015-02-08 Andrew J. Schorr * awk.h (RED_NON_FATAL): Removed. (redirect): Add new failure_fatal parameter. (is_non_fatal_redirect): Add declaration. * builtin.c (efwrite): Rework check for non-fatal. (do_printf): Adjust calls to redirect. (do_print_rec): Ditto. Move check for redirection error up. * io.c (redflags2str): Remove RED_NON_FATAL. (redirect): Add new failure_fatal parameter. Simplify the code. (is_non_fatal_redirect): New function. (do_getline_redir): Adjust calls to redirect. 2014-12-27 Arnold D. Robbins * awk.h (is_non_fatal_std): Declare new function. * io.c (is_non_fatal_std): New function. * builtin.c (efwrite): Call it. 2015-02-07 Arnold D. Robbins * regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, regexec.c: Sync with GLIBC. Mostly copyright date updates. 2015-02-05 Andrew J. Schorr * eval.c (set_IGNORECASE): If IGNORECASE has a numeric value, try using that before treating it as a string. This fixes a problem where setting -v IGNORECASE=0 on the command line was not working properly. 2015-02-01 Arnold D. Robbins Move POSIX requirement for disallowing paramater names with the same name as a function into --posix. * NEWS: Document it. * awkgram.y (parse_program): Check do_posix before calling check_param_names(). * symbol.c (check_param_names): Set up a fake node and call in_array() for function parameter names instead of linear searching the function list a second time. Thanks to Andrew Schorr for the motivation. 2015-01-30 Arnold D. Robbins Don't allow function parameter names to be the same as function names - required by POSIX. Bug first reported in comp.lang.awk. In addition, don't allow use of a parameter as a function name in a call (but it's ok in indirect calls). * NEWS: Updated. * awk.h (check_param_names): Add declaration. * awkgram.y (at_seen): New variable. Communicates between yylex() and the parser. (FUNC_CALL production): Check at_seen and check that the identifier is a function name. (parse_program): Call check_param_names() and set errcount. (yylex): Set at_seen after seeing an at-sign. * symbol.c (check_param_names): New function. 2015-01-24 Arnold D. Robbins Infrastructure updates. Bison 3.0.4. Automake 1.15. Gettext 0.19.4. 2015-01-20 Arnold D. Robbins * gawkapi.c (api_set_array_element): Remove useless call to make_aname. * symbol.c (load_symbols): Ditto. Thanks to Andrew Schorr for pointing out the problem. 2015-01-19 Arnold D. Robbins * awkgram.c: Update to bison 3.0.3. * command.c: Ditto. * NEWS: Note same. 2015-01-16 Stephen Davies * awkgram.y (rule): Set first_rule to false. Catches more cases for gathering comments. Thanks to Hermann Peifer for the test case. 2015-01-15 Arnold D. Robbins * dfa.h, dfa.c: Sync with grep. Mainly copyright updates. * getopt.c, getopt.h, getopt1.c getopt_int.h: Sync with GLIBC. Mainly copyright updates, one minor code fix. 2015-01-14 Arnold D. Robbins Remove deferred variables. * awk.h (register_deferred_variable): Remove declaration. * awkgram.y (is_deferred_variable, process_deferred, symtab_used, extensions_used, deferred_variables, process_deferred): Remove declarations, bodies, and uses. * builtin.c (do_length): Update comment. * main.c (init_vars): Just call load_procinfo() and `load_environ()'. 2015-01-08 Andrew J. Schorr Revert changes to API deferred variable creation -- these variables should be created when lookup is called, not when update is called. * awk.h (variable_create): Remove function declaration. * awkgram.y (variable_create): Remove function. (variable): Restore variable_create functionality inline. * gawkapi.c (api_sym_update): Revert to using install_symbol, since the deferred variable check should be done when lookup is called, not here. 2015-01-07 Andrew J. Schorr * gawkapi.c (api_set_array_element): Remove stray call to make_aname. I cannot see what purpose this served. Maybe I am missing something. 2015-01-07 Arnold D. Robbins * configure.ac: Update debug flags if developing. * awkgram.y (yylex): Regex parsing bug fix for bracket expressions. Thanks to Mike Brennan for the report. * builtin.c (format_tree): Catch non-use of count$ for dynamic field width or precision. Unrelated: Load deferred variables if extensions are used; they might want to access PROCINFO and/or ENVIRON. Thanks to Andrew Schorr for pointing out the issue. * awkgram.y (extensions_used): New variable. Set it on @load. (do_add_scrfile): Set it on -l. (process_deferred): Check it also. 2015-01-06 Andrew J. Schorr * gawkapi.c (api_sym_update): If copying a subarray, must update the parent_array pointer. Also, call the astore hook if non-NULL. (api_set_array_element): Call the astore hook if non-NULL. 2015-01-06 Andrew J. Schorr * awk.h (variable_create): Now takes a 3rd argument to tell caller whether this is a deferred variable. * awkgram.y (variable_create): Return indicator of whether this is a deferred variable in a newly added 3rd arg. (variable): Pass 3rd arg to variable_create. * gawkapi.c (api_sym_update): If we triggered the creation of a deferred variable, we must merge the extension's array elements into the deffered array, not the other way around. The ENVIRON array has special funcs to call setenv and unsetenv. 2015-01-06 Andrew J. Schorr * awk.h (variable_create): Declare new function. * awkgram.y (variable_create): New function to create a variable taking the deferred variable list into consideration. (variable): Call new function variable_create if the variable is not found. * gawkapi.c (api_sym_update): If an array is being created, then call new function variable_create instead of install_symbol. If this is the first reference to a deferred variable, than the new array may contain elements that must be merged into the array provided by the extension. 2015-01-05 Andrew J. Schorr * io.c (wait_any): If the `interesting' argument is non-zero, then we must not return until that child process has exited, since the caller gawk_pclose depends on our returning its exit status. So in that case, do not pass WNOHANG to waitpid. 2015-01-04 Andrew J. Schorr * gawkapi.h: Fix another comment typo. 2015-01-04 Andrew J. Schorr * gawkapi.h: Fix typo in comment. 2015-01-02 Andrew J. Schorr * gawkapi.h (gawk_api): Modify api_get_file to remove the typelen argument. (get_file): Remove typelen argument from the macro. * gawkapi.c (api_get_file): Remove typelen argument. 2014-12-24 Arnold D. Robbins * profile.c (pprint): Be sure to set ip2 in all paths through the code. Thanks to GCC 4.9 for the warning. 2014-12-18 Arnold D. Robbins * builtin.c (do_sub): Do not waste a byte at the end of a string. 2014-12-14 Arnold D. Robbins * awkgram.y (yyerror): Do not waste a byte at the end of a string. * builtin.c (do_match): Ditto. * command.y (append_statement): Ditto. * debug.c (gprintf, serialize): Ditto. * field.c (set_FIELDWIDTHS): Ditto. * io.c.c (grow_iop_buffer): Ditto. * profile.c (pp_string, pp_group3): Ditto. 2014-12-14 Andrew J. Schorr * array.c (concat_exp): Do not waste a byte at the end of a string. * awkgram.y (common_exp): Ditto. * builtin.c (do_substr): Ditto. * eval.c (set_OFS): Ditto. * field.c (rebuild_record): Ditto. * gawkapi.h (r_make_string): Ditto. * interpret.h (r_interpret): Ditto for Op_assign_concat. * node.c (r_format_val, r_dupnode, make_str_node, str2wstr, wstr2str): Ditto. * re.c (make_regexp): Ditto. 2014-12-20 Arnold D. Robbins Enable non-fatal output on per-file or global basis, via PROCINFO. * awk.h (RED_NON_FATAL): New redirection flag. * builtin.c (efwrite): If RED_NON_FATAL set, just set ERRNO and return. (do_printf): Check errflg and if set, set ERRNO and return. (do_print): Ditto. (do_print_rec): Ditto. * io.c (redflags2str): Update table. (redirect): Check for global PROCINFO["nonfatal"] or for PROCINFO[file, "nonfatal"] and don't fail on open if set. Add RED_NON_FATAL to flags. (in_PROCINFO): Make smarter and more general. 2014-12-12 Stephen Davies Improve comment handling in pretty printing. * awk.h (comment_type): New field in the node. (EOL_COMMENT, FULL_COMMENT): New defines. * awkgram.y (block_comment): New variable. (check_comment): New function. (grammar): Add code to handle comments as needed. (get_comment): Now takes a flag indicating kind of comment. (yylex): Collect comments appropriately. (append_rule): Ditto. * profile.c (pprint): Smarten up comment handling. Have printing \n take comments into account. (end_line): New function. (pp_func): Better handling of function comments. 2014-12-10 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-11-26 Arnold D. Robbins * builtin.c (do_sub): Improve wording of gensub warnings. 2014-11-25 Arnold D. Robbins * builtin.c (do_sub): For gensub, add more warnings for invalid third argument. 2014-11-23 Arnold D. Robbins * awk.h: Move all inline functions to the bottom of the file. Keeps modern GCC happier. 2014-11-22 Arnold D. Robbins * awk.h (emalloc, realloc): Redefine in terms of ... (emalloc_real, eralloc_real): New static inline functions. (fatal): Move definition up. * gawkmisc.c (xmalloc): If count is zero, make it one for older mallocs that require size > 0 (such as z/OS). 2014-11-21 Arnold D. Robbins * main.c: Remove a debugging // comment. * NOTES: Removed. Unrelated: Revert changes of 2014-11-20 from Paul Eggert. Causes failures on z/OS. Unrelated: Avoid unnecessary copying of $0. * interpret.h (UNFIELD): New macro. (r_interpret): Use it where *lhs is assigned to. 2014-11-20 Paul Eggert Port to systems where malloc (0) and/or realloc(P, 0) returns NULL. * gawkmisc.c (xmalloc): * xalloc.h (realloc): Do not fail if malloc(0) or realloc(P, 0) returns NULL. Fail only when the allocator returns null when attempting to allocate a nonzero number of bytes. 2014-11-19 Arnold D. Robbins Infrastructure upgrades: * Automake 1.14.1, Gettext 0.19.3, Libtool 2.4.3. * compile, extension/build-aux/compile: New files. 2014-11-19 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.19.3. 2014-11-16 Arnold D. Robbins * interpret.h: Revert change of 2014-11-11 since it breaks certain uses. Unrelated: * dfa.c: Sync with GNU grep. 2014-11-15 Arnold D. Robbins * array.c, awk.h, awkgram.y, builtin.c, dfa.c, eval.c, field.c, interpret.h, io.c, main.c, mpfr.c, node.c, re.c, regex_internal.h, replace.c: Remove all uses of MBS_SUPPORT. * regex_internal.h: Disable wide characters on DJGPP. * mbsupport.h: Rework to be needed only for DJGPP. 2014-11-11 Arnold D. Robbins Don't let memory used increase linearly in the size of the input. Problem reported by dragan legic . * field.c (set_record): NUL-terminate the buffer. * interpret.h (r_interpret): Op_field_spec: if it's $0, increment the valref. Op_store_var: if we got $0, handle it appropriately. 2014-11-10 Arnold D. Robbins Reorder main.c activities so that we can set a locale on the command line with the new, for now undocumented, -Z option. * main.c (parse_args, set_locale_stuff): New functions. (stopped_early): Made file level static. (optlist, optab): Add new argument. (main): Adjust ordering and move inline code into new functions. 2014-11-09 Andrew J. Schorr * gawkapi.c (node_to_awk_value): When the type wanted is AWK_UNDEFINED and a it's a Node_val set to Nnull_string, return AWK_UNDEFINED instead of AWK_NUMBER 0. 2014-11-06 Andrew J. Schorr * awk.h (redirect_string): First argument should be const. Add a new extfd argument to enable extensions to create files with pre-opened file descriptors. (after_beginfile): Declare function used in both eval.c and gawkapi.c. * eval.c (after_beginfile): Remove extern declaration now in awk.h. * gawkapi.c (api_get_file): Implement API changes to return awk_input_buf_t and/or awk_output_buf_t info, as well as accept an fd for inserting an opened file into the table. * gawkapi.h (gawk_api): Modify the api_get_file declaration to return awk_bool_t and add 3 new arguments -- a file descriptor for inserting an already opened file, and awk_input_buf_t and awk_output_buf_t to return info about both input and output. (get_file): Add new arguments to the macro. * io.c (redirect_string): First arg should be const, and add a new extfd arg so extensions can pass in a file that has already been opened by the extension. Use the passed-in fd when appropriate, and pass it into two_way_open. (redirect): Pass new fd -1 arg to redirect_string. (two_way_open): Accept new extension fd parameter and open it as a socket. 2014-11-05 Andrew J. Schorr * io.c (retryable): New function to indicate whether I/O can be retried for this file instead of throwing a hard error. (get_a_record) Check whether this file is configured for retryable I/O before returning nonstandard -2. 2014-11-03 Norihiro Tanaka * re.c (research): Use dfa superset to improve matching speed. 2014-11-02 Arnold D. Robbins * profile.c (div_on_left_mul_on_right): New function. (parenthesize): Call it. 2014-10-30 Arnold D. Robbins * configure: Regenerated after fix to m4/readline.m4. Unrelated; fixes to profiling. Thanks to Hermann Peifer and Manuel Collado for pointing out problems: * profile.c (pprint): For Op_unary_minus, parenthesize -(-x) correctly. (prec_level): Get the levels right (checked the grammar). (is_unary_minus): New function. (pp_concat): Add checks for unary minus; needs to be parenthesized. 2014-10-30 Andrew J. Schorr * NEWS: Mention installation of /etc/profile.d/gawk.{csh,sh}. 2014-10-29 Andrew J. Schorr * configure.ac (AC_CONFIG_FILES): Add extras/Makefile. * Makefile.am (SUBDIRS): Add extras. * extras: Add new subdirectory. 2014-10-29 Arnold D. Robbins * dfa.c: Sync with GNU grep. Again, again. 2014-10-28 Arnold D. Robbins * dfa.c: Sync with GNU grep. Again. 2014-10-25 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-10-17 John E. Malmberg * ext.c (close_extensions): Test for null pointer since since this can be called by signal handler before the pointers are initialized. 2014-10-15 Arnold D. Robbins Make sane the handling of AWKPATH and AWKLIBPATH: 1. Don't explicitly search "."; it must be in the path either physically or as null element a la the shell's $PATH 2. If environment's value was empty, use built-in default value. 3. Set ENVIRON["AWK*PATH"] to the path used. * io.c (path_info): Remove try_cwd member. (get_cwd): Removed, not needed anymore. (do_find_source): Don't do explicit check in current directory. It must come from the AWKPATH or AWKLIBPATH variable. * main.c (path_environ): If value from environment was empty, set it to the default. This is how gawk has behaved since 2.10. 2014-10-13 Arnold D. Robbins * regcomp.c (__re_error_msgid): Make error message for REG_EBRACK more helpful - also used for unmatched [:, [., [=. Thanks to Davide Brini for raising the issue. 2014-10-12 KO Myung-Hun Fixes for OS/2: * Makefile.am (install-exec-hook, uninstall-links): Use $(EXEEXT). * getopt.h: Redefinitions if using KLIBC. * io.c (_S_IFDIR, _S_IRWXU): Define if the more standard versions are available. 2014-10-12 Arnold D. Robbins * README: Remove Pat Rankin from VMS duties, per his request. 2014-10-08 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-10-05 Arnold D. Robbins * profile.c (pprint): Fix typo in header. Sheesh. Unrelated: * awkgram.y (mk_program): Add a comment that we don't need to clear the comment* variables. 2014-10-04 Arnold D. Robbins * profile.c (pp_string_fp): Fix breaklines case to actually output the current letter. This broke at gawk 4.0.0. Sigh. Thanks to Bert Bos (bert@w3.org) for the report. 2014-10-03 Stephen Davies * awkgram.y (program_comment): Renamed from comment0. (function_comment): Renamed from commentf. 2014-10-02 Arnold D. Robbins * awkgram.y, profile.c: Minor white space cleanups. 2014-10-01 Arnold D. Robbins Fix a few compile warnings: * awkgram.y (split_comment): Make static. General: Remove some unused variables, clean up some whitepace nits. * profile.c (indent): Add some braces to turn off compiler warnings. 2014-09-29 Andrew J. Schorr * main.c (main): In optlist, it should say "h", not "h:", since there is no argument for the help option. Thanks to Joep van Delft for the bug report. 2014-09-29 Arnold D. Robbins * gawkapi.h: Minor edits to sync with documentation. Does not influence the behavior of the API. 2014-09-28 Arnold D. Robbins * command.y (cmdtab): Add "where" as an alias for "backtrace". Finally! Unrelated: * dfa.c: Sync with GNU grep. 2014-09-27 Arnold D. Robbins * awkgram.y (check_for_bad): Bitwise-and the bad character with 0xFF to avoid sign extension into a large integer. Unrelated: * configure.ac: Add an option to enable locale letters in identifiers. Undocumented and subject to being rescinded at any time in the future. * NEWS: Mention to look at configure --help. Unrelated: * profile.c (pprint): Use "rule(s)" instead of "block(s)" in the header. 2014-09-23 Arnold D. Robbins * awkgram.y (yylex): Don't check for junk characters inside quoted strings. Caused issues on DJGPP and Solaris. Unrelated: * io.c (devopen): Straighten things out with respect to compatibility with BWK awk. 2014-09-19 Arnold D. Robbins * awkgram.y: Further commentary as to the treacherousness of isalnum and isalpha. 2014-09-15 Arnold D. Robbins Finish removing use of isalpha and isalnum. * awk.h (is_alpha, is_alnum, is_identchar): Add declarations. * awkgram.y (yylex): Use is_alpha. (is_alpha, is_alnum): New functions. (is_identchar): Use is_alnum. * builtin.c (r_format_tree): Use is_alpha, is_alnum. * command.y (yylex): Use is_alpha, is_identchar. * ext.c (is_letter): Use is_alpha. (is_identifier_char): Removed; replaced uses with is_identchar. * main.c (arg_assign): Use is_alpha, is_alnum. * node.c (r_force_number): Use is_alpha. 2014-09-14 Arnold D. Robbins * awkgram.y (is_identchar): Change from simple macro to function since use of isalnum() let non-ASCII letters slip through into identifiers. 2014-09-13 Stephen Davies When doing pretty-printing (but not profiling), include the original comments in the output. General rules: Pretty printing: - Do NOT indent by a tab - Do NOT print the header comments ("# BEGIN rules", etc.) - DO print the comments that are in the program Profiling: - DO indent by a tab - DO print the header comments - Do NOT print the program's original comments * awkgram.y (comment0, commentf): New varibles that are pointers to program and function comments. (get_comment): New function that retrieves consecutive comment lines and empty lines as a unit). (split_comment): New function: iff first block in the program is a function and it is predeeded by comments, take the last non-blank line as function comment and any preceeding lines as program comment.) Following token rules were changed to handle comments: * awkgram.y (pattern, LEX_BEGIN, LEX_END, LEX_BEGINFILE, LEX_ENDFILE, action, function_prologue, statements): Update to handle comments. Following functions were changed to handle comments: * awkgram.y (mk_program, mk_function, allow_newline and yylex): Update to handle comments. (Also fixed typo in case '\\'.) * profile.c (print_comment): New function to format comment printing. (indent, pprint, dump_prog, pp_func): Changed to handle comments and the revised indentation rules. 2014-09-07 Arnold D. Robbins * awk.h: Move libsigsegv stuff to ... * main.c: here. Thanks to Yehezkel Bernat for motivating the cleanup. * symbol.c (make_symbol, install, install_symbol): Add const to first parameter. Adjust decls and fix up uses. 2014-09-05 Arnold D. Robbins Add builtin functions to FUNCTAB for consistency. * awk.h (Node_builtin_func): New node type. (install_builtins): Declare new function. * awkgram.y [DEBUG_USE]: New flag value for debug functions; they don't go into FUNCTAB. (install_builtins): New function. * eval.c (nodetypes): Add Node_builtin_func. * interpret.h (r_interpret): Rework indirect calls of built-ins since they're now in the symbol table. * main.c (main): Call `install_builtins'. * symbol.c (install): Adjust for Node_builtin_func. (load_symbols): Ditto. 2014-09-04 Arnold D. Robbins * profile.c (pprint): Case Op_K_for: Improve printing of empty for loop header. Unrelated: Make indirect function calls work for built-in and extension functions. * awkgram.y (lookup_builtin): New function. * awk.h (builtin_func_t): New typedef. (lookup_builtin): Declare it. * interpret.h (r_interpret): For indirect calls, add code to find and call builtin functions, and call extension functions. 2014-09-01 Arnold D. Robbins * builtin.c (do_substr): Return "" instead of null string in case result is passed to length() with --lint. Based on discussions in comp.lang.awk. Unrelated: * interpret.h (r_interpret): For indirect function call, separate error message if lookup returned NULL. Otherwise got a core dump. Thanks to "Kenny McKormack" for the report in comp.lang.awk. 2014-08-27 Arnold D. Robbins * configure.ac: Add test for strcasecmp. * regcomp.c: Remove special case code around use of strcasecmp(). * replace.c: Include missing/strncasecmp.c if either strcasecmp() or strncasecmp() aren't available. 2014-08-26 Arnold D. Robbins * regcomp.c, regex_internal.c: Sync with GBLIC. Why not. Unrelated: Remove support for MirBSD. It uglified the code too much for no discernable gain. * configure.ac: Remove check for MirBSD and define of LIBC_IS_BORKED. * dfa.c: Remove code depending on LIBC_IS_BORKED. * main.c: Ditto. * regcomp.c: Ditto. * NEWS: Updated. 2014-08-24 Arnold D. Robbins * regex.h: Remove underscores in names of parameters in function declarations. Tweak names as neeeded. 2014-08-20 Arnold D. Robbins * node.c (parse_escape): Max of 2 digits after \x. 2014-08-18 Arnold D. Robbins * symbol.c: General formatting cleanup. 2014-08-15 Arnold D. Robbins * main.c (usage): Adjust whitespace for -L and add "invalid" as a possible value for it. Report from Robert P. J. Day . 2014-08-14 Arnold D. Robbins * Makefile.am (SUBDIRS): Put awklib after doc so that examples get extracted when the doc changes. 2014-08-13 Arnold D. Robbins * builtin.c (do_sub): Move initial allocation of the replacement string down towards code to do the replacement, with a (we hope) better guesstimate of how much to initially allocate. The idea is to avoid unnecessary realloc() calls by making a better guess at how much to allocate. This came up in an email discussion with Tom Dickey about mawk's gsub(). 2014-08-12 Juergen Kahrs * cmake/configure.cmake: * cmake/package.cmake: Copyright update. * README.cmake: * README_d/README.cmake: Moved file. 2014-08-12 Arnold D. Robbins OFS being set should rebuild $0 using previous OFS if $0 needs to be rebuilt. Thanks to Mike Brennan for pointing this out. * awk.h (rebuild_record): Declare. * eval.c (set_OFS): If not being called from var_init(), check if $0 needs rebuilding. If so, parse the record fully and rebuild it. Make OFS point to a separate copy of the new OFS for next time, since OFS_node->var_value->stptr was already updated at this point. * field.c (rebuild_record): Is now extern instead of static. Use OFS and OFSlen instead of the value of OFS_node. Unrelated: * Makefile.am (RM): Define for makes that don't have it, such as on OpenBSD. Thanks to Jeremie Courreges-Anglas for the report. 2014-08-05 Arnold D. Robbins Bug fix: For MPFR sqrt(), need to set precision of result to be the same as that of the argument. Doesn't hurt other functions. See test/mpfrsqrt.awk. Thank to Katie Wasserman for the bug report. * mpfr.c (do_mpfr_func): New function. Runs code for MPFR functions while still enabling debugging. Add call here to mpfr_set_prec(). Original code from SPEC_MATH macro. (SPEC_MATH): Change macro to call do_mpfr_func(). Next MPFR bug fix: The % operator gave strange results for negative numerator. Thanks again to Katie Wasserman for the bug report. * mpfr.c (mpg_mod): Use mpz_tdiv_qr() instead of mpz_mod(). From the GMP doc, mpz_mod() should have worked; it's not clear why it doesn't. 2014-08-03 Arnold D. Robbins * builtin.c (format_tree): Don't need to check return value of wctombr for -2. Thanks to Eli Zaretskii for pointing this out. Unrelated: * gawkapi.h: Fix doc for API get_record - errcode needs to be greater than zero. * interpret.h (r_interpret): Move setting of ERRNO to here, from ... * io.c (inrec): ... here. Makes the code cleaner. 2014-08-03 Andrew J. Schorr * awkgram.y (getfname): Match on either ptr or ptr2 so --profile will work in -M (MPFR bignum) mode. 2014-07-31 Arnold D. Robbins * builtin.c (format_tree): Make %c handling more sane on Windows. Rework the lint messages. Unrelated: * dfa.c: Sync with GNU grep. Mainly white space differences. Unrelated: * mpfr.c (cleanup_mpfr): New function to deallocate _mpf_t1 and _mpf_t2; removes some valgrind warnings. * awk.h (cleanup_mpfr): Add declaration. * main.c (main): Add call to `cleanup_mpfr'. Fix memory leak: * mpfr.c (do_mpfr_div): Add unref to denominator and numerator to not leak memory. Thanks to Katie Wasserman for isolating the problem to that routine. 2014-07-25 Arnold D. Robbins * main.c (main): Add a warning message if -M is used and gawk was compiled without MPFR/GMP. 2014-07-24 Arnold D. Robbins * main.c (usage): Put text for `-n' *after* text for `-m'. Report from Robert P. J. Day . Fix problems with I/O errors reported by Assaf Gordon : * io.c (inrec): Change type to bool to make calling easier. Add check in non-EOF case for error, and if so, return false. Update ERRNO in case there is an ENDFILE block. * awk.h (inrec): Change type in declaration. * interpret.h (r_interpret): Change call of inrec() to boolean notation. 2014-07-10 Arnold D. Robbins New `div()' function to do integer division and remainder; mainly useful for use with GMP integers. Thanks to Katie Wasserman for the suggestion. * awk.h (do_div, do_mpfr_div): Declare new functions. * builtin.c (do_div): New function. * mpfr.c (do_mpfr_div): New function. * awkgram.y (tokentab): New entry. (snode): Add check for do_div/do_mpfr_div to make 3rd arg be an array. * NEWS: Updated. * TODO: Updated. 2014-07-10 Arnold D. Robbins * awkgram.y (check_for_bad): New routine to do the fatal message, with smarter checking. (nextc): Call it as appropriate. * builtin.c (format_tree): Add check for bad returns from mbrlen to avoid trying to malloc (size_t) -1 bytes. Thanks to mail.green.fox@gmail.com for the bug report. 2014-07-03 Arnold D. Robbins * awkgram.y (nextc): Add bool check_for_bad parameter to check for bad characters in the source program. (yylex): Adjust calls. 2014-06-24 Arnold D. Robbins * main.c (main): The --pretty-print option no longer runs the program. This removes the need for the GAWK_NO_PP_RUN environment var. * NEWS: Updated. * TODO: Updated. 2014-06-22 Paul Eggert Bring in from GNULIB: regex: fix memory leak in compiler Fix by Andreas Schwab in: https://sourceware.org/ml/libc-alpha/2014-06/msg00462.html * lib/regcomp.c (parse_expression): Deallocate partially constructed tree before returning error. 2014-06-19 Arnold D. Robbins * builtin.c (do_sub): Add more info to leading comment. Add some whitespace in the code. 2014-06-08 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-06-03 Arnold D. Robbins * dfa.c (mbs_to_wchar): Define a macro if not MBS. 2014-05-29 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-05-26 Arnold D. Robbins * io.c (inetfile): Change return type to bool. Wrap code with ifdef HAVE_SOCKETS so that it'll compile on DJGPP. 2014-05-22 Andrew J. Schorr Allow any redirected getline inside BEGINFILE/ENDFILE. * awkgram.y (LEX_GETLINE): Only require a redirection and not also a variable if getline is in a BEGINFILE or ENDFILE rule. * interpret.h (Op_K_getline_redir): Remove check and fatal error. 2014-05-20 Arnold D. Robbins * dfa.c (dfaexec): Minor sync with GNU grep. 2014-05-14 Arnold D. Robbins * custom.h (_GL_PURE): Move definition to here. Sigh. * dfa.h, dfa.c: Sync with GNU grep. Sigh. Unrelated: * custom.h: Remove stuff for Ultrix 4.3. No one has such systems anymore; this just got missed earlier. 2014-05-11 Arnold D. Robbins * debug.c (do_eval): Repair fix of 2014-05-09 and use assoc_remove to take @eval out of the function table. * symbol.c: Fix a comment. This file needs some work. 2014-05-10 Arnold D. Robbins * io.c (get_a_record): Finish TERMNEAREND handling in case we don't have a regular file but aren't going to get more data. Added some additional comments. 2014-05-09 Arnold D. Robbins * debug.c (do_eval): Don't free `f' which points into the context that was previously freed. Bug reported by Jan Chaloupka . Apparently introduced with move to SYMTAB and FUNCTAB, but only showed up on Fedora 20 and Ubuntu 14.04, which have a newer glibc. (do_eval): Fix a memory leak seen by valgrind on Fedora 20 and Ubuntu 14.04: the new SRCFILE that is added wasn't released. Unrelated: * io.c (get_a_record): Handle return of TERMNEAREND when the entire file has been read into the buffer and we're using a regex for RS. Bug report by Grail Dane . 2014-05-04 Arnold D. Robbins * debug.c (debug_prog): Change check for GAWK_RESTART so that it actually works. Bug fix: run command in debugger would start over again but not actually start running the program. 2014-04-25 Andrew J. Schorr * io.c (two_way_open): In forked child, reset SIGPIPE to SIG_DFL. Fixes problems with "broken pipe" errors from child processes, restoring 4.1.0 and earlier behavior. Thanks to Daryl F for the report. (gawk_popen): Ditto. 2014-04-25 Arnold D. Robbins * dfa.h, dfa.c: Merge with GNU grep; lots of forward motion. 2014-04-24 Arnold D. Robbins Update xalloc.h for pending merge with dfa. * xalloc.h (xstrdup): Implement this. (x2nrealloc): Incorporate changed logic from GNULIB. 2014-04-20 Andrew J. Schorr * io.c (struct inet_socket_info): Define new structure for use in parsing special socket filenames. (inetfile): Parse all components of the special socket filename into the struct inet_socket_info. Returns true only if it is a valid socket fliename, unlike the previous version which checked for the '/inet[46]?/' prefix only. (redirect): Patch to use updated inetfile() function. (devopen): Remove logic to parse socket filenames, since this has been moved into the inetfile() function. (two_way_open): Update args to inetfile(). 2014-04-20 Arnold D. Robbins * builtin.c (do_rand): Make calls to random() in predictable order to avoid order of evaluation differences amongst compilers. Thanks to Anders Magnusson (of the PCC team) for the suggestion. 2014-04-18 Arnold D. Robbins * configure.ac: Change adding of -export-dynamic for GCC to be -Wl,-export-dynamic, which then works for PCC also. 2014-04-11 Arnold D. Robbins * io.c (closemabyesocket): Define if not defined, e.g. building without socket code. Thanks to dave.gma@googlemail.com (Dave Sines) for the report. 2014-04-08 Arnold D. Robbins * 4.1.1: Release tar ball made. 2014-04-08 Arnold D. Robbins * README: Update. * configure.ac: Bump version. 2014-04-03 Arnold D. Robbins * regcomp.c (parse_bracket_exp): Move a call to `re_free' inside an ifdef. Makes the code marginally cleaner. 2014-03-30 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2014-03-28 Arnold D. Robbins * configure.ac: Remove duplicate AC_HEADER_TIME and rearrange order of macros some. May help on older systems. 2014-03-23 Arnold D. Robbins * dfa.c: Move include of dfa.h around for correct building on Irix. Thanks to Nelson H.F. Beebe for the report. Unrelated: * .gitignore: Simplify .dSYM pattern for Mac OS X. 2014-03-21 Arnold D. Robbins * dfa.c (using_simple_locale): Add ifdefs in case there is no locale support at all. Thanks to Scott Deifik for the report. Unrelated: * main.c (UPDATE_YEAR): Set to 2014. 2014-03-17 Arnold D. Robbins * .gitignore: Add .dSYM directories for Mac OS X. Thanks to Hermann Peifer for the suggestion. 2014-03-10 Arnold D. Robbins * dfa.h, dfa.c: Sync with grep. Yet again. * regex_internal.c (built_wcs_upper_buffer, build_upper_buffer): Fixes from GNULIB for mixed case matching on Mac OS X. Unrelated: * builtin.c (format_tree): Smarten handling of %' flag. Always pass it in for floating point formats. Then only add the thousands_sep if there is one. Also, allow for thousands_sep to be a string, not just one character. Thanks to Michal Jaegermann for the report. 2014-03-08 Andrew J. Schorr * gawkapi.c (api_impl): Add memory allocation function pointers. * gawkapi.h (GAWK_API_MINOR_VERSION): Bump. (gawk_api_t): Add memory allocation function pointers api_malloc, api_calloc, api_realloc, and api_free. (gawk_malloc, gawk_calloc, gawk_realloc, gawk_free): New macros. (emalloc): Replace malloc with gawk_malloc. (erealloc): Replace erealloc with gawk_erealloc. 2014-03-05 Arnold D. Robbins Straighten out enumerated types some more. * awk.h (add_srcfile): Fix type of first parameter. * awkgram.y (add_srcfile, do_add_srcfile): Ditto. * cmd.h (A_NONE): New enum nametypeval. * command.y (argtab): Use it in final value. * ext.c (make_builtin): Use awk_false, awk_true. * io.c (init_output_wrapper): Use awk_false. Unrelated: * debug.c (do_commands): Initialize num to silence warnings. Thanks to Michal Jaegermann. Unrelated: * builtin.c (do_mktime): Change lint warning for minutes to check against 59, not 60. Thanks to Hermann Peifer for the report. 2014-03-03 Arnold D. Robbins * dfa.c: Sync with grep. Yet again. 2014-02-28 Arnold D. Robbins * dfa.c: Sync with grep. Looks like good improvement with respect to bracket expressions. 2014-02-27 Arnold D. Robbins Fixes for enum/int mismatches as warned by some compilers. * awk.h (ANONE): New enum for array sorting. * array.c (assoc_list): Use it. * builtin.c (format_tree): New MP_NONE value. * gawkapi.c: Use awk_false and awk_true everywhere instead of false and true. 2014-02-26 Arnold D. Robbins * configure.ac: Set up do-nothing extension/Makefile on MirBSD also. 2014-02-21 Arnold D. Robbins * dfa.h, dfa.c (parse_bracket_exp): Sync with grep. 2014-02-20 Arnold D. Robbins * regex.h, regex.c, regex_internal.c, regex_internal.h: Sync with GLIBC. Mainly copyright updates. * getopt.c, getopt.h, getopt1.c, getopt_int.h: Ditto. * dfa.c (parse_bracket_exp): Sync with grep, where they restored the buggy code. Sigh. Unrelated: * NEWS: Typo fix. * interpret.h (r_interpret): Init a variable for BEGINFILE to avoid compiler warnings. Thanks to Michal Jaegermann. 2014-02-15 Arnold D. Robbins * awkgram.c, command.c: Regenerated - Bison 3.0.2. 2014-02-04 Arnold D. Robbins * dfa.c (to_uchar): Make use of this. Syncs with GNU grep. 2014-02-03 Arnold D. Robbins * awkgram.y (negate_num): Bracket `tval' in #ifdef MPFR since it's only used in that code. 2014-01-31 Arnold D. Robbins * Makefile.am (dist-hook): Improve creation of pc/config.h. We have to jump through a lot of hoops for 'make distcheck' to actually work. 2014-01-30 Arnold D. Robbins * Makefile.am (dist-hook): Improve creation of pc/config.h to copy the new file into the distribution directory being created. Also, put the temporary files into /tmp. 2014-01-28 Arnold D. Robbins * awkgram.y (negate_num): If just a double, return. Fixes a bug that showed up on 32-bit systems with MPFR. Thanks to Eli Zaretskii and Corinna Vinschen for the report. Also, free the MPZ integer. Thanks to valgrind for the report. Unrelated: * dfa.c: Sync with GNU grep - removed some special cased code for grep. 2014-01-24 Arnold D. Robbins * configure.ac, field.c: Update copyright year. 2014-01-19 Arnold D. Robbins * awkgram.y (negate_num): Handle the case of -0 for MPFR; the sign was getting lost. Thanks to Hermann Peifer for the report. 2014-01-18 Arnold D. Robbins * dfa.c (parse_bracket_exp): Sync with GNU grep, which now uses gawk's code for RRI in single-byte locales! Hurray. 2014-01-16 Arnold D. Robbins * configure.ac: For z/OS, restore creation of do-nothing Makefile in extension directory. 2014-01-14 Arnold D. Robbins * field.c (do_split): Make sure split() gets FS value if no third arg even after FPAT was set. Thanks to Janis Papanagnou for the report. 2014-01-13 Arnold D. Robbins * README: Fix John Malmberg's email address. 2014-01-12 Arnold D. Robbins * awkgram.y: Update copyright year. (func_use): Simplify code. * command.y: Update copyright year. * ext.c: Update copyright year. (make_builtin): Small simplification. (make_old_builtin): Make code consistent with make_builtin(), add call to track_ext_func(). * bootstrap.sh: Update copyright year. Remove touch of version.c since that file is no longer autogenerated. 2014-01-07 Arnold D. Robbins * command.y (next_word): Move into ifdef for HAVE_LIBREADLINE, since it's only used by that code. * ext.c (load_old_ext): Minor improvements. 2014-01-03 Arnold D. Robbins * config.guess, config.rpath, config.sub, depcomp, install-sh: Updated. * dfa.h, dfa.c: Sync with GNU grep; comment fix and copyright year. * NEWS: Updated some, including copyright year. 2013-12-26 Arnold D. Robbins * README: Add John Malmberg for VMS. 2013-12-24 Arnold D. Robbins * getopt.h: Add `defined(__sun)' to list of system that do get to include stdlib.h. Needed for Illumos. Thanks to Richard Palo for the report. 2013-12-21 Mike Frysinger * configure.ac: Add --disable-extensions flag to control compiling extensions. Better for cross-compiling. (AC_CANONICAL_HOST): Added. Changed case statments appropriately. * Makefile.am (check-for-shared-lib-support): Removed. (check-recursive, all-recursive): Removed. 2013-12-21 Arnold D. Robbins * config.guess: Updated. * configure, aclocal.m4: Updated based on automake 1.13.4. 2013-12-19 Arnold D. Robbins * regexec.c (re_search_internal): Make sure `dfa' pointer is not NULL before trying to dereference it. 2013-12-16 Arnold D. Robbins * configure.ac (AC_FUNC_VPRINTF): Remove. Not needed on current systems. * awk.h (HAVE_VPRINTF): Remove check. 2013-12-12 John E. Malmberg * io.c (redirect): Add additional VMS error codes. (nextfile): Retry open after closing some files. 2013-12-10 Scott Deifik * io.c (closemaybesocket): Add definition for DJGPP. 2013-12-10 Arnold D. Robbins * awk.h (Floor, Ceil): Remove declarations and VMS redefinitions. * floatcomp.c (Floor, Ceil): Removed, not needed. Move bracketing ifdef to the top of the file. * builtin.c (double_to_int): Use floor() and ceil(). 2013-12-07 Arnold D. Robbins * regex_internal.h (__attribute__): Define to empty if not GCC. * custom.h (__attribute__): Remove the definition from here; the right place was regex_internal.h. 2013-12-06 Arnold D. Robbins No need to generate version.c from version.in. Thanks to John E. Malmberg for the suggestion. * version.in: Removed. * version.c: Use PACKAGE_STRING directly. * Makefile.am (EXTRA_DIST): Remove version.in. (distcleancheck_listfiles): Remove this rule. (MAINTAINERCLEANFILES): Remove this definition. (version.c): Remove the rule to create it. 2013-12-05 Arnold D. Robbins Fixes for Z/OS. * custom.h (__attribute__): Define to empty. * dfa.c (parse_bracket_exp): Add a cast to quiet a warning. * regex.c: Correctly bracket include of . Unrelated: * debug.c (find_rule): Add a FIXME comment. 2013-12-03 John E. Malmberg * io.c (redirect): Add additional VMS error code to check. (do_find_source): Append "/" if not a VMS filename. 2013-12-01 Andrew J. Schorr * main.c (optab): Sort by long option name. 2013-11-27 Andrew J. Schorr * main.c (optab): Add entry for --include. 2013-11-23 Arnold D. Robbins * dfa.c: Merge from grep; minor fixes in how bit twiddling is done. 2013-11-01 Arnold D. Robbins * dfa.c (lex): Reset laststart so that stuff like \s* works. Fix from grep. 2013-10-31 Arnold D. Robbins * builtin.c (efwrite): If write error to stdout is EPIPE, die silently. Thanks to Hermann Peifer for helping find this. 2013-10-22 Arnold D. Robbins Revise error messages when writing to standard output or standard error to ignore EPIPE. Add the ability based on an environment variable to get the source file and line number. * awk.h (r_warning): Renamed from warning. (warning): New macro to set location and call warning. * io.c (flush_io): Print errors only if not EPIPE. (close_io): Ditto. * main.c (lintfunc): Init to r_warning. (main): Enhance explanatory comment. (usage): Print errors only if not EPIPE. (copyleft): Ditto. * msg.c (err): Make printing srcfile and srcline depend upon GAWK_MSG_SRC environment variable. (r_warning): Renamed from warning. 2013-10-17 Arnold D. Robbins * 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 Make -O work again. Turns out that C99 bool variables are clamped to zero or one. * main.c (do_optimize): Init to false. (main): Set do_optimize to true on -O. * eval.c (setup_frame): Change all uses of do_optimize to be a boolean check instead of a test > 1. * awkgram.y: Ditto. (optimize_assignment): Remove check against do_optimize since it was inited to true anyway. Unrelated: * 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 * dfa.c (lex): Sync with GNU grep. Handle multibyte \s and \S. Unrelated: * awk.h [ARRAY_MAXED]: Fix value of this and subsequent flags after addition of NULL_FIELD. * eval.c (flags2str): Add NULL_FIELD. Duh. 2013-10-09 Arnold D. Robbins * awkgram.y (mk_assignment): Rework switch to handle Op_assign, and to provide a better error message upon unknown opcode. 2013-09-28 Arnold D. Robbins * dfa.c: Sync with GNU grep. 2013-09-25 Arnold D. Robbins * builtin.c (do_rand): Make the result more random by calling random() twice. See the comment in the code. Thanks to Bob Jewett for the report and the fix. 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-22 Arnold D. Robbins * 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 * 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 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 * 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-08-02 Arnold D. Robbins * awkgram.y (append_rule): Add attempt to insert any comment before a rule. Commented out at the moment. 2013-07-30 Arnold D. Robbins * awk.h (enum opcodeval): Add Op_comment. * awkgram.y (comment): New variable to hold comment text. (statement): Add saved comments to lists being built. (allow_newline): Save comment text if necessary. Append if have existing text. (yylex): Ditto. * debug.c (print_instruction): Handle Op_comment. * eval.c (optypes): Add entry for Op_comment. * interpret.h (r_interpret): Ditto. * profile.c (pprint): For Op_comment, print the comment text. 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-07 Andrew J. Schorr * configure.ac (AC_CHECK_FUNCS): Check for sigprocmask. * io.c (wait_any): If sigprocmask is available, block signals instead of ignoring them temporarily. 2013-07-05 Andrew J. Schorr * gawkapi.h (gawk_api): Document that the api_get_file function will not access the file type and length arguments if the file name is empty. 2013-07-04 Andrew J. Schorr * configure.ac (AC_CHECK_FUNCS): Add a check for waitpid. * io.c (wait_any): Enhance comment to explain why we loop reaping all exited children when the argument is zero. When available, use waitpid with WNOHANG to avoid blocking. Remove my previous incorrect patch to exit after reaping the first child. The function is intended to wait for all children, since we are not careful about reaping children as soon as they die. 2013-07-02 Andrew J. Schorr * gawkapi.h (gawk_api): Remove unused api_lookup_file hook. (lookup_file): Remove associated macro. * gawkapi.c (api_lookup_file): Remove unused function. (api_impl): Remove unused api_lookup_file hook. 2013-07-02 Andrew J. Schorr * awkgram.y (main_beginfile): Declare new global INSTRUCTION *. (parse_program): Set main_beginfile to point to the BEGINFILE instruction block. * gawkapi.c (api_get_file): After nextfile starts a new file, we need to run the BEGINFILE actions. We retrieve the instruction pointer from main_beginfile and execute it until we reach the Op_after_beginfile opcode. We then run after_beginfile manually and restore the value of currule and source. 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-02 Andrew J. Schorr * eval.c (update_ERRNO_string): Set PROCINFO["errno"] to 0. * io.c (inrec): Since get_a_record may now return -2, be sure to throw an error in that case as well. (wait_any): Fix what appears to be a bug. The old logic repeatedly called wait until it failed. When a process has multiple children, this causes it to stall until all of them have exited. Instead, we now exit the function after the first successful wait call. (do_getline_redir, do_getline): Handle case where get_a_record returns -2. (errno_io_retry): New function to decide whether an I/O operation should be retried. (get_a_record): When read returns an error, call errno_io_retry to decide whether the operation should be retried. If so, return -2 instead of setting the IOP_AT_EOF flag. 2013-07-01 Andrew J. Schorr * eval.c (update_ERRNO_int, unset_ERRNO): Update PROCINFO["errno"]. 2013-06-30 Andrew J. Schorr * awk.h (redirect_string): Declare new function that provides API access to the redirection mechanism. * gawkapi.h (GAWK_API_MINOR_VERSION): Bump from 0 to 1 since 2 new hooks were added to the api. (gawk_api_t): Add 2 new functions api_lookup_file and api_get_file. (lookup_file, get_file): New macros to wrap the new API functions. * gawkapi.c (curfile): Declare this extern, since it is needed by lookup_file and get_flie. (api_lookup_file): Find an open file using curfile or getredirect(). (api_get_file): Find or open a file using curfile or redirect_string(). (api_impl): Add api_lookup_file and api_get_file. * io.c (redirect_string): Renamed from redirect and changed arguments to take a string instead of a 'NODE *'. This allows it to be called through the API's new get_file hook. (redirect): Now implemented by calling redirect_string backend function. 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 Andrew 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.