Skip to content

Commit

Permalink
Merge pull request #14 from canimus/bom_fix
Browse files Browse the repository at this point in the history
Handling of BOM files with search pattern for specific bytes
  • Loading branch information
derks committed Dec 19, 2013
2 parents 88dc853 + 6445cec commit c8a9d84
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/parseconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(config_file=nil)

# Validate the config file, and contents
def validate_config()
if !File.readable?(self.config_file)
unless File.readable?(self.config_file)
raise Errno::EACCES, "#{self.config_file} is not readable"
end

Expand All @@ -53,8 +53,13 @@ def import_config()
# The config is top down.. anything after a [group] gets added as part
# of that group until a new [group] is found.
group = nil
open(self.config_file) { |f| f.each do |line|
open(self.config_file) { |f| f.each_with_index do |line, i|
line.strip!

if i.eql? 0 and line.include?("\xef\xbb\xbf".force_encoding("UTF-8"))
line.delete!("\xef\xbb\xbf".force_encoding("UTF-8"))
end

unless (/^\#/.match(line))
if(/\s*=\s*/.match(line))
param, value = line.split(/\s*=\s*/, 2)
Expand Down

0 comments on commit c8a9d84

Please sign in to comment.