소스 검색

Make sure atoms needing quoting are quoted.

pull/10/head
Andrew Thompson 13 년 전
부모
커밋
3babca112c
1개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. +19
    -1
      src/lager_trunc_io.erl

+ 19
- 1
src/lager_trunc_io.erl 파일 보기

@ -214,7 +214,11 @@ print(Tuple, Max) when is_tuple(Tuple) ->
%%
print(Atom, _Max) when is_atom(Atom) ->
L = atom_to_list(Atom),
{L, length(L)};
R = case atom_needs_quoting_start(L) of
true -> lists:flatten([$', L, $']);
false -> L
end,
{R, length(R)};
print(<<>>, _Max) ->
{"<<>>", 4};
@ -319,6 +323,20 @@ alist(L, Max) ->
{R, Len} = list_body(L, Max-3),
{[$", $[, R, $]], Len + 3}.
%% is the first character in the atom alphabetic & lowercase?
atom_needs_quoting_start([H|T]) when H >= $a, H =< $z ->
atom_needs_quoting(T);
atom_needs_quoting_start(_) ->
true.
atom_needs_quoting([]) ->
false;
atom_needs_quoting([H|T]) when (H >= $a andalso H =< $z);
(H >= $A andalso H =< $Z);
H == $@; H == $_ ->
atom_needs_quoting(T);
atom_needs_quoting(_) ->
true.
-ifdef(TEST).
%%--------------------

불러오는 중...
취소
저장