From c9e4ea6ee2007462554568f156838b0fb6d55c9a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 21 Apr 2010 08:17:59 -0600 Subject: [PATCH] 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. --- THANKS | 1 + src/base64.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 2ea68012c..ecad934ba 100644 --- a/THANKS +++ b/THANKS @@ -636,6 +636,7 @@ Wolfram Kleff kleff@cs.uni-bonn.de Won-kyu Park wkpark@chem.skku.ac.kr Yanko Kaneti yaneti@declera.com Yann Dirson dirson@debian.org +Yutaka Amanai yasai-itame1942@jade.plala.or.jp Zvi Har'El rl@math.technion.ac.il ;; Local Variables: 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); } -- 2.11.4.GIT