summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/couchdb/couch_config.erl20
-rw-r--r--src/couchdb/couch_config_writer.erl16
-rw-r--r--src/couchdb/couch_httpd_db.erl12
-rw-r--r--src/couchdb/couch_log.erl3
-rw-r--r--src/couchdb/couch_server.erl6
-rw-r--r--src/couchdb/couch_view.erl2
6 files changed, 27 insertions, 32 deletions
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
diff --git a/src/couchdb/couch_config_writer.erl b/src/couchdb/couch_config_writer.erl
index a829b40a..cb855ea8 100644
--- a/src/couchdb/couch_config_writer.erl
+++ b/src/couchdb/couch_config_writer.erl
@@ -34,7 +34,7 @@ save_to_file({{Section, Option}, Value}, File) ->
% open file and create a list of lines
{ok, Stream} = file:read_file(File),
OldFileContents = binary_to_list(Stream),
- {ok, Lines} = regexp:split(OldFileContents, "\r\n|\n|\r|\032"),
+ Lines = re:split(OldFileContents, "\r\n|\n|\r|\032", [{return, list}]),
% prepare input variables
SectionName = "[" ++ Section ++ "]",
@@ -136,13 +136,10 @@ append_var_to_section({{Section, Option}, Value}, Line, OldCurrentSection, DoneO
%% @doc Tries to match a line against a pattern specifying a ini module or
%% section ("[Section]"). Returns OldSection if no match is found.
parse_module(Line, OldSection) ->
- case regexp:match(Line, "^\\[([a-zA-Z0-9\_-]*)\\]$") of
+ case re:run(Line, "^\\[([a-zA-Z0-9\_-]*)\\]$", [{capture, global}]) of
nomatch ->
OldSection;
- {error, Error} ->
- io:format("ini file regex error module: '~s'~n", [Error]),
- OldSection;
- {match, Start, Length} ->
+ {match, [_, {Start, Length}]} ->
string:substr(Line, Start, Length)
end.
@@ -152,12 +149,9 @@ parse_module(Line, OldSection) ->
%% Option is not found. Returns a new line composed of the Option and
%% Value otherwise.
parse_variable(Line, Option, Value) ->
- case regexp:match(Line, "^" ++ Option ++ "\s?=") of
+ case re:run(Line, "^" ++ Option ++ "\s?=", [{capture, none}]) of
nomatch ->
nomatch;
- {error, Error}->
- io:format("ini file regex error variable: '~s'~n", [Error]),
- nomatch;
- {match, _Start, _Length} ->
+ match ->
Option ++ " = " ++ Value
end.
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 915a5eae..a3ac69ae 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -496,8 +496,8 @@ db_req(#httpd{path_parts=[_,<<"_revs_limit">>]}=Req, _Db) ->
% as slashes in document IDs must otherwise be URL encoded.
db_req(#httpd{method='GET',mochi_req=MochiReq, path_parts=[DbName,<<"_design/",_/binary>>|_]}=Req, _Db) ->
PathFront = "/" ++ couch_httpd:quote(binary_to_list(DbName)) ++ "/",
- RawSplit = regexp:split(MochiReq:get(raw_path),"_design%2F"),
- {ok, [PathFront|PathTail]} = RawSplit,
+ [PathFront|PathTail] = re:split(MochiReq:get(raw_path), "_design%2F",
+ [{return, list}]),
couch_httpd:send_redirect(Req, PathFront ++ "_design/" ++
mochiweb_util:join(PathTail, "_design%2F"));
@@ -1008,12 +1008,12 @@ extract_header_rev(Req, ExplicitRev) ->
parse_copy_destination_header(Req) ->
Destination = couch_httpd:header_value(Req, "Destination"),
- case regexp:match(Destination, "\\?") of
+ case re:run(Destination, "\\?", [{capture, none}]) of
nomatch ->
{list_to_binary(Destination), {0, []}};
- {match, _, _} ->
- {ok, [DocId, RevQueryOptions]} = regexp:split(Destination, "\\?"),
- {ok, [_RevQueryKey, Rev]} = regexp:split(RevQueryOptions, "="),
+ match ->
+ [DocId, RevQs] = re:split(Destination, "\\?", [{return, list}]),
+ [_RevQueryKey, Rev] = re:split(RevQs, "=", [{return, list}]),
{Pos, RevId} = couch_doc:parse_rev(Rev),
{list_to_binary(DocId), {Pos, [RevId]}}
end.
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index 83fa6e06..5a45c207 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -119,7 +119,8 @@ terminate(_Arg, {Fd, _LoggingLevel}) ->
log(Fd, Pid, Level, Format, Args) ->
Msg = io_lib:format(Format, Args),
ok = io:format("[~s] [~p] ~s~n", [Level, Pid, Msg]), % dump to console too
- {ok, Msg2, _} = regexp:gsub(lists:flatten(Msg),"\\r\\n|\\r|\\n", "\r\n"),
+ Msg2 = re:replace(lists:flatten(Msg),"\\r\\n|\\r|\\n", "\r\n",
+ [global, {return, list}]),
ok = io:format(Fd, "[~s] [~s] [~p] ~s\r~n\r~n", [httpd_util:rfc1123_date(), Level, Pid, Msg2]).
read(Bytes, Offset) ->
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 388647b8..23de5284 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -93,10 +93,10 @@ delete(DbName, Options) ->
gen_server:call(couch_server, {delete, DbName, Options}).
check_dbname(#server{dbname_regexp=RegExp}, DbName) ->
- case regexp:match(DbName, RegExp) of
+ case re:run(DbName, RegExp, [{capture, none}]) of
nomatch ->
{error, illegal_database_name};
- _Match ->
+ match ->
ok
end.
@@ -150,7 +150,7 @@ init([]) ->
% spawn here so couch_config doesn't try to call itself
spawn(fun() -> hash_admin_passwords() end)
end),
- {ok, RegExp} = regexp:parse("^[a-z][a-z0-9\\_\\$()\\+\\-\\/]*$"),
+ {ok, RegExp} = re:compile("^[a-z][a-z0-9\\_\\$()\\+\\-\\/]*$"),
ets:new(couch_dbs_by_name, [set, private, named_table]),
ets:new(couch_dbs_by_pid, [set, private, named_table]),
ets:new(couch_dbs_by_lru, [ordered_set, private, named_table]),
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index a0819ef5..b5509b5d 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -90,7 +90,7 @@ cleanup_index_files(Db) ->
% filter out the ones in use
DeleteFiles = lists:filter(fun(FilePath) ->
- regexp:first_match(FilePath, RegExp)==nomatch
+ re:run(FilePath, RegExp, [{capture, none}]) == nomatch
end, FileList),
% delete unused files
?LOG_DEBUG("deleting unused view index files: ~p",[DeleteFiles]),