From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63249 invoked by alias); 25 Nov 2019 22:00:25 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 63088 invoked by uid 9882); 25 Nov 2019 22:00:21 -0000 Date: Mon, 25 Nov 2019 22:00:00 -0000 Message-ID: <20191125220021.63086.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/contrib] Add -c option to words.sh script X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 5b89c67adb1c6340db2f5afa5030f2bea7c583f4 X-Git-Newrev: 3cf2f2377e460608b94a8ba5c3f23c7e4b2dc232 X-SW-Source: 2019-11/txt/msg00076.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3cf2f2377e460608b94a8ba5c3f23c7e4b2dc232 commit 3cf2f2377e460608b94a8ba5c3f23c7e4b2dc232 Author: Tom de Vries Date: Mon Nov 25 23:00:03 2019 +0100 [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 * contrib/words.sh: Add -c option. Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d Diff: --- gdb/ChangeLog | 4 ++++ gdb/contrib/words.sh | 29 +++++++++++++++++++++-------- 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 + + * contrib/words.sh: Add -c option. + 2019-11-25 Christian Biesinger * 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 . -# 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 @@ EOF # 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' \