Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch regexp module to re and fix obsolete guard

  • Loading branch information...
commit 98b443a41f3d2043f8a05b94382012019d53535b 1 parent 3ba1ad0
@Vagabond authored
Showing with 13 additions and 12 deletions.
  1. +1 −1  elibs/reg.erl
  2. +8 −7 elibs/server.erl
  3. +4 −4 elibs/upload_pack.erl
View
2  elibs/reg.erl
@@ -818,7 +818,7 @@ gsub_bin(Bin, P, Nfa, Rep) ->
split(S, " ") -> split(S, "[ \t]+", true); %This is really special!
split(S, Regexp) -> split(S, Regexp, false).
-split(S, Regexp, Trim) when list(Regexp) ->
+split(S, Regexp, Trim) when is_list(Regexp) ->
case parse(Regexp) of
{ok,RE} -> split(S, RE, Trim);
{error,E} -> {error,E}
View
15 elibs/server.erl
@@ -67,17 +67,18 @@ handle_method_dispatch(invalid, Sock, _Host, _Header) ->
ok = gen_tcp:close(Sock).
extract_method_name(Header) ->
- case regexp:match(Header, "....git[ -][a-z\-]+ ") of
- {match, Start, Length} ->
- {ok, string:substr(Header, Start + 8, Length - 9)};
+ case re:run(Header, "....git[ -][a-z\\-]+ ", []) of
+ {match, [{Start, Length}]} ->
+ {ok, string:substr(Header, Start + 9, Length - 9)};
_Else ->
invalid
end.
extract_host(Header) ->
- case regexp:match(string:to_lower(Header), "\000host=[^\000]+\000") of
- {match, Start, Length} ->
- {ok, string:substr(Header, Start + 6, Length - 7)};
+ case re:run(string:to_lower(Header), "\\000host=[^\\000]+\\000", []) of
+ {match, [{Start, Length}]} ->
+ io:format("Header: ~p Start ~p Length ~p~n", [Header, Start, Length]),
+ {ok, string:substr(Header, Start + 7, Length - 7)};
_Else ->
{ok, "invalid"}
- end.
+ end.
View
8 elibs/upload_pack.erl
@@ -21,9 +21,9 @@ handle(Sock, Host, Header) ->
% Extract the repo from the header.
extract_repo_path(Sock, Host, Header) ->
- case regexp:match(Header, " /[^\000]+\000") of
- {match, Start, Length} ->
- Path = string:substr(Header, Start + 2, Length - 3),
+ case re:run(Header, " /[^\\000]+\\000", []) of
+ {match, [{Start, Length}]} ->
+ Path = string:substr(Header, Start + 3, Length - 3),
convert_path(Sock, Host, Path);
_Else ->
invalid
@@ -130,4 +130,4 @@ last_byte(Bin) ->
Size = erlang:size(Bin),
{_B1, B2} = split_binary(Bin, Size - 1),
[Byte] = binary_to_list(B2),
- Byte.
+ Byte.
Please sign in to comment.
Something went wrong with that request. Please try again.