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

Tom de Vries (Code Review)
2019-11-15T09:53:21Z

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