From 282b96ddd9a84b740788c2358ec0f5fedafb7cc6 Mon Sep 17 00:00:00 2001 From: Noah Slater Date: Mon, 6 Jul 2009 00:33:50 +0000 Subject: trimmed trailing whitespace git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791350 13f79535-47bb-0310-9956-ffa450edef68 --- src/mochiweb/mochijson.erl | 8 ++++---- src/mochiweb/mochijson2.erl | 10 +++++----- src/mochiweb/mochinum.erl | 8 ++++---- src/mochiweb/mochiweb_charref.erl | 2 +- src/mochiweb/mochiweb_cookies.erl | 22 +++++++++++----------- src/mochiweb/mochiweb_echo.erl | 2 +- src/mochiweb/mochiweb_headers.erl | 4 ++-- src/mochiweb/mochiweb_html.erl | 2 +- src/mochiweb/mochiweb_request.erl | 22 +++++++++++----------- src/mochiweb/mochiweb_skel.erl | 6 +++--- src/mochiweb/mochiweb_socket_server.erl | 14 +++++++------- src/mochiweb/mochiweb_util.erl | 2 +- 12 files changed, 51 insertions(+), 51 deletions(-) (limited to 'src/mochiweb') diff --git a/src/mochiweb/mochijson.erl b/src/mochiweb/mochijson.erl index 0e887a91..029642ac 100644 --- a/src/mochiweb/mochijson.erl +++ b/src/mochiweb/mochijson.erl @@ -145,7 +145,7 @@ json_encode_proplist([], _State) -> "{}"; json_encode_proplist(Props, State) -> F = fun ({K, V}, Acc) -> - KS = case K of + KS = case K of K when is_atom(K) -> json_encode_string_utf8(atom_to_list(K)); K when is_integer(K) -> @@ -320,12 +320,12 @@ tokenize_string([$\\, $u, C3, C2, C1, C0 | Rest], S, Acc) -> % coalesce UTF-16 surrogate pair? C = dehex(C0) bor (dehex(C1) bsl 4) bor - (dehex(C2) bsl 8) bor + (dehex(C2) bsl 8) bor (dehex(C3) bsl 12), tokenize_string(Rest, ?ADV_COL(S, 6), [C | Acc]); tokenize_string([C | Rest], S, Acc) when C >= $\s; C < 16#10FFFF -> tokenize_string(Rest, ?ADV_COL(S, 1), [C | Acc]). - + tokenize_number(IoList=[C | _], Mode, S=#decoder{input_encoding=utf8}, Acc) when is_list(C); is_binary(C); C >= 16#7f -> List = xmerl_ucs:from_utf8(iolist_to_binary(IoList)), @@ -418,7 +418,7 @@ is_obj({struct, Props}) -> true; (_) -> false - end, + end, lists:all(F, Props). obj_from_list(Props) -> diff --git a/src/mochiweb/mochijson2.erl b/src/mochiweb/mochijson2.erl index 7d7a8aff..8b6adb1f 100644 --- a/src/mochiweb/mochijson2.erl +++ b/src/mochiweb/mochijson2.erl @@ -500,7 +500,7 @@ is_obj({Props}) -> true; (_) -> false - end, + end, lists:all(F, Props). obj_from_list(Props) -> @@ -586,21 +586,21 @@ e2j_test_vec(utf8) -> {[], "[]"}, {[[]], "[[]]"}, {[1, <<"foo">>], "[1,\"foo\"]"}, - + %% json array in a json object {obj_from_list([{<<"foo">>, [123]}]), "{\"foo\":[123]}"}, - + %% json object in a json object {obj_from_list([{<<"foo">>, obj_from_list([{<<"bar">>, true}])}]), "{\"foo\":{\"bar\":true}}"}, - + %% fold evaluation order {obj_from_list([{<<"foo">>, []}, {<<"bar">>, obj_from_list([{<<"baz">>, true}])}, {<<"alice">>, <<"bob">>}]), "{\"foo\":[],\"bar\":{\"baz\":true},\"alice\":\"bob\"}"}, - + %% json object in a json array {[-123, <<"foo">>, obj_from_list([{<<"bar">>, []}]), null], "[-123,\"foo\",{\"bar\":[]},null]"} diff --git a/src/mochiweb/mochinum.erl b/src/mochiweb/mochinum.erl index 4f88f9a5..6a866042 100644 --- a/src/mochiweb/mochinum.erl +++ b/src/mochiweb/mochinum.erl @@ -40,7 +40,7 @@ digits(Float) -> _ -> R end. - + %% @spec frexp(F::float()) -> {Frac::float(), Exp::float()} %% @doc Return the fractional and exponent part of an IEEE 754 double, %% equivalent to the libc function of the same name. @@ -205,7 +205,7 @@ generate(R0, S, MPlus, MMinus, LowOk, HighOk) -> end end. -unpack(Float) -> +unpack(Float) -> <> = <>, {Sign, Exp, Frac}. @@ -243,7 +243,7 @@ test_int_ceil() -> -1 = int_ceil(-1.5), -2 = int_ceil(-2.0), ok. - + test_int_pow() -> 1 = int_pow(1, 1), 1 = int_pow(1, 0), @@ -252,7 +252,7 @@ test_int_pow() -> 100 = int_pow(10, 2), 1000 = int_pow(10, 3), ok. - + test_digits() -> "0" = digits(0), "0.0" = digits(0.0), diff --git a/src/mochiweb/mochiweb_charref.erl b/src/mochiweb/mochiweb_charref.erl index 59fd4a47..d037d2f8 100644 --- a/src/mochiweb/mochiweb_charref.erl +++ b/src/mochiweb/mochiweb_charref.erl @@ -26,7 +26,7 @@ charref([$# | L]) -> end; charref(L) -> entity(L). - + %% @spec test() -> ok %% @doc Run tests for mochiweb_charref. test() -> diff --git a/src/mochiweb/mochiweb_cookies.erl b/src/mochiweb/mochiweb_cookies.erl index acea12ae..b9da37b4 100644 --- a/src/mochiweb/mochiweb_cookies.erl +++ b/src/mochiweb/mochiweb_cookies.erl @@ -29,8 +29,8 @@ cookie(Key, Value) -> cookie(Key, Value, []). -%% @spec cookie(Key::string(), Value::string(), Options::[Option]) -> header() -%% where Option = {max_age, integer()} | {local_time, {date(), time()}} +%% @spec cookie(Key::string(), Value::string(), Options::[Option]) -> header() +%% where Option = {max_age, integer()} | {local_time, {date(), time()}} %% | {domain, string()} | {path, string()} %% | {secure, true | false} %% @@ -118,9 +118,9 @@ age_to_cookie_date(Age, LocalTime) -> %% @spec parse_cookie(string()) -> [{K::string(), V::string()}] %% @doc Parse the contents of a Cookie header field, ignoring cookie %% attributes, and return a simple property list. -parse_cookie("") -> +parse_cookie("") -> []; -parse_cookie(Cookie) -> +parse_cookie(Cookie) -> parse_cookie(Cookie, []). %% @spec test() -> ok @@ -133,8 +133,8 @@ test() -> %% Internal API parse_cookie([], Acc) -> - lists:reverse(Acc); -parse_cookie(String, Acc) -> + lists:reverse(Acc); +parse_cookie(String, Acc) -> {{Token, Value}, Rest} = read_pair(String), Acc1 = case Token of "" -> @@ -173,7 +173,7 @@ read_quoted([$\\, Any | Rest], Acc) -> read_quoted(Rest, [Any | Acc]); read_quoted([C | Rest], Acc) -> read_quoted(Rest, [C | Acc]). - + skip_whitespace(String) -> F = fun (C) -> ?IS_WHITESPACE(C) end, lists:dropwhile(F, String). @@ -182,7 +182,7 @@ read_token(String) -> F = fun (C) -> not ?IS_SEPARATOR(C) end, lists:splitwith(F, String). -skip_past_separator([]) -> +skip_past_separator([]) -> []; skip_past_separator([$; | Rest]) -> Rest; @@ -193,7 +193,7 @@ skip_past_separator([_ | Rest]) -> parse_cookie_test() -> %% RFC example - C1 = "$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"; + C1 = "$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"; Part_Number=\"Rocket_Launcher_0001\"; $Path=\"/acme\"; Shipping=\"FedEx\"; $Path=\"/acme\"", [ @@ -231,8 +231,8 @@ cookie_test() -> C1 = cookie(<<"Customer">>, <<"WILE_E_COYOTE">>, [{path, <<"/acme">>}]), {"Set-Cookie","=NoKey; Version=1"} = cookie("", "NoKey", []), - - LocalTime = calendar:universal_time_to_local_time({{2007, 5, 15}, {13, 45, 33}}), + + LocalTime = calendar:universal_time_to_local_time({{2007, 5, 15}, {13, 45, 33}}), C2 = {"Set-Cookie", "Customer=WILE_E_COYOTE; " "Version=1; " diff --git a/src/mochiweb/mochiweb_echo.erl b/src/mochiweb/mochiweb_echo.erl index f0c455a5..f32d6803 100644 --- a/src/mochiweb/mochiweb_echo.erl +++ b/src/mochiweb/mochiweb_echo.erl @@ -9,7 +9,7 @@ stop() -> mochiweb_socket_server:stop(?MODULE). - + start() -> mochiweb_socket_server:start([{name, ?MODULE}, {port, 6789}, diff --git a/src/mochiweb/mochiweb_headers.erl b/src/mochiweb/mochiweb_headers.erl index 4c0a2d75..b29ff311 100644 --- a/src/mochiweb/mochiweb_headers.erl +++ b/src/mochiweb/mochiweb_headers.erl @@ -19,7 +19,7 @@ %% @doc Run tests for this module. test() -> H = ?MODULE:make([{hdr, foo}, {"Hdr", "bar"}, {'Hdr', 2}]), - [{hdr, "foo, bar, 2"}] = ?MODULE:to_list(H), + [{hdr, "foo, bar, 2"}] = ?MODULE:to_list(H), H1 = ?MODULE:insert(taco, grande, H), [{hdr, "foo, bar, 2"}, {taco, "grande"}] = ?MODULE:to_list(H1), H2 = ?MODULE:make([{"Set-Cookie", "foo"}]), @@ -69,7 +69,7 @@ default_from_list(List, T) -> %% @spec to_list(headers()) -> [{key(), string()}] %% @doc Return the contents of the headers. The keys will be the exact key -%% that was first inserted (e.g. may be an atom or binary, case is +%% that was first inserted (e.g. may be an atom or binary, case is %% preserved). to_list(T) -> F = fun ({K, {array, L}}, Acc) -> diff --git a/src/mochiweb/mochiweb_html.erl b/src/mochiweb/mochiweb_html.erl index d9a3cf2e..05ea6382 100644 --- a/src/mochiweb/mochiweb_html.erl +++ b/src/mochiweb/mochiweb_html.erl @@ -540,7 +540,7 @@ tree([T={comment, _Comment} | Rest], S) -> tree(Rest, append_stack_child(T, S)); tree(L=[{data, _Data, _Whitespace} | _], S) -> case tree_data(L, true, []) of - {_, true, Rest} -> + {_, true, Rest} -> tree(Rest, S); {Data, false, Rest} -> tree(Rest, append_stack_child(Data, S)) diff --git a/src/mochiweb/mochiweb_request.erl b/src/mochiweb/mochiweb_request.erl index 1a2764e0..64c4f58d 100644 --- a/src/mochiweb/mochiweb_request.erl +++ b/src/mochiweb/mochiweb_request.erl @@ -173,13 +173,13 @@ recv_body() -> recv_body(MaxBody) -> % we could use a sane constant for max chunk size Body = stream_body(?MAX_RECV_BODY, fun - ({0, _ChunkedFooter}, {_LengthAcc, BinAcc}) -> + ({0, _ChunkedFooter}, {_LengthAcc, BinAcc}) -> iolist_to_binary(lists:reverse(BinAcc)); ({Length, Bin}, {LengthAcc, BinAcc}) -> NewLength = Length + LengthAcc, if NewLength > MaxBody -> exit({body_too_large, chunked}); - true -> + true -> {NewLength, [Bin | BinAcc]} end end, {0, []}, MaxBody), @@ -188,7 +188,7 @@ recv_body(MaxBody) -> stream_body(MaxChunkSize, ChunkFun, FunState) -> stream_body(MaxChunkSize, ChunkFun, FunState, undefined). - + stream_body(MaxChunkSize, ChunkFun, FunState, MaxBodyLength) -> case get_header_value("expect") of @@ -215,7 +215,7 @@ stream_body(MaxChunkSize, ChunkFun, FunState, MaxBodyLength) -> exit({body_too_large, content_length}); _ -> stream_unchunked_body(Length, MaxChunkSize, ChunkFun, FunState) - end; + end; Length -> exit({length_not_integer, Length}) end. @@ -510,7 +510,7 @@ read_sub_chunks(Length, MaxChunkSize, Fun, FunState) when Length > MaxChunkSize read_sub_chunks(Length, _MaxChunkSize, Fun, FunState) -> Fun({Length, read_chunk(Length)}, FunState). - + %% @spec serve_file(Path, DocRoot) -> Response %% @doc Serve a file relative to DocRoot. serve_file(Path, DocRoot) -> @@ -723,19 +723,19 @@ test_range() -> %% valid, multiple range io:format("Testing parse_range_request with valid multiple ranges~n"), io:format("1"), - [{20, 30}, {50, 100}, {110, 200}] = + [{20, 30}, {50, 100}, {110, 200}] = parse_range_request("bytes=20-30,50-100,110-200"), io:format("2"), - [{20, none}, {50, 100}, {none, 200}] = + [{20, none}, {50, 100}, {none, 200}] = parse_range_request("bytes=20-,50-100,-200"), io:format(".. ok~n"), - + %% no ranges io:format("Testing out parse_range_request with no ranges~n"), io:format("1"), [] = parse_range_request("bytes="), io:format(".. ok~n"), - + Body = <<"012345678901234567890123456789012345678901234567890123456789">>, BodySize = size(Body), %% 60 BodySize = 60, @@ -751,7 +751,7 @@ test_range() -> io:format("4"), {30, 30} = range_skip_length({30, none}, BodySize), %% 30- io:format(".. ok ~n"), - + %% valid edge cases for range_skip_length io:format("Testing out range_skip_length on valid edge case ranges~n"), io:format("1"), @@ -787,4 +787,4 @@ test_range() -> invalid_range = range_skip_length({BodySize, none}, BodySize), io:format(".. ok ~n"), ok. - + diff --git a/src/mochiweb/mochiweb_skel.erl b/src/mochiweb/mochiweb_skel.erl index a1c37f98..098951be 100644 --- a/src/mochiweb/mochiweb_skel.erl +++ b/src/mochiweb/mochiweb_skel.erl @@ -7,7 +7,7 @@ skelcopy(DestDir, Name) -> ok = ensuredir(DestDir), - LDst = case length(filename:dirname(DestDir)) of + LDst = case length(filename:dirname(DestDir)) of 1 -> %% handle case when dirname returns "/" 0; N -> @@ -17,7 +17,7 @@ skelcopy(DestDir, Name) -> ok = file:make_symlink( filename:join(filename:dirname(code:which(?MODULE)), ".."), filename:join([DestDir, Name, "deps", "mochiweb-src"])). - + %% Internal API @@ -40,7 +40,7 @@ skelcopy(Src, DestDir, Name, LDst) -> io:format("~s/~n", [EDst]), lists:foreach(fun ("." ++ _) -> ok; (F) -> - skelcopy(filename:join(Src, F), + skelcopy(filename:join(Src, F), Dir, Name, LDst) diff --git a/src/mochiweb/mochiweb_socket_server.erl b/src/mochiweb/mochiweb_socket_server.erl index d4853dad..a483c3d0 100644 --- a/src/mochiweb/mochiweb_socket_server.erl +++ b/src/mochiweb/mochiweb_socket_server.erl @@ -106,7 +106,7 @@ ipv6_supported() -> init(State=#mochiweb_socket_server{ip=Ip, port=Port, backlog=Backlog}) -> process_flag(trap_exit, true), - BaseOpts = [binary, + BaseOpts = [binary, {reuseaddr, true}, {packet, 0}, {backlog, Backlog}, @@ -126,7 +126,7 @@ init(State=#mochiweb_socket_server{ip=Ip, port=Port, backlog=Backlog}) -> end, case gen_tcp_listen(Port, Opts, State) of {stop, eacces} -> - case Port < 1024 of + case Port < 1024 of true -> case fdsrv:start() of {ok, _} -> @@ -150,7 +150,7 @@ gen_tcp_listen(Port, Opts, State) -> case gen_tcp:listen(Port, Opts) of {ok, Listen} -> {ok, ListenPort} = inet:port(Listen), - {ok, new_acceptor(State#mochiweb_socket_server{listen=Listen, + {ok, new_acceptor(State#mochiweb_socket_server{listen=Listen, port=ListenPort})}; {error, Reason} -> {stop, Reason} @@ -183,11 +183,11 @@ acceptor_loop({Server, Listen, Loop}) -> lists:flatten(io_lib:format("~p", [Other]))]), exit({error, accept_failed}) end. - + do_get(port, #mochiweb_socket_server{port=Port}) -> Port. - + handle_call({get, Property}, _From, State) -> Res = do_get(Property, State), {reply, Res, State}; @@ -205,7 +205,7 @@ handle_cast(stop, State) -> terminate(_Reason, #mochiweb_socket_server{listen=Listen, port=Port}) -> gen_tcp:close(Listen), - case Port < 1024 of + case Port < 1024 of true -> catch fdsrv:stop(), ok; @@ -228,7 +228,7 @@ handle_info({'EXIT', Pid, Reason}, {noreply, new_acceptor(State)}; handle_info({'EXIT', _LoopPid, Reason}, State=#mochiweb_socket_server{acceptor=Pid, max=Max}) -> - case Reason of + case Reason of normal -> ok; _ -> diff --git a/src/mochiweb/mochiweb_util.erl b/src/mochiweb/mochiweb_util.erl index 9a0675f5..93c03431 100644 --- a/src/mochiweb/mochiweb_util.erl +++ b/src/mochiweb/mochiweb_util.erl @@ -418,7 +418,7 @@ record_to_proplist(Record, Fields) -> record_to_proplist(Record, Fields, '__record'). %% @spec record_to_proplist(Record, Fields, TypeKey) -> proplist() -%% @doc Return a proplist of the given Record with each field in the +%% @doc Return a proplist of the given Record with each field in the %% Fields list set as a key with the corresponding value in the Record. %% TypeKey is the key that is used to store the record type %% Fields should be obtained by calling record_info(fields, record_type) -- cgit v1.2.3