diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-09-16 20:29:55 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-09-16 20:29:55 +0300 |
commit | 05a4e7931d2d75fe87a18f15484553b9aa62b545 (patch) | |
tree | 36031c19082b589628e2a6852979f665ce502394 | |
parent | 87848093635e0d4e647601fe788e024ee90e1be6 (diff) | |
download | egawk-05a4e7931d2d75fe87a18f15484553b9aa62b545.tar.gz egawk-05a4e7931d2d75fe87a18f15484553b9aa62b545.tar.bz2 egawk-05a4e7931d2d75fe87a18f15484553b9aa62b545.zip |
Add lint warning for accessing $0 in an END rule.
-rwxr-xr-x | ChangeLog | 7 | ||||
-rw-r--r-- | builtin.c | 3 | ||||
-rw-r--r-- | field.c | 7 |
3 files changed, 15 insertions, 2 deletions
@@ -1,3 +1,10 @@ +2018-09-16 Arnold D. Robbins <arnold@skeeve.com> + + * field.c (get_field): Add lint check if accessing $0 inside + and END rule, print a "may not be portable" warning. + * builtin.c (do_print_rec): Call get_field() unconditionally + in order to do lint check. + 2018-09-14 Adrian Bunk <bunk@debian.org> * awk.h (init_debug, debug_prog): Move prototypes to here from ... @@ -2364,8 +2364,7 @@ do_print_rec(int nargs, int redirtype) if (fp == NULL) return; - if (! field0_valid) - (void) get_field(0L, NULL); /* rebuild record */ + (void) get_field(0L, NULL); /* rebuild record if necessary */ f0 = fields_arr[0]; @@ -837,6 +837,13 @@ get_field(long requested, Func_ptr *assign) * then the whole line must be rebuilt */ if (requested == 0) { + static bool warned = false; + extern int currule; + + if (do_lint && currule == END) { + warned = true; + lintwarn(_("accessing $0 from an END rule may not be portable")); + } if (! field0_valid) { /* first, parse remainder of input record */ if (NF == -1) { |