[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk --lint-old (was: awk portability notes)
From: |
Aharon Robbins |
Subject: |
Re: gawk --lint-old (was: awk portability notes) |
Date: |
Sat, 13 Jan 2007 21:33:29 +0200 |
These are now applied. Thanks!
Arnold
> Date: Sun, 03 Dec 2006 10:39:08 +0100
> From: Ralf Wildenhues <address@hidden>
> Subject: Re: gawk --lint-old (was: awk portability notes)
> To: address@hidden
>
> On Sun, Dec 03, 2006 at 10:06:07AM +0100, Ralf Wildenhues wrote:
> > The following patch tests some more issues related to V7 awk,
> > and adds a testsuite test for --lint-old.
>
> And a resend for the documentation and --lint-old patches.
>
> Sorry again,
> Ralf
>
> doc/ChangeLog:
> 2006-12-03 Ralf Wildenhues <address@hidden>
>
> * awkcard.in: next is POSIX.
> * gawk.texi: V7/SVR3.1: Mention assignable `$0', `var in index'
> as expression. Specify `FS' limitation.
>
>
> ChangeLog:
> 2006-12-03 Ralf Wildenhues <address@hidden>
>
> Enable more `--lint-old' warnings.
> * awkgram.y: Warning about multiple BEGIN or END rules,
> `index in array' outside of for loops, multidimensional arrays.
> * field.c (set_FS): Warn about regex FS.
> * node.c (parse_escape): Warn about `\b', `\f', `\r'.
>
> test/ChangeLog:
> 2006-12-03 Ralf Wildenhues <address@hidden>
>
> * lintold.awk, lintold.in, lintold.ok: New `--lint-old' test.
> * Gentests, Makefile.am: Adjust.
>
>
>
>
> #####################################################################################
> This Mail Was Scanned by 012.net AntiVirus Service3- Powered by TrendMicro
> Interscan
> --=_0_26854_1165138748
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename="oldawk-doc.diff"
>
> Index: doc/awkcard.in
> ===================================================================
> RCS file: /sources/gawk/gawk-stable/doc/awkcard.in,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 awkcard.in
> --- doc/awkcard.in 11 Aug 2006 12:05:48 -0000 1.1.1.1
> +++ doc/awkcard.in 3 Dec 2006 09:27:16 -0000
> @@ -1168,7 +1168,7 @@
> .br
> co-process pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR.
> .ti -.2i
> -\*(FCnext\fP
> +\*(CD\*(FCnext\fP
> .br
> stop processing the current input
> record. Read next input record and
> Index: doc/gawk.texi
> ===================================================================
> RCS file: /sources/gawk/gawk-stable/doc/gawk.texi,v
> retrieving revision 1.5
> diff -u -r1.5 gawk.texi
> --- doc/gawk.texi 15 Sep 2006 13:49:28 -0000 1.5
> +++ doc/gawk.texi 3 Dec 2006 09:28:04 -0000
> @@ -22776,10 +22776,17 @@
> and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}).
>
> @item
> +Assignable @code{$0}.
> +
> address@hidden
> The conditional expression using the ternary operator @samp{?:}
> (@pxref{Conditional Exp}).
>
> @item
> +The expression @address@hidden in @var{array}} outside of @samp{for}
> +statements (@pxref{Reference to Elements}).
> +
> address@hidden
> The exponentiation operator @samp{^}
> (@pxref{Arithmetic Ops}) and its assignment operator
> form @samp{^=} (@pxref{Assignment Ops}).
> @@ -22792,7 +22799,8 @@
> Regexps as the value of @code{FS}
> (@pxref{Field Separators}) and as the
> third argument to the @code{split} function
> -(@pxref{String Functions}).
> +(@pxref{String Functions}), rather than using only the first character
> +of @code{FS}.
>
> @item
> Dynamic regexps as operands of the @samp{~} and @samp{!~} operators
>
> --=_0_26854_1165138748
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename="lint-old.diff"
>
> 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: gawk --lint-old (was: awk portability notes),
Aharon Robbins <=