emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#5996: closed ([PATCH] base64: always treat input


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#5996: closed ([PATCH] base64: always treat input in binary mode)
Date: Thu, 22 Apr 2010 17:53:02 +0000

Your message dated Thu, 22 Apr 2010 19:52:14 +0200
with message-id <address@hidden>
and subject line Re: bug#5996: [PATCH] base64: always treat input in binary mode
has caused the GNU bug report #5996,
regarding [PATCH] base64: always treat input in binary mode
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
5996: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5996
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] base64: always treat input in binary mode Date: Wed, 21 Apr 2010 08:23:00 -0600
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.
---

> base64 doesn't call freopen() nor setmode() against stdin, and doesn't
> give "rb" flag to fopen(). So, base64 sometimes fails to encode data
> correctly on some environment. For example, zsh on Cygwin forces stdin
> to be text-mode.

Thanks for the report.  I'll commit this later today if there are no
objections; it should have no impact for any platform that does not
have O_BINARY, and although it is not perfect on Cygwin, it is not
too much to add to my workload for creating the cygwin port of coreutils
8.5.  And someday I'll get around to creating the new gnulib interface
for gracefully enforcing binary streams without clobbering O_APPEND.

 src/base64.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/base64.c b/src/base64.c
index 34569ec..41e9dea 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);
     }
-- 
1.6.6.1





--- End Message ---
--- Begin Message --- Subject: Re: bug#5996: [PATCH] base64: always treat input in binary mode Date: Thu, 22 Apr 2010 19:52:14 +0200
Eric Blake wrote:
> On 04/22/2010 11:00 AM, Glenn Morris wrote:
>>
>> Hi,
>>
>> The following message got resent to bug-gnu-emacs rather than
>> bug-coreutils, because debbugs got confused.
>
> Well, my screw-up with To: fields means that my planned review period
> was delayed...
>
>>> Thanks for the report.  I'll commit this later today if there are no
>>> objections; it should have no impact for any platform that does not
>>> have O_BINARY, and although it is not perfect on Cygwin, it is not
>>> too much to add to my workload for creating the cygwin port of coreutils
>>> 8.5.  And someday I'll get around to creating the new gnulib interface
>>> for gracefully enforcing binary streams without clobbering O_APPEND.
>
> But I'd still like to commit this in time for coreutils 8.5 later today
> if there are no complaints.

That patch looks fine.
You're welcome to push it.  Thanks!


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]