[uim-commit] r2722 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Mon Jan 2 04:56:41 PST 2006
Author: yamaken
Date: 2006-01-02 04:56:36 -0800 (Mon, 02 Jan 2006)
New Revision: 2722
Modified:
branches/r5rs/sigscheme/encoding.c
Log:
* sigscheme/encoding.c
- (eucjp_char_len, euc_char_len, utf8_char_len, sjis_char_len): Fix
null character handling
Modified: branches/r5rs/sigscheme/encoding.c
===================================================================
--- branches/r5rs/sigscheme/encoding.c 2006-01-02 12:10:33 UTC (rev 2721)
+++ branches/r5rs/sigscheme/encoding.c 2006-01-02 12:56:36 UTC (rev 2722)
@@ -405,9 +405,11 @@
int
eucjp_char_len(int ch)
{
- char buf[SCM_MB_MAX_LEN + sizeof("")];
+ char *end, buf[SCM_MB_MAX_LEN + sizeof("")];
- return (eucjp_int2str((uchar *)buf, ch, SCM_MB_STATELESS)) ? strlen(buf) : 0;
+ end = eucjp_int2str((uchar *)buf, ch, SCM_MB_STATELESS);
+
+ return (end) ? end - buf : 0;
}
/* G0 <- (96) ASCII (or was it JIS X 0201 Roman?)
@@ -558,9 +560,11 @@
int
euc_char_len(int ch)
{
- char buf[SCM_MB_MAX_LEN + sizeof("")];
+ char *end, buf[SCM_MB_MAX_LEN + sizeof("")];
- return (euc_int2str((uchar *)buf, ch, SCM_MB_STATELESS)) ? strlen(buf) : 0;
+ end = euc_int2str((uchar *)buf, ch, SCM_MB_STATELESS);
+
+ return (end) ? end - buf : 0;
}
static uchar *
@@ -718,9 +722,11 @@
int
utf8_char_len(int ch)
{
- char buf[SCM_MB_MAX_LEN + sizeof("")];
+ char *end, buf[SCM_MB_MAX_LEN + sizeof("")];
- return (utf8_int2str((uchar *)buf, ch, SCM_MB_STATELESS)) ? strlen(buf) : 0;
+ end = utf8_int2str((uchar *)buf, ch, SCM_MB_STATELESS);
+
+ return (end) ? end - buf : 0;
}
static ScmMultibyteCharInfo
@@ -873,9 +879,11 @@
int
sjis_char_len(int ch)
{
- char buf[SCM_MB_MAX_LEN + sizeof("")];
+ char *end, buf[SCM_MB_MAX_LEN + sizeof("")];
- return (sjis_int2str((uchar *)buf, ch, SCM_MB_STATELESS)) ? strlen(buf) : 0;
+ end = sjis_int2str((uchar *)buf, ch, SCM_MB_STATELESS);
+
+ return (end) ? end - buf : 0;
}
static ScmMultibyteCharInfo
More information about the uim-commit
mailing list