]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/contrib] Allow thru in spellcheck.sh
authorTom de Vries <tdevries@suse.de>
Mon, 18 Nov 2024 08:42:03 +0000 (09:42 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 18 Nov 2024 08:42:03 +0000 (09:42 +0100)
Eli mentioned that "thru" is a widely-accepted shorthand [1].

Skip the "thru->through" rule by adding an overriding identity rule
"thru->thru".

Verified with shellcheck.

[1] https://sourceware.org/pipermail/gdb-patches/2024-November/213380.html

gdb/contrib/common-misspellings.txt
gdb/contrib/spellcheck.sh

index 23a43461fb141bbea223209d3943ca827cf7c42a..11ca8ecaac460d15be5b6e6c4c5f3c65307d1bbd 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# This file contains additions to and overrides for
+# wikipedia-common-misspellings.txt.
+
 # Common spelling mistakes.
 
 inbetween->between, in between, in-between
 sofar->so far
 doens't->doesn't
+
+# Identity rules.
+
+thru->thru
index 02238857521956ef71f4bd6b4c7881e38e4ad367..2c34b03d4d3c92402fc7bacfc6528f7fefd7a733 100755 (executable)
@@ -231,6 +231,32 @@ parse_dictionary ()
            < <(awk -F '->' '{print $1}' <(output_dictionaries))
     mapfile -t replacements \
            < <(awk -F '->' '{print $2}' <(output_dictionaries))
+
+    local words_done
+    declare -A words_done
+    local i word replacement
+    i=0
+    for word in "${words[@]}"; do
+       replacement=${replacements[$i]}
+
+       # Skip words that are already handled.  This ensures that the local
+       # dictionary overrides the wiki dictionary.
+       if [ "${words_done[$word]}" == 1 ]; then
+           words[$i]=""
+           replacements[$i]=""
+           i=$((i + 1))
+           continue
+       fi
+       words_done[$word]=1
+
+       # Skip identity rules.
+       if [ "$word" = "$replacement" ]; then
+           words[$i]=""
+           replacements[$i]=""
+       fi
+
+       i=$((i + 1))
+    done
 }
 
 find_files_matching_words ()
@@ -252,6 +278,9 @@ find_files_matching_words ()
        declare -a re_words
        mapfile -t re_words \
                < <(for f in "${words[@]}"; do
+                       if [ "$f" = "" ]; then
+                           continue
+                       fi
                        echo "$f"
                    done \
                        | sed "s/^\(.\)/[\u\1\1]/")
@@ -417,19 +446,15 @@ main ()
        exit 1
     fi
 
-    declare -A words_done
     local i word replacement
     i=0
     for word in "${words[@]}"; do
        replacement=${replacements[$i]}
        i=$((i + 1))
 
-       # Skip words that are already handled.  This ensures that the local
-       # dictionary overrides the wiki dictionary.
-       if [ "${words_done[$word]}" == 1 ]; then
+       if [ "$word" = "" ]; then
            continue
        fi
-       words_done[$word]=1
 
        replace_word_in_files \
            "$word" \