[1/3,gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
While trying to add more separators here:
...
# Separators: space, slash, tab.
grep_separator=" |/| "
sed_separator=" \|/\|\t"
...
I mistakingly used "|" instead of "\|" in sed_separator.
Factor out new variables grep_or and sed_or, and construct the grep_separator
and sed_separator variables by joining the elements of a list using grep_or
and sed_or.
Verified with shellcheck, and tested by rerunning on x86_64-linux.
---
gdb/contrib/spellcheck.sh | 43 +++++++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
base-commit: 23ca0175c66b1add6fe51efc160628c824f6d32f
Comments
>
> usage ()
> {
>
> base-commit: 23ca0175c66b1add6fe51efc160628c824f6d32f
> --
> 2.35.3
>
> Looks great, and also works perfectly on aarch64.
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
On 10/7/24 20:58, Alexandra Petlanova Hajkova wrote:
>
>
>
>
> usage ()
> {
>
> base-commit: 23ca0175c66b1add6fe51efc160628c824f6d32f
> --
> 2.35.3
>
> Looks great, and also works perfectly on aarch64.
> Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com
Hi,
thanks for the review, I've pushed the series.
Thanks,
- Tom
@@ -27,8 +27,47 @@ cache_file=wikipedia-common-misspellings.txt
dictionary=$cache_dir/$cache_file
# Separators: space, slash, tab.
-grep_separator=" |/| "
-sed_separator=" \|/\|\t"
+declare -a grep_separators
+grep_separators=(
+ " "
+ "/"
+ " "
+)
+declare -a sed_separators
+sed_separators=(
+ " "
+ "/"
+ "\t"
+)
+
+join ()
+{
+ local or
+ or="$1"
+ shift
+
+ local res
+ res=""
+
+ local first
+ first=true
+
+ for item in "$@"; do
+ if $first; then
+ first=false
+ res="$item"
+ else
+ res="$res$or$item"
+ fi
+ done
+
+ echo "$res"
+}
+
+grep_or="|"
+sed_or="\|"
+grep_separator=$(join $grep_or "${grep_separators[@]}")
+sed_separator=$(join $sed_or "${sed_separators[@]}")
usage ()
{