]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use O_BINARY where necessary.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2001 18:41:37 +0000 (18:41 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2001 18:41:37 +0000 (18:41 +0000)
lib/system.h
src/ChangeLog
src/msgfmt.c
src/msgunfmt.c

index 10c2faf953692e4a2b4c372b10286234c0264532..dcec66789692b3a2132674e1d9258eac2fd0df1c 100644 (file)
@@ -128,4 +128,27 @@ extern char *gnu_basename PARAMS ((const char *));
 # define basename(Arg) gnu_basename (Arg)
 #endif
 
+
+#include <fcntl.h>
+/* For systems that distinguish between text and binary I/O.
+   O_BINARY is usually declared in <fcntl.h>. */
+#if !defined O_BINARY && defined _O_BINARY
+  /* For MSC-compatible compilers.  */
+# define O_BINARY _O_BINARY
+# define O_TEXT _O_TEXT
+#endif
+#ifdef __BEOS__
+  /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
+# undef O_BINARY
+# undef O_TEXT
+#endif
+#if O_BINARY
+# if !(defined(__EMX__) || defined(__DJGPP__))
+#  define setmode _setmode
+#  define fileno _fileno
+# endif
+#else
+# define setmode(fd, mode) /* nothing */
+#endif
+
 #endif
index c569b9d6af04558b2b78796cea82d36c8f1c5505..7d9f4407b3c3dae0e0f93ea99452edd9dcfaf321 100644 (file)
@@ -1,3 +1,8 @@
+2001-02-04  Bruno Haible  <haible@clisp.cons.org>
+
+       * msgfmt.c (main): Open the output file in binary mode.
+       * msgunfmt.c (read_mo_file): Open the input file in binary mode.
+
 2001-01-21  Bruno Haible  <haible@clisp.cons.org>
 
        Use libtool.
index 0f653ab8463b3c529487a6d36a47c93b25bf7d6c..00bab404b0f6b72efaf24d23cd093073d9c2af37 100644 (file)
@@ -319,7 +319,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
       if (domain->symbol_tab.filled != 0)
        {
          if (strcmp (domain->domain_name, "-") == 0)
-           output_file = stdout;
+           {
+             output_file = stdout;
+             setmode (fileno (output_file), O_BINARY);
+           }
          else
            {
              const char *fname;
@@ -327,7 +330,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
              fname = strict_uniforum ? add_mo_suffix (domain->domain_name)
                                      : domain->domain_name;
 
-             output_file = fopen (fname, "w");
+             output_file = fopen (fname, "wb");
              if (output_file == NULL)
                {
                  error (0, errno,
index 3dd2cec5e011d871acd204580837c04c592514bd..04064d8a11aa57bf3d281316c1d957fa4623a7f3 100644 (file)
@@ -348,7 +348,10 @@ read_mo_file (mlp, fn)
   int j;
 
   if (strcmp (fn, "-") == 0 || strcmp (fn, "/dev/stdin") == 0)
-    fp = stdin;
+    {
+      fp = stdin;
+      setmode (fileno (fp), O_BINARY);
+    }
   else
     {
       fp = fopen (fn, "rb");