3 # Copyright (C) 2019 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This script intends to facilitate spell checking of comments in C sources.
19 # - extracts comments from C files
20 # - transforms the comments into a list of lowercase words
21 # - prefixes each word with the frequency
22 # - filters out words within a frequency range
23 # - sorts the words, longest first
27 # $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h")
29 # it generates a list of ~15000 words prefixed with frequency.
31 # This could be used to generate a dictionary that is kept as part of the
32 # sources, against which new code can be checked, generating a warning or
33 # error. The hope is that misspellings would trigger this frequently, and rare
34 # words rarely, otherwise the burden of updating the dictionary would be too
39 # $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h")
41 # it generates a list of ~5000 words with frequency 1.
43 # This can be used to scan for misspellings manually.
48 while [ $# -gt 0 ]; do
57 if [ "$maxfreq" = "" ]; then
64 if [ "$minfreq" = "" ]; then
75 if [ "$minfreq" = "" ] && [ "$maxfreq" = "" ]; then
81 trap 'rm -f "$awkfile"' EXIT
83 cat > "$awkfile" <<EOF
94 sub(/.*\/\*/, "", line)
98 sub(/\*\/.*/, "", line)
118 -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
122 -e 's/[0-9][0-9]*/\n/g' \
124 |
tr '[:upper:]' '[:lower:]' \
127 |
awk "{ if (($minfreq == 0 || $minfreq <= \$1) \
128 && ($maxfreq == 0 || \$1 <= $maxfreq)) { print \$0; } }" \
129 |
awk '{ print length($0) " " $0; }' \
This page took 0.033535 seconds and 4 git commands to generate.