]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Merge from textutils.
authorJim Meyering <jim@meyering.net>
Sun, 12 Mar 2000 20:07:17 +0000 (20:07 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 12 Mar 2000 20:07:17 +0000 (20:07 +0000)
(O_BINARY, O_TEXT): Define if necessary.
(SET_BINARY, SET_BINARY2): Define.
(DEV_BSIZE): Define to BBSIZE if appropriate.

src/system.h

index e7f987d43e2c8bdf0270f76d7ffb3c2bfe0a7d32..0847f15a68cb1ae1c8bc2a066f5fa9fed7586c1e 100644 (file)
@@ -152,6 +152,35 @@ extern int errno;
 # define R_OK 4
 #endif
 
+/* 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
+#if O_BINARY
+# ifndef __DJGPP__
+#  define setmode _setmode
+#  define fileno(_fp) _fileno (_fp)
+# endif /* not DJGPP */
+# define SET_BINARY(_f) do {if (!isatty(_f)) setmode (_f, O_BINARY);} while (0)
+# define SET_BINARY2(_f1, _f2)         \
+  do {                                 \
+    if (!isatty (_f1))                 \
+      {                                        \
+        setmode (_f1, O_BINARY);       \
+       if (!isatty (_f2))              \
+         setmode (_f2, O_BINARY);      \
+      }                                        \
+  } while(0)
+#else
+# define SET_BINARY(f) (void)0
+# define SET_BINARY2(f1,f2) (void)0
+# define O_BINARY 0
+# define O_TEXT 0
+#endif /* O_BINARY */
+
 #if HAVE_DIRENT_H
 # include <dirent.h>
 # define NLENGTH(direct) (strlen((direct)->d_name))
@@ -178,13 +207,15 @@ extern int errno;
 
 /* Get or fake the disk device blocksize.
    Usually defined by sys/param.h (if at all).  */
+#if !defined DEV_BSIZE && defined BSIZE
+# define DEV_BSIZE BSIZE
+#endif
+#if !defined DEV_BSIZE && defined BBSIZE /* SGI */
+# define DEV_BSIZE BBSIZE
+#endif
 #ifndef DEV_BSIZE
-# ifdef BSIZE
-#  define DEV_BSIZE BSIZE
-# else /* !BSIZE */
-#  define DEV_BSIZE 4096
-# endif /* !BSIZE */
-#endif /* !DEV_BSIZE */
+# define DEV_BSIZE 4096
+#endif
 
 /* Extract or fake data from a `struct stat'.
    ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.