From patchwork Fri Nov 15 09:53:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35935 Received: (qmail 57264 invoked by alias); 15 Nov 2019 09:53:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 57217 invoked by uid 89); 15 Nov 2019 09:53:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Nov 2019 09:53:19 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id AD66D20C05; Fri, 15 Nov 2019 04:53:16 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 8F6DE2032F for ; Fri, 15 Nov 2019 04:53:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 5EFDF28171 for ; Fri, 15 Nov 2019 04:53:15 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Fri, 15 Nov 2019 04:53:15 -0500 From: "Tom de Vries (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] [gdb/contrib] Add -c option to words.sh script X-Gerrit-Change-Id: Ifa34d435b3c41b3ff845dc07ae4b0d9f02d92a2d X-Gerrit-Change-Number: 654 X-Gerrit-ChangeURL: X-Gerrit-Commit: c7bb54fc77478469c0cfce602a9b1d81c8c787cd References: Reply-To: tdevries@suse.de, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 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 * 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' \