diff --git a/Units/parser-gemspec.r/simple-gemspec.d/expected.tags b/Units/parser-gemspec.r/simple-gemspec.d/expected.tags index a1db3cde3e..e93cbfce6d 100644 --- a/Units/parser-gemspec.r/simple-gemspec.d/expected.tags +++ b/Units/parser-gemspec.r/simple-gemspec.d/expected.tags @@ -4,12 +4,17 @@ rspec-support input.gemspec /^ s.add_runtime_dependency "rspec-support", "= # rspec-support input.gemspec /^ s.add_runtime_dependency "rspec-support", "~> #{RSpec::Core::Version::STRING.split('.')[0..1/;" g roles:runtimeDep cucumber input.gemspec /^ s.add_development_dependency "cucumber", "~> 1.3"$/;" g roles:develDep minitest input.gemspec /^ s.add_development_dependency "minitest", "~> 5.3"$/;" g roles:develDep -aruba input.gemspec /^ s.add_development_dependency "aruba", "~> 0.14.9"$/;" g roles:develDep -coderay input.gemspec /^ s.add_development_dependency "coderay", "~> 1.1.1"$/;" g roles:develDep -mocha input.gemspec /^ s.add_development_dependency "mocha", "~> 0.13.0"$/;" g roles:develDep -rr input.gemspec /^ s.add_development_dependency "rr", "~> 1.0.4"$/;" g roles:develDep -flexmock input.gemspec /^ s.add_development_dependency "flexmock", "~> 0.9.0"$/;" g roles:develDep -thread_order input.gemspec /^ s.add_development_dependency "thread_order", "~> 1.1.0"$/;" g roles:develDep +aruba input.gemspec /^ s.add_development_dependency %q{aruba}, "~> 0.14.9"$/;" g roles:develDep +coderay input.gemspec /^ s.add_development_dependency %q[coderay], "~> 1.1.1"$/;" g roles:develDep +mocha input.gemspec /^ s.add_development_dependency %q(mocha), "~> 0.13.0"$/;" g roles:develDep +rr input.gemspec /^ s.add_development_dependency %q, "~> 1.0.4"$/;" g roles:develDep +flexmock input.gemspec /^ s.add_development_dependency %q flexmock , "~> 0.9.0"$/;" g roles:develDep +thread_order input.gemspec /^ s.add_development_dependency %q!thread_order!, "~> 1.1.0"$/;" g roles:develDep +strange{name}(just){-}{-}{testing} input.gemspec /^ s.add_runtime_dependency %q{strange{name}(just){-}{-}{testing}}.freeze, [">= 1.2.4".freez/;" g roles:runtimeDep +net-ssh input.gemspec /^ s.add_runtime_dependency("net-ssh", ">= 1.0.1")$/;" g roles:runtimeDep +ed25519 input.gemspec /^ s.add_runtime_dependency(%q.freeze, [">= 1.2.4".freeze, "< 1.4".freeze])$/;" g roles:runtimeDep +strangejust-for-testing input.gemspec /^ s.add_runtime_dependency(%qjust-for-testing>.freeze, [">= 1.2.4".freeze, "< 1.4"/;" g roles:runtimeDep katello/version input-0.gemspec /^require "katello\/version"$/;" L roles:required katello input-0.gemspec /^ gem.name = "katello"$/;" g roles:def rails input-0.gemspec /^ gem.add_dependency "rails"$/;" g roles:runtimeDep +G1 input-1.gemspec /^ gem.name = %q!G1!$/;" g roles:def diff --git a/Units/parser-gemspec.r/simple-gemspec.d/input-1.gemspec b/Units/parser-gemspec.r/simple-gemspec.d/input-1.gemspec new file mode 100644 index 0000000000..236b2b28bf --- /dev/null +++ b/Units/parser-gemspec.r/simple-gemspec.d/input-1.gemspec @@ -0,0 +1,4 @@ +Gem::Specification.new do |gem| + gem.name = %q!G1! + # ... +end diff --git a/Units/parser-gemspec.r/simple-gemspec.d/input.gemspec b/Units/parser-gemspec.r/simple-gemspec.d/input.gemspec index dcff51278f..ce31e21bcc 100644 --- a/Units/parser-gemspec.r/simple-gemspec.d/input.gemspec +++ b/Units/parser-gemspec.r/simple-gemspec.d/input.gemspec @@ -49,12 +49,17 @@ Gem::Specification.new do |s| s.add_development_dependency "cucumber", "~> 1.3" s.add_development_dependency "minitest", "~> 5.3" - s.add_development_dependency "aruba", "~> 0.14.9" + s.add_development_dependency %q{aruba}, "~> 0.14.9" - s.add_development_dependency "coderay", "~> 1.1.1" + s.add_development_dependency %q[coderay], "~> 1.1.1" - s.add_development_dependency "mocha", "~> 0.13.0" - s.add_development_dependency "rr", "~> 1.0.4" - s.add_development_dependency "flexmock", "~> 0.9.0" - s.add_development_dependency "thread_order", "~> 1.1.0" + s.add_development_dependency %q(mocha), "~> 0.13.0" + s.add_development_dependency %q, "~> 1.0.4" + s.add_development_dependency %q flexmock , "~> 0.9.0" + s.add_development_dependency %q!thread_order!, "~> 1.1.0" + s.add_development_dependency %qadonttagmea, "~> 1.1.0" + s.add_runtime_dependency %q{strange{name}(just){-}{-}{testing}}.freeze, [">= 1.2.4".freeze, "< 1.4".freeze] + s.add_runtime_dependency("net-ssh", ">= 1.0.1") + s.add_runtime_dependency(%q.freeze, [">= 1.2.4".freeze, "< 1.4".freeze]) + s.add_runtime_dependency(%qjust-for-testing>.freeze, [">= 1.2.4".freeze, "< 1.4".freeze]) end diff --git a/parsers/gemspec.c b/parsers/gemspec.c index 272071abc1..2ae2ad2c35 100644 --- a/parsers/gemspec.c +++ b/parsers/gemspec.c @@ -117,9 +117,9 @@ static int lineNotify (rubySubparser *s, const unsigned char **cp) if (p) { rubySkipWhitespace (&p); - if ((!is_attr) || *p == '=') + if (is_attr == false || *p == '=') { - if (is_attr) + if (*p == '(' || *p == '=') { p++; rubySkipWhitespace (&p); @@ -138,6 +138,19 @@ static int lineNotify (rubySubparser *s, const unsigned char **cp) } vStringDelete (gem); } + else if (p [0] == '%') + { + vString *gem = vStringNew (); + p++; + if (rubyParsePercentString(&p, gem)) + { + if (role == ROLE_DEFINITION_INDEX) + makeSimpleTag (gem, kind); + else + makeSimpleRefTag (gem, kind, role); + } + vStringDelete (gem); + } } } } diff --git a/parsers/ruby.c b/parsers/ruby.c index 56b44599ec..949c597de3 100644 --- a/parsers/ruby.c +++ b/parsers/ruby.c @@ -410,6 +410,7 @@ extern bool rubySkipWhitespace (const unsigned char** cp) return r; } +/* TODO: handle double quote if boundary == '"' */ static void parseString (const unsigned char** cp, unsigned char boundary, vString* vstr) { while (**cp != 0 && **cp != boundary) @@ -431,6 +432,77 @@ extern bool rubyParseString (const unsigned char** cp, unsigned char boundary, v return (p != *cp); } +static bool rubyParsePercent_q (const unsigned char** cp, vString* vstr) +{ + const unsigned char *p = *cp; + bool recursive; + unsigned char boundary[2]; + + if (*p == '\0' || isalnum (*p)) + return false; + + boundary[0] = *p; + boundary[1] = *p; + recursive = false; + switch (*p) + { + case '{': + boundary[1] = '}'; + recursive = true; + break; + case '[': + boundary[1] = ']'; + recursive = true; + break; + case '(': + boundary[1] = ')'; + recursive = true; + break; + case '<': + boundary[1] = '>'; + recursive = true; + break; + } + p++; + + unsigned int depth = 1; + while (*p != '\0') + { + if (*p == boundary[1]) + { + depth--; + if (depth == 0) + { + *cp = p; + return true; + } + } + else if (recursive && boundary[0] == *p) + depth++; + vStringPut (vstr, *p); + p++; + } + return false; +} + +extern bool rubyParsePercentString (const unsigned char** cp, vString* vstr) +{ + const unsigned char *p = *cp; + + switch (*p) + { + case 'q': + ++p; + if (rubyParsePercent_q(&p, vstr)) + { + *cp = p; + return true; + } + break; + } + return false; +} + /* If the current scope is A.B, and the name is B.C, B is overlapped. * In that case, the function returns true. Else false. */ diff --git a/parsers/x-ruby.h b/parsers/x-ruby.h index 231ebbfc0a..9767cb21d9 100644 --- a/parsers/x-ruby.h +++ b/parsers/x-ruby.h @@ -37,6 +37,7 @@ extern bool rubyCanMatchKeyword (const unsigned char** s, const char* literal); extern bool rubyCanMatchKeywordWithAssign (const unsigned char** s, const char* literal); extern bool rubyParseString (const unsigned char** cp, unsigned char boundary, vString* vstr); +extern bool rubyParsePercentString (const unsigned char** cp, vString* vstr); extern bool rubyParseMethodName (const unsigned char **cp, vString* vstr); extern bool rubyParseModuleName (const unsigned char **cp, vString* vstr);