diff options
author | Loïc Hoguin <[email protected]> | 2011-11-05 03:23:21 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-11-05 03:23:21 +0100 |
commit | 3e443f0a6c4f8076298f5a1a37c30417594ae75e (patch) | |
tree | fd14f52c1e4063728525bf6321de89b1e6542789 /src | |
parent | aba1ea46360a1f84f71102ca3727b584faad8946 (diff) | |
download | cowboy-3e443f0a6c4f8076298f5a1a37c30417594ae75e.tar.gz cowboy-3e443f0a6c4f8076298f5a1a37c30417594ae75e.tar.bz2 cowboy-3e443f0a6c4f8076298f5a1a37c30417594ae75e.zip |
Remove the IS_DIGIT macro
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_http.erl | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index aea75d3..4f482ff 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -29,11 +29,6 @@ %% Parsing. -%% Use only as a guard. --define(IS_DIGIT(C), - C =:= $0; C =:= $1; C =:= $2; C =:= $3; C =:= $4; - C =:= $5; C =:= $6; C =:= $7; C =:= $8; C =:= $9). - %% @doc Parse a non-empty list of the given type. -spec nonempty_list(binary(), fun()) -> [any(), ...] | {error, badarg}. nonempty_list(Data, Fun) -> @@ -450,13 +445,15 @@ digits(Data) -> end). -spec digits(binary(), fun()) -> any(). -digits(<< C, Rest/bits >>, Fun) when ?IS_DIGIT(C) -> +digits(<< C, Rest/bits >>, Fun) + when C >= $0, C =< $9 -> digits(Rest, Fun, C - $0); digits(_Data, _Fun) -> {error, badarg}. -spec digits(binary(), fun(), non_neg_integer()) -> any(). -digits(<< C, Rest/bits >>, Fun, Acc) when ?IS_DIGIT(C) -> +digits(<< C, Rest/bits >>, Fun, Acc) + when C >= $0, C =< $9 -> digits(Rest, Fun, Acc * 10 + (C - $0)); digits(Data, Fun, Acc) -> Fun(Data, Acc). @@ -524,7 +521,8 @@ qvalue(_Data, _Fun) -> -spec qvalue(binary(), fun(), integer(), 1 | 10 | 100) -> any(). qvalue(Data, Fun, Q, 0) -> Fun(Data, Q); -qvalue(<< C, Rest/bits >>, Fun, Q, M) when ?IS_DIGIT(C) -> +qvalue(<< C, Rest/bits >>, Fun, Q, M) + when C >= $0, C =< $9 -> qvalue(Rest, Fun, Q + (C - $0) * M, M div 10); qvalue(Data, Fun, Q, _M) -> Fun(Data, Q). |