52 |
|
|
53 |
|
Iffy::Iffy(const ext::String& in, const ext::String& out) |
54 |
|
{ |
55 |
< |
if (in == "-" && out == "-") |
56 |
< |
{ |
57 |
< |
iffy(api::Cin, api::Cout); |
58 |
< |
} |
59 |
< |
else if (in == "-") |
60 |
< |
{ |
61 |
< |
api::FileWriter fout(out); |
62 |
< |
|
63 |
< |
iffy(api::Cin, fout); |
64 |
< |
} |
65 |
< |
else if (out == "-") |
66 |
< |
{ |
67 |
< |
api::FileReader fin(in); |
55 |
> |
_H<ios::Reader> rin; |
56 |
> |
_H<ios::Writer> rout; |
57 |
|
|
58 |
< |
iffy(fin, api::Cout); |
59 |
< |
} |
71 |
< |
else |
72 |
< |
{ |
73 |
< |
api::FileReader fin(in); |
74 |
< |
api::FileWriter fout(out); |
58 |
> |
if (in == "-") rin = &api::Cin; else rin = new api::FileReader(in); |
59 |
> |
if (out == "-") rout = &api::Cout; else rout = new api::FileWriter(out); |
60 |
|
|
61 |
< |
iffy(fin, fout); |
77 |
< |
} |
61 |
> |
iffy(*rin, *rout); |
62 |
|
} |
63 |
|
|
64 |
|
ext::String Iffy::program; |
66 |
|
|
67 |
|
void Iffy::iffy(ios::Reader& in, ios::Writer& out) |
68 |
|
{ |
69 |
< |
ext::String segment; |
69 |
> |
ext::Buffer segment; |
70 |
|
bool text(false); |
71 |
|
Cleaner cleaner; |
72 |
|
|
73 |
|
while (read(in, segment, (text = !text))) if (text) |
74 |
|
{ |
75 |
< |
cleaner.insert(segment); |
75 |
> |
if (!segment.IsEmpty()) cleaner.insert(segment); |
76 |
|
} |
77 |
|
else |
78 |
|
{ |
96 |
|
|
97 |
|
ios::FormatWriter fout(out); |
98 |
|
|
99 |
< |
fout << cleaner; |
99 |
> |
fout << cleaner << ios::NewLine; |
100 |
|
} |
101 |
|
|
102 |
< |
bool Iffy::read(ios::Reader& in, ext::String& segment, bool text) |
102 |
> |
bool Iffy::read(ios::Reader& in, ext::Buffer& segment, bool text) |
103 |
|
{ |
104 |
|
segment.Clear(); |
105 |
|
|
106 |
< |
utf8_t atom; |
106 |
> |
byte_t atom; |
107 |
|
|
108 |
|
while (in.Get(atom)) |
109 |
|
{ |