public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] [gdb/contrib] Add -c option to words.sh script
@ 2019-11-15  9:53 Tom de Vries (Code Review)
  2019-11-22  3:45 ` Kevin Buettner (Code Review)
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tom de Vries (Code Review) @ 2019-11-15  9:53 UTC (permalink / raw)
  To: gdb-patches

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................

[gdb/contrib] Add -c option to words.sh script

The words.sh script in its current form extracts c comments from files, which
it then transforms into a list of words.

To use the script on the documentation (as I did for commit 6b92c0d3533
"[gdb/doc] Fix typos"), I needed to disable the "extract c comments" part.

Add an option -c that enables extracting c comments, and is off by default.

gdb/ChangeLog:

2019-11-15  Tom de Vries  <tdevries@suse.de>

	* contrib/words.sh: Add -c option.

Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
---
M gdb/contrib/words.sh
1 file changed, 16 insertions(+), 5 deletions(-)



diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh
index 8c4fdd0..e48b82e 100755
--- a/gdb/contrib/words.sh
+++ b/gdb/contrib/words.sh
@@ -24,7 +24,8 @@
 #
 # For:
 # ...
-# $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c $files
 # ...
 # it generates a list of ~15000 words prefixed with frequency.
 #
@@ -36,7 +37,8 @@
 #
 # And for:
 # ...
-# $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c -f 1 $files
 # ...
 # it generates a list of ~5000 words with frequency 1.
 #
@@ -45,8 +47,13 @@
 
 minfreq=
 maxfreq=
+c=false
 while [ $# -gt 0 ]; do
     case "$1" in
+	-c)
+	    c=true
+	    shift
+	    ;;
 	--freq|-f)
 	    minfreq=$2
 	    maxfreq=$2
@@ -111,9 +118,13 @@
 # Stabilize sort.
 export LC_ALL=C
 
-awk \
-    -f "$awkfile" \
-    -- "$@" \
+if $c; then
+    awk \
+	-f "$awkfile" \
+	-- "$@"
+else
+    cat "$@"
+fi \
     | sed \
 	  -e 's/[%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
 	  -e 's/\[/\n/g' \

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 1
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-MessageType: newchange

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [review] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
@ 2019-11-22  3:45 ` Kevin Buettner (Code Review)
  2019-11-22 15:34 ` [review v2] " Tom de Vries (Code Review)
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Buettner (Code Review) @ 2019-11-22  3:45 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Kevin Buettner has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................


Patch Set 1: Code-Review-1

Two concerns...

1) The current behavior, IIUC, is that comments are extracted.  Your patch changes the default behavior to extract all words. This may come as a surprise to anyone with existing scripts which use words.sh.  It might make more sense to add some other switch (perhaps -a for "all") which keeps the present default behavior intact.  It's not really that important to me that this be changed, but I thought I'd mention it.

2) I'd like to see a line or two documenting the new switch in the blurb at the beginning of the file.


-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 1
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-Comment-Date: Fri, 22 Nov 2019 03:45:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [review v2] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
  2019-11-22  3:45 ` Kevin Buettner (Code Review)
@ 2019-11-22 15:34 ` Tom de Vries (Code Review)
  2019-11-22 15:39 ` Tom de Vries (Code Review)
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries (Code Review) @ 2019-11-22 15:34 UTC (permalink / raw)
  To: Kevin Buettner, gdb-patches

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................

[gdb/contrib] Add -c option to words.sh script

The words.sh script in its current form extracts c comments from files, which
it then transforms into a list of words.

To use the script on the documentation (as I did for commit 6b92c0d3533
"[gdb/doc] Fix typos"), I needed to disable the "extract c comments" part.

Add an option -c that enables extracting c comments, and is off by default.

gdb/ChangeLog:

2019-11-15  Tom de Vries  <tdevries@suse.de>

	* contrib/words.sh: Add -c option.

Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
---
M gdb/contrib/words.sh
1 file changed, 21 insertions(+), 8 deletions(-)



diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh
index ec8bcd0..d4c436d 100755
--- a/gdb/contrib/words.sh
+++ b/gdb/contrib/words.sh
@@ -14,17 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This script intends to facilitate spell checking of comments in C sources.
+# This script intends to facilitate spell checking of source/doc files.
 # It:
-# - extracts comments from C files
-# - transforms the comments into a list of lowercase words
+# - transforms the files into a list of lowercase words
 # - prefixes each word with the frequency
 # - filters out words within a frequency range
 # - sorts the words, longest first
 #
+# If '-c' is passed as option, it operates on the C comments only, rather than
+# on the entire file.
+#
 # For:
 # ...
-# $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c $files
 # ...
 # it generates a list of ~15000 words prefixed with frequency.
 #
@@ -36,7 +39,8 @@
 #
 # And for:
 # ...
-# $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c -f 1 $files
 # ...
 # it generates a list of ~5000 words with frequency 1.
 #
@@ -45,8 +49,13 @@
 
 minfreq=
 maxfreq=
+c=false
 while [ $# -gt 0 ]; do
     case "$1" in
+	-c)
+	    c=true
+	    shift
+	    ;;
 	--freq|-f)
 	    minfreq=$2
 	    maxfreq=$2
@@ -111,9 +120,13 @@
 # Stabilize sort.
 export LC_ALL=C
 
-awk \
-    -f "$awkfile" \
-    -- "$@" \
+if $c; then
+    awk \
+	-f "$awkfile" \
+	-- "$@"
+else
+    cat "$@"
+fi \
     | sed \
 	  -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
 	  -e 's/\[/\n/g' \

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 2
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [review v2] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
  2019-11-22  3:45 ` Kevin Buettner (Code Review)
  2019-11-22 15:34 ` [review v2] " Tom de Vries (Code Review)
@ 2019-11-22 15:39 ` Tom de Vries (Code Review)
  2019-11-25 18:45 ` Kevin Buettner (Code Review)
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries (Code Review) @ 2019-11-22 15:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

Tom de Vries has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................


Patch Set 2:

> Patch Set 1: Code-Review-1
> 
> Two concerns...
> 
> 1) The current behavior, IIUC, is that comments are extracted.  Your patch changes the default behavior to extract all words. This may come as a surprise to anyone with existing scripts which use words.sh.  It might make more sense to add some other switch (perhaps -a for "all") which keeps the present default behavior intact.  It's not really that important to me that this be changed, but I thought I'd mention it.
> 

Agreed, we shouldn't change default behaviour without thinking through the consequences for others, but given that this is a very recently added script as well as that there's most likely exactly one user (me!), I think we can allow ourselves this change.

> 2) I'd like to see a line or two documenting the new switch in the blurb at the beginning of the file.

I've improved docs of '-c' in the blurb.


-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 2
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-Reviewer: Tom de Vries <tdevries@suse.de>
Gerrit-Comment-Date: Fri, 22 Nov 2019 15:39:31 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [review v2] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
                   ` (2 preceding siblings ...)
  2019-11-22 15:39 ` Tom de Vries (Code Review)
@ 2019-11-25 18:45 ` Kevin Buettner (Code Review)
  2019-11-25 22:01 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  2019-11-25 22:01 ` Sourceware to Gerrit sync (Code Review)
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Buettner (Code Review) @ 2019-11-25 18:45 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Kevin Buettner has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................


Patch Set 2: Code-Review+2


-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 2
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-Reviewer: Tom de Vries <tdevries@suse.de>
Gerrit-Comment-Date: Mon, 25 Nov 2019 18:45:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pushed] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
                   ` (3 preceding siblings ...)
  2019-11-25 18:45 ` Kevin Buettner (Code Review)
@ 2019-11-25 22:01 ` Sourceware to Gerrit sync (Code Review)
  2019-11-25 22:01 ` Sourceware to Gerrit sync (Code Review)
  5 siblings, 0 replies; 7+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-25 22:01 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches; +Cc: Kevin Buettner

Sourceware to Gerrit sync has submitted this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................

[gdb/contrib] Add -c option to words.sh script

The words.sh script in its current form extracts c comments from files, which
it then transforms into a list of words.

To use the script on the documentation (as I did for commit 6b92c0d3533
"[gdb/doc] Fix typos"), I needed to disable the "extract c comments" part.

Add an option -c that enables extracting c comments, and is off by default.

gdb/ChangeLog:

2019-11-25  Tom de Vries  <tdevries@suse.de>

	* contrib/words.sh: Add -c option.

Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
---
M gdb/ChangeLog
M gdb/contrib/words.sh
2 files changed, 25 insertions(+), 8 deletions(-)


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 440edff..fdba64e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-25  Tom de Vries  <tdevries@suse.de>
+
+	* contrib/words.sh: Add -c option.
+
 2019-11-25  Christian Biesinger  <cbiesinger@google.com>
 
 	* solib.c (solib_find_1): Change int to bool.
diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh
index ec8bcd0..d4c436d 100755
--- a/gdb/contrib/words.sh
+++ b/gdb/contrib/words.sh
@@ -14,17 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This script intends to facilitate spell checking of comments in C sources.
+# This script intends to facilitate spell checking of source/doc files.
 # It:
-# - extracts comments from C files
-# - transforms the comments into a list of lowercase words
+# - transforms the files into a list of lowercase words
 # - prefixes each word with the frequency
 # - filters out words within a frequency range
 # - sorts the words, longest first
 #
+# If '-c' is passed as option, it operates on the C comments only, rather than
+# on the entire file.
+#
 # For:
 # ...
-# $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c $files
 # ...
 # it generates a list of ~15000 words prefixed with frequency.
 #
@@ -36,7 +39,8 @@
 #
 # And for:
 # ...
-# $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c -f 1 $files
 # ...
 # it generates a list of ~5000 words with frequency 1.
 #
@@ -45,8 +49,13 @@
 
 minfreq=
 maxfreq=
+c=false
 while [ $# -gt 0 ]; do
     case "$1" in
+	-c)
+	    c=true
+	    shift
+	    ;;
 	--freq|-f)
 	    minfreq=$2
 	    maxfreq=$2
@@ -111,9 +120,13 @@
 # Stabilize sort.
 export LC_ALL=C
 
-awk \
-    -f "$awkfile" \
-    -- "$@" \
+if $c; then
+    awk \
+	-f "$awkfile" \
+	-- "$@"
+else
+    cat "$@"
+fi \
     | sed \
 	  -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
 	  -e 's/\[/\n/g' \

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 3
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-Reviewer: Tom de Vries <tdevries@suse.de>
Gerrit-MessageType: merged

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pushed] [gdb/contrib] Add -c option to words.sh script
  2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
                   ` (4 preceding siblings ...)
  2019-11-25 22:01 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-25 22:01 ` Sourceware to Gerrit sync (Code Review)
  5 siblings, 0 replies; 7+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-25 22:01 UTC (permalink / raw)
  To: Tom de Vries, Kevin Buettner, gdb-patches

The original change was created by Tom de Vries.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/654
......................................................................

[gdb/contrib] Add -c option to words.sh script

The words.sh script in its current form extracts c comments from files, which
it then transforms into a list of words.

To use the script on the documentation (as I did for commit 6b92c0d3533
"[gdb/doc] Fix typos"), I needed to disable the "extract c comments" part.

Add an option -c that enables extracting c comments, and is off by default.

gdb/ChangeLog:

2019-11-25  Tom de Vries  <tdevries@suse.de>

	* contrib/words.sh: Add -c option.

Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
---
M gdb/ChangeLog
M gdb/contrib/words.sh
2 files changed, 25 insertions(+), 8 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 440edff..fdba64e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-25  Tom de Vries  <tdevries@suse.de>
+
+	* contrib/words.sh: Add -c option.
+
 2019-11-25  Christian Biesinger  <cbiesinger@google.com>
 
 	* solib.c (solib_find_1): Change int to bool.
diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh
index ec8bcd0..d4c436d 100755
--- a/gdb/contrib/words.sh
+++ b/gdb/contrib/words.sh
@@ -14,17 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This script intends to facilitate spell checking of comments in C sources.
+# This script intends to facilitate spell checking of source/doc files.
 # It:
-# - extracts comments from C files
-# - transforms the comments into a list of lowercase words
+# - transforms the files into a list of lowercase words
 # - prefixes each word with the frequency
 # - filters out words within a frequency range
 # - sorts the words, longest first
 #
+# If '-c' is passed as option, it operates on the C comments only, rather than
+# on the entire file.
+#
 # For:
 # ...
-# $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c $files
 # ...
 # it generates a list of ~15000 words prefixed with frequency.
 #
@@ -36,7 +39,8 @@
 #
 # And for:
 # ...
-# $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h")
+# $ files=$(find gdb -type f -name "*.c" -o -name "*.h")
+# $ ./gdb/contrib/words.sh -c -f 1 $files
 # ...
 # it generates a list of ~5000 words with frequency 1.
 #
@@ -45,8 +49,13 @@
 
 minfreq=
 maxfreq=
+c=false
 while [ $# -gt 0 ]; do
     case "$1" in
+	-c)
+	    c=true
+	    shift
+	    ;;
 	--freq|-f)
 	    minfreq=$2
 	    maxfreq=$2
@@ -111,9 +120,13 @@
 # Stabilize sort.
 export LC_ALL=C
 
-awk \
-    -f "$awkfile" \
-    -- "$@" \
+if $c; then
+    awk \
+	-f "$awkfile" \
+	-- "$@"
+else
+    cat "$@"
+fi \
     | sed \
 	  -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
 	  -e 's/\[/\n/g' \

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d
Gerrit-Change-Number: 654
Gerrit-PatchSet: 3
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-Reviewer: Tom de Vries <tdevries@suse.de>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-25 22:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15  9:53 [review] [gdb/contrib] Add -c option to words.sh script Tom de Vries (Code Review)
2019-11-22  3:45 ` Kevin Buettner (Code Review)
2019-11-22 15:34 ` [review v2] " Tom de Vries (Code Review)
2019-11-22 15:39 ` Tom de Vries (Code Review)
2019-11-25 18:45 ` Kevin Buettner (Code Review)
2019-11-25 22:01 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-25 22:01 ` Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).