aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/re_SUITE.erl
diff options
context:
space:
mode:
authorRory Byrne <[email protected]>2010-01-16 11:18:39 +0000
committerBjörn Gustavsson <[email protected]>2010-01-27 12:27:35 +0100
commit98cb178fe80be7ee560c16e02dc31bf3df7700c8 (patch)
treedf6db0aa87d742af449463c7eb8c76f6c14df168 /lib/stdlib/test/re_SUITE.erl
parentdf88b47cdafcc2e04452456942ea572a7b72e2f2 (diff)
downloadotp-98cb178fe80be7ee560c16e02dc31bf3df7700c8.tar.gz
otp-98cb178fe80be7ee560c16e02dc31bf3df7700c8.tar.bz2
otp-98cb178fe80be7ee560c16e02dc31bf3df7700c8.zip
Fix re:replace/4 to handle binary unicode output when nothing replaced
A bug with re:replace/4 causes an exception when: (a) it's given a unicode charlist as input; (b) it's set to {return,binary}; and (c) it finds nothing to replace. The problem is: when re:replace/4 does not find anything to replace in its Subject input, it calls iolist_to_binary on this data. This fails if the original input is a charlist with non-ascii codepoints.
Diffstat (limited to 'lib/stdlib/test/re_SUITE.erl')
-rw-r--r--lib/stdlib/test/re_SUITE.erl4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl
index 98eb66d1fb..a9c9afea94 100644
--- a/lib/stdlib/test/re_SUITE.erl
+++ b/lib/stdlib/test/re_SUITE.erl
@@ -289,6 +289,10 @@ replace_return(Config) when is_list(Config) ->
?line <<"iXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\9X",[{return,binary}]),
?line <<"jXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\10X",[{return,binary}]),
?line <<"Xk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\11X",[{return,binary}]),
+ ?line "a\x{400}bcX" = re:replace("a\x{400}bcd","d","X",[global,{return,list},unicode]),
+ ?line <<"a",208,128,"bcX">> = re:replace("a\x{400}bcd","d","X",[global,{return,binary},unicode]),
+ ?line "a\x{400}bcd" = re:replace("a\x{400}bcd","Z","X",[global,{return,list},unicode]),
+ ?line <<"a",208,128,"bcd">> = re:replace("a\x{400}bcd","Z","X",[global,{return,binary},unicode]),
?t:timetrap_cancel(Dog),
ok.