-*todo.txt* For Vim version 7.0aa. Last change: 2005 Aug 09
+*todo.txt* For Vim version 7.0aa. Last change: 2005 Aug 10
VIM REFERENCE MANUAL by Bram Moolenaar
*known-bugs*
-------------------- Known bugs and current work -----------------------
-Spell checking: code for pre-compressing tree. (Olaf Seibert)
-Any problems with the reference counting?
-
-spell checking for Yiddish: (Raphael Finkel)
-- use ~/tmp/yiddish.uspell.dat
-- suggestions are not displayed with 'rightleft'
-- suggestions don't have composing characters
-- out-of-mem error when using suggestion?
-
-Spell suggestion for "WOrd" should be "Word" instead of "word".
-
Spell checking: default value for 'spellcapcheck' in spell file?
+For Hebrew and Yiddish it should be empty.
When 'insertmode' is set, CTRL-L no longer moves the cursor left. What
compatibility problems does this cause?
# "aap": generate all the .spl files
# "aap diff" create all the diff files
-LANG = de en fr he it nl pl
+LANG = de en fr he it nl pl yi
diff: $*LANG/diff
:print done
--- /dev/null
+# Aap recipe for Hebrew 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 = ..
+FILE = wordlist.utf8.txt
+
+all: $SPELLDIR/yi.utf-8.spl ../README_yi.txt
+
+$SPELLDIR/yi.utf-8.spl : $VIM $FILE
+ :sys $VIM -u NONE -e -c "set enc=utf-8"
+ -c "mkspell! $(SPELLDIR)/yi $FILE" -c q
+
+../README_yi.txt : README.txt
+ :copy $source $target
+
+#
+# Fetch the word list when needed.
+#
+URLDIR = http://www.cs.uky.edu/~raphael/yiddish
+:attr {fetch = $URLDIR/%file%} $FILE
+
+
+# There is no diff file, the word list is used as-is
+diff:
+ :print No diff file.
+
+
+# vim: set sts=4 sw=4 :
while (l >= item[groupitem[groupdepth]].maxwid)
{
l -= ptr2cells(t + n);
- n += (*mb_ptr2len_check)(t + n);
+ n += (*mb_ptr2len)(t + n);
}
}
else
if (has_mbyte)
{
l -= ptr2cells(t);
- t += (*mb_ptr2len_check)(t);
+ t += (*mb_ptr2len)(t);
}
else
#endif
width += ptr2cells(s);
if (width >= maxwidth)
break;
- s += (*mb_ptr2len_check)(s);
+ s += (*mb_ptr2len)(s);
}
/* Fill up for half a double-wide character. */
while (++width < maxwidth)
while (width >= maxwidth)
{
width -= ptr2cells(s + n);
- n += (*mb_ptr2len_check)(s + n);
+ n += (*mb_ptr2len)(s + n);
}
}
else
{
# ifdef FEAT_MBYTE
/* Assume a multi-byte character doesn't need translation. */
- if (has_mbyte && (trs_len = (*mb_ptr2len_check)(buf)) > 1)
+ if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)
len -= trs_len;
else
# endif
p = s;
while (*p != NUL)
{
- if ((l = (*mb_ptr2len_check)(p)) > 1)
+ if ((l = (*mb_ptr2len)(p)) > 1)
{
c = (*mb_ptr2char)(p);
p += l;
while (*p != NUL)
{
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
c = (*mb_ptr2char)(p);
if (vim_isprintc(c))
}
}
/* skip to next multi-byte char */
- i += (*mb_ptr2len_check)(STR_PTR(i));
+ i += (*mb_ptr2len)(STR_PTR(i));
}
else
#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int l = (*mb_ptr2len_check)(s);
+ int l = (*mb_ptr2len)(s);
size += ptr2cells(s);
s += l;
else
{
#ifdef FEAT_MBYTE
- l = (*mb_ptr2len_check)(p1);
- if (l != (*mb_ptr2len_check)(p2))
+ l = (*mb_ptr2len)(p1);
+ if (l != (*mb_ptr2len)(p2))
break;
if (l > 1)
{
#ifdef FEAT_MBYTE
else if (has_mbyte)
{
- i = (*mb_ptr2len_check)(ptr);
+ i = (*mb_ptr2len)(ptr);
if (ptr[i] == NUL)
curwin->w_cursor.col += i;
}
last_vcol = vcol;
#ifdef FEAT_MBYTE
if (has_mbyte && new_cursor_col >= 0)
- new_cursor_col += (*mb_ptr2len_check)(ptr + new_cursor_col);
+ new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);
else
#endif
++new_cursor_col;
* with single-byte non-word characters. */
while (*ptr != NUL)
{
- int l = (*mb_ptr2len_check)(ptr);
+ int l = (*mb_ptr2len)(ptr);
if (l < 2 && !vim_iswordc(*ptr))
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1)
- ptr += (*mb_ptr2len_check)(ptr);
+ ptr += (*mb_ptr2len)(ptr);
else
#endif
while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr))
if (start_class > 1)
while (*ptr != NUL)
{
- ptr += (*mb_ptr2len_check)(ptr);
+ ptr += (*mb_ptr2len)(ptr);
if (mb_get_class(ptr) != start_class)
break;
}
{
int i, mb_len;
- mb_len = (*mb_ptr2len_check)(src) - 1;
+ mb_len = (*mb_ptr2len)(src) - 1;
if (mb_len > 0 && len >= mb_len)
for (i = 0; i < mb_len; ++i)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
foundcol = curwin->w_cursor.col
- + (*mb_ptr2len_check)(ml_get_cursor());
+ + (*mb_ptr2len)(ml_get_cursor());
else
#endif
foundcol = curwin->w_cursor.col + 1;
ptr = ml_get_cursor();
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(ptr)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(ptr)) > 1)
{
/* The character under the cursor is a multi-byte character, move
* several bytes right, but don't end up on the NUL. */
{
vcol += chartabsize(p + i, vcol);
#ifdef FEAT_MBYTE
- i += (*mb_ptr2len_check)(p) - 1;
+ i += (*mb_ptr2len)(p) - 1;
#endif
}
vcol -= start_vcol;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- curwin->w_cursor.col += (*mb_ptr2len_check)(ml_get_cursor());
+ curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else
#endif
++curwin->w_cursor.col;
{
if (*t == NUL) /* EOL reached */
return;
- t += mb_ptr2len_check(t);
+ t += (*mb_ptr2len)(t);
}
rettv->vval.v_number = t - str;
#else
# ifdef FEAT_MBYTE
int l;
- if (*p != NUL && p[(l = (*mb_ptr2len_check)(p))] == NUL)
+ if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL)
col += l;
# else
if (*p != NUL && p[1] == NUL)
else
{
#ifdef FEAT_MBYTE
- str = regmatch.startp[0] + mb_ptr2len_check(regmatch.startp[0]);
+ str = regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]);
#else
str = regmatch.startp[0] + 1;
#endif
{
/* Don't get stuck at the same match. */
#ifdef FEAT_MBYTE
- col = mb_ptr2len_check(regmatch.endp[0]);
+ col = (*mb_ptr2len)(regmatch.endp[0]);
#else
col = 1;
#endif
c = utf_ptr2char(p);
lc = utf_tolower(c);
- l = utf_ptr2len_check(p);
+ l = utf_ptr2len(p);
/* TODO: reallocate string when byte count changes. */
if (utf_char2len(lc) == l)
utf_char2bytes(lc, p);
p += l;
}
- else if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- inlen = mb_ptr2len_check(instr);
+ inlen = (*mb_ptr2len)(instr);
cpstr = instr;
cplen = inlen;
idx = 0;
for (p = fromstr; *p != NUL; p += fromlen)
{
- fromlen = mb_ptr2len_check(p);
+ fromlen = (*mb_ptr2len)(p);
if (fromlen == inlen && STRNCMP(instr, p, inlen) == 0)
{
for (p = tostr; *p != NUL; p += tolen)
{
- tolen = mb_ptr2len_check(p);
+ tolen = (*mb_ptr2len)(p);
if (idx-- == 0)
{
cplen = tolen;
first = FALSE;
for (p = tostr; *p != NUL; p += tolen)
{
- tolen = mb_ptr2len_check(p);
+ tolen = (*mb_ptr2len)(p);
--idx;
}
if (idx != 0)
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int i = (*mb_ptr2len_check)(p);
+ int i = (*mb_ptr2len)(p);
(void)msg_outtrans_len_attr(p, i, echo_attr);
p += i - 1;
vcol += chartabsize(ptr + col, (colnr_T)vcol);
#ifdef FEAT_MBYTE
if (has_mbyte)
- col += (*mb_ptr2len_check)(ptr + col);
+ col += (*mb_ptr2len)(ptr + col);
else
#endif
++col;
}
#ifdef FEAT_MBYTE
else if (has_mbyte)
- p1 += (*mb_ptr2len_check)(p1) - 1;
+ p1 += (*mb_ptr2len)(p1) - 1;
#endif
}
int l;
this_utf = TRUE;
- l = utf_ptr2len_check(s);
+ l = utf_ptr2len(s);
if (l == 1)
this_utf = FALSE;
s += l - 1;
int l;
this_utf8 = TRUE;
- l = utf_ptr2len_check(s);
+ l = utf_ptr2len(s);
if (l == 1)
{
/* Illegal UTF-8 byte sequence. */
if (has_mbyte)
{
cells = 0;
- for (s = arg; s < p; s += (*mb_ptr2len_check)(s))
+ for (s = arg; s < p; s += (*mb_ptr2len)(s))
{
if (!vim_isprintc((*mb_ptr2char)(s)))
break;
if (*p == CSI) /* leadbyte CSI */
len += 2;
# endif
- for (l = (*mb_ptr2len_check)(p) - 1; l > 0; --l)
+ for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */
# ifdef FEAT_GUI
|| *p == CSI
arg[len++] = (int)KE_CSI;
}
# endif
- for (l = (*mb_ptr2len_check)(p) - 1; l > 0; --l)
+ for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
{
arg[len++] = *++p;
if (*p == K_SPECIAL)
{
int l;
- if (has_mbyte && (l = (*mb_ptr2len_check)(name)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(name)) > 1)
{
/* copy a multibyte char */
while (--l >= 0)
while (p > ccline.cmdbuff && mb_get_class(p) == i)
p = mb_prevptr(ccline.cmdbuff, p);
if (mb_get_class(p) != i)
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
}
else
ccline.cmdspos += i;
#ifdef FEAT_MBYTE
if (has_mbyte)
- ccline.cmdpos += (*mb_ptr2len_check)(ccline.cmdbuff
+ ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ ccline.cmdpos);
else
#endif
{
/* Count ">" for double-wide char that doesn't fit. */
correct_cmdspos(ccline.cmdpos, i);
- ccline.cmdpos += (*mb_ptr2len_check)(ccline.cmdbuff
+ ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ ccline.cmdpos) - 1;
}
#endif
}
#ifdef FEAT_MBYTE
if (has_mbyte)
- i += (*mb_ptr2len_check)(ccline.cmdbuff + i) - 1;
+ i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1;
#endif
}
}
int idx;
int cells;
{
- if ((*mb_ptr2len_check)(ccline.cmdbuff + idx) > 1
+ if ((*mb_ptr2len)(ccline.cmdbuff + idx) > 1
&& (*mb_ptr2cells)(ccline.cmdbuff + idx) > 1
&& ccline.cmdspos % Columns + cells > Columns)
ccline.cmdspos++;
int i = 0;
for (col = 0; i < ccline.cmdpos; ++col)
- i += (*mb_ptr2len_check)(ccline.cmdbuff + i);
+ i += (*mb_ptr2len)(ccline.cmdbuff + i);
return col;
}
&& cmdpos < ccline.cmdlen; ++col)
{
cmdspos += (*mb_ptr2cells)(ccline.cmdbuff + cmdpos);
- cmdpos += (*mb_ptr2len_check)(ccline.cmdbuff + cmdpos);
+ cmdpos += (*mb_ptr2len)(ccline.cmdbuff + cmdpos);
}
}
else
# ifdef FEAT_MBYTE
if (has_mbyte)
- char_len = (*mb_ptr2len_check)(ccline.cmdbuff + cmdpos);
+ char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos);
else
# endif
char_len = 1;
msg_putchar('*');
# ifdef FEAT_MBYTE
if (has_mbyte)
- i += (*mb_ptr2len_check)(ccline.cmdbuff + start + i) - 1;
+ i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1;
# endif
}
else
{
p = ccline.cmdbuff + j;
u8c = utfc_ptr2char_len(p, &u8c_c1, &u8c_c2, start + len - j);
- mb_l = utfc_ptr2len_check_len(p, start + len - j);
+ mb_l = utfc_ptr2len_len(p, start + len - j);
if (ARABIC_CHAR(u8c))
{
/* Do Arabic shaping. */
{
/* Count nr of characters in the new string. */
m = 0;
- for (i = 0; i < len; i += (*mb_ptr2len_check)(str + i))
+ for (i = 0; i < len; i += (*mb_ptr2len)(str + i))
++m;
/* Count nr of bytes in cmdline that are overwritten by these
* characters. */
for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0;
- i += (*mb_ptr2len_check)(ccline.cmdbuff + i))
+ i += (*mb_ptr2len)(ccline.cmdbuff + i))
--m;
if (i < ccline.cmdlen)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- c = (*mb_ptr2len_check)(ccline.cmdbuff + ccline.cmdpos) - 1;
+ c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1;
if (c > len - i - 1)
c = len - i - 1;
ccline.cmdpos += c;
p = ptr;
for (flen = from_size; flen > 0; flen -= l)
{
- l = utf_ptr2len_check_len(p, flen);
+ l = utf_ptr2len_len(p, flen);
if (l > flen) /* incomplete char */
{
if (l > CONV_RESTLEN)
p = ptr;
for (flen = from_size; flen > 0; flen -= l)
{
- l = utf_ptr2len_check_len(p, flen);
+ l = utf_ptr2len_len(p, flen);
u8c = utf_ptr2char(p);
ucsp[needed * 2] = (u8c & 0xff);
ucsp[needed * 2 + 1] = (u8c >> 8);
{
if (*p >= 0x80)
{
- len = utf_ptr2len_check(p);
+ len = utf_ptr2len(p);
/* A length of 1 means it's an illegal byte. Accept
* an incomplete character at the end though, the next
* read() will get the next bytes, we'll check it
if (l > len)
l = len;
mch_memmove(ip->bw_rest + ip->bw_restlen, buf, (size_t)l);
- n = utf_ptr2len_check_len(ip->bw_rest, ip->bw_restlen + l);
+ n = utf_ptr2len_len(ip->bw_rest, ip->bw_restlen + l);
if (n > ip->bw_restlen + len)
{
/* We have an incomplete byte sequence at the end to
}
else
{
- n = utf_ptr2len_check_len(buf + wlen, len - wlen);
+ n = utf_ptr2len_len(buf + wlen, len - wlen);
if (n > len - wlen)
{
/* We have an incomplete byte sequence at the end to
* The buffer has been allocated to be big enough. */
while (fromlen > 0)
{
- n = utf_ptr2len_check_len(from, fromlen);
+ n = utf_ptr2len_len(from, fromlen);
if (n > (int)fromlen) /* incomplete byte sequence */
break;
u8c = utf_ptr2char(from);
for (p = fname; *p != NUL; ++p)
# ifdef FEAT_MBYTE
/* The Big5 encoding can have '\' in the trail byte. */
- if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
+ if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
++p;
else
# endif
default:
size++;
# ifdef FEAT_MBYTE
- if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
+ if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
{
++p;
++size;
break;
default:
# ifdef FEAT_MBYTE
- if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
+ if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
reg_pat[i++] = *p++;
else
# endif
# ifdef FEAT_MBYTE
int len;
- if (has_mbyte && (len = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1)
{
if (!vim_isprintc((*mb_ptr2char)(p)))
break;
/* Handle a special or multibyte character. */
#ifdef FEAT_MBYTE
if (has_mbyte)
- {
- c = (*mb_ptr2char)(s);
- if (enc_utf8)
- /* Handle composing chars as well. */
- s += utf_ptr2len_check(s);
- else
- s += (*mb_ptr2len_check)(s);
- }
+ /* Handle composing chars separately. */
+ c = mb_cptr2char_adv(&s);
else
#endif
c = *s++;
* multi-byte char. Happens when mapping
* <M-a> and then changing 'encoding'. */
if (has_mbyte && MB_BYTE2LEN(c1)
- > (*mb_ptr2len_check)(mp->m_keys))
+ > (*mb_ptr2len)(mp->m_keys))
mlen = 0;
#endif
/*
(colnr_T)vcol);
#ifdef FEAT_MBYTE
if (has_mbyte)
- col += (*mb_ptr2len_check)(ptr + col);
+ col += (*mb_ptr2len)(ptr + col);
else
#endif
++col;
first = vim_iswordp(keys);
last = first;
- p = keys + mb_ptr2len_check(keys);
+ p = keys + (*mb_ptr2len)(keys);
n = 1;
while (p < keys + len)
{
last = vim_iswordp(p); /* type of last char */
if (same == -1 && last != first)
same = n - 1; /* count of same char type */
- p += mb_ptr2len_check(p);
+ p += (*mb_ptr2len)(p);
}
if (last && n > 2 && same >= 0 && same < n - 1)
{
p = mb_prevptr(ptr, p);
if (vim_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p)))
{
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
break;
}
++clen;
* (DBCS).
* The value is set in mb_init();
*/
-EXTERN int (*mb_ptr2len_check) __ARGS((char_u *p)) INIT(= latin_ptr2len_check);
+/* length of char in bytes, including following composing chars */
+EXTERN int (*mb_ptr2len) __ARGS((char_u *p)) INIT(= latin_ptr2len);
+/* byte length of char */
EXTERN int (*mb_char2len) __ARGS((int c)) INIT(= latin_char2len);
+/* convert char to bytes, return the length */
EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
cells += (*mb_ptr2cells)(s + this_len);
if (gui.col + cells > Columns)
break;
- this_len += (*mb_ptr2len_check)(s + this_len);
+ this_len += (*mb_ptr2len)(s + this_len);
}
if (this_len > len)
this_len = len; /* don't include following composing char */
/* Draw non-multi-byte character or DBCS character. */
return gui_outstr_nowrap(ScreenLines + off,
- enc_dbcs ? (*mb_ptr2len_check)(ScreenLines + off) : 1,
+ enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1,
flags, fg, bg, back);
#else
return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back);
comping = utf_iscomposing(c);
if (!comping) /* count cells from non-composing chars */
cells += cn;
- cl = utf_ptr2len_check(s + i);
+ cl = utf_ptr2len(s + i);
if (cl == 0) /* hit end of string */
len = i + cl; /* len must be wrong "cannot happen" */
/* Get the length in display cells, this can be different from the
* number of bytes for "euc-jp". */
- for (i = 0; i < len; i += (*mb_ptr2len_check)(s + i))
+ for (i = 0; i < len; i += (*mb_ptr2len)(s + i))
clen += (*mb_ptr2cells)(s + i);
len = clen;
}
/* Stop at a double-byte single-width char. */
if (ScreenLines[off + idx] == 0x8e)
break;
- if (len > 1 && (*mb_ptr2len_check)(ScreenLines
+ if (len > 1 && (*mb_ptr2len)(ScreenLines
+ off + idx) == 2)
++idx; /* skip second byte of double-byte char */
}
while (*text != NUL)
{
#ifdef FEAT_MBYTE
- int l = (*mb_ptr2len_check)(text);
+ int l = (*mb_ptr2len)(text);
if (l > 1)
{
while (--l >= 0)
}
else
{
- charlen = utf_ptr2len_check(p);
+ charlen = utf_ptr2len(p);
uc = utf_ptr2char(p);
if (charlen != utf_char2len(uc))
}
else
{
- charlen = utf_ptr2len_check(p);
+ charlen = utf_ptr2len(p);
uc = utf_ptr2char(p);
if (charlen != utf_char2len(uc))
* compensate for that. */
for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; )
{
- plen = utf_ptr2len_check(bp);
+ plen = utf_ptr2len(bp);
if ((*mb_ptr2cells)(sp) == 2 && utf_ptr2cells(bp) == 1)
{
new_conv_buf = alloc(convlen + 2);
bp = conv_buf + plen;
plen = 1;
}
- sp += (*mb_ptr2len_check)(sp);
+ sp += (*mb_ptr2len)(sp);
bp += plen;
}
s = conv_buf;
c = 0xbf;
buf[textlen].byte1 = c >> 8;
buf[textlen].byte2 = c;
- p += utf_ptr2len_check(p);
+ p += utf_ptr2len(p);
width += utf_char2cells(c);
}
else
if (has_mbyte)
{
width = 0;
- for (p = s; p < s + len; p += (*mb_ptr2len_check)(p))
+ for (p = s; p < s + len; p += (*mb_ptr2len)(p))
width += (*mb_ptr2cells)(p);
}
else
else
draw_feedback[n] = XIMReverse;
preedit_end_col += (*mb_ptr2cells)(p);
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
im_preedit_cursor = e->cursorPos();
im_preedit_trailing = preedit_buf_len - im_preedit_cursor;
unicodepdy[clen] = cw * gui.char_width;
}
cells += cw;
- i += utfc_ptr2len_check_len(text + i, len - i);
+ i += utfc_ptr2len_len(text + i, len - i);
++clen;
}
ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
for (pend = pstart; *pend != NUL && *pend != '\n'; )
{
#ifdef FEAT_MBYTE
- l = mb_ptr2len_check(pend);
+ l = (*mb_ptr2len)(pend);
#else
l = 1;
#endif
buf[wlen].byte2 = c;
++wlen;
cells += utf_char2cells(c);
- p += utf_ptr2len_check(p);
+ p += utf_ptr2len(p);
}
}
else if (has_mbyte)
for (p = s; p < s + len; )
{
cells += ptr2cells(p);
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
}
{
if (mch_print_text_out(p,
#ifdef FEAT_MBYTE
- (l = (*mb_ptr2len_check)(p))
+ (l = (*mb_ptr2len)(p))
#else
1
#endif
{
outputlen = 1;
#ifdef FEAT_MBYTE
- if (has_mbyte && (outputlen = (*mb_ptr2len_check)(line + col)) < 1)
+ if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1)
outputlen = 1;
#endif
#ifdef FEAT_SYN_HL
* PTR2CHAR(): get character from pointer.
*/
#ifdef FEAT_MBYTE
-# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len_check)(p) : 1
+/* Advance multi-byte pointer, skip over composing chars. */
+# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
+/* Advance multi-byte pointer, do not skip over composing chars. */
+# define mb_cptr_adv(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
+/* Backup multi-byte pointer. */
# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
+/* get length of multi-byte char, not including composing chars */
+# define mb_cptr2len(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
+
# define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
# define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : STRLEN(p))
-# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : *(p))
+# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
#else
# define mb_ptr_adv(p) ++p
+# define mb_cptr_adv(p) ++p
# define mb_ptr_back(s, p) --p
# define MB_COPY_CHAR(f, t) *t++ = *f++
# define MB_CHARLEN(p) STRLEN(p)
-# define PTR2CHAR(p) (*(p))
+# define PTR2CHAR(p) ((int)*(p))
#endif
static int enc_canon_search __ARGS((char_u *name));
static int dbcs_char2len __ARGS((int c));
static int dbcs_char2bytes __ARGS((int c, char_u *buf));
-static int dbcs_ptr2len_check __ARGS((char_u *p));
+static int dbcs_ptr2len __ARGS((char_u *p));
static int dbcs_char2cells __ARGS((int c));
static int dbcs_ptr2char __ARGS((char_u *p));
*/
if (enc_utf8)
{
- mb_ptr2len_check = utfc_ptr2len_check;
+ mb_ptr2len = utfc_ptr2len;
mb_char2len = utf_char2len;
mb_char2bytes = utf_char2bytes;
mb_ptr2cells = utf_ptr2cells;
}
else if (enc_dbcs != 0)
{
- mb_ptr2len_check = dbcs_ptr2len_check;
+ mb_ptr2len = dbcs_ptr2len;
mb_char2len = dbcs_char2len;
mb_char2bytes = dbcs_char2bytes;
mb_ptr2cells = dbcs_ptr2cells;
}
else
{
- mb_ptr2len_check = latin_ptr2len_check;
+ mb_ptr2len = latin_ptr2len;
mb_char2len = latin_char2len;
mb_char2bytes = latin_char2bytes;
mb_ptr2cells = latin_ptr2cells;
}
/*
- * mb_ptr2len_check() function pointer.
+ * mb_ptr2len() function pointer.
* Get byte length of character at "*p" but stop at a NUL.
* For UTF-8 this includes following composing characters.
* Returns 0 when *p is NUL.
*
*/
int
-latin_ptr2len_check(p)
+latin_ptr2len(p)
char_u *p;
{
return MB_BYTE2LEN(*p);
}
static int
-dbcs_ptr2len_check(p)
+dbcs_ptr2len(p)
char_u *p;
{
int len;
{
c = utf_ptr2char(p);
/* An illegal byte is displayed as <xx>. */
- if (utf_ptr2len_check(p) == 1 || c == NUL)
+ if (utf_ptr2len(p) == 1 || c == NUL)
return 4;
/* If the char is ASCII it must be an overlong sequence. */
if (c < 0x80)
int c;
c = (*mb_ptr2char)(*pp);
- *pp += (*mb_ptr2len_check)(*pp);
+ *pp += (*mb_ptr2len)(*pp);
+ return c;
+}
+
+/*
+ * Get character at **pp and advance *pp to the next character.
+ * Note: composing characters are returned as separate characters.
+ */
+ int
+mb_cptr2char_adv(pp)
+ char_u **pp;
+{
+ int c;
+
+ c = (*mb_ptr2char)(*pp);
+ if (enc_utf8)
+ *pp += utf_ptr2len(*pp);
+ else
+ *pp += (*mb_ptr2len)(*pp);
return c;
}
int cc;
c = utf_ptr2char(p);
- len = utf_ptr2len_check(p);
+ len = utf_ptr2len(p);
/* Only accept a composing char when the first char isn't illegal. */
if ((len > 1 || *p < 0x80)
&& p[len] >= 0x80
&& UTF_COMPOSINGLIKE(p, p + len))
{
*p1 = utf_ptr2char(p + len);
- len += utf_ptr2len_check(p + len);
+ len += utf_ptr2len(p + len);
if (p[len] >= 0x80 && utf_iscomposing(cc = utf_ptr2char(p + len)))
*p2 = cc;
else
int cc;
c = utf_ptr2char(p);
- len = utf_ptr2len_check_len(p, maxlen);
+ len = utf_ptr2len_len(p, maxlen);
/* Only accept a composing char when the first char isn't illegal. */
if ((len > 1 || *p < 0x80)
&& len < maxlen
&& UTF_COMPOSINGLIKE(p, p + len))
{
*p1 = utf_ptr2char(p + len);
- len += utf_ptr2len_check_len(p + len, maxlen - len);
+ len += utf_ptr2len_len(p + len, maxlen - len);
if (len < maxlen
&& p[len] >= 0x80
&& utf_iscomposing(cc = utf_ptr2char(p + len)))
* Returns 1 for an illegal byte sequence.
*/
int
-utf_ptr2len_check(p)
+utf_ptr2len(p)
char_u *p;
{
int len;
* Returns number > "size" for an incomplete byte sequence.
*/
int
-utf_ptr2len_check_len(p, size)
+utf_ptr2len_len(p, size)
char_u *p;
int size;
{
* This includes following composing characters.
*/
int
-utfc_ptr2len_check(p)
+utfc_ptr2len(p)
char_u *p;
{
int len;
return 1;
/* Skip over first UTF-8 char, stopping at a NUL byte. */
- len = utf_ptr2len_check(p);
+ len = utf_ptr2len(p);
/* Check for illegal byte. */
if (len == 1 && b0 >= 0x80)
#ifdef FEAT_ARABIC
prevlen = len;
#endif
- len += utf_ptr2len_check(p + len);
+ len += utf_ptr2len(p + len);
}
}
* Returns 1 for an illegal char or an incomplete byte sequence.
*/
int
-utfc_ptr2len_check_len(p, size)
+utfc_ptr2len_len(p, size)
char_u *p;
int size;
{
return 1;
/* Skip over first UTF-8 char, stopping at a NUL byte. */
- len = utf_ptr2len_check_len(p, size);
+ len = utf_ptr2len_len(p, size);
/* Check for illegal byte and incomplete byte sequence. */
if ((len == 1 && p[0] >= 0x80) || len > size)
#ifdef FEAT_ARABIC
prevlen = len;
#endif
- len += utf_ptr2len_check_len(p + len, size - len);
+ len += utf_ptr2len_len(p + len, size - len);
}
return len;
}
}
else
{
- l = (*mb_ptr2len_check)(s1 + i);
+ l = (*mb_ptr2len)(s1 + i);
if (l <= 1)
{
/* Single byte: first check normally, then with ignore case. */
/* Get the byte length of the char under the cursor, including composing
* characters. */
line = ml_get_cursor();
- len = utfc_ptr2len_check(line);
+ len = utfc_ptr2len(line);
if (len == 0)
{
MSG("NUL");
STRCPY(IObuff + rlen, "+ ");
rlen += 2;
}
- clen = utf_ptr2len_check(line + i);
+ clen = utf_ptr2len(line + i);
}
sprintf((char *)IObuff + rlen, "%02x ", line[i]);
--clen;
* byte we are looking for. Return 1 when we went past it, 0 otherwise. */
q = base;
while (q < p)
- q += dbcs_ptr2len_check(q);
+ q += dbcs_ptr2len(q);
return (q == p) ? 0 : 1;
}
if (enc_dbcs == DBCS_JPNU && *q == 0x8e)
++q;
else
- q += dbcs_ptr2len_check(q);
+ q += dbcs_ptr2len(q);
}
return (q == p) ? 0 : 1;
}
char_u **fp;
char_u **tp;
{
- int l = (*mb_ptr2len_check)(*fp);
+ int l = (*mb_ptr2len)(*fp);
mch_memmove(*tp, *fp, (size_t)l);
*tp += l;
}
/*
- * Return the character length of "str". Each multi-byte character counts as
- * one.
+ * Return the character length of "str". Each multi-byte character (with
+ * following composing characters) counts as one.
*/
int
mb_charlen(str)
return 0;
for (count = 0; *str != NUL; count++)
- str += (*mb_ptr2len_check)(str);
+ str += (*mb_ptr2len)(str);
return count;
}
/* Return a multi-byte character if it's found. An illegal sequence
* will result in a 1 here. */
- if ((*mb_ptr2len_check)(buf) > 1)
+ if ((*mb_ptr2len)(buf) > 1)
{
*pp = str + n + 1;
return buf;
if ((*mb_ptr2cells)((char_u *)from) > 1)
*to++ = '?';
if (enc_utf8)
- l = utfc_ptr2len_check_len((char_u *)from, fromlen);
+ l = utfc_ptr2len_len((char_u *)from, fromlen);
else
{
- l = (*mb_ptr2len_check)((char_u *)from);
+ l = (*mb_ptr2len)((char_u *)from);
if (l > (int)fromlen)
l = fromlen;
}
else
im_str = (char_u *)str;
clen = 0;
- for (p = im_str; p < im_str + len; p += (*mb_ptr2len_check)(p))
+ for (p = im_str; p < im_str + len; p += (*mb_ptr2len)(p))
clen += (*mb_ptr2cells)(p);
if (input_conv.vc_type != CONV_NONE)
vim_free(im_str);
/* Get the byte index as used by PangoAttrIterator */
for (index = 0; col > 0 && preedit_string[index] != '\0'; --col)
- index += utfc_ptr2len_check((char_u *)preedit_string + index);
+ index += utfc_ptr2len((char_u *)preedit_string + index);
if (preedit_string[index] != '\0')
{
}
}
if (has_mbyte)
- ptr += mb_ptr2len_check(ptr);
+ ptr += (*mb_ptr2len)(ptr);
else
#endif
ptr++;
d = retval;
for (i = 0; i < len; ++i)
{
- l = utf_ptr2len_check(ptr + i);
+ l = utf_ptr2len(ptr + i);
if (l == 0)
*d++ = NUL;
else if (l == 1)
buf[e] = s[e];
#ifdef FEAT_MBYTE
if (has_mbyte)
- for (n = (*mb_ptr2len_check)(s + e); --n > 0; )
+ for (n = (*mb_ptr2len)(s + e); --n > 0; )
{
++e;
buf[e] = s[e];
while (len + n > room)
{
n -= ptr2cells(s + i);
- i += (*mb_ptr2len_check)(s + i);
+ i += (*mb_ptr2len)(s + i);
}
}
else if (enc_utf8)
for (n = 0; size >= room; )
{
size -= (*mb_ptr2cells)(s + n);
- n += (*mb_ptr2len_check)(s + n);
+ n += (*mb_ptr2len)(s + n);
}
--n;
}
#ifdef FEAT_MBYTE
int l;
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
msg_outtrans_len_attr(p, l, attr);
return p + l;
#ifdef FEAT_MBYTE
if (enc_utf8)
/* Don't include composing chars after the end. */
- mb_l = utfc_ptr2len_check_len(str, len + 1);
+ mb_l = utfc_ptr2len_len(str, len + 1);
else if (has_mbyte)
- mb_l = (*mb_ptr2len_check)(str);
+ mb_l = (*mb_ptr2len)(str);
else
mb_l = 1;
if (has_mbyte && mb_l > 1)
/* Highlight special keys */
msg_puts_attr(string, len > 1
#ifdef FEAT_MBYTE
- && (*mb_ptr2len_check)(string) <= 1
+ && (*mb_ptr2len)(string) <= 1
#endif
? attr : 0);
retval += len;
#ifdef FEAT_MBYTE
/* For multi-byte characters check for an illegal byte. */
- if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len_check)(str))
+ if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str))
{
transchar_nonprint(buf, c);
return buf;
c = *p_extra++;
}
#ifdef FEAT_MBYTE
- else if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
+ else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
{
col += (*mb_ptr2cells)(s);
mch_memmove(buf, s, (size_t)l);
{
if (enc_utf8 && maxlen >= 0)
/* avoid including composing chars after the end */
- l = utfc_ptr2len_check_len(s,
- (int)((str + maxlen) - s));
+ l = utfc_ptr2len_len(s, (int)((str + maxlen) - s));
else
- l = (*mb_ptr2len_check)(s);
+ l = (*mb_ptr2len)(s);
s = screen_puts_mbyte(s, l, attr);
}
else
if (*s == '\n') /* go to next line */
{
msg_didout = FALSE; /* remember that line is empty */
- msg_col = 0;
+#ifdef FEAT_RIGHTLEFT
+ if (cmdmsg_rl)
+ msg_col = Columns - 1;
+ else
+#endif
+ msg_col = 0;
if (++msg_row >= Rows) /* safety check */
msg_row = Rows - 1;
}
cw = (*mb_ptr2cells)(s);
if (enc_utf8 && maxlen >= 0)
/* avoid including composing chars after the end */
- l = utfc_ptr2len_check_len(s, (int)((str + maxlen) - s));
+ l = utfc_ptr2len_len(s, (int)((str + maxlen) - s));
else
- l = (*mb_ptr2len_check)(s);
+ l = (*mb_ptr2len)(s);
}
else
{
}
if (col >= Columns) /* not enough room */
col = Columns - 1;
- while (msg_col < col)
- msg_putchar(' ');
+#ifdef FEAT_RIGHTLEFT
+ if (cmdmsg_rl)
+ while (msg_col > Columns - col)
+ msg_putchar(' ');
+ else
+#endif
+ while (msg_col < col)
+ msg_putchar(' ');
}
#if defined(FEAT_CON_DIALOG) || defined(PROTO)
{
if ((*mb_ptr2char)(hotkeys + i) == c)
break;
- i += (*mb_ptr2len_check)(hotkeys + i) - 1;
+ i += (*mb_ptr2len)(hotkeys + i) - 1;
}
else
#endif
}
else
{
- len = (*mb_ptr2len_check)(from);
+ len = (*mb_ptr2len)(from);
mch_memmove(to, from, (size_t)len);
return len;
}
/* advance to next hotkey and set default hotkey */
#ifdef FEAT_MBYTE
if (has_mbyte)
- hotkp += (*mb_ptr2len_check)(hotkp);
+ hotkp += (*mb_ptr2len)(hotkp);
else
#endif
++hotkp;
for (i = 0; p[i] != NUL && i < lead_len; i += l)
{
- l = mb_ptr2len_check(p + i);
+ l = (*mb_ptr2len)(p + i);
if (vim_strnsize(p, i + l) > repl_size)
break;
}
else
{
#ifdef FEAT_MBYTE
- int l = mb_ptr2len_check(p);
+ int l = (*mb_ptr2len)(p);
if (l > 1)
{
for (i = 0; i < len; i += n)
{
- n = (*mb_ptr2len_check)(p + i);
+ n = (*mb_ptr2len)(p + i);
ins_char_bytes(p + i, n);
}
# else
if (vcol > new_vcol && oldp[col + oldlen] == TAB)
break;
#ifdef FEAT_MBYTE
- oldlen += (*mb_ptr2len_check)(oldp + col + oldlen);
+ oldlen += (*mb_ptr2len)(oldp + col + oldlen);
#else
++oldlen;
#endif
{
/* normal replace */
#ifdef FEAT_MBYTE
- oldlen = (*mb_ptr2len_check)(oldp + col);
+ oldlen = (*mb_ptr2len)(oldp + col);
#else
oldlen = 1;
#endif
for (i = 0; i < oldlen; ++i)
{
#ifdef FEAT_MBYTE
- l = (*mb_ptr2len_check)(oldp + col + i) - 1;
+ l = (*mb_ptr2len)(oldp + col + i) - 1;
for (j = l; j >= 0; --j)
replace_push(oldp[col + i + j]);
i += l;
p = ml_get_cursor();
for (i = 0; i < count && *p != NUL; ++i)
{
- l = (*mb_ptr2len_check)(p);
+ l = (*mb_ptr2len)(p);
bytes += l;
p += l;
}
#ifdef FEAT_MBYTE
/* If 'delcombine' is set and deleting (less than) one character, only
* delete the last combining character. */
- if (p_deco && enc_utf8 && utfc_ptr2len_check(oldp + col) >= count)
+ if (p_deco && enc_utf8 && utfc_ptr2len(oldp + col) >= count)
{
int c1, c2;
int n;
do
{
col = n;
- count = utf_ptr2len_check(oldp + n);
+ count = utf_ptr2len(oldp + n);
n += count;
} while (UTF_COMPOSINGLIKE(oldp + col, oldp + n));
fixpos = 0;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- len = (*mb_ptr2len_check)(path_end);
+ len = (*mb_ptr2len)(path_end);
STRNCPY(p, path_end, len);
p += len;
path_end += len;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- len = (*mb_ptr2len_check)(path_end);
+ len = (*mb_ptr2len)(path_end);
STRNCPY(p, path_end, len);
p += len;
path_end += len;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int l = (*mb_ptr2len_check)(p);
+ int l = (*mb_ptr2len)(p);
lp->col += l;
return ((p[l] != NUL) ? 0 : 2);
for (p = string; *p; p++)
{
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
length += l; /* count a multibyte char */
p += l - 1;
for (p = string; *p; p++)
{
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
mch_memmove(p2, p, (size_t)l);
p2 += l;
/* Reallocate string when byte count changes. This is rare,
* thus it's OK to do another malloc()/free(). */
- l = utf_ptr2len_check(p);
+ l = utf_ptr2len(p);
nl = utf_char2len(uc);
if (nl != l)
{
utf_char2bytes(uc, p);
p += nl;
}
- else if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
# endif
{
if (utf_ptr2char(p) == c)
return p;
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
return NULL;
}
{
if (b == c && p[1] == n2)
return p;
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
return NULL;
}
{
if (b == c)
return p;
- p += (*mb_ptr2len_check)(p);
+ p += (*mb_ptr2len)(p);
}
return NULL;
}
{
int l;
- l = (*mb_ptr2len_check)(ml_get_pos(&oap->end));
+ l = (*mb_ptr2len)(ml_get_pos(&oap->end));
if (l > 1)
oap->end.col += l - 1;
}
if (*p_sel == 'e' && *ml_get_cursor() != NUL)
#ifdef FEAT_MBYTE
curwin->w_cursor.col +=
- (*mb_ptr2len_check)(ml_get_cursor());
+ (*mb_ptr2len)(ml_get_cursor());
#else
++curwin->w_cursor.col;
#endif
while (line[pos->col] != NUL)
{
#ifdef FEAT_MBYTE
- col = pos->col + (*mb_ptr2len_check)(line + pos->col);
+ col = pos->col + (*mb_ptr2len)(line + pos->col);
#else
col = pos->col + 1;
#endif
this_class = mb_get_class(ptr + col);
if (this_class != 0 && (i == 1 || this_class != 1))
break;
- col += (*mb_ptr2len_check)(ptr + col);
+ col += (*mb_ptr2len)(ptr + col);
}
}
else
&& find_is_eval_item(ptr + col, &col, &bn, FORWARD))
# endif
))
- col += (*mb_ptr2len_check)(ptr + col);
+ col += (*mb_ptr2len)(ptr + col);
}
else
#endif
if (has_mbyte)
{
int i;
- int len = (*mb_ptr2len_check)(ptr) - 1;
+ int len = (*mb_ptr2len)(ptr) - 1;
for (i = 0; i < len && n >= 1; ++i, --n)
*p++ = *ptr++;
#ifdef FEAT_MBYTE
if (has_mbyte)
/* Correct the length to include the whole last character. */
- *lenp += (*mb_ptr2len_check)(*pp + (*lenp - 1)) - 1;
+ *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
#endif
}
reset_VIsual_and_resel();
# ifdef FEAT_MBYTE
if (has_mbyte)
curwin->w_cursor.col +=
- (*mb_ptr2len_check)(ml_get_cursor());
+ (*mb_ptr2len)(ml_get_cursor());
else
# endif
++curwin->w_cursor.col;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- bd.textstart += (*mb_ptr2len_check)(bd.textstart);
+ bd.textstart += (*mb_ptr2len)(bd.textstart);
#endif
++bd.textstart;
}
#ifdef FEAT_MBYTE
if (has_mbyte)
/* move to start of next multi-byte character */
- curwin->w_cursor.col += (*mb_ptr2len_check)(ml_get_cursor());
+ curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else
#endif
#ifdef FEAT_VIRTUALEDIT
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int bytelen = (*mb_ptr2len_check)(ml_get_cursor());
+ int bytelen = (*mb_ptr2len)(ml_get_cursor());
/* put it on the next of the multi-byte character. */
col += bytelen;
for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; ++p)
{
#ifdef FEAT_MBYTE
- clen = (*mb_ptr2len_check)(p);
+ clen = (*mb_ptr2len)(p);
#endif
msg_outtrans_len(p, clen);
#ifdef FEAT_MBYTE
&& (n -= ptr2cells(p)) >= 0)
{
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
msg_outtrans_len(p, l);
p += l;
is_word = 1;
++chars;
#ifdef FEAT_MBYTE
- i += mb_ptr2len_check(line + i);
+ i += (*mb_ptr2len)(line + i);
#else
++i;
#endif
++arg; /* remove backslash */
#ifdef FEAT_MBYTE
if (has_mbyte
- && (i = (*mb_ptr2len_check)(arg)) > 1)
+ && (i = (*mb_ptr2len)(arg)) > 1)
{
/* copy multibyte char */
mch_memmove(s, arg, (size_t)i);
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int len = (*mb_ptr2len_check)(path);
+ int len = (*mb_ptr2len)(path);
STRNCPY(p, path, len);
p += len;
for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;)
{
if (from == kCFStringEncodingUTF8)
- l = utf_ptr2len_check(ptr + in);
+ l = utf_ptr2len(ptr + in);
else
l = 1;
cfstr = CFStringCreateWithBytes(NULL, ptr + in, l, from, 0);
while (todo > 0)
{
/* Only convert if we have a complete sequence. */
- l = utf_ptr2len_check_len(p, todo);
+ l = utf_ptr2len_len(p, todo);
if (l > todo)
{
/* Return length of incomplete sequence. */
ta_buf[i] = '\n';
# ifdef FEAT_MBYTE
if (has_mbyte)
- i += (*mb_ptr2len_check)(ta_buf + i) - 1;
+ i += (*mb_ptr2len)(ta_buf + i) - 1;
# endif
}
# ifdef FEAT_MBYTE
else if (has_mbyte)
{
- int l = (*mb_ptr2len_check)(ta_buf + i);
+ int l = (*mb_ptr2len)(ta_buf + i);
msg_outtrans_len(ta_buf + i, l);
i += l - 1;
* round. */
for (p = buffer; p < buffer + len; p += l)
{
- if (enc_utf8) /* exclude composing chars */
- l = utf_ptr2len_check(p);
- else
- l = (*mb_ptr2len_check)(p);
+ l = mb_cptr2len(p);
if (l == 0)
l = 1; /* NUL byte? */
else if (MB_BYTE2LEN(*p) != l)
if (enc_dbcs)
{
- l = (*mb_ptr2len_check)(porig);
+ l = (*mb_ptr2len)(porig);
while (--l >= 0)
*ptrue++ = *porig++;
}
int dbcs_class __ARGS((unsigned lead, unsigned trail));
int latin_char2len __ARGS((int c));
int latin_char2bytes __ARGS((int c, char_u *buf));
-int latin_ptr2len_check __ARGS((char_u *p));
+int latin_ptr2len __ARGS((char_u *p));
int utf_char2cells __ARGS((int c));
int latin_ptr2cells __ARGS((char_u *p));
int utf_ptr2cells __ARGS((char_u *p));
int latin_ptr2char __ARGS((char_u *p));
int utf_ptr2char __ARGS((char_u *p));
int mb_ptr2char_adv __ARGS((char_u **pp));
+int mb_cptr2char_adv __ARGS((char_u **pp));
int arabic_combine __ARGS((int one, int two));
int arabic_maycombine __ARGS((int two));
int utf_composinglike __ARGS((char_u *p1, char_u *p2));
int utfc_ptr2char __ARGS((char_u *p, int *p1, int *p2));
int utfc_ptr2char_len __ARGS((char_u *p, int *p1, int *p2, int maxlen));
int utfc_char2bytes __ARGS((int off, char_u *buf));
-int utf_ptr2len_check __ARGS((char_u *p));
+int utf_ptr2len __ARGS((char_u *p));
int utf_byte2len __ARGS((int b));
-int utf_ptr2len_check_len __ARGS((char_u *p, int size));
-int utfc_ptr2len_check __ARGS((char_u *p));
-int utfc_ptr2len_check_len __ARGS((char_u *p, int size));
+int utf_ptr2len_len __ARGS((char_u *p, int size));
+int utfc_ptr2len __ARGS((char_u *p));
+int utfc_ptr2len_len __ARGS((char_u *p, int size));
int utf_char2len __ARGS((int c));
int utf_char2bytes __ARGS((int c, char_u *buf));
int utf_iscomposing __ARGS((int c));
void update_screen __ARGS((int type));
void update_debug_sign __ARGS((buf_T *buf, linenr_T lnum));
void updateWindow __ARGS((win_T *wp));
+void rl_mirror __ARGS((char_u *str));
void status_redraw_all __ARGS((void));
void status_redraw_curbuf __ARGS((void));
void redraw_statuslines __ARGS((void));
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- l = mb_ptr2len_check(p + 2);
+ l = (*mb_ptr2len)(p + 2);
#endif
if (p[l + 2] == '=' && p[l + 3] == ']')
{
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- l = mb_ptr2len_check(p + 2);
+ l = (*mb_ptr2len)(p + 2);
#endif
if (p[l + 2] == '.' && p[l + 3] == ']')
{
while (*p != NUL && *p != ']')
{
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l;
else
#endif
/* produce a multibyte character, including any
* following composing characters */
startc = mb_ptr2char(regparse);
- len = (*mb_ptr2len_check)(regparse);
+ len = (*mb_ptr2len)(regparse);
if (enc_utf8 && utf_char2len(startc) != len)
startc = -1; /* composing chars */
while (--len >= 0)
off = 0;
for (;;)
{
- l = utf_ptr2len_check(regparse + off);
+ l = utf_ptr2len(regparse + off);
if (!UTF_COMPOSINGLIKE(regparse + off,
regparse + off + l))
break;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- prevchr_len += (*mb_ptr2len_check)(regparse + prevchr_len);
+ prevchr_len += (*mb_ptr2len)(regparse + prevchr_len);
else
#endif
++prevchr_len;
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
- col += (*mb_ptr2len_check)(regline + col);
+ col += (*mb_ptr2len)(regline + col);
else
#endif
++col;
opnd = OPERAND(scan);
/* Safety check (just in case 'encoding' was changed since
* compiling the program). */
- if ((len = (*mb_ptr2len_check)(opnd)) < 2)
+ if ((len = (*mb_ptr2len)(opnd)) < 2)
{
status = RA_NOMATCH;
break;
break;
}
#ifdef FEAT_MBYTE
- else if (has_mbyte && (l = (*mb_ptr2len_check)(scan)) > 1)
+ else if (has_mbyte && (l = (*mb_ptr2len)(scan)) > 1)
{
if (testval != 0)
break;
/* Safety check (just in case 'encoding' was changed since
* compiling the program). */
- if ((len = (*mb_ptr2len_check)(opnd)) > 1)
+ if ((len = (*mb_ptr2len)(opnd)) > 1)
{
if (ireg_ic && enc_utf8)
cf = utf_fold(utf_ptr2char(opnd));
else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
++scan;
#ifdef FEAT_MBYTE
- else if (has_mbyte && (len = (*mb_ptr2len_check)(scan)) > 1)
+ else if (has_mbyte && (len = (*mb_ptr2len)(scan)) > 1)
{
if ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval)
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- for (p = s; *p != NUL; p += (*mb_ptr2len_check)(p))
+ for (p = s; *p != NUL; p += (*mb_ptr2len)(p))
{
if (enc_utf8 && c > 0x80)
{
++p;
#ifdef FEAT_MBYTE
if (has_mbyte)
- p += (*mb_ptr2len_check)(p) - 1;
+ p += (*mb_ptr2len)(p) - 1;
#endif
}
}
/* Write to buffer, if copy is set. */
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(src - 1)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(src - 1)) > 1)
{
/* TODO: should use "func" here. */
if (copy)
dst += 2;
}
#ifdef FEAT_MBYTE
- else if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
+ else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
{
/* TODO: should use "func" here. */
if (copy)
static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width));
# define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c))
#endif
-#ifdef FEAT_RIGHTLEFT
-static void rl_mirror __ARGS((char_u *str));
-#endif
#ifdef FEAT_VERTSPLIT
static void draw_vsep_win __ARGS((win_T *wp, int row));
#endif
for (p = text; *p != NUL; )
{
cells = (*mb_ptr2cells)(p);
- c_len = (*mb_ptr2len_check)(p);
+ c_len = (*mb_ptr2len)(p);
if (col + cells > W_WIDTH(wp)
# ifdef FEAT_RIGHTLEFT
- (wp->w_p_rl ? col : 0)
{
#ifdef FEAT_MBYTE
if (has_mbyte && line[shl->endcol] != NUL)
- shl->endcol += (*mb_ptr2len_check)(line + shl->endcol);
+ shl->endcol += (*mb_ptr2len)(line + shl->endcol);
else
#endif
++shl->endcol;
* it */
#ifdef FEAT_MBYTE
if (has_mbyte)
- shl->endcol += (*mb_ptr2len_check)(line
+ shl->endcol += (*mb_ptr2len)(line
+ shl->endcol);
else
#endif
{
/* If the UTF-8 character is more than one byte:
* Decode it into "mb_c". */
- mb_l = (*mb_ptr2len_check)(p_extra);
+ mb_l = (*mb_ptr2len)(p_extra);
mb_utf8 = FALSE;
if (mb_l > n_extra)
mb_l = 1;
{
/* If the UTF-8 character is more than one byte: Decode it
* into "mb_c". */
- mb_l = (*mb_ptr2len_check)(ptr);
+ mb_l = (*mb_ptr2len)(ptr);
mb_utf8 = FALSE;
if (mb_l > 1)
{
}
}
-#ifdef FEAT_RIGHTLEFT
+#if defined(FEAT_RIGHTLEFT) || defined(PROTO)
/*
- * Mirror text "str" for right-lieft displaying.
+ * Mirror text "str" for right-left displaying.
+ * Only works for single-byte characters (e.g., numbers).
*/
- static void
+ void
rl_mirror(str)
char_u *str;
{
++s;
clen += ptr2cells(s);
#ifdef FEAT_MBYTE
- if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
{
STRNCPY(buf + len, s, l);
s += l - 1;
int clen = 0, i;
/* Count total number of display cells. */
- for (i = 0; p[i] != NUL; i += (*mb_ptr2len_check)(p + i))
+ for (i = 0; p[i] != NUL; i += (*mb_ptr2len)(p + i))
clen += (*mb_ptr2cells)(p + i);
/* Find first character that will fit.
* Going from start to end is much faster for DBCS. */
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
- i += (*mb_ptr2len_check)(p + i))
+ i += (*mb_ptr2len)(p + i))
clen -= (*mb_ptr2cells)(p + i);
len = clen;
if (i > 0)
if (has_mbyte)
{
if (enc_utf8 && len > 0)
- mbyte_blen = utfc_ptr2len_check_len(ptr,
- (int)((text + len) - ptr));
+ mbyte_blen = utfc_ptr2len_len(ptr, (int)((text + len) - ptr));
else
- mbyte_blen = (*mb_ptr2len_check)(ptr);
+ mbyte_blen = (*mb_ptr2len)(ptr);
if (enc_dbcs == DBCS_JPNU && c == 0x8e)
mbyte_cells = 1;
else if (enc_dbcs != 0)
if (has_mbyte)
{
o = 0;
- for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len_check)(buffer + i))
+ for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len)(buffer + i))
{
o += (*mb_ptr2cells)(buffer + i);
if (this_ru_col + o > WITH_WIDTH(width))
{
int mb_len;
- mb_len = (*mb_ptr2len_check)(s + s_i);
+ mb_len = (*mb_ptr2len)(s + s_i);
rev_i -= mb_len;
mch_memmove(rev + rev_i, s + s_i, mb_len);
s_i += mb_len - 1;
#ifdef FEAT_MBYTE
int l;
- if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
if (enc_utf8 && utf_isupper(utf_ptr2char(p)))
{
/* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
else if (has_mbyte && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
&& pos->col < MAXCOL - 2)
- extra_col = (*mb_ptr2len_check)(ml_get_buf(buf, pos->lnum, FALSE)
+ extra_col = (*mb_ptr2len)(ml_get_buf(buf, pos->lnum, FALSE)
+ pos->col);
#endif
else
#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
- (*mb_ptr2len_check)(ptr + matchcol);
+ (*mb_ptr2len)(ptr + matchcol);
else
#endif
++matchcol;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- matchcol += (*mb_ptr2len_check)(ptr
+ matchcol += (*mb_ptr2len)(ptr
+ matchcol);
else
#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
- (*mb_ptr2len_check)(ptr + matchcol);
+ (*mb_ptr2len)(ptr + matchcol);
else
#endif
++matchcol;
#ifdef FEAT_MBYTE
if (has_mbyte)
matchcol +=
- (*mb_ptr2len_check)(ptr + matchcol);
+ (*mb_ptr2len)(ptr + matchcol);
else
#endif
++matchcol;
{
if (dir > 0)
{
- col += (*mb_ptr2len_check)(p + col);
+ col += (*mb_ptr2len)(p + col);
if (col >= len)
return FAIL;
}
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
- pos.col += (*mb_ptr2len_check)(linep + pos.col);
+ pos.col += (*mb_ptr2len)(linep + pos.col);
else
#endif
++pos.col;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- pos.col += (*mb_ptr2len_check)(linep + pos.col);
+ pos.col += (*mb_ptr2len)(linep + pos.col);
else
#endif
++pos.col;
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
- col += (*mb_ptr2len_check)(line + col);
+ col += (*mb_ptr2len)(line + col);
else
#endif
++col;
*/
/* Use SPELL_PRINTTREE for debugging: dump the word tree after adding a word.
- * Only use for small word lists!
- * SPELL_COMPRESS_CNT is in how many words we compress the tree. */
+ * Only use it for small word lists!
+ * SPELL_COMPRESS_CNT is in how many words we compress the tree to limit the
+ * amount of memory used (esp. for Italian). */
#if 0
# define SPELL_PRINTTREE
# define SPELL_COMPRESS_CNT 1
static void use_midword __ARGS((slang_T *lp, buf_T *buf));
static int find_region __ARGS((char_u *rp, char_u *region));
static int captype __ARGS((char_u *word, char_u *end));
+static int badword_captype __ARGS((char_u *word, char_u *end));
static void spell_reload_one __ARGS((char_u *fname, int added_word));
static int set_spell_charflags __ARGS((char_u *flags, int cnt, char_u *upp));
static int set_spell_chartab __ARGS((char_u *fol, char_u *low, char_u *upp));
: (c) < 256 ? spelltab.st_isu[c] : iswupper(c))
# else
# define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
- : (c) < 256 ? spelltab.st_isu[c] : (c))
+ : (c) < 256 ? spelltab.st_isu[c] : (FALSE))
# endif
#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
- return mb_ptr2len_check(ptr);
+ return (*mb_ptr2len)(ptr);
#endif
return 1;
}
{
return ((wordflags == WF_ALLCAP && (treeflags & WF_FIXCAP) == 0)
|| ((treeflags & (WF_ALLCAP | WF_KEEPCAP)) == 0
- && ((treeflags & WF_ONECAP) == 0 || wordflags == WF_ONECAP)));
+ && ((treeflags & WF_ONECAP) == 0
+ || (wordflags & WF_ONECAP) != 0)));
}
/*
* sl_sal_first[] for this. */
for (p = from, s = to; *p != NUL && *s != NUL; )
{
- c = mb_ptr2char_adv(&p);
- mb_ptr_adv(s);
+ c = mb_cptr2char_adv(&p);
+ mb_cptr_adv(s);
if (c >= 256)
++lp->sl_sal_first[c & 0xff];
}
vim_memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256);
for (p = from, s = to; *p != NUL && *s != NUL; )
{
- c = mb_ptr2char_adv(&p);
- i = mb_ptr2char_adv(&s);
+ c = mb_cptr2char_adv(&p);
+ i = mb_cptr2char_adv(&s);
if (c >= 256)
{
/* Append the from-to chars at the end of the list with
char_u *bp;
c = mb_ptr2char(p);
- l = mb_ptr2len_check(p);
- if (c < 256)
+ l = (*mb_ptr2len)(p);
+ if (c < 256 && l <= 2)
buf->b_spell_ismw[c] = TRUE;
else if (buf->b_spell_ismw_mb == NULL)
/* First multi-byte char in "b_spell_ismw_mb". */
return 0;
}
+/*
+ * Like captype() but for a KEEPCAP word add ONECAP if the word starts with a
+ * capital. So that make_case_word() can turn WOrd into Word.
+ * Add ALLCAP for "WOrD".
+ */
+ static int
+badword_captype(word, end)
+ char_u *word;
+ char_u *end;
+{
+ int flags = captype(word, end);
+ int l, u;
+ int first;
+ char_u *p;
+
+ if (flags & WF_KEEPCAP)
+ {
+ /* Count the number of UPPER and lower case letters. */
+ l = u = 0;
+ first = FALSE;
+ for (p = word; p < end; mb_ptr_adv(p))
+ {
+ if (SPELL_ISUPPER(PTR2CHAR(p)))
+ {
+ ++u;
+ if (p == word)
+ first = TRUE;
+ }
+ else
+ ++l;
+ }
+
+ /* If there are more UPPER than lower case letters suggest an
+ * ALLCAP word. Otherwise, if the first letter is UPPER then
+ * suggest ONECAP. Exception: "ALl" most likely should be "All",
+ * require three upper case letters. */
+ if (u > l && u > 2)
+ flags |= WF_ALLCAP;
+ else if (first)
+ flags |= WF_ONECAP;
+ }
+ return flags;
+}
+
# if defined(FEAT_MBYTE) || defined(EXITFREE) || defined(PROTO)
/*
* Free all languages.
/*
* Structure that is used to store the items in the word tree. This avoids
- * the need to keep track of each allocated thing, it's freed all at once
- * after ":mkspell" is done.
+ * the need to keep track of each allocated thing, everything is freed all at
+ * once after ":mkspell" is done.
*/
#define SBLOCKSIZE 16000 /* size of sb_data */
typedef struct sblock_S sblock_T;
wordnode_T *wn_child; /* child (next byte in word) */
wordnode_T *wn_sibling; /* next sibling (alternate byte in word,
always sorted) */
- int wn_refs; /* nr of references to this node */
+ int wn_refs; /* Nr. of references to this node. Only
+ relevant for first node in a list of
+ siblings, in following siblings it is
+ always one. */
char_u wn_byte; /* Byte for this node. NUL for word end */
char_u wn_prefixID; /* when "wn_byte" is NUL: supported/required
prefix ID or 0 */
{
wordnode_T *si_foldroot; /* tree with case-folded words */
long si_foldwcount; /* nr of words in si_foldroot */
+ int si_fold_added; /* nr of words added since compressing */
+
wordnode_T *si_keeproot; /* tree with keep-case words */
long si_keepwcount; /* nr of words in si_keeproot */
+ int si_keep_added; /* nr of words added since compressing */
+
wordnode_T *si_prefroot; /* tree with postponed prefixes */
+
sblock_T *si_blocks; /* memory blocks used */
+ wordnode_T *si_first_free; /* List of nodes that have been freed during
+ compression, linked by "wn_child" field. */
+#ifdef SPELL_PRINTTREE
+ int si_wordnode_nr; /* sequence nr for nodes */
+#endif
+
+
int si_ascii; /* handling only ASCII words */
int si_add; /* addition file */
int si_clear_chartab; /* when TRUE clear char tables */
vimconv_T si_conv; /* for conversion to 'encoding' */
int si_memtot; /* runtime memory used */
int si_verbose; /* verbose messages */
+ int si_msg_count; /* number of words added since last message */
int si_region_count; /* number of regions supported (1 when there
are no regions) */
char_u si_region_name[16]; /* region names (if count > 1) */
int si_newID; /* current value for ah_newID */
} spellinfo_T;
-static afffile_T *spell_read_aff __ARGS((char_u *fname, spellinfo_T *spin));
+static afffile_T *spell_read_aff __ARGS((spellinfo_T *spin, char_u *fname));
static int str_equal __ARGS((char_u *s1, char_u *s2));
static void add_fromto __ARGS((spellinfo_T *spin, garray_T *gap, char_u *from, char_u *to));
static int sal_to_bool __ARGS((char_u *s));
static int has_non_ascii __ARGS((char_u *s));
static void spell_free_aff __ARGS((afffile_T *aff));
-static int spell_read_dic __ARGS((char_u *fname, spellinfo_T *spin, afffile_T *affile));
-static char_u *get_pfxlist __ARGS((afffile_T *affile, char_u *afflist, sblock_T **blp));
-static int store_aff_word __ARGS((char_u *word, spellinfo_T *spin, char_u *afflist, afffile_T *affile, hashtab_T *ht, hashtab_T *xht, int comb, int flags, char_u *pfxlist));
-static int spell_read_wordfile __ARGS((char_u *fname, spellinfo_T *spin));
-static void *getroom __ARGS((sblock_T **blp, size_t len, int align));
-static char_u *getroom_save __ARGS((sblock_T **blp, char_u *s));
+static int spell_read_dic __ARGS((spellinfo_T *spin, char_u *fname, afffile_T *affile));
+static char_u *get_pfxlist __ARGS((spellinfo_T *spin, afffile_T *affile, char_u *afflist));
+static int store_aff_word __ARGS((spellinfo_T *spin, char_u *word, char_u *afflist, afffile_T *affile, hashtab_T *ht, hashtab_T *xht, int comb, int flags, char_u *pfxlist));
+static int spell_read_wordfile __ARGS((spellinfo_T *spin, char_u *fname));
+static void *getroom __ARGS((spellinfo_T *spin, size_t len, int align));
+static char_u *getroom_save __ARGS((spellinfo_T *spin, char_u *s));
static void free_blocks __ARGS((sblock_T *bl));
-static wordnode_T *wordtree_alloc __ARGS((sblock_T **blp));
-static int store_word __ARGS((char_u *word, spellinfo_T *spin, int flags, int region, char_u *pfxlist));
-static int tree_add_word __ARGS((char_u *word, wordnode_T *tree, int flags, int region, int prefixID, spellinfo_T *spin));
-static wordnode_T *get_wordnode __ARGS((sblock_T **blp));
-static void free_wordnode __ARGS((wordnode_T *n));
-static void wordtree_compress __ARGS((wordnode_T *root, spellinfo_T *spin));
-static int node_compress __ARGS((wordnode_T *node, hashtab_T *ht, int *tot));
+static wordnode_T *wordtree_alloc __ARGS((spellinfo_T *spin));
+static int store_word __ARGS((spellinfo_T *spin, char_u *word, int flags, int region, char_u *pfxlist));
+static int tree_add_word __ARGS((spellinfo_T *spin, char_u *word, wordnode_T *tree, int flags, int region, int prefixID));
+static wordnode_T *get_wordnode __ARGS((spellinfo_T *spin));
+static void deref_wordnode __ARGS((spellinfo_T *spin, wordnode_T *node));
+static void free_wordnode __ARGS((spellinfo_T *spin, wordnode_T *n));
+static void wordtree_compress __ARGS((spellinfo_T *spin, wordnode_T *root));
+static int node_compress __ARGS((spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, int *tot));
static int node_equal __ARGS((wordnode_T *n1, wordnode_T *n2));
-static void write_vim_spell __ARGS((char_u *fname, spellinfo_T *spin));
+static void write_vim_spell __ARGS((spellinfo_T *spin, char_u *fname));
static void clear_node __ARGS((wordnode_T *node));
static int put_node __ARGS((FILE *fd, wordnode_T *node, int index, int regionmask, int prefixtree));
static void mkspell __ARGS((int fcount, char_u **fnames, int ascii, int overwrite, int added_word));
* Use a negative number with the lower 8 bits zero. */
#define PFX_FLAGS -256
-static int words_added = 0; /* number of words added to tree */
-
#ifdef SPELL_PRINTTREE
/*
* For debugging the tree code: print the current tree in a (more or less)
* Returns an afffile_T, NULL for complete failure.
*/
static afffile_T *
-spell_read_aff(fname, spin)
- char_u *fname;
+spell_read_aff(spin, fname)
spellinfo_T *spin;
+ char_u *fname;
{
FILE *fd;
afffile_T *aff;
/*
* Allocate and init the afffile_T structure.
*/
- aff = (afffile_T *)getroom(&spin->si_blocks, sizeof(afffile_T), TRUE);
+ aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);
if (aff == NULL)
return NULL;
hash_init(&aff->af_pref);
fname, lnum, items[4]);
/* New affix letter. */
- cur_aff = (affheader_T *)getroom(&spin->si_blocks,
+ cur_aff = (affheader_T *)getroom(spin,
sizeof(affheader_T), TRUE);
if (cur_aff == NULL)
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- l = mb_ptr2len_check(items[1]);
+ l = (*mb_ptr2len)(items[1]);
if (l >= AH_KEY_LEN)
l = 1; /* too long, must be an overlong sequence */
else
/* New item for an affix letter. */
--aff_todo;
- aff_entry = (affentry_T *)getroom(&spin->si_blocks,
+ aff_entry = (affentry_T *)getroom(spin,
sizeof(affentry_T), TRUE);
if (aff_entry == NULL)
break;
aff_entry->ae_rare = rare;
if (STRCMP(items[2], "0") != 0)
- aff_entry->ae_chop = getroom_save(&spin->si_blocks,
- items[2]);
+ aff_entry->ae_chop = getroom_save(spin, items[2]);
if (STRCMP(items[3], "0") != 0)
- aff_entry->ae_add = getroom_save(&spin->si_blocks,
- items[3]);
+ aff_entry->ae_add = getroom_save(spin, items[3]);
/* Don't use an affix entry with non-ASCII characters when
* "spin->si_ascii" is TRUE. */
{
char_u buf[MAXLINELEN];
- aff_entry->ae_cond = getroom_save(&spin->si_blocks,
- items[4]);
+ aff_entry->ae_cond = getroom_save(spin, items[4]);
if (*items[0] == 'P')
sprintf((char *)buf, "^%s", items[4]);
else
if (aff_entry->ae_chop != NULL
&& aff_entry->ae_add != NULL
#ifdef FEAT_MBYTE
- && aff_entry->ae_chop[mb_ptr2len_check(
+ && aff_entry->ae_chop[(*mb_ptr2len)(
aff_entry->ae_chop)] == NUL
#else
&& aff_entry->ae_chop[1] == NUL
{
onecap_copy(items[4], buf, TRUE);
aff_entry->ae_cond = getroom_save(
- &spin->si_blocks, buf);
+ spin, buf);
}
else
#endif
if (aff_entry->ae_cond == NULL)
*pp = NULL;
else
- *pp = getroom_save(&spin->si_blocks,
+ *pp = getroom_save(spin,
aff_entry->ae_cond);
}
n |= WFP_NC;
if (upper)
n |= WFP_UP;
- tree_add_word(p, spin->si_prefroot, n,
- idx, cur_aff->ah_newID, spin);
+ tree_add_word(spin, p, spin->si_prefroot, n,
+ idx, cur_aff->ah_newID);
}
}
}
{
ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
(void)spell_casefold(from, STRLEN(from), word, MAXWLEN);
- ftp->ft_from = getroom_save(&spin->si_blocks, word);
+ ftp->ft_from = getroom_save(spin, word);
(void)spell_casefold(to, STRLEN(to), word, MAXWLEN);
- ftp->ft_to = getroom_save(&spin->si_blocks, word);
+ ftp->ft_to = getroom_save(spin, word);
++gap->ga_len;
}
}
* Returns OK or FAIL;
*/
static int
-spell_read_dic(fname, spin, affile)
- char_u *fname;
+spell_read_dic(spin, fname, affile)
spellinfo_T *spin;
+ char_u *fname;
afffile_T *affile;
{
hashtab_T ht;
/* The hashtable is only used to detect duplicated words. */
hash_init(&ht);
- spin->si_foldwcount = 0;
- spin->si_keepwcount = 0;
-
if (spin->si_verbose || p_verbose > 2)
{
if (!spin->si_verbose)
verbose_leave();
}
+ /* start with a message for the first line */
+ spin->si_msg_count = 999999;
+
/* Read and ignore the first line: word count. */
(void)vim_fgets(line, MAXLINELEN, fd);
if (!vim_isdigit(*skipwhite(line)))
w = line;
}
- /* This takes time, print a message now and then. */
- if (spin->si_verbose && (lnum & 0x3ff) == 0)
+ /* This takes time, print a message every 10000 words. */
+ if (spin->si_verbose && spin->si_msg_count > 10000)
{
+ spin->si_msg_count = 0;
vim_snprintf((char *)message, sizeof(message),
_("line %6d, word %6d - %s"),
lnum, spin->si_foldwcount + spin->si_keepwcount, w);
}
/* Store the word in the hashtable to be able to find duplicates. */
- dw = (char_u *)getroom_save(&spin->si_blocks, w);
+ dw = (char_u *)getroom_save(spin, w);
if (dw == NULL)
retval = FAIL;
vim_free(pc);
if (affile->af_pfxpostpone)
/* Need to store the list of prefix IDs with the word. */
- pfxlist = get_pfxlist(affile, afflist, &spin->si_blocks);
+ pfxlist = get_pfxlist(spin, affile, afflist);
}
/* Add the word to the word tree(s). */
- if (store_word(dw, spin, flags, spin->si_region, pfxlist) == FAIL)
+ if (store_word(spin, dw, flags, spin->si_region, pfxlist) == FAIL)
retval = FAIL;
if (afflist != NULL)
{
/* Find all matching suffixes and add the resulting words.
* Additionally do matching prefixes that combine. */
- if (store_aff_word(dw, spin, afflist, affile,
+ if (store_aff_word(spin, dw, afflist, affile,
&affile->af_suff, &affile->af_pref,
FALSE, flags, pfxlist) == FAIL)
retval = FAIL;
/* Find all matching prefixes and add the resulting words. */
- if (store_aff_word(dw, spin, afflist, affile,
+ if (store_aff_word(spin, dw, afflist, affile,
&affile->af_pref, NULL,
FALSE, flags, pfxlist) == FAIL)
retval = FAIL;
* or when out of memory.
*/
static char_u *
-get_pfxlist(affile, afflist, blp)
+get_pfxlist(spin, affile, afflist)
+ spellinfo_T *spin;
afffile_T *affile;
char_u *afflist;
- sblock_T **blp;
{
char_u *p;
int cnt;
}
}
if (round == 1 && cnt > 0)
- res = getroom(blp, cnt + 1, FALSE);
+ res = getroom(spin, cnt + 1, FALSE);
if (res == NULL)
break;
}
* Returns FAIL when out of memory.
*/
static int
-store_aff_word(word, spin, afflist, affile, ht, xht, comb, flags, pfxlist)
- char_u *word; /* basic word start */
+store_aff_word(spin, word, afflist, affile, ht, xht, comb, flags, pfxlist)
spellinfo_T *spin; /* spell info */
+ char_u *word; /* basic word start */
char_u *afflist; /* list of names of supported affixes */
afffile_T *affile;
hashtab_T *ht;
}
/* Store the modified word. */
- if (store_word(newword, spin, use_flags,
+ if (store_word(spin, newword, use_flags,
spin->si_region, use_pfxlist) == FAIL)
retval = FAIL;
/* When added a suffix and combining is allowed also
* try adding prefixes additionally. */
if (xht != NULL && ah->ah_combine)
- if (store_aff_word(newword, spin, afflist, affile,
+ if (store_aff_word(spin, newword, afflist, affile,
xht, NULL, TRUE,
use_flags, use_pfxlist) == FAIL)
retval = FAIL;
* Read a file with a list of words.
*/
static int
-spell_read_wordfile(fname, spin)
- char_u *fname;
+spell_read_wordfile(spin, fname)
spellinfo_T *spin;
+ char_u *fname;
{
FILE *fd;
long lnum = 0;
}
/* Normal word: store it. */
- if (store_word(line, spin, flags, regionmask, NULL) == FAIL)
+ if (store_word(spin, line, flags, regionmask, NULL) == FAIL)
{
retval = FAIL;
break;
/*
* Get part of an sblock_T, "len" bytes long.
- * This avoids calling free() for every little struct we use.
+ * This avoids calling free() for every little struct we use (and keeping
+ * track of them).
* The memory is cleared to all zeros.
* Returns NULL when out of memory.
*/
static void *
-getroom(blp, len, align)
- sblock_T **blp;
+getroom(spin, len, align)
+ spellinfo_T *spin;
size_t len; /* length needed */
int align; /* align for pointer */
{
char_u *p;
- sblock_T *bl = *blp;
+ sblock_T *bl = spin->si_blocks;
if (align && bl != NULL)
/* Round size up for alignment. On some systems structures need to be
bl = (sblock_T *)alloc_clear((unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
if (bl == NULL)
return NULL;
- bl->sb_next = *blp;
- *blp = bl;
+ bl->sb_next = spin->si_blocks;
+ spin->si_blocks = bl;
bl->sb_used = 0;
}
* Make a copy of a string into memory allocated with getroom().
*/
static char_u *
-getroom_save(blp, s)
- sblock_T **blp;
+getroom_save(spin, s)
+ spellinfo_T *spin;
char_u *s;
{
char_u *sc;
- sc = (char_u *)getroom(blp, STRLEN(s) + 1, FALSE);
+ sc = (char_u *)getroom(spin, STRLEN(s) + 1, FALSE);
if (sc != NULL)
STRCPY(sc, s);
return sc;
* Allocate the root of a word tree.
*/
static wordnode_T *
-wordtree_alloc(blp)
- sblock_T **blp;
+wordtree_alloc(spin)
+ spellinfo_T *spin;
{
- return (wordnode_T *)getroom(blp, sizeof(wordnode_T), TRUE);
+ return (wordnode_T *)getroom(spin, sizeof(wordnode_T), TRUE);
}
/*
* When "pfxlist" is not NULL store the word for each postponed prefix ID.
*/
static int
-store_word(word, spin, flags, region, pfxlist)
- char_u *word;
+store_word(spin, word, flags, region, pfxlist)
spellinfo_T *spin;
+ char_u *word;
int flags; /* extra flags, WF_BANNED */
int region; /* supported region(s) */
char_u *pfxlist; /* list of prefix IDs or NULL */
(void)spell_casefold(word, len, foldword, MAXWLEN);
for (p = pfxlist; res == OK; ++p)
{
- res = tree_add_word(foldword, spin->si_foldroot, ct | flags,
- region, p == NULL ? 0 : *p, spin);
+ res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
+ region, p == NULL ? 0 : *p);
if (p == NULL || *p == NUL)
break;
}
++spin->si_foldwcount;
- if (res == OK && (ct == WF_KEEPCAP || flags & WF_KEEPCAP))
+ if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP)))
{
for (p = pfxlist; res == OK; ++p)
{
- res = tree_add_word(word, spin->si_keeproot, flags,
- region, p == NULL ? 0 : *p, spin);
+ res = tree_add_word(spin, word, spin->si_keeproot, flags,
+ region, p == NULL ? 0 : *p);
if (p == NULL || *p == NUL)
break;
}
* Returns FAIL when out of memory.
*/
static int
-tree_add_word(word, root, flags, region, prefixID, spin)
+tree_add_word(spin, word, root, flags, region, prefixID)
+ spellinfo_T *spin;
char_u *word;
wordnode_T *root;
int flags;
int region;
int prefixID;
- spellinfo_T *spin;
{
wordnode_T *node = root;
wordnode_T *np;
wordnode_T *copyp, **copyprev;
wordnode_T **prev = NULL;
int i;
- sblock_T **blp = &spin->si_blocks;
/* Add each byte of the word to the tree, including the NUL at the end. */
for (i = 0; ; ++i)
for (copyp = node; copyp != NULL; copyp = copyp->wn_sibling)
{
/* Allocate a new node and copy the info. */
- np = get_wordnode(blp);
+ np = get_wordnode(spin);
if (np == NULL)
return FAIL;
np->wn_child = copyp->wn_child;
|| node->wn_prefixID != prefixID)))
{
/* Allocate a new node. */
- np = get_wordnode(blp);
+ np = get_wordnode(spin);
if (np == NULL)
return FAIL;
np->wn_byte = word[i];
spell_print_tree(root->wn_sibling);
#endif
+ /* count nr of words added since last message */
+ ++spin->si_msg_count;
+
/*
* Every so many words compress the tree, so that we don't use too much
* memory.
*/
- if (++words_added >= SPELL_COMPRESS_CNT)
+ i = FALSE;
+ if (root == spin->si_foldroot)
{
- words_added = 0;
-
- msg_start();
- msg_puts((char_u *)_(msg_compressing));
- msg_clr_eos();
- msg_didout = FALSE;
- msg_col = 0;
- out_flush();
- wordtree_compress(root->wn_sibling, spin);
+ if (++spin->si_fold_added >= SPELL_COMPRESS_CNT)
+ {
+ i = TRUE;
+ spin->si_fold_added = 0;
+ }
+ }
+ else if (root == spin->si_keeproot)
+ {
+ if (++spin->si_keep_added >= SPELL_COMPRESS_CNT)
+ {
+ i = TRUE;
+ spin->si_keep_added = 0;
+ }
+ }
+ if (i)
+ {
+ if (spin->si_verbose)
+ {
+ msg_start();
+ msg_puts((char_u *)_(msg_compressing));
+ msg_clr_eos();
+ msg_didout = FALSE;
+ msg_col = 0;
+ out_flush();
+ }
+ wordtree_compress(spin, root);
}
return OK;
}
-/* We keep a list of nodes that have been freed during compression. They are
- * re-used when adding a new node. The "wn_child" fields links them. */
-static wordnode_T *first_free_node = NULL;
-#ifdef SPELL_PRINTTREE
-static int wordnode_nr = 0;
-#endif
-
/*
* Get a wordnode_T, either from the list of previously freed nodes or
* allocate a new one.
*/
static wordnode_T *
-get_wordnode(blp)
- sblock_T **blp;
+get_wordnode(spin)
+ spellinfo_T *spin;
{
wordnode_T *n;
- if (first_free_node == NULL)
- n = (wordnode_T *)getroom(blp, sizeof(wordnode_T), TRUE);
+ if (spin->si_first_free == NULL)
+ n = (wordnode_T *)getroom(spin, sizeof(wordnode_T), TRUE);
else
{
- n = first_free_node;
- first_free_node = n->wn_child;
+ n = spin->si_first_free;
+ spin->si_first_free = n->wn_child;
vim_memset(n, 0, sizeof(wordnode_T));
}
#ifdef SPELL_PRINTTREE
- n->wn_nr = ++wordnode_nr;
+ n->wn_nr = ++spin->si_wordnode_nr;
#endif
return n;
}
+/*
+ * Decrement the reference count on a node (which is the head of a list of
+ * siblings). If the reference count becomes zero free the node and its
+ * siblings.
+ */
+ static void
+deref_wordnode(spin, node)
+ spellinfo_T *spin;
+ wordnode_T *node;
+{
+ wordnode_T *np;
+
+ if (--node->wn_refs == 0)
+ for (np = node; np != NULL; np = np->wn_sibling)
+ {
+ if (np->wn_child != NULL)
+ deref_wordnode(spin, np->wn_child);
+ free_wordnode(spin, np);
+ }
+}
+
/*
* Free a wordnode_T for re-use later.
+ * Only the "wn_child" field becomes invalid.
*/
static void
-free_wordnode(n)
- wordnode_T *n;
+free_wordnode(spin, n)
+ spellinfo_T *spin;
+ wordnode_T *n;
{
- n->wn_child = first_free_node;
- first_free_node = n;
+ n->wn_child = spin->si_first_free;
+ spin->si_first_free = n;
}
/*
* Compress a tree: find tails that are identical and can be shared.
*/
static void
-wordtree_compress(root, spin)
- wordnode_T *root;
+wordtree_compress(spin, root)
spellinfo_T *spin;
+ wordnode_T *root;
{
hashtab_T ht;
int n;
int tot = 0;
int perc;
- if (root != NULL)
+ /* Skip the root itself, it's not actually used. The first sibling is the
+ * start of the tree. */
+ if (root->wn_sibling != NULL)
{
hash_init(&ht);
- n = node_compress(root, &ht, &tot);
+ n = node_compress(spin, root->wn_sibling, &ht, &tot);
#ifndef SPELL_PRINTTREE
if (spin->si_verbose || p_verbose > 2)
verbose_leave();
}
#ifdef SPELL_PRINTTREE
- spell_print_tree(root);
+ spell_print_tree(root->wn_sibling);
#endif
hash_clear(&ht);
}
* Returns the number of compressed nodes.
*/
static int
-node_compress(node, ht, tot)
+node_compress(spin, node, ht, tot)
+ spellinfo_T *spin;
wordnode_T *node;
hashtab_T *ht;
int *tot; /* total count of nodes before compressing,
if ((child = np->wn_child) != NULL)
{
/* Compress the child. This fills hashkey. */
- compressed += node_compress(child, ht, tot);
+ compressed += node_compress(spin, child, ht, tot);
/* Try to find an identical child. */
hash = hash_hash(child->wn_u1.hashkey);
* current one. This means the current child and all
* its siblings is unlinked from the tree. */
++tp->wn_refs;
- --child->wn_refs;
- if (child->wn_refs == 0)
- for (; child != NULL; child = child->wn_sibling)
- {
- if (child->wn_child != NULL)
- --child->wn_child->wn_refs;
- free_wordnode(child);
- }
+ deref_wordnode(spin, child);
np->wn_child = tp;
++compressed;
break;
* Write the Vim spell file "fname".
*/
static void
-write_vim_spell(fname, spin)
- char_u *fname;
+write_vim_spell(spin, fname)
spellinfo_T *spin;
+ char_u *fname;
{
FILE *fd;
int regionmask;
ga_init2(&spin.si_sal, (int)sizeof(fromto_T), 20);
ga_init2(&spin.si_map, (int)sizeof(char_u), 100);
ga_init2(&spin.si_prefcond, (int)sizeof(char_u *), 50);
- first_free_node = NULL;
-#ifdef SPELL_PRINTTREE
- wordnode_nr = 0;
-#endif
- words_added = 0;
/* default: fnames[0] is output file, following are input files */
innames = &fnames[1];
}
spin.si_region_count = incount;
- spin.si_foldroot = wordtree_alloc(&spin.si_blocks);
- spin.si_keeproot = wordtree_alloc(&spin.si_blocks);
- spin.si_prefroot = wordtree_alloc(&spin.si_blocks);
+ spin.si_foldroot = wordtree_alloc(&spin);
+ spin.si_keeproot = wordtree_alloc(&spin);
+ spin.si_prefroot = wordtree_alloc(&spin);
if (spin.si_foldroot == NULL
|| spin.si_keeproot == NULL
|| spin.si_prefroot == NULL)
{
/* Read the .aff file. Will init "spin->si_conv" based on the
* "SET" line. */
- afile[i] = spell_read_aff(fname, &spin);
+ afile[i] = spell_read_aff(&spin, fname);
if (afile[i] == NULL)
error = TRUE;
else
/* Read the .dic file and store the words in the trees. */
vim_snprintf((char *)fname, sizeof(fname), "%s.dic",
innames[i]);
- if (spell_read_dic(fname, &spin, afile[i]) == FAIL)
+ if (spell_read_dic(&spin, fname, afile[i]) == FAIL)
error = TRUE;
}
}
{
/* No .aff file, try reading the file as a word list. Store
* the words in the trees. */
- if (spell_read_wordfile(innames[i], &spin) == FAIL)
+ if (spell_read_wordfile(&spin, innames[i]) == FAIL)
error = TRUE;
}
/*
* Combine tails in the tree.
*/
- if (!added_word || p_verbose > 2)
+ if (spin.si_verbose || p_verbose > 2)
{
- if (added_word)
+ if (!spin.si_verbose)
verbose_enter();
MSG(_(msg_compressing));
out_flush();
- if (added_word)
+ if (!spin.si_verbose)
verbose_leave();
}
- wordtree_compress(spin.si_foldroot->wn_sibling, &spin);
- wordtree_compress(spin.si_keeproot->wn_sibling, &spin);
- wordtree_compress(spin.si_prefroot->wn_sibling, &spin);
+ wordtree_compress(&spin, spin.si_foldroot);
+ wordtree_compress(&spin, spin.si_keeproot);
+ wordtree_compress(&spin, spin.si_prefroot);
}
if (!error)
/*
* Write the info in the spell file.
*/
- if (!added_word || p_verbose > 2)
+ if (spin.si_verbose || p_verbose > 2)
{
- if (added_word)
+ if (!spin.si_verbose)
verbose_enter();
smsg((char_u *)_("Writing spell file %s ..."), wfname);
out_flush();
- if (added_word)
+ if (!spin.si_verbose)
verbose_leave();
}
- write_vim_spell(wfname, &spin);
+ write_vim_spell(&spin, wfname);
- if (!added_word || p_verbose > 2)
+ if (spin.si_verbose || p_verbose > 2)
{
- if (added_word)
+ if (!spin.si_verbose)
verbose_enter();
MSG(_("Done!"));
smsg((char_u *)_("Estimated runtime memory use: %d bytes"),
spin.si_memtot);
out_flush();
- if (added_word)
+ if (!spin.si_verbose)
verbose_leave();
}
buf[outi] = NUL;
return FAIL;
}
- c = mb_ptr2char_adv(&p);
+ c = mb_cptr2char_adv(&p);
outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi);
}
buf[outi] = NUL;
vim_free(repl_to);
repl_to = NULL;
+#ifdef FEAT_RIGHTLEFT
+ /* When 'rightleft' is set the list is drawn right-left. */
+ cmdmsg_rl = curwin->w_p_rl;
+ if (cmdmsg_rl)
+ msg_col = Columns - 1;
+#endif
+
/* List the suggestions. */
msg_start();
lines_left = Rows; /* avoid more prompt */
vim_snprintf((char *)IObuff, IOSIZE, _("Change \"%.*s\" to:"),
sug.su_badlen, sug.su_badptr);
+#ifdef FEAT_RIGHTLEFT
+ if (cmdmsg_rl && STRNCMP(IObuff, "Change", 6) == 0)
+ {
+ /* And now the rabbit from the high hat: Avoid showing the
+ * untranslated message rightleft. */
+ vim_snprintf((char *)IObuff, IOSIZE, ":ot \"%.*s\" egnahC",
+ sug.su_badlen, sug.su_badptr);
+ }
+#endif
msg_puts(IObuff);
msg_clr_eos();
msg_putchar('\n');
vim_strncpy(wcopy + STRLEN(wcopy),
sug.su_badptr + stp->st_orglen,
sug.su_badlen - stp->st_orglen);
- vim_snprintf((char *)IObuff, IOSIZE, _("%2d \"%s\""), i + 1, wcopy);
+ vim_snprintf((char *)IObuff, IOSIZE, "%2d", i + 1);
+#ifdef FEAT_RIGHTLEFT
+ if (cmdmsg_rl)
+ rl_mirror(IObuff);
+#endif
+ msg_puts(IObuff);
+
+ vim_snprintf((char *)IObuff, IOSIZE, " \"%s\"", wcopy);
msg_puts(IObuff);
/* The word may replace more than "su_badlen". */
{
/* Add the score. */
if (sps_flags & (SPS_DOUBLE | SPS_BEST))
- vim_snprintf((char *)IObuff, IOSIZE, _(" (%s%d - %d)"),
+ vim_snprintf((char *)IObuff, IOSIZE, " (%s%d - %d)",
stp->st_salscore ? "s " : "",
stp->st_score, stp->st_altscore);
else
- vim_snprintf((char *)IObuff, IOSIZE, _(" (%d)"),
+ vim_snprintf((char *)IObuff, IOSIZE, " (%d)",
stp->st_score);
+#ifdef FEAT_RIGHTLEFT
+ if (cmdmsg_rl)
+ /* Mirror the numbers, but keep the leading space. */
+ rl_mirror(IObuff + 1);
+#endif
msg_advance(30);
msg_puts(IObuff);
}
msg_putchar('\n');
}
+#ifdef FEAT_RIGHTLEFT
+ cmdmsg_rl = FALSE;
+ msg_col = 0;
+#endif
/* Ask for choice. */
i = prompt_for_number(&mouse_used);
if (mouse_used)
(void)spell_casefold(su->su_badptr, su->su_badlen,
su->su_fbadword, MAXWLEN);
/* get caps flags for bad word */
- su->su_badflags = captype(su->su_badptr, su->su_badptr + su->su_badlen);
+ su->su_badflags = badword_captype(su->su_badptr,
+ su->su_badptr + su->su_badlen);
if (need_cap)
su->su_badflags |= WF_ONECAP;
#endif
/*
- * Find suggestions a file "fname".
+ * Find suggestions in file "fname". Used for "file:" in 'spellsuggest'.
*/
static void
spell_suggest_file(su, fname)
p = word;
#ifdef FEAT_MBYTE
if (has_mbyte)
- c = mb_ptr2char_adv(&p);
+ c = mb_cptr2char_adv(&p);
else
#endif
c = *p++;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- c = mb_ptr2char_adv(&s);
+ c = mb_cptr2char_adv(&s);
else
#endif
c = *s++;
else
#endif
n = sp->ts_fidx;
- flags = captype(su->su_badptr, su->su_badptr + n);
- su->su_badflags = captype(su->su_badptr + n,
+ flags = badword_captype(su->su_badptr,
+ su->su_badptr + n);
+ su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
-
++depth;
stack[depth] = stack[depth - 1];
sp = &stack[depth];
c = su->su_badflags;
if ((c & WF_ALLCAP)
#ifdef FEAT_MBYTE
- && su->su_badlen == mb_ptr2len_check(su->su_badptr)
+ && su->su_badlen == (*mb_ptr2len)(su->su_badptr)
#else
&& su->su_badlen == 1
#endif
else
#endif
n = sp->ts_fidx;
- su->su_badflags = captype(su->su_badptr + n,
+ su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
/* Restart at top of the tree. */
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- n = mb_ptr2len_check(p);
+ n = mb_cptr2len(p);
c = mb_ptr2char(p);
c2 = mb_ptr2char(p + n);
}
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- n = mb_ptr2len_check(p);
+ n = mb_cptr2len(p);
c = mb_ptr2char(p);
- fl = mb_ptr2len_check(p + n);
+ fl = mb_cptr2len(p + n);
c2 = mb_ptr2char(p + n);
c3 = mb_ptr2char(p + n + fl);
}
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- n = mb_ptr2len_check(p);
+ n = mb_cptr2len(p);
c = mb_ptr2char(p);
- fl = mb_ptr2len_check(p + n);
- fl += mb_ptr2len_check(p + n + fl);
+ fl = mb_cptr2len(p + n);
+ fl += mb_cptr2len(p + n + fl);
mch_memmove(p, p + n, fl);
mb_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- n = mb_ptr2len_check(p);
- n += mb_ptr2len_check(p + n);
+ n = mb_cptr2len(p);
+ n += mb_cptr2len(p + n);
c = mb_ptr2char(p + n);
- tl = mb_ptr2len_check(p + n);
+ tl = mb_cptr2len(p + n);
mch_memmove(p + tl, p, n);
mb_char2bytes(c, p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- flen = mb_ptr2len_check(fword + fwordidx[depth]);
- ulen = mb_ptr2len_check(uword + uwordidx[depth]);
+ flen = mb_cptr2len(fword + fwordidx[depth]);
+ ulen = mb_cptr2len(uword + uwordidx[depth]);
}
else
#endif
for (p = map; *p != NUL; )
{
#ifdef FEAT_MBYTE
- c = mb_ptr2char_adv(&p);
+ c = mb_cptr2char_adv(&p);
#else
c = *p++;
#endif
* 255, sl_sal the rest. */
for (s = inword; *s != NUL; )
{
- c = mb_ptr2char_adv(&s);
+ c = mb_cptr2char_adv(&s);
if (enc_utf8 ? utf_class(c) == 0 : vim_iswhite(c))
c = ' ';
else if (c < 256)
for (s = inword; *s != NUL; )
{
t = s;
- c = mb_ptr2char_adv(&s);
+ c = mb_cptr2char_adv(&s);
if (slang->sl_rem_accents)
{
if (enc_utf8 ? utf_class(c) == 0 : vim_iswhite(c))
/* Get the characters from the multi-byte strings and put them in an
* int array for easy access. */
for (p = badword, badlen = 0; *p != NUL; )
- wbadword[badlen++] = mb_ptr2char_adv(&p);
+ wbadword[badlen++] = mb_cptr2char_adv(&p);
wbadword[badlen++] = 0;
for (p = goodword, goodlen = 0; *p != NUL; )
- wgoodword[goodlen++] = mb_ptr2char_adv(&p);
+ wgoodword[goodlen++] = mb_cptr2char_adv(&p);
wgoodword[goodlen++] = 0;
}
else
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- kwlen += (*mb_ptr2len_check)(kwp + kwlen);
+ kwlen += (*mb_ptr2len)(kwp + kwlen);
else
#endif
++kwlen;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- int l = (*mb_ptr2len_check)(p + 1);
+ int l = (*mb_ptr2len)(p + 1);
mch_memmove(p, p + 1, l);
p += l;
#ifdef FEAT_MBYTE
/* skip multibyte char correctly */
- for (i = (*mb_ptr2len_check)(src); i > 0; --i)
+ for (i = (*mb_ptr2len)(src); i > 0; --i)
#endif
{
/*
end = curwin->w_cursor;
#ifdef FEAT_MBYTE
if (has_mbyte)
- end.col += (*mb_ptr2len_check)(ml_get_cursor()) - 1;
+ end.col += (*mb_ptr2len)(ml_get_cursor()) - 1;
#endif
}
else
if (has_mbyte)
{
clen += ptr2cells(p + l);
- l += (*mb_ptr2len_check)(p + l) - 1;
+ l += (*mb_ptr2len)(p + l) - 1;
}
else
#endif
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 9)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 9, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 10)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 10, compiled "
|| ((options & FNAME_HYP) && path_is_url(ptr + len)))
#ifdef FEAT_MBYTE
if (has_mbyte)
- len += (*mb_ptr2len_check)(ptr + len);
+ len += (*mb_ptr2len)(ptr + len);
else
#endif
++len;