From 7333c4bb5962d6e08a7903d8963c9021c0ea0fd6 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 18 Feb 2021 18:33:21 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E4=BF=AE=E6=94=B9=E4=B8=BA=E4=BA=8C?= =?UTF-8?q?=E8=BF=9B=E5=88=B6=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eFmtFormat.erl | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/eFmtFormat.erl b/src/eFmtFormat.erl index d92aca1..8cb555d 100644 --- a/src/eFmtFormat.erl +++ b/src/eFmtFormat.erl @@ -72,13 +72,24 @@ scan(Format, Args) -> collect(Format, Args) end. -doCollect(FmtBinStr, Args) -> - MatchList = binary:matches(FmtBinStr, <<"~">>), - doCollectList(MatchList, FmtBinStr, Args, 0, []). - -doCollectList([], _FmtBinStr, _Args, Index, Acc) -> +doCollect(FmtBinStr, Args, Acc) -> + case binary:split(FmtBinStr, <<"~">>) of + [NotMatch] -> + [NotMatch | Acc]; + [FPart, LPart] -> + doCollectList(LPart, Args, [FPart | Acc]). + end, + +%% 格式 ~F.P.PadModC +doCollectList(<<>>, _Args, Acc) -> Acc; -doCollectList([OneMatch | MatchList], FmtBinStr, Args, Index, Acc) -> +doCollectList(LPart, Args, Acc) -> + %% 匹配宽度 + case LPart of + <<"-", FBin/binary>> -> + + end, + ok.