diff options
| author | Jack Nagel | 2012-09-27 17:03:43 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-09-27 17:26:26 -0500 |
| commit | 71dbaaae1b028e03d0ade62af22ac29bf217c421 (patch) | |
| tree | 78d9eb11f43f699a2da3d725a2e559f7038cfa69 /Library/Formula/node.rb | |
| parent | 3d97092ab39ba0631ae9e73af80643e5ebf97a64 (diff) | |
| download | homebrew-71dbaaae1b028e03d0ade62af22ac29bf217c421.tar.bz2 | |
Improve text_executable heuristic
Previously we detected this by reading the first line of the file.
However, "first line" is meaningless when dealing with binary files, but
IO#readline will happily keep reading until it finds a newline
character, which can result in some unnecessarily large buffers.
Aside from the performance issue, this causes an additional problem
under Ruby 1.9: trying to match the binary string against a pattern will
raise ArgumentError (unless the binary string just happens to also be
valid UTF-8, heh).
Fix both issues: only read the first 1024 bytes, as no sane shebang will
ever be that long, and use a plain read(), which returns an ASCII
encoded string even on 1.9.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Formula/node.rb')
0 files changed, 0 insertions, 0 deletions
