Permalink
Browse files

Work-around (OSX) awk POSIX conformance issue #4.

  • Loading branch information...
1 parent 19ee376 commit 7deb01857e551e9b547323ca49692e1bf750dfb7 @step- committed Apr 10, 2015
Showing with 15 additions and 4 deletions.
  1. +7 −4 JSON.awk
  2. +2 −0 test-cases/20150410-issue-004-test.json
  3. +6 −0 test-cases/20150410-issue-004-test.log
View
@@ -1,7 +1,7 @@
#!/bin/awk -f
#
# Software: JSON.awk - a practical JSON parser written in awk
-# Version: 1.10
+# Version: 1.11
# Author: step- on github.com
# License: This software is licensed under the MIT or the Apache 2 license.
# Project home: https://github.com/step-/JSON.awk.git
@@ -154,10 +154,13 @@ function parse_value(a1, a2, jpath,ret,x) { #{{{
} else if (TOKEN == "[") {
if (ret = parse_array(jpath)) {
return ret
- }
- } else if (TOKEN ~ /^(|[^0-9])$/) {
+ }
+ } else if (TOKEN == "") { #test case 20150410 #4
+ report("value", "EOF")
+ return 9
+ } else if (TOKEN ~ /^([^0-9])$/) {
# At this point, the only valid single-character tokens are digits.
- report("value", TOKEN!="" ? TOKEN : "EOF")
+ report("value", TOKEN)
return 9
} else {
VALUE=TOKEN
@@ -0,0 +1,2 @@
+{"a":
+
@@ -0,0 +1,6 @@
+# { echo 20150410-issue-004-test.json ; echo ; } | awk -f ../JSON.awk
+20150410-issue-004-test.json: expected <value> but got <EOF> at input token 4
+{ "a" : <<EOF>>
+invalid: 20150410-issue-004-test.json
+expected <value> but got <EOF> at input token 4
+{ "a" : <<EOF>>

0 comments on commit 7deb018

Please sign in to comment.