summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
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