summaryrefslogtreecommitdiff
path: root/src/base64.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-04-21 08:17:59 -0600
committerEric Blake <eblake@redhat.com>2010-04-22 08:42:54 -0600
commitc9e4ea6ee2007462554568f156838b0fb6d55c9a (patch)
treef163c976a45c1d09fde9791829bf4e0a09a898cb /src/base64.c
parent819265b8be20225096573d4f0e0012b59827b013 (diff)
downloadcoreutils-c9e4ea6ee2007462554568f156838b0fb6d55c9a.tar.xz
base64: always treat input in binary mode
Necessary for cygwin. Technically, this patch is not correct, in that it clobbers O_APPEND, but it is no different than any other use of xfreopen to force binary mode, so all such uses should be fixed at once in a later patch. * src/base64.c (main): Open input in binary mode. * THANKS: Update. Reported by Yutaka Amanai.
Diffstat (limited to 'src/base64.c')
-rw-r--r--src/base64.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/base64.c b/src/base64.c
index 34569eca4..41e9dea93 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -29,6 +29,7 @@
#include "xstrtol.h"
#include "quote.h"
#include "quotearg.h"
+#include "xfreopen.h"
#include "base64.h"
@@ -289,10 +290,14 @@ main (int argc, char **argv)
infile = "-";
if (STREQ (infile, "-"))
- input_fh = stdin;
+ {
+ if (O_BINARY)
+ xfreopen (NULL, "rb", stdin);
+ input_fh = stdin;
+ }
else
{
- input_fh = fopen (infile, "r");
+ input_fh = fopen (infile, "rb");
if (input_fh == NULL)
error (EXIT_FAILURE, errno, "%s", infile);
}