aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/string.erl
diff options
context:
space:
mode:
authorSeyed Mirsadeghi <[email protected]>2018-03-01 06:29:54 -0500
committerDan Gudmundsson <[email protected]>2018-03-01 12:29:54 +0100
commit693315d23293cb107c2ad7e50960dee40d7a3ca9 (patch)
tree9541bc9c715acfe51d591250c450f591e4b642e7 /lib/stdlib/src/string.erl
parent6c03897a8aceab079c7169b01d9611e0708d4f9e (diff)
downloadotp-693315d23293cb107c2ad7e50960dee40d7a3ca9.tar.gz
otp-693315d23293cb107c2ad7e50960dee40d7a3ca9.tar.bz2
otp-693315d23293cb107c2ad7e50960dee40d7a3ca9.zip
ERL-558 Add the missing function clause for string:prefix (#1702)
OTP-14942
Diffstat (limited to 'lib/stdlib/src/string.erl')
-rw-r--r--lib/stdlib/src/string.erl8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/stdlib/src/string.erl b/lib/stdlib/src/string.erl
index ab041ff53c..6f5e617230 100644
--- a/lib/stdlib/src/string.erl
+++ b/lib/stdlib/src/string.erl
@@ -411,10 +411,12 @@ to_number(_, Number, Rest, _, Tail) ->
%% Return the remaining string with prefix removed or else nomatch
-spec prefix(String::unicode:chardata(), Prefix::unicode:chardata()) ->
'nomatch' | unicode:chardata().
-prefix(Str, []) -> Str;
prefix(Str, Prefix0) ->
- Prefix = unicode:characters_to_list(Prefix0),
- case prefix_1(Str, Prefix) of
+ Result = case unicode:characters_to_list(Prefix0) of
+ [] -> Str;
+ Prefix -> prefix_1(Str, Prefix)
+ end,
+ case Result of
[] when is_binary(Str) -> <<>>;
Res -> Res
end.