summaryrefslogtreecommitdiff
path: root/lib/coderay
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-04-17 00:03:51 +0000
committermurphy <murphy@rubychan.de>2010-04-17 00:03:51 +0000
commite84bb5d9cf6a40bafbde0c3bcc3c99adbfd18c09 (patch)
tree618ba6c85f0ac44472acc70935146edeae00e7b9 /lib/coderay
parent8b22841f80adce856445d1998098511d829f2438 (diff)
downloadcoderay-e84bb5d9cf6a40bafbde0c3bcc3c99adbfd18c09.tar.gz
Fixing bug in Java and JSON scanners (unfinished strings where not closed correctly).
Diffstat (limited to 'lib/coderay')
-rw-r--r--lib/coderay/scanners/java.rb2
-rw-r--r--lib/coderay/scanners/json.rb8
2 files changed, 3 insertions, 7 deletions
diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb
index 2dfb1b6..e4a7421 100644
--- a/lib/coderay/scanners/java.rb
+++ b/lib/coderay/scanners/java.rb
@@ -149,7 +149,7 @@ module Scanners
elsif scan(/\\./m)
kind = :content
elsif scan(/ \\ | $ /x)
- tokens << [:close, :delimiter]
+ tokens << [:close, state]
kind = :error
state = :initial
else
diff --git a/lib/coderay/scanners/json.rb b/lib/coderay/scanners/json.rb
index 163ec46..ca74ff3 100644
--- a/lib/coderay/scanners/json.rb
+++ b/lib/coderay/scanners/json.rb
@@ -14,9 +14,6 @@ module Scanners
:error, :integer, :operator, :value,
] # :nodoc:
- CONSTANTS = %w( true false null ) # :nodoc:
- IDENT_KIND = WordList.new(:key).add(CONSTANTS, :value) # :nodoc:
-
ESCAPE = / [bfnrt\\"\/] /x # :nodoc:
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc:
@@ -26,7 +23,6 @@ module Scanners
state = :initial
stack = []
- string_delimiter = nil
key_expected = false
until eos?
@@ -50,7 +46,7 @@ module Scanners
when '}', ']' then stack.pop # no error recovery, but works for valid JSON
end
elsif match = scan(/ true | false | null /x)
- kind = IDENT_KIND[match]
+ kind = :value
elsif match = scan(/-?(?:0|[1-9]\d*)/)
kind = :integer
if scan(/\.\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+/)
@@ -79,7 +75,7 @@ module Scanners
elsif scan(/\\./m)
kind = :content
elsif scan(/ \\ | $ /x)
- tokens << [:close, :delimiter]
+ tokens << [:close, state]
kind = :error
state = :initial
else