On 11.08.2009, at 07:36, Paul Davis wrote:
diff -wur mochiweb/src/mochiweb_headers.erl cmw/mochiweb_headers.erl
--- mochiweb/src/mochiweb_headers.erl 2009-08-11 00:22:33.000000000 -0400
+++ cmw/mochiweb_headers.erl    2009-08-11 00:23:31.000000000 -0400
@@ -168,7 +168,7 @@
    V0 ++ ", " ++ V1.

normalize(K) when is_list(K) ->
-    string:to_lower(K);
+    mochiweb_util:to_lower(K);
normalize(K) when is_atom(K) ->
    normalize(atom_to_list(K));
normalize(K) when is_binary(K) ->
diff -wur mochiweb/src/mochiweb_html.erl cmw/mochiweb_html.erl
--- mochiweb/src/mochiweb_html.erl      2009-08-11 00:26:21.000000000 -0400
+++ cmw/mochiweb_html.erl       2009-08-11 00:23:31.000000000 -0400
@@ -330,7 +330,7 @@
    end.

parse_flag({start_tag, B, _, false}) ->
-    case string:to_lower(binary_to_list(B)) of
+    case mochiweb_util:to_lower(binary_to_list(B)) of
        "script" ->
            script;
        "textarea" ->
@@ -551,7 +551,7 @@
norm(Tag) when is_binary(Tag) ->
    Tag;
norm(Tag) ->
-    list_to_binary(string:to_lower(Tag)).
+    list_to_binary(mochiweb_util:to_lower(Tag)).

test_destack() ->
    {<<"a">>, [], []} =
diff -wur mochiweb/src/mochiweb_multipart.erl cmw/ mochiweb_multipart.erl --- mochiweb/src/mochiweb_multipart.erl 2009-08-11 00:22:33.000000000 -0400
+++ cmw/mochiweb_multipart.erl  2009-08-11 00:23:31.000000000 -0400
@@ -103,7 +103,7 @@
split_header(Line) ->
    {Name, [$: | Value]} = lists:splitwith(fun (C) -> C =/= $: end,
                                           binary_to_list(Line)),
-    {string:to_lower(string:strip(Name)),
+    {mochiweb_util:to_lower(string:strip(Name)),
     mochiweb_util:parse_header(Value)}.

read_chunk(Req, Length) when Length > 0 ->
diff -wur mochiweb/src/mochiweb_util.erl cmw/mochiweb_util.erl
--- mochiweb/src/mochiweb_util.erl      2009-08-11 00:22:33.000000000 -0400
+++ cmw/mochiweb_util.erl       2009-08-11 00:23:31.000000000 -0400
@@ -12,6 +12,7 @@
-export([shell_quote/1, cmd/1, cmd_string/1, cmd_port/2]).
-export([record_to_proplist/2, record_to_proplist/3]).
-export([safe_relative_path/1, partition/2]).
+-export([to_lower/1]).
-export([test/0]).

-define(PERCENT, 37).  % $\%
@@ -78,7 +79,7 @@
        [] ->
            "";
        _ ->
-            string:join(lists:reverse(Acc), "/")
+            join(lists:reverse(Acc), "/")
    end;
safe_relative_path(P, Acc) ->
    case partition(P, "/") of
@@ -238,7 +239,7 @@
urlsplit_scheme([], Acc) ->
    {"", lists:reverse(Acc)};
urlsplit_scheme(":" ++ Rest, Acc) ->
-    {string:to_lower(lists:reverse(Acc)), Rest};
+    {to_lower(lists:reverse(Acc)), Rest};
urlsplit_scheme([C | Rest], Acc) ->
    urlsplit_scheme(Rest, [C | Acc]).

@@ -390,11 +391,11 @@
                        %% Skip anything with no value
                        Acc;
                    {Name, [$\= | Value]} ->
-                        [{string:to_lower(string:strip(Name)),
+                        [{to_lower(string:strip(Name)),
                          unquote_header(string:strip(Value))} | Acc]
                end
        end,
-    {string:to_lower(Type),
+    {to_lower(Type),
     lists:foldr(F, [], Parts)}.

unquote_header("\"" ++ Rest) ->
@@ -437,6 +438,20 @@
shell_quote([C | Rest], Acc) ->
    shell_quote(Rest, [C | Acc]).

+to_lower_char(C) when is_integer(C),  C >= $A, C =< $Z ->
+    C + 32;
+to_lower_char(C) when is_integer(C),  C >= 16#C1, C =< 16#D6 ->
+    C + 32;
+to_lower_char(C) when is_integer(C),  C >= 16#D8, C =< 16#DE ->
+    C + 32;
+to_lower_char(C) ->
+    C.
+
+to_lower(S) when is_list(S) ->
+    [to_lower_char(C) || C <- S];
+to_lower(C) when is_integer(C) ->
+    to_lower_char(C).
+
test() ->
    test_join(),
    test_quote_plus(),

All of those to_lower related differences can be reverted, I added that patch way back when we were still supporting older Erlang versions (R11Bx IIRC), and mochiweb was using string:to_lower() which was added in some later version of Erlang.

Cheers,
Chris
--
Christopher Lenz
  cmlenz at gmx.de
  http://www.cmlenz.net/

Reply via email to