Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Switch regexp module to re and fix obsolete guard

  • Loading branch information...
commit 98b443a41f3d2043f8a05b94382012019d53535b 1 parent 3ba1ad0
Andrew Thompson authored February 06, 2011
2  elibs/reg.erl
@@ -818,7 +818,7 @@ gsub_bin(Bin, P, Nfa, Rep) ->
818 818
 split(S, " ") -> split(S, "[ \t]+", true);	%This is really special!
819 819
 split(S, Regexp) -> split(S, Regexp, false).
820 820
 
821  
-split(S, Regexp, Trim) when list(Regexp) ->
  821
+split(S, Regexp, Trim) when is_list(Regexp) ->
822 822
     case parse(Regexp) of
823 823
 	{ok,RE} -> split(S, RE, Trim);
824 824
 	{error,E} -> {error,E}
15  elibs/server.erl
@@ -67,17 +67,18 @@ handle_method_dispatch(invalid, Sock, _Host, _Header) ->
67 67
   ok = gen_tcp:close(Sock).
68 68
   
69 69
 extract_method_name(Header) ->
70  
-  case regexp:match(Header, "....git[ -][a-z\-]+ ") of
71  
-    {match, Start, Length} ->
72  
-      {ok, string:substr(Header, Start + 8, Length - 9)};
  70
+  case re:run(Header, "....git[ -][a-z\\-]+ ", []) of
  71
+    {match, [{Start, Length}]} ->
  72
+      {ok, string:substr(Header, Start + 9, Length - 9)};
73 73
     _Else ->
74 74
       invalid
75 75
   end.
76 76
   
77 77
 extract_host(Header) ->
78  
-  case regexp:match(string:to_lower(Header), "\000host=[^\000]+\000") of
79  
-    {match, Start, Length} ->
80  
-      {ok, string:substr(Header, Start + 6, Length - 7)};
  78
+  case re:run(string:to_lower(Header), "\\000host=[^\\000]+\\000", []) of
  79
+    {match, [{Start, Length}]} ->
  80
+      io:format("Header: ~p Start ~p Length ~p~n", [Header, Start, Length]),
  81
+      {ok, string:substr(Header, Start + 7, Length - 7)};
81 82
     _Else ->
82 83
       {ok, "invalid"}
83  
-  end.
  84
+  end.
8  elibs/upload_pack.erl
@@ -21,9 +21,9 @@ handle(Sock, Host, Header) ->
21 21
 
22 22
 % Extract the repo from the header.
23 23
 extract_repo_path(Sock, Host, Header) ->
24  
-  case regexp:match(Header, " /[^\000]+\000") of
25  
-    {match, Start, Length} ->
26  
-      Path = string:substr(Header, Start + 2, Length - 3),
  24
+  case re:run(Header, " /[^\\000]+\\000", []) of
  25
+    {match, [{Start, Length}]} ->
  26
+      Path = string:substr(Header, Start + 3, Length - 3),
27 27
       convert_path(Sock, Host, Path);
28 28
     _Else ->
29 29
       invalid
@@ -130,4 +130,4 @@ last_byte(Bin) ->
130 130
   Size = erlang:size(Bin),
131 131
   {_B1, B2} = split_binary(Bin, Size - 1),
132 132
   [Byte] = binary_to_list(B2),
133  
-  Byte.
  133
+  Byte.

0 notes on commit 98b443a

Please sign in to comment.
Something went wrong with that request. Please try again.