Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/contrib] Handle capitalized words in spellcheck.sh
@ 2024-11-13  1:08 Tom de Vries
  2024-11-13 20:37 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2024-11-13  1:08 UTC (permalink / raw)
  To: gdb-patches

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.
---
 gdb/amd64-linux-nat.c                      |  4 ++--
 gdb/amd64-tdep.c                           |  2 +-
 gdb/contrib/spellcheck.sh                  | 25 ++++++++++++++++------
 gdb/i386-linux-nat.c                       |  6 +++---
 gdb/linux-tdep.c                           |  2 +-
 gdb/m2-exp.y                               |  2 +-
 gdb/m32r-linux-nat.c                       |  4 ++--
 gdb/m68k-linux-nat.c                       |  2 +-
 gdb/or1k-linux-nat.c                       |  2 +-
 gdb/target.h                               |  2 +-
 gdb/testsuite/gdb.arch/arc-decode-insn.S   |  2 +-
 gdb/testsuite/gdb.cp/static-print-quit.exp |  2 +-
 gdb/tilegx-linux-nat.c                     |  4 ++--
 13 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 742fc81f832..c3b7a19b5cb 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -90,7 +90,7 @@ static int amd64_linux_gregset32_reg_offset[] =
 };
 \f
 
-/* Transfering the general-purpose registers between GDB, inferiors
+/* Transferring the general-purpose registers between GDB, inferiors
    and core files.  */
 
 /* See amd64_collect_native_gregset.  This linux specific version handles
@@ -178,7 +178,7 @@ fill_gregset (const struct regcache *regcache,
   amd64_linux_collect_native_gregset (regcache, gregsetp, regnum);
 }
 
-/* Transfering floating-point registers between GDB, inferiors and cores.  */
+/* Transferring floating-point registers between GDB, inferiors and cores.  */
 
 /* Fill GDB's register cache with the floating-point and SSE register
    values in *FPREGSETP.  */
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index c17b5f7f6f3..ba6532fcee7 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -1227,7 +1227,7 @@ amd64_get_unused_input_int_reg (const struct amd64_insn *details)
 
   /* Avoid RAX.  */
   used_regs_mask |= 1 << EAX_REG_NUM;
-  /* Similarily avoid RDX, implicit operand in divides.  */
+  /* Similarly avoid RDX, implicit operand in divides.  */
   used_regs_mask |= 1 << EDX_REG_NUM;
   /* Avoid RSP.  */
   used_regs_mask |= 1 << ESP_REG_NUM;
diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh
index 1b3e88e259b..f8d9274440c 100755
--- a/gdb/contrib/spellcheck.sh
+++ b/gdb/contrib/spellcheck.sh
@@ -190,8 +190,10 @@ output_local_dictionary ()
 
 output_dictionaries ()
 {
-    output_local_dictionary
-    cat "$dictionary"
+    (
+	output_local_dictionary
+	cat "$dictionary"
+    ) | grep -E -v "[A-Z]"
 }
 
 parse_dictionary ()
@@ -219,7 +221,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 \
@@ -257,6 +266,8 @@ find_files_matching_word ()
 		"\." \
 		"$")
 
+    pat="(${pat@u}|$pat)"
+
     pat="$before$pat$after"
 
     grep -E \
@@ -285,11 +296,13 @@ replace_word_in_file ()
 		"\." \
 		"$")
 
-    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"
 }
 
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 41c1113257c..d2cbe51e72b 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -137,7 +137,7 @@ store_register (const struct regcache *regcache, int regno)
 }
 \f
 
-/* Transfering the general-purpose registers between GDB, inferiors
+/* Transferring the general-purpose registers between GDB, inferiors
    and core files.  */
 
 /* Fill GDB's register array with the general-purpose register values
@@ -234,7 +234,7 @@ static void store_regs (const struct regcache *regcache, int tid, int regno) {}
 #endif
 \f
 
-/* Transfering floating-point registers between GDB, inferiors and cores.  */
+/* Transferring floating-point registers between GDB, inferiors and cores.  */
 
 /* Fill GDB's register array with the floating-point register values in
    *FPREGSETP.  */
@@ -304,7 +304,7 @@ store_fpregs (const struct regcache *regcache, int tid, int regno)
 #endif
 \f
 
-/* Transfering floating-point and SSE registers to and from GDB.  */
+/* Transferring floating-point and SSE registers to and from GDB.  */
 
 /* Fetch all registers covered by the PTRACE_GETREGSET request from
    process/thread TID and store their values in GDB's register array.
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 65ec221ef48..d3452059ce2 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -2104,7 +2104,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
   if (!note_data)
     return NULL;
 
-  /* Auxillary vector.  */
+  /* Auxiliary vector.  */
   std::optional<gdb::byte_vector> auxv =
     target_read_alloc (current_inferior ()->top_target (),
 		       TARGET_OBJECT_AUXV, NULL);
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 2887ad2be21..0201f84cfa5 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -961,7 +961,7 @@ yylex (void)
 
        case LOC_LABEL:
        case LOC_UNRESOLVED:
-	  error (_("internal:  Unforseen case in m2lex()"));
+	  error (_("internal:  Unforeseen case in m2lex()"));
 
        default:
 	  error (_("unhandled token in m2lex()"));
diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c
index 08a4db1d39a..bb8667539b5 100644
--- a/gdb/m32r-linux-nat.c
+++ b/gdb/m32r-linux-nat.c
@@ -66,7 +66,7 @@ static int regmap[] = {
 \f
 
 
-/* Transfering the general-purpose registers between GDB, inferiors
+/* Transferring the general-purpose registers between GDB, inferiors
    and core files.  */
 
 /* Fill GDB's register array with the general-purpose register values
@@ -176,7 +176,7 @@ store_regs (const struct regcache *regcache, int tid, int regno)
 \f
 
 
-/* Transfering floating-point registers between GDB, inferiors and cores.  
+/* Transferring floating-point registers between GDB, inferiors and cores.
    Since M32R has no floating-point registers, these functions do nothing.  */
 
 void
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index 49cd49193bb..7ea5847a2a6 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -300,7 +300,7 @@ static void store_regs (const struct regcache *regcache, int tid, int regno)
 #endif
 
 \f
-/* Transfering floating-point registers between GDB, inferiors and cores.  */
+/* Transferring floating-point registers between GDB, inferiors and cores.  */
 
 /* What is the address of fpN within the floating-point register set F?  */
 #define FPREG_ADDR(f, n) (&(f)->fpregs[(n) * 3])
diff --git a/gdb/or1k-linux-nat.c b/gdb/or1k-linux-nat.c
index 21392245f48..e6cc9c70293 100644
--- a/gdb/or1k-linux-nat.c
+++ b/gdb/or1k-linux-nat.c
@@ -106,7 +106,7 @@ fill_gregset (const struct regcache *regcache, prgregset_t *gregs, int regnum)
     regcache->raw_collect (OR1K_NPC_REGNUM, regp + 32);
 }
 
-/* Transfering floating-point registers between GDB, inferiors and cores.
+/* Transferring floating-point registers between GDB, inferiors and cores.
    Since OpenRISC floating-point registers are the same as GPRs these do
    nothing.  */
 
diff --git a/gdb/target.h b/gdb/target.h
index 6da58c7e179..d8729913b3b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1651,7 +1651,7 @@ struct memory_write_request
     : begin (begin_), end (end_), data (data_), baton (baton_)
   {}
 
-  /* Begining address that must be written.  */
+  /* Beginning address that must be written.  */
   ULONGEST begin;
   /* Past-the-end address.  */
   ULONGEST end;
diff --git a/gdb/testsuite/gdb.arch/arc-decode-insn.S b/gdb/testsuite/gdb.arch/arc-decode-insn.S
index ea37455d890..6b37d545c31 100644
--- a/gdb/testsuite/gdb.arch/arc-decode-insn.S
+++ b/gdb/testsuite/gdb.arch/arc-decode-insn.S
@@ -394,7 +394,7 @@ start_branch_tests:
 
 #ifdef TEST_B
 .Lb_target:
-    ; Artifical nop, so that first b will not branch to itself.
+    ; Artificial nop, so that first b will not branch to itself.
     nop_s
     ; b s25
     .set b_s25_target, @.Lb_target
diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index 109bf8dc336..72364390ceb 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -55,7 +55,7 @@ gdb_test_multiple "" $test {
 
 gdb_test "q" ".*"
 
-# Now the obstack is uninitialized.  Excercise it.
+# Now the obstack is uninitialized.  Exercise it.
 
 gdb_test_no_output "set pagination off"
 gdb_test "print c" ".*" "first print"
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index 440a5cc89ce..5755e7078e7 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -72,7 +72,7 @@ static const int regmap[] =
   56, 58
 };
 
-/* Transfering the general-purpose registers between GDB, inferiors
+/* Transferring the general-purpose registers between GDB, inferiors
    and core files.  */
 
 /* Fill GDB's register array with the general-purpose register values
@@ -105,7 +105,7 @@ fill_gregset (const struct regcache* regcache,
       regcache->raw_collect (i, regp + regmap[i]);
 }
 
-/* Transfering floating-point registers between GDB, inferiors and cores.  */
+/* Transferring floating-point registers between GDB, inferiors and cores.  */
 
 /* Fill GDB's register array with the floating-point register values in
    *FPREGSETP.  */

base-commit: 2e7d431af880736d6a6e8144a8e3d6d1e65008f5
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/contrib] Handle capitalized words in spellcheck.sh
  2024-11-13  1:08 [PATCH] [gdb/contrib] Handle capitalized words in spellcheck.sh Tom de Vries
@ 2024-11-13 20:37 ` Kevin Buettner
  2024-11-13 21:38   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2024-11-13 20:37 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Wed, 13 Nov 2024 02:08:52 +0100
Tom de Vries <tdevries@suse.de> wrote:

> 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".

...

-	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[@]}")

It took me a while to puzzle out that process substitution is being
used to provide input to the mapfile command, but once I figured that
out, it made sense to me.

Approved-by: Kevin Buettner <kevinb@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/contrib] Handle capitalized words in spellcheck.sh
  2024-11-13 20:37 ` Kevin Buettner
@ 2024-11-13 21:38   ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2024-11-13 21:38 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

On 11/13/24 21:37, Kevin Buettner wrote:
> On Wed, 13 Nov 2024 02:08:52 +0100
> Tom de Vries <tdevries@suse.de> wrote:
> 
>> 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".
> 
> ...
> 
> -	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[@]}")
> 
> It took me a while to puzzle out that process substitution is being
> used to provide input to the mapfile command, but once I figured that
> out, it made sense to me.
> 
> Approved-by: Kevin Buettner <kevinb@redhat.com>

Thanks for the review, pushed.

- Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-13 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-13  1:08 [PATCH] [gdb/contrib] Handle capitalized words in spellcheck.sh Tom de Vries
2024-11-13 20:37 ` Kevin Buettner
2024-11-13 21:38   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox