[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/fix-comments, updated. gawk-4.1.
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/fix-comments, updated. gawk-4.1.0-3542-g1e6c88c |
Date: |
Mon, 26 Nov 2018 13:52:49 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/fix-comments has been updated
via 1e6c88c44319694bfb2e9c0ca11db01ec670f0ad (commit)
from ed06eeafe3dc901759e20466446fec48e83402fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1e6c88c44319694bfb2e9c0ca11db01ec670f0ad
commit 1e6c88c44319694bfb2e9c0ca11db01ec670f0ad
Author: Arnold D. Robbins <address@hidden>
Date: Mon Nov 26 20:52:23 2018 +0200
Continue polishing comments. New test.
diff --git a/ChangeLog b/ChangeLog
index b43973c..c58ea9d 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-26 Arnold D. Robbins <address@hidden>
+
+ * profile.c (print_comment): Indent for chained comment.
+ * awkgram.y (load_library): Return early if just pretty printing.
+ (yylex): Fix handling of ?: and allow_newline etc.
+
2018-11-25 Arnold D. Robbins <address@hidden>
* main.c (platform_name): New function returning platform name.
diff --git a/awkgram.c b/awkgram.c
index e063d03..c89fc03 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -5353,6 +5353,9 @@ load_library(INSTRUCTION *file, void **srcfile_p)
return false;
}
+ if (do_pretty_print && ! do_profile)
+ return true;
+
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after
@load"));
@@ -6188,13 +6191,14 @@ retry:
// fall through
case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (c == ':' && qm_col_count > 0) {
- if (do_posix) {
+ if (qm_col_count > 0) {
+ if (! do_posix) {
INSTRUCTION *new_comment = NULL;
allow_newline(& new_comment);
yylval->comment = new_comment;
}
- qm_col_count--;
+ if (c == ':')
+ qm_col_count--;
}
return lasttok = c;
diff --git a/awkgram.y b/awkgram.y
index 4d3e44e..4be4413 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2882,6 +2882,9 @@ load_library(INSTRUCTION *file, void **srcfile_p)
return false;
}
+ if (do_pretty_print && ! do_profile)
+ return true;
+
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after
@load"));
@@ -3717,13 +3720,14 @@ retry:
// fall through
case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (c == ':' && qm_col_count > 0) {
- if (do_posix) {
+ if (qm_col_count > 0) {
+ if (! do_posix) {
INSTRUCTION *new_comment = NULL;
allow_newline(& new_comment);
yylval->comment = new_comment;
}
- qm_col_count--;
+ if (c == ':')
+ qm_col_count--;
}
return lasttok = c;
diff --git a/profile.c b/profile.c
index 5494b17..3041545 100644
--- a/profile.c
+++ b/profile.c
@@ -1349,6 +1349,10 @@ print_comment(INSTRUCTION* pc, long in)
if (pc->comment) {
// chaining should only be two deep
assert(pc->comment->comment == NULL);
+ // if first was EOL comment, next must be block comment,
+ // it needs to be indented.
+ if (pc->memory->comment_type == EOL_COMMENT)
+ in++;
print_comment(pc->comment, in);
}
}
diff --git a/test/ChangeLog b/test/ChangeLog
index bf0cbff..3def182 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
+2018-11-26 Arnold D. Robbins <address@hidden>
+
+ * profile5.ok: Updated after code change.
+ * Makefile.am (GAWK_EXT_TESTS): New test, profile11.ok. Add
+ to the other relevant macros.
+ * profile11.awk, profile11.ok: New files.
+
2018-11-25 Arnold D. Robbins <address@hidden>
* Makefile.am (GAWK_EXT_TESTS): Fix layout of the list.
diff --git a/test/Makefile.am b/test/Makefile.am
index e1ecc64..3e7394f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -899,6 +899,8 @@ EXTRA_DIST = \
profile9.ok \
profile10.awk \
profile10.ok \
+ profile11.awk \
+ profile11.ok \
prt1eval.awk \
prt1eval.ok \
prtoeval.awk \
@@ -1307,7 +1309,7 @@ GAWK_EXT_TESTS = \
nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \
procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6
\
- profile7 profile8 profile9 profile10 pty1 pty2 \
+ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \
rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline
rsglstdin \
rsstart1 rsstart2 rsstart3 rstest6 \
shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit
split_after_fpat \
@@ -1364,7 +1366,7 @@ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum
NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix
# List of tests that need --pretty-print
-NEED_PRETTY = profile4 profile5 profile8 profile9 profile10
+NEED_PRETTY = profile4 profile5 profile8 profile9 profile10 profile11
# List of tests that need --re-interval
NEED_RE_INTERVAL = gsubtst3 reint reint2
diff --git a/test/Makefile.in b/test/Makefile.in
index 1e3fe2e..3daf698 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1157,6 +1157,8 @@ EXTRA_DIST = \
profile9.ok \
profile10.awk \
profile10.ok \
+ profile11.awk \
+ profile11.ok \
prt1eval.awk \
prt1eval.ok \
prtoeval.awk \
@@ -1565,7 +1567,7 @@ GAWK_EXT_TESTS = \
nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \
procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6
\
- profile7 profile8 profile9 profile10 pty1 pty2 \
+ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \
rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline
rsglstdin \
rsstart1 rsstart2 rsstart3 rstest6 \
shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit
split_after_fpat \
@@ -1621,7 +1623,7 @@ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum
NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix
# List of tests that need --pretty-print
-NEED_PRETTY = profile4 profile5 profile8 profile9 profile10
+NEED_PRETTY = profile4 profile5 profile8 profile9 profile10 profile11
# List of tests that need --re-interval
NEED_RE_INTERVAL = gsubtst3 reint reint2
@@ -4396,6 +4398,11 @@ profile10:
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden --pretty-print=_$@ >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+profile11:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f address@hidden --pretty-print=_$@ >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
regnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 65f0197..067854e 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1724,6 +1724,11 @@ profile10:
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden --pretty-print=_$@ >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+profile11:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f address@hidden --pretty-print=_$@ >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
regnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
diff --git a/test/profile11.awk b/test/profile11.awk
new file mode 100644
index 0000000..180e3bb
--- /dev/null
+++ b/test/profile11.awk
@@ -0,0 +1,321 @@
+
+# comments/for.awk
+BEGIN {
+ for (i = 1; i <= 10; i++) print i
+
+ for (i = 1; i <= 10; i++) # comment 0
+ print i
+
+ for (i = 1; # comment 1a
+ i <= 10; i++) print i
+
+ for (i = 1; i <= 10; # comment 2a
+ i++) print i
+
+ for (i = 1; # comment 1b
+ i <= 10; # comment 2b
+ i++) print i
+
+ for (i = 1; # comment 1c
+ i <= 10; # comment 2c
+ i++) # comment 3c
+ print i
+}
+
+# comments/for0.awk
+BEGIN {
+ for (iggy in foo) # comment 5
+ # comment 6
+ ;
+}
+
+# comments/for1.awk
+BEGIN {
+ for (iggy in foo) # comment 1
+ # comment 2
+ {
+ print iggy
+ }
+
+ for (iggy in foo) # comment 3
+ # comment 4
+ print iggy
+
+ for (iggy in foo) # comment 5
+ # comment 6
+ ;
+}
+
+# comments/for2.awk
+BEGIN {
+ for (;;) print i
+
+ for (;;) # comment 0
+ print i
+
+ for (; # comment 1a
+ ;) print i
+
+ for (; ; # comment 2a
+ ) print i
+
+ for (; # comment 1b
+ ; # comment 2b
+ ) print i
+
+ for (; # comment 1c
+ ; # comment 2c
+ ) # comment 3c
+ print i
+}
+
+# comments/for_del.awk
+BEGIN { for (iggy in foo) delete foo[iggy] }
+
+# comments/do.awk
+BEGIN {
+ do # DO comment
+ { # LBRACE comment
+ # block comment
+ print 42
+ } # rbrace comment
+ while (0) # WHILE comment
+}
+
+# comments/do2.awk
+BEGIN {
+ do # DO comment
+ { # LBRACE comment
+ # block comment
+ print 42
+ } # rbrace comment
+ while (0)
+}
+
+# comments2/do.awk
+BEGIN {
+ do # do comment
+ { # lbrace comment
+ # block comment
+ print 42
+ } # rbace EOL comment
+ # rbrace block comment
+ while (1) # while comment
+}
+
+# comments2/if.awk
+BEGIN {
+ if (a) # IF comment
+ print "foo" # print comment
+
+ if (a) # IF comment 2
+ { # lbrace comment
+ print "bar"
+ }
+ else # ELSE comment
+ print "baz"
+}
+
+# comments/if0.awk
+BEGIN {
+ if (a)
+ ; # nothing
+ else
+ print "b"
+}
+
+# comments/switch.awk
+BEGIN {
+ a = 5
+ switch (a) # switch EOL comment
+ # switch block comment
+ { # lbrace EOL comment
+ # lbrace block comment
+ case 5: # comment after case
+ print "five!"
+ break
+ # block comment after case
+ default: # comment after default
+ print "default" # print comment
+ break
+ } # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch.awk
+BEGIN {
+ a = 5
+ switch (a) # switch EOL comment
+ # switch block comment
+ { # lbrace EOL comment
+ # lbrace block comment
+ case 5:
+ print "five!"
+ break;
+ # block comment after case
+ } # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch0.awk
+BEGIN {
+ a = 5
+ switch (a)
+ {
+ case 5: # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/switch1.awk
+BEGIN {
+ a = 5
+ switch (a)
+ {
+ case 5:
+ # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/while.awk
+BEGIN {
+ while (1) # while comment
+ { # lbrace comment
+ # block comment
+ print 42
+ }
+}
+
+# comments2/while2.awk
+BEGIN {
+ while (1) # while comment
+ { # lbrace comment
+ # block comment
+ }
+}
+
+# comments2/f.awk
+function bar(p1,
+ p2)
+{
+ print "foo"
+} # rbrace eol
+ # rbrace block
+
+# comments2/function.awk
+function baz(p1, # comment
+ p2)
+ # comment before braces
+{ # lbrace eol
+ # lbrace block
+ print "foo"
+} # rbrace eol
+ # rbrace block
+
+# comments/function.awk
+function funny(param1, # param comment 1
+ param2, param3, # param comment 2
+ param4)
+ # Comment between header and body
+{ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+} # rbrace EOL comment
+ # rbrace block comment
+
+# comments/function2.awk
+function funnyhaha(param1,
+ param2, param3,
+ param4)
+{ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+} # rbrace EOL comment
+ # rbrace block comment
+
+# comments/callcoma.awk
+function callme(a, b, c)
+{
+ printf("a = %s, b = %s, c = %s\n", # format comment
+ a, # a2 comment
+ b, # b2 comment
+ c)
+}
+
+BEGIN {
+ callme(1, # 1 comment
+ 2, # 2 comment
+ 3)
+}
+
+# comments/exp.awk
+/foo/, # range comment
+ # range comment 2
+
+# range comment b
+
+# range comment c
+/bar/ { print }
+
+# comments/load.awk
address@hidden "filefuncs" # get file functions
+
+BEGIN {
+ stat("/etc/passwd", data)
+ for (i in data)
+ print i, data[i]
+}
+
+# comments/andor.awk
+BEGIN {
+ if (a && # and comment
+ b || # or comment
+ c)
+ print "foo"
+}
+
+# comments/qmcol-qm.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 :
+ 3
+ print a
+}
+
+# comments/qmcol-colon.awk
+BEGIN {
+ a = 1 ?
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# comments/qmcolboth.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# test beginning of line block comments (com2.awk)
+BEGIN {
+ print "hi" # comment 1
+# comment 2
+ print "there"
+
+ if (foo) {
+ print "hello" # comment 3
+# comment 4
+ print "world"
+ }
+}
diff --git a/test/profile11.ok b/test/profile11.ok
new file mode 100644
index 0000000..1be49aa
--- /dev/null
+++ b/test/profile11.ok
@@ -0,0 +1,346 @@
+# comments/for.awk
+BEGIN {
+ for (i = 1; i <= 10; i++) {
+ print i
+ }
+ for (i = 1; i <= 10; i++) { # comment 0
+ print i
+ }
+ for (i = 1; # comment 1a
+ i <= 10; i++) {
+ print i
+ }
+ for (i = 1; i <= 10; # comment 2a
+ i++) {
+ print i
+ }
+ for (i = 1; # comment 1b
+ i <= 10; # comment 2b
+ i++) {
+ print i
+ }
+ for (i = 1; # comment 1c
+ i <= 10; # comment 2c
+ i++) { # comment 3c
+ print i
+ }
+}
+
+# comments/for0.awk
+BEGIN {
+ for (iggy in foo) {
+ # comment 5
+
+ # comment 6
+ }
+}
+
+# comments/for1.awk
+BEGIN {
+ for (iggy in foo) {
+ # comment 1
+
+ # comment 2
+ print iggy
+ }
+ for (iggy in foo) {
+ # comment 3
+
+ # comment 4
+ print iggy
+ }
+ for (iggy in foo) {
+ # comment 5
+
+ # comment 6
+ }
+}
+
+# comments/for2.awk
+BEGIN {
+ for (;;) {
+ print i
+ }
+ for (;;) { # comment 0
+ print i
+ }
+ for (; # comment 1a
+ ; ) {
+ print i
+ }
+ for (; ; # comment 2a
+ ) {
+ print i
+ }
+ for (; # comment 1b
+ ; # comment 2b
+ ) {
+ print i
+ }
+ for (; # comment 1c
+ ; # comment 2c
+ ) { # comment 3c
+ print i
+ }
+}
+
+# comments/for_del.awk
+BEGIN {
+ for (iggy in foo) {
+ delete foo[iggy]
+ }
+}
+
+# comments/do.awk
+BEGIN {
+ do { # DO comment
+ # LBRACE comment
+ # block comment
+ print 42
+ } while (0) # WHILE comment
+ # rbrace comment
+}
+
+# comments/do2.awk
+BEGIN {
+ do { # DO comment
+ # LBRACE comment
+ # block comment
+ print 42
+ } while (0) # rbrace comment
+}
+
+# comments2/do.awk
+BEGIN {
+ do { # do comment
+ # lbrace comment
+ # block comment
+ print 42
+ } while (1) # while comment
+ # rbace EOL comment
+ # rbrace block comment
+}
+
+# comments2/if.awk
+BEGIN {
+ if (a) {
+ # IF comment
+ print "foo" # print comment
+ }
+ if (a) { # lbrace comment
+ # IF comment 2
+ print "bar"
+ } else {
+ # ELSE comment
+ print "baz"
+ }
+}
+
+# comments/if0.awk
+BEGIN {
+ if (a) {
+ # nothing
+ } else {
+ print "b"
+ }
+}
+
+# comments/switch.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ # switch EOL comment
+
+ # switch block comment
+
+ # lbrace EOL comment
+
+ # lbrace block comment
+ case 5: # comment after case
+ print "five!"
+ break
+ # block comment after case
+ default: # comment after default
+ print "default" # print comment
+ break
+ }
+ # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ # switch EOL comment
+
+ # switch block comment
+
+ # lbrace EOL comment
+
+ # lbrace block comment
+ case 5:
+ print "five!"
+ break
+ # block comment after case
+ }
+ # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch0.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ case 5: # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/switch1.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ case 5:
+ # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/while.awk
+BEGIN {
+ while (1) {
+ # while comment
+ # lbrace comment
+ # block comment
+ print 42
+ }
+}
+
+# comments2/while2.awk
+BEGIN {
+ while (1) {
+ # while comment
+ # lbrace comment
+ # block comment
+ }
+}
+
+# comments2/f.awk
+BEGIN {
+ callme(1, # 1 comment
+ 2, # 2 comment
+ 3)
+}
+
+# comments/load.awk
+BEGIN {
+ stat("/etc/passwd", data)
+ for (i in data) {
+ print i, data[i]
+ }
+}
+
+# comments/andor.awk
+BEGIN {
+ if (a && # and comment
+ b || # or comment
+ c) {
+ print "foo"
+ }
+}
+
+# comments/qmcol-qm.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : 3
+ print a
+}
+
+# comments/qmcol-colon.awk
+BEGIN {
+ a = 1 ? 2 : # colon comment
+ 3
+ print a
+}
+
+# comments/qmcolboth.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# test beginning of line block comments (com2.awk)
+BEGIN {
+ print "hi" # comment 1
+ # comment 2
+ print "there"
+ if (foo) {
+ print "hello" # comment 3
+ # comment 4
+ print "world"
+ }
+}
+
+# range comment
+# range comment 2
+
+# range comment b
+
+# range comment c
+/foo/, /bar/ {
+ print
+}
+
+
+function bar(p1, p2)
+{
+ print "foo"
+}
+
+# comment
+
+# comment before braces
+function baz(p1, p2)
+{
+ # lbrace eol
+ # lbrace block
+ print "foo"
+}
+
+function callme(a, b, c)
+{
+ printf "a = %s, b = %s, c = %s\n", # format comment
+ a, # a2 comment
+ b, # b2 comment
+ c
+}
+
+# param comment 1
+
+# param comment 2
+
+# Comment between header and body
+function funny(param1, param2, param3, param4)
+{
+ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+}
+
+function funnyhaha(param1, param2, param3, param4)
+{
+ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+}
diff --git a/test/profile5.ok b/test/profile5.ok
index 7ac2402..0880f02 100644
--- a/test/profile5.ok
+++ b/test/profile5.ok
@@ -72,7 +72,7 @@ BEGIN {
########################################################################
_QSTR[_CHR[i]] = _QSTRQ[_CHR[i]]
}
_QSTR["\\"] = "\\\\" #; _QSTR["\""]="\\\""
-#_____________________________________________________________________________
+
#_____________________________________________________________________________
_CHR["CR"] = "\r"
_CHR["EOL"] = "\r\n"
_CHR["EOF"] = "\032"
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 +
awkgram.c | 10 +-
awkgram.y | 10 +-
profile.c | 4 +
test/ChangeLog | 7 ++
test/Makefile.am | 6 +-
test/Makefile.in | 11 +-
test/Maketests | 5 +
test/profile11.awk | 321 +++++++++++++++++++++++++++++++++++++++++++++++++
test/profile11.ok | 346 +++++++++++++++++++++++++++++++++++++++++++++++++++++
test/profile5.ok | 2 +-
11 files changed, 717 insertions(+), 11 deletions(-)
create mode 100644 test/profile11.awk
create mode 100644 test/profile11.ok
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/fix-comments, updated. gawk-4.1.0-3542-g1e6c88c,
Arnold Robbins <=