C++ compiler doesn't like Pythonic code.

This commit is contained in:
Quantum 2014-11-03 00:08:37 -05:00
parent 1f1e1196ca
commit a809e6c203

View file

@ -40,7 +40,7 @@ ZalgoProcess &ZalgoProcess::open() {
infile = std::fopen(input.c_str(), "r,ccs=UTF-8"); infile = std::fopen(input.c_str(), "r,ccs=UTF-8");
if (infile == NULL) if (infile == NULL)
throw std::string("Can't open input file: ") + input; throw std::string("Can't open input file: ") + input;
if (output == "-") if (output == "-")
outfile = stdout; outfile = stdout;
else else
@ -56,19 +56,16 @@ ZalgoProcess &ZalgoProcess::zalgo(int level, bool up, bool mid, bool down) {
std::uniform_int_distribution<> dist_mid(level / 6, level / 2); std::uniform_int_distribution<> dist_mid(level / 6, level / 2);
std::uniform_int_distribution<> dist_down(level / 3, level); std::uniform_int_distribution<> dist_down(level / 3, level);
bool initial = true; bool initial = true;
wint_t ch;
while (true) { while ((ch = fgetwc(infile)) != WEOF) {
wint_t ch = fgetwc(infile);
if (ch == WEOF)
return *this;
if (ch == 0xFEFF) if (ch == 0xFEFF)
continue; continue;
if (ch == L'?' && initial) { if (ch == L'?' && initial) {
initial = false; initial = false;
continue; continue;
} }
fputwc(ch, outfile); fputwc(ch, outfile);
switch (ch) { switch (ch) {
case L' ': case L' ':
@ -88,26 +85,26 @@ ZalgoProcess &ZalgoProcess::zalgo(int level, bool up, bool mid, bool down) {
IMPLEMENT_ZALGO(mid); IMPLEMENT_ZALGO(mid);
IMPLEMENT_ZALGO(down); IMPLEMENT_ZALGO(down);
} }
return *this;
} }
ZalgoProcess &ZalgoProcess::unzalgo() { ZalgoProcess &ZalgoProcess::unzalgo() {
bool initial = true; bool initial = true;
while (true) { wint_t ch;
wint_t ch = fgetwc(infile);
if (ch == WEOF) while ((ch = fgetwc(infile)) != WEOF) {
return *this;
if (ch == 0xFEFF) if (ch == 0xFEFF)
continue; continue;
if (ch == L'?' && initial) { if (ch == L'?' && initial) {
initial = false; initial = false;
continue; continue;
} }
if (ch >= 0x0300 && ch < 0x0370 || ch == 0x489) if (ch >= 0x0300 && ch < 0x0370 || ch == 0x489)
continue; continue;
fputwc(ch, outfile); fputwc(ch, outfile);
} }
return *this;
} }
ZalgoProcess &ZalgoProcess::close() { ZalgoProcess &ZalgoProcess::close() {