Permalink
Browse files

Fixes for split and pcre_exec.

  • Loading branch information...
1 parent b7180e4 commit 5f37d7dd94c87390b7259bd5c9b46c3f03ecb3d6 @StefanKarpinski StefanKarpinski committed Apr 16, 2012
Showing with 5 additions and 4 deletions.
  1. +1 −0 base/pcre.jl
  2. +4 −4 base/string.jl
View
1 base/pcre.jl
@@ -94,6 +94,7 @@ pcre_study(re::Array{Uint8}) = pcre_study(re, int32(0))
function pcre_exec(regex::Array{Uint8}, extra::Ptr{Void},
str::ByteString, offset::Integer, options::Integer, cap::Bool)
+ if offset > length(str) error("pcre_exec: index out of range") end
ncap = pcre_info(regex, extra, PCRE_INFO_CAPTURECOUNT, Int32)
ovec = Array(Int32, 3(ncap+1))
n = ccall(dlsym(_jl_libpcre, :pcre_exec), Int32,
View
8 base/string.jl
@@ -827,12 +827,12 @@ function split(str::String, splitter, limit::Integer, keep_empty::Bool)
end
return strs
end
-split(s::String, spl, n::Integer) = split(s, spl, true, n)
-split(s::String, spl, keep::Bool) = split(s, spl, keep, 0)
-split(s::String, spl) = split(s, spl, true, 0)
+split(s::String, spl, n::Integer) = split(s, spl, n, true)
+split(s::String, spl, keep::Bool) = split(s, spl, 0, keep)
+split(s::String, spl) = split(s, spl, 0, true)
# a bit oddball, but standard behavior in Perl, Ruby & Python:
-split(str::String) = split(str, [' ','\t','\n','\v','\f','\r'], false, 0)
+split(str::String) = split(str, [' ','\t','\n','\v','\f','\r'], 0, false)
function print_joined(strings, delim, last)
i = start(strings)

0 comments on commit 5f37d7d

Please sign in to comment.