Index: awkgram.y =================================================================== RCS file: /sources/gawk/gawk-stable/awkgram.y,v retrieving revision 1.3 diff -u -r1.3 awkgram.y --- awkgram.y 5 Sep 2006 23:10:41 -0000 1.3 +++ awkgram.y 3 Dec 2006 09:27:00 -0000 @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2005 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2006 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -245,11 +245,19 @@ } | LEX_BEGIN { + static int begin_seen = 0; + if (++begin_seen == 2 && do_lint_old) { + warning(_("old awk does not support multiple `BEGIN' or `END' rules")); + } begin_or_end_rule = TRUE; $$ = append_pattern(&begin_block, (NODE *) NULL); } | LEX_END { + static int end_seen = 0; + if (++end_seen == 2 && do_lint_old) { + warning(_("old awk does not support multiple `BEGIN' or `END' rules")); + } begin_or_end_rule = parsing_end_rule = TRUE; $$ = append_pattern(&end_block, (NODE *) NULL); } @@ -808,7 +816,11 @@ $$ = node($1, $2, mk_rexp($3)); } | exp LEX_IN NAME - { $$ = node(variable($3, CAN_FREE, Node_var_array), Node_in_array, $1); } + { + if (do_lint_old) + warning(_("old awk does not support the keyword `in' except after `for'")); + $$ = node(variable($3, CAN_FREE, Node_var_array), Node_in_array, $1); + } | exp a_relop exp %prec RELOP { if (do_lint && $3->type == Node_regex) @@ -854,7 +866,13 @@ $2); } | '(' expression_list r_paren LEX_IN NAME - { $$ = node(variable($5, CAN_FREE, Node_var_array), Node_in_array, $2); } + { + if (do_lint_old) { + warning(_("old awk does not support the keyword `in' except after `for'")); + warning(_("old awk does not support multidimensional arrays")); + } + $$ = node(variable($5, CAN_FREE, Node_var_array), Node_in_array, $2); + } | simp_exp { $$ = $1; } | common_exp simp_exp %prec CONCAT_OP Index: field.c =================================================================== RCS file: /sources/gawk/gawk-stable/field.c,v retrieving revision 1.2 diff -u -r1.2 field.c --- field.c 11 Aug 2006 12:49:40 -0000 1.2 +++ field.c 3 Dec 2006 09:27:11 -0000 @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2005 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2006 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -1027,6 +1027,8 @@ lintwarn(_("null string for `FS' is a gawk extension")); } } else if (fs->stlen > 1) { + if (do_lint_old) + warning(_("old awk does not support regexps as value of `FS'")); parse_field = re_parse_field; } else if (RS_is_null) { /* we know that fs->stlen <= 1 */ Index: node.c =================================================================== RCS file: /sources/gawk/gawk-stable/node.c,v retrieving revision 1.2 diff -u -r1.2 node.c --- node.c 11 Aug 2006 12:49:40 -0000 1.2 +++ node.c 3 Dec 2006 09:27:12 -0000 @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003-2005 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003-2006 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -545,6 +545,15 @@ register int i; register int count; + if (do_lint_old) { + switch (c) { + case 'b': + case 'f': + case 'r': + warning(_("old awk does not support the escape sequences `\\b', `\\f' and `\\r'")); + } + } + switch (c) { case 'a': return BELL; Index: test/Gentests =================================================================== RCS file: /sources/gawk/gawk-stable/test/Gentests,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Gentests --- test/Gentests 11 Aug 2006 12:05:50 -0000 1.1.1.1 +++ test/Gentests 3 Dec 2006 09:28:04 -0000 @@ -29,6 +29,13 @@ next } +/^NEED_LINT_OLD *=/,/[^\\]$/ { + gsub(/(^NEED_LINT_OLD *=|\\$)/,"") + for (i = 1; i <= NF; i++) + lint_old[$i] + next +} + /^GENTESTS_UNUSED *=/,/[^\\]$/ { gsub(/(^GENTESTS_UNUSED *=|\\$)/,"") for (i = 1; i <= NF; i++) @@ -71,6 +78,10 @@ s = s " --lint" delete lint[x] } + if (x in lint_old) { + s = s " --lint-old" + delete lint_old[x] + } if (x".in" in files) { s = s " < $(srcdir)/address@hidden" delete files[x".in"] @@ -85,6 +96,9 @@ for (x in lint) if (!(x in targets)) printf "WARNING: --lint target `%s' is missing.\n", x > "/dev/stderr" + for (x in lint_old) + if (!(x in targets)) + printf "WARNING: --lint-old target `%s' is missing.\n", x > "/dev/stderr" for (x in files) if (!(x in unused) && \ !(gensub(/\.(awk|in)$/,"","",x) in targets)) Index: test/Makefile.am =================================================================== RCS file: /sources/gawk/gawk-stable/test/Makefile.am,v retrieving revision 1.3 diff -u -r1.3 Makefile.am --- test/Makefile.am 5 Sep 2006 23:10:55 -0000 1.3 +++ test/Makefile.am 3 Dec 2006 09:28:04 -0000 @@ -292,6 +292,9 @@ leadnl.ok \ lint.awk \ lint.ok \ + lintold.awk \ + lintold.in \ + lintold.ok \ litoct.awk \ litoct.ok \ longdbl.awk \ @@ -624,7 +627,7 @@ GAWK_EXT_TESTS = argtest asort asorti backw badargs binmode1 clos1way devfd1 devfd2 \ fieldwdth fsfwfs fwtest gensub gensub2 gnuops2 gnuops3 gnureops icasefs \ - icasers igncdym igncfs ignrcase ignrcas2 lint match1 match2 manyfiles \ + icasers igncdym igncfs ignrcase ignrcas2 lint lintold match1 match2 manyfiles \ nondec nondec2 posix procinfs printfbad1 regx8bit rebuf reint rsstart1 \ rsstart2 rsstart3 rstest6 shadow sort1 strtonum strftime whiny @@ -635,6 +638,9 @@ # List of the tests which should be run with --lint option: NEED_LINT = defref noeffect nofmtch shadow uninit2 uninit3 uninit4 uninitialized +# List of the tests which should be run with --lint-old option: +NEED_LINT_OLD = lintold + # List of the files that appear in manual tests or are for reserve testing: GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk switch2.awk --- /dev/null 2006-12-03 10:36:30.828125000 +0100 +++ test/lintold.awk 2006-12-02 12:29:49.296875000 +0100 @@ -0,0 +1,21 @@ +# lintold.awk --- test --lint-old + +BEGIN { + a[1] = 1 + for (i in a) + print a[i] + delete a[1] + if (2 in a) + a[2] **= 2; + if ((2,3) in a) + a[2,3] ^= 2 ** 3 ^ 15; +} +BEGIN { + FS = "ab" + foo = "\b\f\r" +} +END { +} +END { + print "done" +} --- /dev/null 2006-12-03 10:36:42.343750000 +0100 +++ test/lintold.in 2006-12-02 12:29:49.296875000 +0100 @@ -0,0 +1 @@ + --- /dev/null 2006-12-03 10:36:45.046875000 +0100 +++ test/lintold.ok 2006-12-02 12:29:49.296875000 +0100 @@ -0,0 +1,16 @@ +gawk: lintold.awk:7: warning: `delete' is not supported in old awk +gawk: lintold.awk:8: warning: old awk does not support the keyword `in' except after `for' +gawk: lintold.awk:9: warning: old awk does not support operator `**=' +gawk: lintold.awk:10: warning: old awk does not support the keyword `in' except after `for' +gawk: lintold.awk:10: warning: old awk does not support multidimensional arrays +gawk: lintold.awk:11: warning: operator `^=' is not supported in old awk +gawk: lintold.awk:11: warning: old awk does not support operator `**' +gawk: lintold.awk:11: warning: operator `^' is not supported in old awk +gawk: lintold.awk:13: warning: old awk does not support multiple `BEGIN' or `END' rules +gawk: lintold.awk:15: warning: old awk does not support the escape sequences `\b', `\f' and `\r' +gawk: lintold.awk:15: warning: old awk does not support the escape sequences `\b', `\f' and `\r' +gawk: lintold.awk:15: warning: old awk does not support the escape sequences `\b', `\f' and `\r' +gawk: lintold.awk:19: warning: old awk does not support multiple `BEGIN' or `END' rules +1 +gawk: lintold.awk:14: warning: old awk does not support regexps as value of `FS' +done