From 52685ad5d548c1f4c5dd1a160c37dbbd5e99e631 Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 4 Aug 2024 14:55:01 +0200 Subject: [PATCH 1/9] Adds missing escape in config-debug --- config-debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-debug b/config-debug index 74d28f2..1197447 100755 --- a/config-debug +++ b/config-debug @@ -4,5 +4,5 @@ mkdir -p build cd build ../configure --enable-maintainer-mode \ --disable-shared --disable-pspell-compatibility\ - --enable-w-all-error + --enable-w-all-error \ --prefix="`pwd`/../inst" CFLAGS='-g' CXXFLAGS='-g' "$@" From 4f1c3200b2a41fb527d84386ccc68d9703fe012f Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 4 Aug 2024 23:19:56 +0200 Subject: [PATCH 2/9] add camel case test script --- test/camel-case | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 test/camel-case diff --git a/test/camel-case b/test/camel-case new file mode 100755 index 0000000..e58590d --- /dev/null +++ b/test/camel-case @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e +set -x + +# export PATH="`pwd`"/inst/bin:$PATH + +checkString () { + #echo $1 | aspell --camel-case -a > tmp/camel-case-res + echo $1 | /home/kris/proj/aspell/build/aspell --camel-case -a > tmp/camel-case-res +} + +checkString 'thisCamelCaseStringHasSevenWords' +if grep '^-$' tmp/camel-case-res; then + echo "pass" +else + echo "fail:" + cat tmp/camel-case-res + exit 1 +fi + +checkString 'thisCamelCaseStringHasMoreThanEightWords' +if grep '^-$' tmp/camel-case-res; then + echo "pass" +else + echo "fail:" + cat tmp/camel-case-res + exit 1 +fi + +checkString 'thisCamelCaseStringHasWordsThatAreALLCAPSAsWell' +if grep '^-$' tmp/camel-case-res; then + echo "pass" +else + echo "fail:" + cat tmp/camel-case-res + exit 1 +fi From db045dfb5ca19b20d823f5b582b1a391112bf84a Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 4 Aug 2024 23:37:18 +0200 Subject: [PATCH 3/9] add check_camelcase function --- modules/speller/default/speller_impl.cpp | 11 ++++++++++- modules/speller/default/speller_impl.hpp | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/speller/default/speller_impl.cpp b/modules/speller/default/speller_impl.cpp index 12e226a..8ffe916 100644 --- a/modules/speller/default/speller_impl.cpp +++ b/modules/speller/default/speller_impl.cpp @@ -214,6 +214,15 @@ namespace aspeller { return NULL; } + CheckInfo * SpellerImpl::check_camelcase(char * word, char * word_end, + bool try_uppercase, // @kris uppercase as runtogether? + unsigned camel_case_limit, + CheckInfo * ci, CheckInfo * ci_end, + GuessInfo * gi) + { + return NULL; + } + PosibErr SpellerImpl::check(char * word, char * word_end, /* it WILL modify word */ bool try_uppercase, @@ -225,7 +234,7 @@ namespace aspeller { bool res = check_runtogether(word, word_end, try_uppercase, run_together_limit, ci, ci_end, gi); if (res) return true; - CompoundWord cw = lang_->split_word(word, word_end - word, camel_case_); + CompoundWord cw = lang_->split_word(word, word_end - word, camel_case_); // @kris allcaps words? if (cw.single()) return false; bool ok = true; CheckInfo * ci_prev = NULL; diff --git a/modules/speller/default/speller_impl.hpp b/modules/speller/default/speller_impl.hpp index 14a6933..d0a3dc9 100644 --- a/modules/speller/default/speller_impl.hpp +++ b/modules/speller/default/speller_impl.hpp @@ -131,6 +131,13 @@ namespace aspeller { unsigned run_together_limit, CheckInfo *, CheckInfo *, GuessInfo *); + + CheckInfo * check_camelcase(char * word, char * word_end, /* @kris? it WILL modify word */ + bool try_uppercase, + unsigned camel_case_limit, + CheckInfo *, CheckInfo *, + GuessInfo *); + bool check_single(char * word, /* it WILL modify word */ bool try_uppercase, From 1dd1f8829b7963b56aaefb113225dc93f9becfa8 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 21:06:56 +0200 Subject: [PATCH 4/9] remove camel case limit by reusing last element of CheckInfo array --- modules/speller/default/speller_impl.cpp | 20 +++++++------------- modules/speller/default/speller_impl.hpp | 6 ------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/modules/speller/default/speller_impl.cpp b/modules/speller/default/speller_impl.cpp index 8ffe916..ee19841 100644 --- a/modules/speller/default/speller_impl.cpp +++ b/modules/speller/default/speller_impl.cpp @@ -214,15 +214,6 @@ namespace aspeller { return NULL; } - CheckInfo * SpellerImpl::check_camelcase(char * word, char * word_end, - bool try_uppercase, // @kris uppercase as runtogether? - unsigned camel_case_limit, - CheckInfo * ci, CheckInfo * ci_end, - GuessInfo * gi) - { - return NULL; - } - PosibErr SpellerImpl::check(char * word, char * word_end, /* it WILL modify word */ bool try_uppercase, @@ -234,11 +225,13 @@ namespace aspeller { bool res = check_runtogether(word, word_end, try_uppercase, run_together_limit, ci, ci_end, gi); if (res) return true; - CompoundWord cw = lang_->split_word(word, word_end - word, camel_case_); // @kris allcaps words? + CompoundWord cw = lang_->split_word(word, word_end - word, camel_case_); if (cw.single()) return false; bool ok = true; CheckInfo * ci_prev = NULL; + CheckInfo * ci_overflow = NULL; do { + if (ci_overflow) ci = ci_overflow; unsigned len = cw.word_len(); char save = word[len]; @@ -272,9 +265,10 @@ namespace aspeller { ci_prev = ci_last; ci = ci_last + 1; - if (ci >= ci_end) { - if (cpi) cpi->count = 0; - return false; + if (!ci_overflow && ci >= ci_end) { + // if (cpi) cpi->count = 0; + // return false; + ci_overflow = ci_last; } word = word + cw.rest_offset(); diff --git a/modules/speller/default/speller_impl.hpp b/modules/speller/default/speller_impl.hpp index d0a3dc9..2a24da8 100644 --- a/modules/speller/default/speller_impl.hpp +++ b/modules/speller/default/speller_impl.hpp @@ -132,12 +132,6 @@ namespace aspeller { CheckInfo *, CheckInfo *, GuessInfo *); - CheckInfo * check_camelcase(char * word, char * word_end, /* @kris? it WILL modify word */ - bool try_uppercase, - unsigned camel_case_limit, - CheckInfo *, CheckInfo *, - GuessInfo *); - bool check_single(char * word, /* it WILL modify word */ bool try_uppercase, From 6a0c66b7fa4c19960b9337e54212b67c2d93fe04 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 21:09:49 +0200 Subject: [PATCH 5/9] Remove test case for partial all caps --- test/camel-case | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/camel-case b/test/camel-case index e58590d..dbdee47 100755 --- a/test/camel-case +++ b/test/camel-case @@ -27,12 +27,3 @@ else cat tmp/camel-case-res exit 1 fi - -checkString 'thisCamelCaseStringHasWordsThatAreALLCAPSAsWell' -if grep '^-$' tmp/camel-case-res; then - echo "pass" -else - echo "fail:" - cat tmp/camel-case-res - exit 1 -fi From a9f366e3cd5bc1d905a4aa50ff41b7ee36a24dfb Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 21:31:35 +0200 Subject: [PATCH 6/9] Remove commented-out lines --- modules/speller/default/speller_impl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/speller/default/speller_impl.cpp b/modules/speller/default/speller_impl.cpp index ee19841..5409de6 100644 --- a/modules/speller/default/speller_impl.cpp +++ b/modules/speller/default/speller_impl.cpp @@ -266,8 +266,6 @@ namespace aspeller { ci_prev = ci_last; ci = ci_last + 1; if (!ci_overflow && ci >= ci_end) { - // if (cpi) cpi->count = 0; - // return false; ci_overflow = ci_last; } From 35474bfa8cf30592fc52cd11d86c3f81da8cfa35 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 21:53:48 +0200 Subject: [PATCH 7/9] Make camel-case use same aspell path as sanity --- test/camel-case | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/camel-case b/test/camel-case index dbdee47..3111a0f 100755 --- a/test/camel-case +++ b/test/camel-case @@ -3,11 +3,10 @@ set -e set -x -# export PATH="`pwd`"/inst/bin:$PATH +export PATH="`pwd`"/inst/bin:$PATH checkString () { - #echo $1 | aspell --camel-case -a > tmp/camel-case-res - echo $1 | /home/kris/proj/aspell/build/aspell --camel-case -a > tmp/camel-case-res + echo $1 | aspell --camel-case -a > tmp/camel-case-res } checkString 'thisCamelCaseStringHasSevenWords' From 2e278633940317aa48233cfb6a445f4321b1246d Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 22:28:48 +0200 Subject: [PATCH 8/9] Revert "Remove commented-out lines" This reverts commit a9f366e3cd5bc1d905a4aa50ff41b7ee36a24dfb. --- modules/speller/default/speller_impl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/speller/default/speller_impl.cpp b/modules/speller/default/speller_impl.cpp index 5409de6..ee19841 100644 --- a/modules/speller/default/speller_impl.cpp +++ b/modules/speller/default/speller_impl.cpp @@ -266,6 +266,8 @@ namespace aspeller { ci_prev = ci_last; ci = ci_last + 1; if (!ci_overflow && ci >= ci_end) { + // if (cpi) cpi->count = 0; + // return false; ci_overflow = ci_last; } From 4daac3621d6aa0c651803d3463523a8442dbdbb2 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 13 Aug 2024 22:30:07 +0200 Subject: [PATCH 9/9] Check against ci_overflow a cpi is passed --- modules/speller/default/speller_impl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/speller/default/speller_impl.cpp b/modules/speller/default/speller_impl.cpp index ee19841..83bf125 100644 --- a/modules/speller/default/speller_impl.cpp +++ b/modules/speller/default/speller_impl.cpp @@ -242,6 +242,10 @@ namespace aspeller { if (!found) { if (cpi) { + if (ci_overflow) { + cpi->count = 0; + return false; + } ci_last = ci; ok = false; ci->word.str = word; @@ -266,8 +270,6 @@ namespace aspeller { ci_prev = ci_last; ci = ci_last + 1; if (!ci_overflow && ci >= ci_end) { - // if (cpi) cpi->count = 0; - // return false; ci_overflow = ci_last; }