/*
* Open the output file.
*/
- tf.fp = fopen(conf.filename, "w");
+ if (!strcmp(conf.filename, "-"))
+ tf.fp = stdout;
+ else
+ tf.fp = fopen(conf.filename, "w");
if (!tf.fp) {
error(err_cantopenw, conf.filename);
return;
* Tidy up
*/
text_output(&tf, NULL); /* end charset conversion */
- fclose(tf.fp);
+ if (tf.fp != stdout)
+ fclose(tf.fp);
sfree(conf.asect);
sfree(conf.filename);
}
wchar_t s[2];
s[0] = c;
s[1] = L'\0';
- while (n--)
+ while (n-- > 0)
text_output(tf, s);
}