summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-07 08:13:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-07 08:13:55 +0000
commit5a12fb5fb87fe373ad251d68752388148c1363a3 (patch)
treeb794a8c94a3f3d2aceaca62f0094e7ac067f9233 /io.c
parentf64949e2764a95e86a3851c07273f88aaac2fc7b (diff)
* io.c (io_encname_bom_p): removed magic number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/io.c b/io.c
index 3391bea4d0..31a86da6b9 100644
--- a/io.c
+++ b/io.c
@@ -3938,11 +3938,13 @@ rb_io_fmode_modestr(int fmode)
static int
io_encname_bom_p(const char *name, long len)
{
+ static const char bom_prefix[] = "bom|utf-";
+ enum {bom_prefix_len = (int)sizeof(bom_prefix) - 1};
if (!len) {
const char *p = strchr(name, ':');
- len = p ? p - name : strlen(name);
+ len = p ? (long)(p - name) : (long)strlen(name);
}
- return len > 8 && STRNCASECMP(name, "bom|utf-", 8) == 0;
+ return len > bom_prefix_len && STRNCASECMP(name, bom_prefix, bom_prefix_len) == 0;
}
int