From 714a1da4628fb49487484b47325a525d85660320 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Wed, 21 Jul 2021 11:02:02 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/eFmt.hrl | 2 -- src/eFmt.erl | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/eFmt.hrl b/include/eFmt.hrl index 85f1a28..24948dd 100644 --- a/include/eFmt.hrl +++ b/include/eFmt.hrl @@ -18,6 +18,4 @@ , strings :: boolean() %% 如果存在修饰符l,则将 string设置为false。 }). --define(log(Args), io:format("IMY**********~w~n", [Args])). - diff --git a/src/eFmt.erl b/src/eFmt.erl index 8195f44..a712be2 100644 --- a/src/eFmt.erl +++ b/src/eFmt.erl @@ -83,7 +83,9 @@ format(Format, Args, Options) -> -spec formatBin(Format :: format(), Data :: [term()]) -> chars(). formatBin(Format, Args) -> - try iolist_to_binary(fWrite(Format, Args)) + try fWrite(Format, Args) of + Ret -> + iolist_to_binary(Ret) catch _C:_R -> erlang:error(badarg, [Format, Args, _C, _R]) @@ -91,7 +93,9 @@ formatBin(Format, Args) -> -spec formatBin(Format :: format(), Data :: [term()], Options :: [{charsLimit, CharsLimit :: charsLimit()}]) -> chars(). formatBin(Format, Args, Options) -> - try iolist_to_binary(fWrite(Format, Args, Options)) + try fWrite(Format, Args, Options) of + Ret -> + iolist_to_binary(Ret) catch _C:_R -> erlang:error(badarg, [Format, Args]) @@ -494,7 +498,7 @@ writeTerm(Term, _Depth, _Width, _Encoding, _Strings) when is_function(Term) -> ? fWrite(Format, Args) -> fBuild(fScan(Format, Args), []). --spec fWrite(Format :: format(), Data :: [term()], Options :: [{'chars_limit', CharsLimit :: integer()}]) -> chars(). +-spec fWrite(Format :: format(), Data :: [term()], Options :: [{charsLimit, CharsLimit :: integer()}]) -> chars(). fWrite(Format, Args, Options) -> fBuild(fScan(Format, Args), Options). @@ -634,9 +638,9 @@ doCollCA(LPart, Args, Width, Adjust, Precision, PadChar, Encoding, Strings, Acc) fBuild(Cs) -> fBuild(Cs, []). --spec fBuild(FormatList :: [char() | fmtSpec()], Options :: [{'chars_limit', CharsLimit :: integer()}]) -> chars(). +-spec fBuild(FormatList :: [char() | fmtSpec()], Options :: [{charsLimit, CharsLimit :: integer()}]) -> chars(). fBuild(Cs, Options) -> - CharsLimit = getOpt(chars_limit, Options, -1), + CharsLimit = getOpt(charsLimit, Options, -1), buildSmall(Cs, CharsLimit, 0, 0, 0, 0, []). buildSmall([], CharsLimit, P, S, W, Other, Acc) -> @@ -1077,8 +1081,7 @@ visualUtf8Char($\v, _) -> true; visualUtf8Char($\b, _) -> true; visualUtf8Char($\f, _) -> true; visualUtf8Char($\e, _) -> true; -visualUtf8Char(C, _Encoding) -> - C >= $\s andalso C =< $~ orelse C >= 16#A0 andalso C < 16#D800 orelse C > 16#DFFF andalso C < 16#FFFE orelse C > 16#FFFF andalso C =< 16#10FFFF. +visualUtf8Char(C, _Encoding) -> C >= $\s andalso C =< $~ orelse C >= 16#A0 andalso C < 16#D800 orelse C > 16#DFFF andalso C < 16#FFFE orelse C > 16#FFFF andalso C =< 16#10FFFF. %% case Encoding of %% latin1 -> %% C >= $\s andalso C =< $~ orelse C >= 16#A0 andalso C =< 16#FF;