diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-07 08:13:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-07 08:13:55 +0000 |
commit | 5a12fb5fb87fe373ad251d68752388148c1363a3 (patch) | |
tree | b794a8c94a3f3d2aceaca62f0094e7ac067f9233 /io.c | |
parent | f64949e2764a95e86a3851c07273f88aaac2fc7b (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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 |