]> granicus.if.org Git - jq/commitdiff
Restore `split/1`; don't use regexp (fix #576)
authorNicolas Williams <nico@cryptonector.com>
Fri, 3 Oct 2014 22:52:11 +0000 (17:52 -0500)
committerNicolas Williams <nico@cryptonector.com>
Fri, 3 Oct 2014 22:58:45 +0000 (17:58 -0500)
builtin.c
docs/content/3.manual/manual.yml
tests/all.test

index 4dc34a593debe47cab4674b03796f7501dbf2c75..6f6689427688f18a8f1d4dff405f27714ea03774 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -1046,7 +1046,6 @@ static const char* const jq_builtins[] = {
   //
   // split emits an array for backward compatibility
   "def split($re; flags): [ splits($re; flags) ];",
-  "def split($re): [ splits($re; null) ];",
   //
   // If s contains capture variables, then create a capture object and pipe it to s
   "def sub($re; s):"
index a6dfd81d1a4269d10673b603af769d69907aa2f8..16bee1eb8f17bd9939c78289d78b933a867d0442 100644 (file)
@@ -1736,7 +1736,7 @@ sections:
       input: ("", "")
       output: ['[]', '[]']
 
-  - title: "`split(regex)`, `split(regex; flags)`"
+  - title: "`split(regex; flags)`"
     body: |
 
       For backwards compatibility, `split` emits an array of the strings
@@ -1746,11 +1746,8 @@ sections:
       themselves are excluded.  If regex is the empty string, then the first
       match will be the empty string.
 
-      `split(regex)` can be thought of as a wrapper around `splits(regex)`,
-      and similarly for `split(regex; flags)`.
-
     example:
-    - program: 'split(", *")'
+    - program: 'split(", *"; null)'
       input: '"ab,cd, ef"'
       output: ['"ab","cd","ef"']
 
index d1cdc2ca2a8686e130b580ef6caffd026c8f848a..180789093d32042024f3c8c0ccb412c50be69777 100644 (file)
@@ -869,16 +869,16 @@ capture("(?<a>[a-z]+)-(?<n>[0-9]+)")
 
 [.[] | split(", ")]
 ["a,b, c, d, e,f",", a,b, c, d, e,f, "]
-[["a,b","c","d","e,f"],["","a,b","c","d","e,f",""]]
+[["a,b","c","d","e,f"],["","a,b","c","d","e,f"]]
 
 ########################
-[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")], split(", *")]]
+[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")]]]
 ["a,b, c, d, e,f",", a,b, c, d, e,f, "]
-[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","],["a","b","c","d","e","f"]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "],["","a","b","c","d","e","f",""]]]
+[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "]]]
 
-[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")], split(", +")]]
+[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")]]]
 ["a,b, c, d, e,f",", a,b, c, d, e,f, "]
-[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "],["a,b","c","d","e,f"]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "],["","a,b","c","d","e,f",""]]]
+[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "]]]
 
 # reference to named captures
 gsub("(?<x>.)[^a]*"; "+\(.x)-")