Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] [gdb/contrib] Handle parentheses in spellcheck.sh
Date: Tue, 12 Nov 2024 17:07:50 +0100	[thread overview]
Message-ID: <20241112160752.27661-2-tdevries@suse.de> (raw)
In-Reply-To: <20241112160752.27661-1-tdevries@suse.de>

Currently, text adjacent to parentheses is not spell-checked:
...
$ cat tmp.txt
(upto)
$ ./gdb/contrib/spellcheck.sh tmp.txt
$
...

Add handling of parentheses, such that we get:
...
$ ./gdb/contrib/spellcheck.sh tmp.txt
upto -> up to
$
...

Rerun spellcheck.sh, resulting in a few "thru->through" replacements.

Tested on x86_64--linux.
---
 gdb/contrib/spellcheck.sh                   | 41 ++++++++++++++++-----
 gdb/objc-lang.c                             |  2 +-
 gdb/testsuite/gdb.reverse/step-precsave.exp |  4 +-
 gdb/testsuite/gdb.reverse/step-reverse.exp  |  4 +-
 4 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh
index 1b3e88e259b..3399e41ea7f 100755
--- a/gdb/contrib/spellcheck.sh
+++ b/gdb/contrib/spellcheck.sh
@@ -47,6 +47,32 @@ sed_separators=(
     ","
 )
 
+# Pre: start of line, left parenthesis.
+declare -a grep_pre
+grep_pre=(
+    "^"
+    "\("
+)
+declare -a sed_pre
+sed_pre=(
+    "^"
+    "("
+)
+
+# Post: dot, right parenthesis, end of line.
+declare -a grep_post
+grep_post=(
+    "\."
+    "\)"
+    "$"
+)
+declare -a sed_post
+sed_post=(
+    "\."
+    ")"
+    "$"
+)
+
 join ()
 {
     local or
@@ -223,12 +249,11 @@ find_files_matching_words ()
 
 	local before after
 	before=$(grep_join \
-		     "^" \
+		     "${grep_pre[@]}" \
 		     "${grep_separators[@]}")
 	after=$(grep_join \
 		    "${grep_separators[@]}" \
-		    "\." \
-		    "$")
+		    "${grep_post[@]}")
 
 	pat="$before$pat$after"
 
@@ -250,12 +275,11 @@ find_files_matching_word ()
 
     local before after
     before=$(grep_join \
-		 "^" \
+		 "${grep_pre[@]}" \
 		 "${grep_separators[@]}")
     after=$(grep_join \
 		"${grep_separators[@]}" \
-		"\." \
-		"$")
+		"${grep_post[@]}")
 
     pat="$before$pat$after"
 
@@ -278,12 +302,11 @@ replace_word_in_file ()
 
     local before after
     before=$(sed_join \
-		 "^" \
+		 "${sed_pre[@]}" \
 		 "${sed_separators[@]}")
     after=$(sed_join \
 		"${sed_separators[@]}" \
-		"\." \
-		"$")
+		"${sed_post[@]}")
 
     local repl
     repl="s%$before$word$after%\1$replacement\2%g"
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index fa2befd1a35..58aca298dbc 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1203,7 +1203,7 @@ print_object_command (const char *args, int from_tty)
   gdb_printf ("\n");
 }
 
-/* The data structure 'methcalls' is used to detect method calls (thru
+/* The data structure 'methcalls' is used to detect method calls (through
  * ObjC runtime lib functions objc_msgSend, objc_msgSendSuper, etc.),
  * and ultimately find the method being called.
  */
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 27b417ec262..04880085cb8 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -268,12 +268,12 @@ gdb_test_multiple "stepi" "$test_message" {
     }
 }
 
-# step backward into function (thru return)
+# step backward into function (through return)
 
 gdb_test "step" "(RETURN FROM CALLEE|ARRIVED IN CALLEE).*" \
     "reverse step into fn call"
 
-# step backward out of called function (thru call)
+# step backward out of called function (through call)
 
 set test_message "reverse step out of called fn"
 gdb_test_multiple "step" "$test_message" {
diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp
index a3c3b5a5cd1..4bfe289ea73 100644
--- a/gdb/testsuite/gdb.reverse/step-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/step-reverse.exp
@@ -230,12 +230,12 @@ gdb_test_multiple "stepi" "$test_message" {
     }
 }
 
-# step backward into function (thru return)
+# step backward into function (through return)
 
 gdb_test "step" "(RETURN FROM CALLEE|ARRIVED IN CALLEE).*" \
     "reverse step into fn call"
 
-# step backward out of called function (thru call)
+# step backward out of called function (through call)
 
 set test_message "reverse step out of called fn"
 gdb_test_multiple "step" "$test_message" {
-- 
2.35.3


  reply	other threads:[~2024-11-12 16:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 16:07 [PATCH 0/3] [gdb/contrib] A few improvements for spellcheck.sh Tom de Vries
2024-11-12 16:07 ` Tom de Vries [this message]
2024-11-12 16:07 ` [PATCH 2/3] [gdb/contrib] Handle double quotes in spellcheck.sh Tom de Vries
2024-11-12 16:07 ` [PATCH 3/3] [gdb/contrib] Add "doens't->doesn't" to common-misspellings.txt Tom de Vries
2024-11-13 19:40 ` [PATCH 0/3] [gdb/contrib] A few improvements for spellcheck.sh Kevin Buettner
2024-11-13 20:07   ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241112160752.27661-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox