|
|
@ -1,5 +1,7 @@ |
|
|
|
-module(eFmtFormat). |
|
|
|
|
|
|
|
-include("eFmt.hrl"). |
|
|
|
|
|
|
|
%% Formatting functions of io library. |
|
|
|
-export([ |
|
|
|
fwrite/2 |
|
|
@ -70,6 +72,18 @@ scan(Format, Args) -> |
|
|
|
collect(Format, Args) |
|
|
|
end. |
|
|
|
|
|
|
|
doCollect(FmtBinStr, Args) -> |
|
|
|
MatchList = binary:matches(FmtBinStr, <<"~">>), |
|
|
|
doCollectList(MatchList, FmtBinStr, Args, 0, []). |
|
|
|
|
|
|
|
doCollectList([], _FmtBinStr, _Args, Index, Acc) -> |
|
|
|
Acc; |
|
|
|
doCollectList([OneMatch | MatchList], FmtBinStr, Args, Index, Acc) -> |
|
|
|
ok. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collect([$~ | Fmt0], Args0) -> |
|
|
|
{C, Fmt1, Args1} = collect_cseq(Fmt0, Args0), |
|
|
|
[C | collect(Fmt1, Args1)]; |
|
|
@ -175,10 +189,8 @@ count_small([], P, S, W, Other) -> |
|
|
|
{P, S, W, Other}. |
|
|
|
|
|
|
|
%% build_small([Control]) -> eFmt:chars(). |
|
|
|
%% Interpret the control structures, but only the small ones. |
|
|
|
%% The big ones are saved for later. |
|
|
|
%% build_limited([Control], NumberOfPps, NumberOfLimited, |
|
|
|
%% CharsLimit, Indentation) |
|
|
|
%% Interpret the control structures, but only the small ones. The big ones are saved for later. |
|
|
|
%% build_limited([Control], NumberOfPps, NumberOfLimited, CharsLimit, Indentation) |
|
|
|
%% Interpret the control structures. Count the number of print |
|
|
|
%% remaining and only calculate indentation when necessary. Must also |
|
|
|
%% be smart when calculating indentation for characters in format. |
|
|
@ -191,9 +203,7 @@ build_small([#{control_char := C, args := As, width := F, adjust := Ad, precisio |
|
|
|
build_small([C | Cs]) -> [C | build_small(Cs)]; |
|
|
|
build_small([]) -> []. |
|
|
|
|
|
|
|
build_limited([#{control_char := C, args := As, width := F, adjust := Ad, |
|
|
|
precision := P, pad_char := Pad, encoding := Enc, |
|
|
|
strings := Str} | Cs], NumOfPs0, Count0, MaxLen0, I) -> |
|
|
|
build_limited([#{control_char := C, args := As, width := F, adjust := Ad, precision := P, pad_char := Pad, encoding := Enc, strings := Str} | Cs], NumOfPs0, Count0, MaxLen0, I) -> |
|
|
|
MaxChars = if |
|
|
|
MaxLen0 < 0 -> MaxLen0; |
|
|
|
true -> MaxLen0 div Count0 |
|
|
|