aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--encoding.c2
-rw-r--r--include/ruby/encoding.h2
-rw-r--r--string.c3
4 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 512cc6f589..c4fab6d80c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Dec 27 15:25:16 2007 Tanaka Akira <akr@fsij.org>
+
+ * encoding.c (rb_enc_codelen): show codepoint in error message.
+
+ * include/ruby/encoding.h (rb_enc_codelen): comment it returns
+ positive integer.
+
+ * string.c (rb_str_concat): rb_enc_codelen doesn't return 0.
+
Thu Dec 27 15:18:44 2007 Tanaka Akira <akr@fsij.org>
* encoding.c (rb_enc_codelen): error message refined.
diff --git a/encoding.c b/encoding.c
index 5c74871ecd..2e8b9b54ea 100644
--- a/encoding.c
+++ b/encoding.c
@@ -680,7 +680,7 @@ rb_enc_codelen(int c, rb_encoding *enc)
{
int n = ONIGENC_CODE_TO_MBCLEN(enc,c);
if (n == 0) {
- rb_raise(rb_eArgError, "invalid codepoint");
+ rb_raise(rb_eArgError, "invalid codepoint 0x%x", c);
}
return n;
}
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 1b1e3d7c59..1a57876555 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -87,7 +87,7 @@ int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
#define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE(enc,(UChar*)(p),(UChar*)(e))
-/* -> codelen or raise exception */
+/* -> codelen>0 or raise exception */
int rb_enc_codelen(int code, rb_encoding *enc);
/* code,ptr,encoding -> write buf */
diff --git a/string.c b/string.c
index 7a88e79330..e780d1a992 100644
--- a/string.c
+++ b/string.c
@@ -1104,9 +1104,6 @@ rb_str_concat(VALUE str1, VALUE str2)
int pos = RSTRING_LEN(str1);
int len = rb_enc_codelen(c, enc);
- if (len == 0) {
- rb_raise(rb_eArgError, "invalid codepoint 0x%x", c);
- }
rb_str_resize(str1, pos+len);
rb_enc_mbcput(c, RSTRING_PTR(str1)+pos, enc);
return str1;