Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Unicode Character Prop fix, update appveyor, travis #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.2.8
- 2.3.5
- 2.4.2
3 changes: 3 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
.autotest
.bundle/config
.hoeignore
.travis.yml
Gemfile
Gemfile.lock
History.txt
LICENSE
Manifest.txt
README.rdoc
Rakefile
appveyor.yml
bin/kpeg
examples/calculator/calculator.kpeg
examples/calculator/calculator.rb
Expand Down
35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '{build}'
skip_tags: true
clone_depth: 5
build: off
deploy: off

init:
- mklink /d C:\git "C:\Program Files\Git"
- if %ruby_version%==_trunk (
appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z &
7z x C:\ruby_trunk.7z -oC:\ruby_trunk )

install:
- gem install hoe --no-document
- if "%ruby_version%" LSS "22" ( gem update minitest )

test_script:
- rake test
on_finish:
- ruby -v

environment:
PATH: C:/ruby%ruby_version%/bin;C:/Program Files/7-Zip;C:/Program Files/AppVeyor/BuildAgent;C:/git/cmd;C:/Program Files (x86)/GNU/GnuPG/pub;C:/Windows/system32;C:\Windows;
matrix:
- ruby_version: 200
- ruby_version: 200-x64
- ruby_version: 21
- ruby_version: 21-x64
- ruby_version: 22
- ruby_version: 22-x64
- ruby_version: 23
- ruby_version: 23-x64
- ruby_version: 24
- ruby_version: 24-x64
- ruby_version: _trunk
4 changes: 2 additions & 2 deletions lib/kpeg/format_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def _dbl_not_quote
break
end
_tmp = apply(:_dbl_escapes)
s = @result
# warning unused s = @result
unless _tmp
self.pos = _save3
end
Expand All @@ -924,7 +924,7 @@ def _dbl_not_quote
break if _tmp
self.pos = _save2
_tmp = apply(:_dbl_seq)
s = @result
# warning unused s = @result
break if _tmp
self.pos = _save2
break
Expand Down
6 changes: 6 additions & 0 deletions lib/kpeg/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def initialize(reg, opts=nil)
end
end
end
# Windows - force to UTF-8 if reg contains a Unicode character property
# of the \p{**} style
if reg =~ /\{[LMNPSZC][c-u]?\}/ && RUBY_PLATFORM =~ /mswin|mingw/ &&
reg.encoding == Encoding::IBM437
reg.force_encoding('UTF-8')
end

@regexp = Regexp.new(reg, flags, lang)
else
Expand Down
18 changes: 9 additions & 9 deletions test/test_kpeg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_str
end

assert_match KPeg.match("hello", gram), "hello"
assert_equal nil, KPeg.match("vador", gram)
assert_nil KPeg.match("vador", gram)
end

def test_reg
Expand All @@ -48,7 +48,7 @@ def test_any

assert_match KPeg.match("hello", gram), "hello"
assert_match KPeg.match("chicken", gram), "chicken"
assert_equal nil, KPeg.match("vador", gram)
assert_nil KPeg.match("vador", gram)
end

def test_maybe
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_many
assert_match sm, "run"
end

assert_equal nil, KPeg.match("vador", gram)
assert_nil KPeg.match("vador", gram)
end

def test_kleene
Expand Down Expand Up @@ -124,9 +124,9 @@ def test_multiple
assert_match sm, "run"
end

assert_equal nil, KPeg.match("run", gram)
assert_equal nil, KPeg.match("runrunrunrunrun", gram)
assert_equal nil, KPeg.match("vador", gram)
assert_nil KPeg.match("run", gram)
assert_nil KPeg.match("runrunrunrunrun", gram)
assert_nil KPeg.match("vador", gram)
end

def test_seq
Expand All @@ -141,8 +141,8 @@ def test_seq

assert_equal m.value, ["hello", ", world"]

assert_equal nil, KPeg.match("vador", gram)
assert_equal nil, KPeg.match("hello, vador", gram)
assert_nil KPeg.match("vador", gram)
assert_nil KPeg.match("hello, vador", gram)
end

def test_andp
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_left_recursion
parser = KPeg::Parser.new "hello", gram
m = parser.parse

assert_equal nil, m
assert_nil m
end

def test_math_grammar
Expand Down
2 changes: 1 addition & 1 deletion test/test_kpeg_code_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ def _root

code = cg.make("")
assert code.parse
assert_equal nil, code.result
assert_nil code.result
end


Expand Down
1 change: 0 additions & 1 deletion test/test_kpeg_string_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ def parse(str, embed = false)
end

end