aboutsummaryrefslogtreecommitdiff
path: root/gdb/contrib
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-11-13 22:38:19 +0100
committerTom de Vries <tdevries@suse.de>2024-11-13 22:38:19 +0100
commit5cb0406bb64da200520ab3a9ee8f2a3c58ea6be0 (patch)
tree02739297d2ffb812315ecc3ed18d8af3b2842ad1 /gdb/contrib
parent74b9033e6f79dcc4947af7756c6e2aed96986504 (diff)
downloadbinutils-5cb0406bb64da200520ab3a9ee8f2a3c58ea6be0.zip
binutils-5cb0406bb64da200520ab3a9ee8f2a3c58ea6be0.tar.gz
binutils-5cb0406bb64da200520ab3a9ee8f2a3c58ea6be0.tar.bz2
[gdb/contrib] Handle capitalized words in spellcheck.sh
The dictionary contains a few entries with capital letters: ... $ grep -E '[A-Z]' .git/wikipedia-common-misspellings.txt | wc -l 143 ... but they don't look too interesting in the gdb context (for instance, Habsbourg->Habsburg), so filter them out. That leaves us with entries looking only like "foobat->foobar", so add handling of capitalized words, such that we also rewrite "Foobat" to "Foobar". Tested on aarch64-linux. Verified with shellcheck. Approved-by: Kevin Buettner <kevinb@redhat.com>
Diffstat (limited to 'gdb/contrib')
-rwxr-xr-xgdb/contrib/spellcheck.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh
index a95b325..0223885 100755
--- a/gdb/contrib/spellcheck.sh
+++ b/gdb/contrib/spellcheck.sh
@@ -218,8 +218,10 @@ output_local_dictionary ()
output_dictionaries ()
{
- output_local_dictionary
- cat "$dictionary"
+ (
+ output_local_dictionary
+ cat "$dictionary"
+ ) | grep -E -v "[A-Z]"
}
parse_dictionary ()
@@ -247,7 +249,14 @@ find_files_matching_words ()
else
rm -f "$cache_dir/$cache_file2".*
- pat=$(grep_join "${words[@]}")
+ declare -a re_words
+ mapfile -t re_words \
+ < <(for f in "${words[@]}"; do
+ echo "$f"
+ done \
+ | sed "s/^\(.\)/[\u\1\1]/")
+
+ pat=$(grep_join "${re_words[@]}")
local before after
before=$(grep_join \
@@ -283,6 +292,8 @@ find_files_matching_word ()
"${grep_separators[@]}" \
"${grep_post[@]}")
+ pat="(${pat@u}|$pat)"
+
pat="$before$pat$after"
grep -E \
@@ -310,11 +321,13 @@ replace_word_in_file ()
"${sed_separators[@]}" \
"${sed_post[@]}")
- local repl
- repl="s%$before$word$after%\1$replacement\2%g"
+ local repl1
+ local repl2
+ repl1="s%$before$word$after%\1$replacement\2%g"
+ repl2="s%$before${word@u}$after%\1${replacement@u}\2%g"
sed -i \
- "$repl" \
+ "$repl1;$repl2" \
"$file"
}