From f56afb1ea2dbd59262947ed27bb1913394aeb5c6 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Sat, 15 Aug 2009 02:09:16 +0000 Subject: replace regexp with re. Thanks Kim Shrier, Gordon Stratton. Closes COUCHDB-245 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@804428 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_config.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/couchdb/couch_config.erl') diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl index c6fffe49..1e9ae41f 100644 --- a/src/couchdb/couch_config.erl +++ b/src/couchdb/couch_config.erl @@ -184,13 +184,13 @@ parse_ini_file(IniFile) -> throw({startup_error, Msg}) end, - {ok, Lines} = regexp:split(binary_to_list(IniBin), "\r\n|\n|\r|\032"), + Lines = re:split(IniBin, "\r\n|\n|\r|\032", [{return, list}]), {_, ParsedIniValues} = lists:foldl(fun(Line, {AccSectionName, AccValues}) -> case string:strip(Line) of "[" ++ Rest -> - case regexp:split(Rest, "\\]") of - {ok, [NewSectionName, ""]} -> + case re:split(Rest, "\\]", [{return, list}]) of + [NewSectionName, ""] -> {NewSectionName, AccValues}; _Else -> % end bracket not at end, ignore this line {AccSectionName, AccValues} @@ -198,20 +198,20 @@ parse_ini_file(IniFile) -> ";" ++ _Comment -> {AccSectionName, AccValues}; Line2 -> - case regexp:split(Line2, "\s?=\s?") of - {ok, [_SingleElement]} -> % no "=" found, ignore this line + case re:split(Line2, "\s?=\s?", [{return, list}]) of + [_SingleElement] -> % no "=" found, ignore this line {AccSectionName, AccValues}; - {ok, [""|_LineValues]} -> % line begins with "=", ignore + [""|_LineValues] -> % line begins with "=", ignore {AccSectionName, AccValues}; - {ok, [ValueName|LineValues]} -> % yeehaw, got a line! + [ValueName|LineValues] -> % yeehaw, got a line! RemainingLine = couch_util:implode(LineValues, "="), % removes comments - case regexp:split(RemainingLine, " ;|\t;") of - {ok, [[]]} -> + case re:split(RemainingLine, " ;|\t;", [{return, list}]) of + [[]] -> % empty line means delete this key ets:delete(?MODULE, {AccSectionName, ValueName}), {AccSectionName, AccValues}; - {ok, [LineValue | _Rest]} -> + [LineValue | _Rest] -> {AccSectionName, [{{AccSectionName, ValueName}, LineValue} | AccValues]} end -- cgit v1.2.3