diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2011-08-26 10:09:27 +0200 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2011-10-27 12:26:49 +0200 |
commit | 69542150b2863a2b715e03682539ec68402cb0ff (patch) | |
tree | d726f3a87b38bfc32cb07342b8e7efce74b60654 | |
parent | 3077842ea7098c51b0b0e5b4fad88fbe5e8e29a6 (diff) | |
download | otp-69542150b2863a2b715e03682539ec68402cb0ff.tar.gz otp-69542150b2863a2b715e03682539ec68402cb0ff.tar.bz2 otp-69542150b2863a2b715e03682539ec68402cb0ff.zip |
erl_interface tests: Eliminate use of deprecated regexp module
-rw-r--r-- | lib/erl_interface/test/all_SUITE_data/init_tc.erl | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/erl_interface/test/all_SUITE_data/init_tc.erl b/lib/erl_interface/test/all_SUITE_data/init_tc.erl index 8157d590fc..8db4667bf9 100644 --- a/lib/erl_interface/test/all_SUITE_data/init_tc.erl +++ b/lib/erl_interface/test/all_SUITE_data/init_tc.erl @@ -40,23 +40,11 @@ run([]) -> run1(Name) -> CFile = Name ++ ".c", {ok, Bin} = file:read_file(CFile), - String = binary_to_list(Bin), - - %% This ConstPart stuff is because you can't retrieve part of a match. - %% Long live Perl! - - ConstPart = "\nTESTCASE\\(", - ConstPartLen = 10, - {match, Matches} = regexp:matches(String, ConstPart++"[_a-zA-Z]*"), - Cases = get_names(Matches, ConstPartLen, Bin, []), + RE = "\nTESTCASE\\(([_a-zA-Z]*)\\)", + {match, Cases0} = re:run(Bin, RE, [{capture,all_but_first,list},global]), + Cases = lists:concat(Cases0), generate(Name, Cases). -get_names([{Start, Length}|Rest], Skip, Bin, Result) -> - Name = binary_to_list(Bin, Start+Skip, Start+Length-1), - get_names(Rest, Skip, Bin, [Name|Result]); -get_names([], _Skip, _Bin, Result) -> - lists:reverse(Result). - generate(TcName, Cases) -> Hrl = TcName ++ "_cases.hrl", {ok, HrlFile} = file:open(Hrl, write), |