Skip to content

Commit

Permalink
* io.c (io_encname_bom_p): removed magic number.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Sep 7, 2009
1 parent f64949e commit 5a12fb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Mon Sep 7 17:13:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>

* io.c (io_encname_bom_p): removed magic number.

Mon Sep 7 12:26:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>

* lib/irb/inspector.rb (IRB::INSPECTORS.def_inspector): support
Expand Down
6 changes: 4 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a12fb5

Please sign in to comment.