Skip to search.
vim-multibyte · Vim (Vi IMproved) text editor special language list

Group Information

? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

  Messages Help
Advanced
Vim multibyte support for non-utf8 encodings   Message List  
Reply Message #2001 of 2749 |
Hi,

The current version of vim doesn't handle non-utf8 multibyte encodings
such as EUC and/or GBK in FreeBSD. Cursor moves around weird places
inside a character and the last character on each lines disappears
sometimes.

This problem is due to vim's dependency to undefined behavior of
mblen(3). Looking vim's source code mbyte.c:653, the routine assumes
that mblen(3) isn't stateful. On glibc or Solaris libc, mblen(3)
does not change the internal state when EILSEQ or EINVAL is occurred.
But FreeBSD libc changes the internal state even when it meets an
error. The mblen(3) behavior is undefined in POSIX [1] and none
of each libc implementations are wrong. So I think it's required
to reset multibyte states before a mblen(3) call to work the routine
free from implementation.

My patch is attached.

[1] http://www.opengroup.org/onlinepubs/009695399/functions/mblen.html

Hye-Shik


Sat Jul 16, 2005 12:20 am

perky@...
Send Email Send Email

--- mbyte.c.orig Fri Apr 23 17:44:36 2004
+++ mbyte.c Thu May 12 08:48:35 2005
@@ -650,6 +650,7 @@
* where mblen() returns 0 for invalid character.
* Therefore, following condition includes 0.
*/
+ (void)mblen(NULL, 0);
if (mblen(buf, (size_t)1) <= 0)
n = 2;
else


Attachment
attachment
Type:
application/pgp-signature
Message #2001 of 2749 |
Expand Messages Author Sort by Date

Hi, The current version of vim doesn't handle non-utf8 multibyte encodings such as EUC and/or GBK in FreeBSD. Cursor moves around weird places inside a...
Hye-Shik Chang
perky@... Send Email
Jul 16, 2005
12:20 am

... The behavior of mblen() on various systems has always been a bit unclear to me. Your remark makes a lot of sense, but I wonder why nobody had this problem...
Bram Moolenaar
Bram@... Send Email
Jul 16, 2005
10:55 am

... [snip] ... In fact, many of Japanese FreeBSD users seems to have been suffered from the problem: ...
Hye-Shik Chang
perky@... Send Email
Jul 16, 2005
11:46 am
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help