#include <locale.h>
#include "getopt.h"
+#include "xbinary-io.h"
\f
/* Variables. */
if (asprintf (&output_name, "%s/recode-XXXXXX.tmp", output_dir) == -1)
error (EXIT_FAILURE, errno, "asprintf");
int fd = mkstemps (output_name, 4);
+ xset_binary_mode (fd, O_BINARY);
if (fd == -1)
error (EXIT_FAILURE, errno, "mkstemps (%s)", output_name);
if (!*(task->input.name))
task->input.file = stdin;
- else if (task->input.file = fopen (mixed->input_name, "r"),
+ else if (task->input.file = fopen (mixed->input_name, "rb"),
!task->input.file)
{
recode_perror (NULL, "fopen (%s)", task->input.name);
if (!*(task->output.name))
task->output.file = stdout;
- else if (task->output.file = fopen (mixed->output_name, "w"),
+ else if (task->output.file = fopen (mixed->output_name, "wb"),
!task->output.file)
{
recode_perror (NULL, "fopen (%s)", task->output.name);
{
if (!*subtask->input.name)
subtask->input.file = stdin;
- else if (subtask->input.file = fopen (subtask->input.name, "r"),
+ else if (subtask->input.file = fopen (subtask->input.name, "rb"),
subtask->input.file == NULL)
{
recode_perror (NULL, "fopen (%s)", subtask->input.name);
recode_perror (NULL, "close ()");
recode_if_nogo (RECODE_SYSTEM_ERROR, subtask);
}
- if (subtask->output.file = fdopen (pipe_pair[1], "w"),
+ if (subtask->output.file = fdopen (pipe_pair[1], "wb"),
subtask->output.file == NULL)
{
recode_perror (NULL, "fdopen ()");
{
if (!*subtask->output.name)
subtask->output.file = stdout;
- else if (subtask->output.file = fopen (subtask->output.name, "w"),
+ else if (subtask->output.file = fopen (subtask->output.name, "wb"),
subtask->output.file == NULL)
{
recode_perror (NULL, "fopen (%s)", subtask->output.name);