aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-05-06 14:28:42 +0200
committerBjörn Gustavsson <[email protected]>2015-05-06 14:34:52 +0200
commitfd9525a6764e3aa0c29e6456ddaf75035559ebd5 (patch)
treea13ad081a3ee6ef5b19bb8b093b9c86b3e2cf538 /lib
parent83ff5ec3ced8ce1c456bfdf75fcbf5be01385388 (diff)
downloadotp-fd9525a6764e3aa0c29e6456ddaf75035559ebd5.tar.gz
otp-fd9525a6764e3aa0c29e6456ddaf75035559ebd5.tar.bz2
otp-fd9525a6764e3aa0c29e6456ddaf75035559ebd5.zip
Correct filename:split(<<"">>)
filename:split("") returns [], while filename:split(<<"">>) returns [<<"/">>]. Since the support in the filename module for binary arguments is much more recent than support for strings, change filename:split(<<"">>) so that it returns []. Noticed-by: KOUCHANG
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/filename.erl2
-rw-r--r--lib/stdlib/test/filename_SUITE.erl4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index 632af17e2a..68bd4f71cc 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -648,7 +648,7 @@ split(Name0) ->
unix_splitb(Name) ->
L = binary:split(Name,[<<"/">>],[global]),
LL = case L of
- [<<>>|Rest] ->
+ [<<>>|Rest] when Rest =/= [] ->
[<<"/">>|Rest];
_ ->
L
diff --git a/lib/stdlib/test/filename_SUITE.erl b/lib/stdlib/test/filename_SUITE.erl
index 6f1d1a891d..70e7ad9788 100644
--- a/lib/stdlib/test/filename_SUITE.erl
+++ b/lib/stdlib/test/filename_SUITE.erl
@@ -395,6 +395,8 @@ split(Config) when is_list(Config) ->
?line ["foo", "bar", "hello"]= filename:split("foo////bar//hello"),
?line ["foo", "bar", "hello"]= filename:split(["foo//",'//bar//h',"ello"]),
?line ["foo", "bar", "hello"]= filename:split(["foo//",'//bar//h'|ello]),
+ ["/"] = filename:split("/"),
+ [] = filename:split(""),
case os:type() of
{win32,_} ->
?line ["a:/","msdev","include"] =
@@ -767,6 +769,8 @@ split_bin(Config) when is_list(Config) ->
[<<"/">>,<<"usr">>,<<"local">>,<<"bin">>] = filename:split(<<"/usr/local/bin">>),
[<<"foo">>,<<"bar">>]= filename:split(<<"foo/bar">>),
[<<"foo">>, <<"bar">>, <<"hello">>]= filename:split(<<"foo////bar//hello">>),
+ [<<"/">>] = filename:split(<<"/">>),
+ [] = filename:split(<<"">>),
case os:type() of
{win32,_} ->
[<<"a:/">>,<<"msdev">>,<<"include">>] =