diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-01 22:44:44 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-01 22:44:44 +0300 |
commit | fb838ec318104f66a36e59f71ffb4f9eaa9b2eaa (patch) | |
tree | 144d88026bf6a306c39a6931f309e12d998a0ba8 | |
parent | ba1e7ab66563efb5b597a418e2e9fb4a01998d03 (diff) | |
parent | 2783f2c7d4e52fa7accfba7b847c416d8c71cd0f (diff) | |
download | egawk-fb838ec318104f66a36e59f71ffb4f9eaa9b2eaa.tar.gz egawk-fb838ec318104f66a36e59f71ffb4f9eaa9b2eaa.tar.bz2 egawk-fb838ec318104f66a36e59f71ffb4f9eaa9b2eaa.zip |
Merge branch 'gawk-4.1-stable'
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | builtin.c | 13 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/gawk.info | 12 | ||||
-rw-r--r-- | doc/gawk.texi | 9 | ||||
-rw-r--r-- | doc/gawktexi.in | 9 | ||||
-rw-r--r-- | interpret.h | 6 |
7 files changed, 63 insertions, 4 deletions
@@ -1,3 +1,15 @@ +2014-09-01 Arnold D. Robbins <arnold@skeeve.com> + + * 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 <arnold@skeeve.com> * configure.ac: Add test for strcasecmp. @@ -1759,7 +1759,14 @@ do_substr(int nargs) else if (do_lint == DO_LINT_INVALID && ! (d_length >= 0)) lintwarn(_("substr: length %g is not >= 0"), d_length); DEREF(t1); - return dupnode(Nnull_string); + /* + * Return explicit null string instead of doing + * dupnode(Nnull_string) so that if the result + * is checked with the combination of length() + * and lint, no error is reported about using + * an uninitialized value. Same thing later, too. + */ + return make_string("", 0); } if (do_lint) { if (double_to_int(d_length) != d_length) @@ -1813,7 +1820,7 @@ do_substr(int nargs) if (do_lint && (do_lint == DO_LINT_ALL || ((indx | length) != 0))) lintwarn(_("substr: source string is zero length")); DEREF(t1); - return dupnode(Nnull_string); + return make_string("", 0); } /* get total len of input string, for following checks */ @@ -1830,7 +1837,7 @@ do_substr(int nargs) lintwarn(_("substr: start index %g is past end of string"), d_index); DEREF(t1); - return dupnode(Nnull_string); + return make_string("", 0); } if (length > src_len - indx) { if (do_lint) diff --git a/doc/ChangeLog b/doc/ChangeLog index 4eaa8138..69069fd2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-01 Arnold D. Robbins <arnold@skeeve.com> + + * gaktexi.in: Add index entry for @ - @load, @include, + and indirect function calls. Thanks to "Kenny McKormack" in + comp.lang.awk. + 2014-08-29 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Continuing on reviewer comments, and other diff --git a/doc/gawk.info b/doc/gawk.info index afa825cc..f4b2b913 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -31205,6 +31205,10 @@ Index * ? (question mark), regexp operator <1>: GNU Regexp Operators. (line 59) * ? (question mark), regexp operator: Regexp Operators. (line 111) +* @-notation for indirect function calls: Indirect Calls. (line 47) +* @include directive: Include Files. (line 8) +* @load directive: Loading Shared Libraries. + (line 8) * [] (square brackets), regexp operator: Regexp Operators. (line 56) * \ (backslash): Comments. (line 50) * \ (backslash), \" escape sequence: Escape Sequences. (line 84) @@ -32274,6 +32278,8 @@ Index * extensions, common, single character fields: Single Character Fields. (line 6) * extensions, in gawk, not in POSIX awk: POSIX/GNU. (line 6) +* extensions, loading, @load directive: Loading Shared Libraries. + (line 8) * extensions, mawk: Common Extensions. (line 6) * extensions, where to find: gawkextlib. (line 6) * extract.awk program: Extract Program. (line 79) @@ -32324,6 +32330,7 @@ Index * FIELDWIDTHS variable <1>: User-modified. (line 37) * FIELDWIDTHS variable: Constant Size. (line 23) * file descriptors: Special FD. (line 6) +* file inclusion, @include directive: Include Files. (line 8) * file names, distinguishing: Auto-set. (line 56) * file names, in compatibility mode: Special Caveats. (line 9) * file names, standard streams in gawk: Special FD. (line 46) @@ -32450,6 +32457,7 @@ Index * FUNCTAB array: Auto-set. (line 123) * function calls: Function Calls. (line 6) * function calls, indirect: Indirect Calls. (line 6) +* function calls, indirect, @-notation for: Indirect Calls. (line 47) * function definition example: Function Example. (line 6) * function pointers: Indirect Calls. (line 6) * functions, arrays as parameters to: Pass By Value/Reference. @@ -32730,10 +32738,12 @@ Index * in operator, testing if array element exists: Reference to Elements. (line 38) * in operator, use in loops: Scanning an Array. (line 17) +* including files, @include directive: Include Files. (line 8) * increment operators: Increment Ops. (line 6) * index: String Functions. (line 155) * indexing arrays: Array Intro. (line 50) * indirect function calls: Indirect Calls. (line 6) +* indirect function calls, @-notation: Indirect Calls. (line 47) * infinite precision: Arbitrary Precision Arithmetic. (line 6) * info debugger command: Debugger Info. (line 13) @@ -32906,6 +32916,8 @@ Index * list debugger command: Miscellaneous Debugger Commands. (line 72) * list function definitions, in debugger: Debugger Info. (line 30) +* loading extensions, @load directive: Loading Shared Libraries. + (line 8) * loading, extensions: Options. (line 173) * local variables, in a function: Variable Scope. (line 6) * locale categories: Explaining gettext. (line 81) diff --git a/doc/gawk.texi b/doc/gawk.texi index 74dd35f8..6d37c556 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -4435,6 +4435,9 @@ to @code{EXIT_FAILURE}. This @value{SECTION} describes a feature that is specific to @command{gawk}. +@cindex @code{@@include} directive +@cindex file inclusion, @code{@@include} directive +@cindex including files, @code{@@include} directive The @code{@@include} keyword can be used to read external @command{awk} source files. This gives you the ability to split large @command{awk} source files into smaller, more manageable pieces, and also lets you reuse common @command{awk} @@ -4554,6 +4557,9 @@ and this also applies to files named with @code{@@include}. This @value{SECTION} describes a feature that is specific to @command{gawk}. +@cindex @code{@@load} directive +@cindex loading extensions, @code{@@load} directive +@cindex extensions, loading, @code{@@load} directive The @code{@@load} keyword can be used to read external @command{awk} extensions (stored as system shared libraries). This allows you to link in compiled code that may offer superior @@ -19851,6 +19857,9 @@ This style of programming works, but can be awkward. With @dfn{indirect} function calls, you tell @command{gawk} to use the @emph{value} of a variable as the name of the function to call. +@cindex @code{@@}-notation for indirect function calls +@cindex indirect function calls, @code{@@}-notation +@cindex function calls, indirect, @code{@@}-notation for The syntax is similar to that of a regular function call: an identifier immediately followed by a left parenthesis, any arguments, and then a closing right parenthesis, with the addition of a leading @samp{@@} diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 8091e16c..589c50b2 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -4346,6 +4346,9 @@ to @code{EXIT_FAILURE}. This @value{SECTION} describes a feature that is specific to @command{gawk}. +@cindex @code{@@include} directive +@cindex file inclusion, @code{@@include} directive +@cindex including files, @code{@@include} directive The @code{@@include} keyword can be used to read external @command{awk} source files. This gives you the ability to split large @command{awk} source files into smaller, more manageable pieces, and also lets you reuse common @command{awk} @@ -4465,6 +4468,9 @@ and this also applies to files named with @code{@@include}. This @value{SECTION} describes a feature that is specific to @command{gawk}. +@cindex @code{@@load} directive +@cindex loading extensions, @code{@@load} directive +@cindex extensions, loading, @code{@@load} directive The @code{@@load} keyword can be used to read external @command{awk} extensions (stored as system shared libraries). This allows you to link in compiled code that may offer superior @@ -18978,6 +18984,9 @@ This style of programming works, but can be awkward. With @dfn{indirect} function calls, you tell @command{gawk} to use the @emph{value} of a variable as the name of the function to call. +@cindex @code{@@}-notation for indirect function calls +@cindex indirect function calls, @code{@@}-notation +@cindex function calls, indirect, @code{@@}-notation for The syntax is similar to that of a regular function call: an identifier immediately followed by a left parenthesis, any arguments, and then a closing right parenthesis, with the addition of a leading @samp{@@} diff --git a/interpret.h b/interpret.h index c26a9d46..be017355 100644 --- a/interpret.h +++ b/interpret.h @@ -1038,7 +1038,11 @@ match_re: f = lookup(t1->stptr); } - if (f == NULL || f->type != Node_func) { + if (f == NULL) { + /* FIXME: See if function is a built-in and try to call it */ + fatal(_("`%s' is not a user-defined function, so it cannot be called indirectly"), + t1->stptr); + } else if(f->type != Node_func) { if (f->type == Node_ext_func || f->type == Node_old_ext_func) fatal(_("cannot (yet) call extension functions indirectly")); else |