[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] lint Option Future
From: |
arnold |
Subject: |
Re: [bug-gawk] lint Option Future |
Date: |
Wed, 22 May 2019 11:54:49 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
M <address@hidden> wrote:
> Thank you for a fast feedback!
>
> No, the only thing under consideration is to be able to disable the "foo
> is a gawk extension" warnings somehow, keeping the others present. Nothing
> more.
Patch is below. It'll be in git shortly.
> Perhaps, it would be useful for a society too.
Not sure what you mean by that.
Arnold
------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 29a31b3..0219f79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2019-05-22 Arnold D. Robbins <address@hidden>
+
+ Add --lint=no-ext. Suggest by Mark Krauze <address@hidden>.
+
+ * NEWS: Updated.
+ * awk.h (DO_LINT_EXTENSIONS): New enum.
+ (do_lint_extensions): New macro.
+ * awkgram.y (yylex, snode): Use do_lint_extensions instead of
+ do_lint where appropriate.
+ * builtin.c (do_length): Ditto.
+ * eval.c (set_IGNORECASE, set_BINMODE): Ditto.
+ (set_LINT): Revise logic.
+ * field.c (do_split, set_FIELDWIDTHS, chose_fs_function, set_FPAT):
+ Ditto.
+ * io.c (set_RS): Ditto.
+ * main.c (usage): Updated.
+ (parse_args): Revise the code to handle --lint=no-ext.
+
2019-05-10 Arnold D. Robbins <address@hidden>
* NEWS: Updated.
diff --git a/NEWS b/NEWS
index c60f687..26ed3b5 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ Changes from 5.0.0 to 5.0.1
4. There are many small documentation improvements in the manual.
+5. The new argument "no-ext" to --lint disables ``XXX is a gawk extension''
+ lint warnings.
+
N. A number of bugs, some of them quite significant, have been fixed.
See the ChangeLog for details.
diff --git a/awk.h b/awk.h
index 8d87fc6..363e440 100644
--- a/awk.h
+++ b/awk.h
@@ -1139,21 +1139,22 @@ extern int do_flags;
extern SRCFILE *srcfiles; /* source files */
enum do_flag_values {
- DO_LINT_INVALID = 0x0001, /* only warn about invalid */
- DO_LINT_ALL = 0x0002, /* warn about all things */
- DO_LINT_OLD = 0x0004, /* warn about stuff not in V7 awk */
- DO_TRADITIONAL = 0x0008, /* no gnu extensions, add traditional
weirdnesses */
- DO_POSIX = 0x0010, /* turn off gnu and unix extensions */
- DO_INTL = 0x0020, /* dump locale-izable strings to stdout
*/
- DO_NON_DEC_DATA = 0x0040, /* allow octal/hex C style DATA. Use
with caution! */
- DO_INTERVALS = 0x0080, /* allow {...,...} in regexps, see
resetup() */
- DO_PRETTY_PRINT = 0x0100, /* pretty print the program */
- DO_DUMP_VARS = 0x0200, /* dump all global variables at end */
- DO_TIDY_MEM = 0x0400, /* release vars when done */
- DO_SANDBOX = 0x0800, /* sandbox mode - disable 'system'
function & redirections */
- DO_PROFILE = 0x1000, /* profile the program */
- DO_DEBUG = 0x2000, /* debug the program */
- DO_MPFR = 0x4000 /* arbitrary-precision floating-point
math */
+ DO_LINT_INVALID = 0x00001, /* only warn about invalid */
+ DO_LINT_EXTENSIONS = 0x00002, /* warn about gawk extensions */
+ DO_LINT_ALL = 0x00004, /* warn about all things */
+ DO_LINT_OLD = 0x00008, /* warn about stuff not in V7 awk */
+ DO_TRADITIONAL = 0x00010, /* no gnu extensions, add traditional
weirdnesses */
+ DO_POSIX = 0x00020, /* turn off gnu and unix extensions */
+ DO_INTL = 0x00040, /* dump locale-izable strings to stdout
*/
+ DO_NON_DEC_DATA = 0x00080, /* allow octal/hex C style DATA. Use
with caution! */
+ DO_INTERVALS = 0x00100, /* allow {...,...} in regexps, see
resetup() */
+ DO_PRETTY_PRINT = 0x00200, /* pretty print the program */
+ DO_DUMP_VARS = 0x00400, /* dump all global variables at end */
+ DO_TIDY_MEM = 0x00800, /* release vars when done */
+ DO_SANDBOX = 0x01000, /* sandbox mode - disable 'system'
function & redirections */
+ DO_PROFILE = 0x02000, /* profile the program */
+ DO_DEBUG = 0x04000, /* debug the program */
+ DO_MPFR = 0x08000 /* arbitrary-precision floating-point
math */
};
#define do_traditional (do_flags & DO_TRADITIONAL)
@@ -1179,6 +1180,7 @@ extern int exit_val;
#else
#define do_lint (do_flags & (DO_LINT_INVALID|DO_LINT_ALL))
#define do_lint_old (do_flags & DO_LINT_OLD)
+#define do_lint_extensions (do_flags & DO_LINT_EXTENSIONS)
#endif
extern int gawk_mb_cur_max;
diff --git a/awkgram.y b/awkgram.y
index 08bd096..3cbcfd3 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -4379,7 +4379,7 @@ retry:
}
if (do_lint) {
- if ((tokentab[mid].flags & GAWKX) != 0 && (warntab[mid]
& GAWKX) == 0) {
+ if (do_lint_extensions && (tokentab[mid].flags & GAWKX)
!= 0 && (warntab[mid] & GAWKX) == 0) {
lintwarn(_("`%s' is a gawk extension"),
tokentab[mid].operator);
warntab[mid] |= GAWKX;
@@ -4702,7 +4702,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
(void) mk_rexp(arg);
if (nexp == 3) { /* 3rd argument there */
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("match: third argument is a gawk
extension"));
}
@@ -4759,7 +4759,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
} else if (r->builtin == do_close) {
static bool warned = false;
if (nexp == 2) {
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("close: second argument is a gawk
extension"));
}
diff --git a/builtin.c b/builtin.c
index 491a96b..bea88b8 100644
--- a/builtin.c
+++ b/builtin.c
@@ -529,7 +529,7 @@ do_length(int nargs)
if (do_posix)
fatal(_("length: received array argument"));
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("`length(array)' is a gawk extension"));
}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 6220648..42c44fe 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2019-05-22 Arnold D. Robbins <address@hidden>
+
+ * gawk1, gawktexi.in: Document --lint=no-ext.
+
2019-05-06 Arnold D. Robbins <address@hidden>
* gawktexi.in: Fix some typos. Thanks to Mark Krauze
diff --git a/doc/gawk.1 b/doc/gawk.1
index f24e62a..de613aa 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -13,7 +13,7 @@
. if \w'\(rq' .ds rq "\(rq
. \}
.\}
-.TH GAWK 1 "Feb 19 2019" "Free Software Foundation" "Utility Commands"
+.TH GAWK 1 "May 22 2019" "Free Software Foundation" "Utility Commands"
.SH NAME
gawk \- pattern scanning and processing language
.SH SYNOPSIS
@@ -354,6 +354,11 @@ With an optional argument of
.BR invalid ,
only warnings about things that are
actually invalid are issued. (This is not fully implemented yet.)
+With an optional argument of
+.BR no-ext ,
+warnings about
+.I gawk
+extensions are disabled.
.TP
.PD 0
.B \-M
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 8065051..850d4e1 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -54,9 +54,9 @@
@c applies to and all the info about who's publishing this edition
@c These apply across the board.
address@hidden UPDATE-MONTH March, 2019
address@hidden UPDATE-MONTH May, 2019
@set VERSION 5.0
address@hidden PATCHLEVEL 0
address@hidden PATCHLEVEL 1
@set GAWKINETTITLE TCP/IP Internetworking with @command{gawk}
@ifset FOR_PRINT
@@ -4025,6 +4025,8 @@ This may be drastic, but its use will certainly encourage
the
development of cleaner @command{awk} programs.
With an optional argument of @samp{invalid}, only warnings about things
that are actually invalid are issued. (This is not fully implemented yet.)
+With an optional argument of @samp{no-ext}, warnings about @command{gawk}
+extensions are disabled.
Some warnings are only printed once, even if the dubious constructs they
warn about occur multiple times in your @command{awk} program. Thus,
diff --git a/eval.c b/eval.c
index 132c850..8acfba0 100644
--- a/eval.c
+++ b/eval.c
@@ -706,7 +706,7 @@ set_IGNORECASE()
{
static bool warned = false;
- if ((do_lint || do_traditional) && ! warned) {
+ if ((do_lint_extensions || do_traditional) && ! warned) {
warned = true;
lintwarn(_("`IGNORECASE' is a gawk extension"));
}
@@ -727,7 +727,7 @@ set_BINMODE()
char *p;
NODE *v = fixtype(BINMODE_node->var_value);
- if ((do_lint || do_traditional) && ! warned) {
+ if ((do_lint_extensions || do_traditional) && ! warned) {
warned = true;
lintwarn(_("`BINMODE' is a gawk extension"));
}
@@ -964,6 +964,8 @@ set_LINT()
if (lintlen > 0) {
if (lintlen == 7 && strncmp(lintval, "invalid", 7) == 0)
do_flags |= DO_LINT_INVALID;
+ else if (lintlen == 6 && strncmp(lintval, "no-ext", 6)
== 0)
+ do_flags &= ~DO_LINT_EXTENSIONS;
else {
do_flags |= DO_LINT_ALL;
if (lintlen == 5 && strncmp(lintval, "fatal",
5) == 0)
diff --git a/field.c b/field.c
index 6502b2f..285376f 100644
--- a/field.c
+++ b/field.c
@@ -978,7 +978,7 @@ do_split(int nargs)
sep_arr = POP_PARAM();
if (sep_arr->type != Node_var_array)
fatal(_("split: fourth argument is not an array"));
- if ((do_lint || do_lint_old) && ! warned) {
+ if ((do_lint_extensions || do_lint_old) && ! warned) {
warned = true;
lintwarn(_("split: fourth argument is a gawk
extension"));
}
@@ -1144,7 +1144,7 @@ set_FIELDWIDTHS()
bool fatal_error = false;
NODE *tmp;
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("`FIELDWIDTHS' is a gawk extension"));
}
@@ -1307,7 +1307,7 @@ choose_fs_function:
set_parser(null_parse_field);
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("null string for `FS' is a gawk extension"));
}
@@ -1438,7 +1438,7 @@ set_FPAT()
bool remake_re = true;
NODE *fpat;
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
warned = true;
lintwarn(_("`FPAT' is a gawk extension"));
}
diff --git a/io.c b/io.c
index 3d90e71..c49d128 100644
--- a/io.c
+++ b/io.c
@@ -4075,7 +4075,7 @@ set_RS()
matchrec = rsrescan;
- if (do_lint && ! warned) {
+ if (do_lint_extensions && ! warned) {
lintwarn(_("multicharacter value of `RS' is a gawk
extension"));
warned = true;
}
diff --git a/main.c b/main.c
index 1f23e57..c2e3aa5 100644
--- a/main.c
+++ b/main.c
@@ -605,7 +605,7 @@ usage(int exitval, FILE *fp)
* TRANSLATORS: the "fatal" and "invalid" here are literal
* values, they should not be translated. Thanks.
*/
- fputs(_("\t-L[fatal|invalid]\t--lint[=fatal|invalid]\n"), fp);
+ fputs(_("\t-L[fatal|invalid|no-ext]\t--lint[=fatal|invalid|no-ext]\n"),
fp);
fputs(_("\t-M\t\t\t--bignum\n"), fp);
fputs(_("\t-N\t\t\t--use-lc-numeric\n"), fp);
fputs(_("\t-n\t\t\t--non-decimal-data\n"), fp);
@@ -1622,7 +1622,7 @@ parse_args(int argc, char **argv)
#ifndef NO_LINT
case 'L':
- do_flags |= DO_LINT_ALL;
+ do_flags |= (DO_LINT_ALL|DO_LINT_EXTENSIONS);
if (optarg != NULL) {
if (strcmp(optarg, "fatal") == 0)
lintfunc = r_fatal;
@@ -1630,6 +1630,9 @@ parse_args(int argc, char **argv)
do_flags &= ~DO_LINT_ALL;
do_flags |= DO_LINT_INVALID;
}
+ else if (strcmp(optarg, "no-ext") == 0) {
+ do_flags &= ~DO_LINT_EXTENSIONS;
+ }
}
break;
diff --git a/test/ChangeLog b/test/ChangeLog
index 9032753..8292726 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2019-05-22 Arnold D. Robbins <address@hidden>
+
+ * badargs.ok: Updated after code changes.
+
2019-05-07 Arnold D. Robbins <address@hidden>
* Gentests: Finish handlinig NEED_SANDBOX.
diff --git a/test/badargs.ok b/test/badargs.ok
index 4999873..dfbd1c1 100644
--- a/test/badargs.ok
+++ b/test/badargs.ok
@@ -17,7 +17,7 @@ Short options: GNU long options: (extensions)
-h --help
-i includefile --include=includefile
-l library --load=library
- -L[fatal|invalid] --lint[=fatal|invalid]
+ -L[fatal|invalid|no-ext] --lint[=fatal|invalid|no-ext]
-M --bignum
-N --use-lc-numeric
-n --non-decimal-data