summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-08-22 22:54:29 +0000
committerBram Moolenaar <Bram@vim.org>2005-08-22 22:54:29 +0000
commite52325c254d929c7c8d68efb9ace0c7868433675 (patch)
tree4777b4f43174185a5d2afc8bcfa4e67c15778fad
parentd52d9741ee3770678b1cf6ebc748896a64f3e2ed (diff)
downloadvim-git-e52325c254d929c7c8d68efb9ace0c7868433675.tar.gz
updated for version 7.0134
-rw-r--r--runtime/spell/am/main.aap63
-rw-r--r--runtime/spell/main.aap2
-rw-r--r--src/spell.c93
3 files changed, 142 insertions, 16 deletions
diff --git a/runtime/spell/am/main.aap b/runtime/spell/am/main.aap
new file mode 100644
index 000000000..e8ba35c30
--- /dev/null
+++ b/runtime/spell/am/main.aap
@@ -0,0 +1,63 @@
+# Aap recipe for Amharic Vim spell files.
+
+# Use a freshly compiled Vim if it exists.
+@if os.path.exists('../../../src/vim'):
+ VIM = ../../../src/vim
+@else:
+ :progsearch VIM vim
+
+SPELLDIR = ..
+FILES = am_ET.aff am_ET.dic
+
+all: $SPELLDIR/am.utf-8.spl ../README_am.txt
+
+$SPELLDIR/am.utf-8.spl : $FILES
+ :sys env LANG=am_ET.UTF-8 $VIM -u NONE -e -c "mkspell! $SPELLDIR/am am_ET" -c q
+
+../README_am.txt: README_am.txt
+ :copy $source $target
+
+#
+# Fetching the files from Hunspell.
+#
+HTTPDIR = http://hunspell.sourceforge.net
+TARNAME = am-demo.tar.gz
+:attr {fetch = $HTTPDIR/%file%} $TARNAME
+
+# The files don't depend on the .zip file so that we can delete it.
+# Only download the zip file if the targets don't exist.
+# This is a bit tricky, since the file name includes the date.
+am_ET.aff am_ET.dic: {buildcheck=}
+ :assertpkg tar gzip
+ :fetch $TARNAME
+ :sys gzip -d -c $TARNAME | tar xf -
+ :move am/am.aff am_ET.aff
+ :move am/am.dic am_ET.dic
+ :move am/README README_am.txt
+ :delete {recursive} am
+ :delete $TARNAME
+ @if not os.path.exists('am_ET.orig.aff'):
+ :copy am_ET.aff am_ET.orig.aff
+ @if not os.path.exists('am_ET.orig.dic'):
+ :copy am_ET.dic am_ET.orig.dic
+ @if os.path.exists('am_ET.diff'):
+ :sys patch <am_ET.diff
+
+
+# Generate diff files, so that others can get the OpenOffice files and apply
+# the diffs to get the Vim versions.
+
+diff:
+ :assertpkg diff
+ :sys {force} diff -a -C 1 am_ET.orig.aff am_ET.aff >am_ET.diff
+ :sys {force} diff -a -C 1 am_ET.orig.dic am_ET.dic >>am_ET.diff
+
+
+# Check for updated spell files. When there are changes the
+# ".new.aff" and ".new.dic" files are left behind for manual inspection.
+
+check:
+ :print Sorry, not implemented yet.
+
+
+# vim: set sts=4 sw=4 :
diff --git a/runtime/spell/main.aap b/runtime/spell/main.aap
index 352bc5565..e98b36533 100644
--- a/runtime/spell/main.aap
+++ b/runtime/spell/main.aap
@@ -4,7 +4,7 @@
# aap generate all the .spl files
# aap diff create all the diff files
-LANG = af bg ca cs da de el en eo fr fo gl he hr it nl ny pl sk yi hu
+LANG = af am bg ca cs da de el en eo fr fo gl he hr it nl ny pl sk yi hu
# "hu" is at the end, because it takes very long.
#
diff --git a/src/spell.c b/src/spell.c
index 2d20e9a0b..dd0fe834f 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -250,9 +250,9 @@
Some places assume a word length fits in a
byte, thus it can't be above 255. */
-/* Type used for indexes in the word tree need to be at least 3 bytes. If int
+/* Type used for indexes in the word tree need to be at least 4 bytes. If int
* is 8 bytes we could use something smaller, but what? */
-#if SIZEOF_INT > 2
+#if SIZEOF_INT > 3
typedef int idx_T;
#else
typedef long idx_T;
@@ -986,8 +986,8 @@ find_word(mip, mode)
idx_T lo, hi, m;
#ifdef FEAT_MBYTE
char_u *s;
- char_u *p;
#endif
+ char_u *p;
int res = SP_BAD;
slang_T *slang = mip->mi_lp->lp_slang;
unsigned flags;
@@ -1218,11 +1218,14 @@ find_word(mip, mode)
* Makes you wonder why someone puts a compound flag on a word
* that's too short... Myspell compatibility requires this
* anyway. */
- if (((unsigned)flags >> 24) == 0 || wlen < slang->sl_compminlen)
+ if (((unsigned)flags >> 24) == 0
+ || wlen - mip->mi_compoff < slang->sl_compminlen)
continue;
- /* Limit the number of compound words to COMPOUNDMAX. */
- if (!word_ends && mip->mi_complen + 2 > slang->sl_compmax)
+ /* Limit the number of compound words to COMPOUNDMAX if no
+ * maximum for syllables is specified. */
+ if (!word_ends && mip->mi_complen + 2 > slang->sl_compmax
+ && slang->sl_compsylmax == MAXWLEN)
continue;
/* Quickly check if compounding is possible with this flag. */
@@ -1232,6 +1235,44 @@ find_word(mip, mode)
((unsigned)flags >> 24)) == NULL)
continue;
+ if (mode == FIND_COMPOUND)
+ {
+ int capflags;
+
+ /* Need to check the caps type of the appended compound
+ * word. */
+#ifdef FEAT_MBYTE
+ if (has_mbyte && STRNCMP(ptr, mip->mi_word,
+ mip->mi_compoff) != 0)
+ {
+ /* case folding may have changed the length */
+ p = mip->mi_word;
+ for (s = ptr; s < ptr + mip->mi_compoff; mb_ptr_adv(s))
+ mb_ptr_adv(p);
+ }
+ else
+#endif
+ p = mip->mi_word + mip->mi_compoff;
+ capflags = captype(p, mip->mi_word + wlen);
+ if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
+ && (flags & WF_FIXCAP) != 0))
+ continue;
+
+ if (capflags != WF_ALLCAP)
+ {
+ /* When the character before the word is a word
+ * character we do not accept a Onecap word. We do
+ * accept a no-caps word, even when the dictionary
+ * word specifies ONECAP. */
+ mb_ptr_back(mip->mi_word, p);
+ if (spell_iswordp_nmw(p)
+ ? capflags == WF_ONECAP
+ : (flags & WF_ONECAP) != 0
+ && capflags != WF_ONECAP)
+ continue;
+ }
+ }
+
/* If the word ends the sequence of compound flags of the
* words must match with one of the COMPOUNDFLAGS items and
* the number of syllables must not be too large. */
@@ -1348,10 +1389,12 @@ can_compound(slang, word, flags)
if (!vim_regexec(&regmatch, flags, 0))
return FALSE;
- /* Count the number of syllables. This may be slow, do it last. */
+ /* Count the number of syllables. This may be slow, do it last. If there
+ * are too many syllables AND the number of compound words is above
+ * COMPOUNDMAX then compounding is not allowed. */
if (slang->sl_compsylmax < MAXWLEN
&& count_syllables(slang, word) > slang->sl_compsylmax)
- return FALSE;
+ return STRLEN(flags) < slang->sl_compmax;
return TRUE;
}
@@ -8596,11 +8639,22 @@ suggest_try_change(su)
break;
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
- if (fword_ends && !can_compound(slang,
- tword + sp->ts_splitoff,
+ vim_strncpy(preword + sp->ts_prewordlen,
+ tword + sp->ts_splitoff,
+ sp->ts_twordlen - sp->ts_splitoff);
+ p = preword;
+ while (*skiptowhite(p) != NUL)
+ p = skipwhite(skiptowhite(p));
+ if (fword_ends && !can_compound(slang, p,
compflags + sp->ts_compsplit))
break;
+
+ /* Get pointer to last char of previous word. */
+ p = preword + sp->ts_prewordlen;
+ mb_ptr_back(preword, p);
}
+ else
+ p = NULL;
/*
* Form the word with proper case in preword.
@@ -8624,8 +8678,14 @@ suggest_try_change(su)
#endif
)
c = WF_ONECAP;
+ c |= flags;
+
+ /* When appending a compound word after a word character
+ * don't use Onecap. */
+ if (p != NULL && spell_iswordp_nmw(p))
+ c &= ~WF_ONECAP;
make_case_word(tword + sp->ts_splitoff,
- preword + sp->ts_prewordlen, flags | c);
+ preword + sp->ts_prewordlen, c);
}
/* Don't use a banned word. It may appear again as a good
@@ -8702,8 +8762,9 @@ suggest_try_change(su)
&& ((unsigned)flags >> 24) != 0
&& sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen
- && sp->ts_complen + 1 - sp->ts_compsplit
- < slang->sl_compmax
+ && (slang->sl_compsylmax < MAXWLEN
+ || sp->ts_complen + 1 - sp->ts_compsplit
+ < slang->sl_compmax)
&& (vim_strchr(sp->ts_complen == sp->ts_compsplit
? slang->sl_compstartflags
: slang->sl_compallflags,
@@ -8733,9 +8794,11 @@ suggest_try_change(su)
{
/* If we're going to split need to check that the
* words so far are valid for compounding. */
+ p = preword;
+ while (*skiptowhite(p) != NUL)
+ p = skipwhite(skiptowhite(p));
if (sp->ts_complen > sp->ts_compsplit
- && !can_compound(slang,
- tword + sp->ts_splitoff,
+ && !can_compound(slang, p,
compflags + sp->ts_compsplit))
break;
newscore += SCORE_SPLIT;