diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-07-06 23:25:57 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-07-06 23:25:57 +0200 |
commit | 005de2e8273853e155c21767b1c8bdb4f3f3ca53 (patch) | |
tree | 1f215bb57b2bc61926e3d27357f7c43e993e73b9 /lib/binary-io.h | |
parent | 32299e49e83b941082bee348c993630bb455a324 (diff) | |
download | guile-005de2e8273853e155c21767b1c8bdb4f3f3ca53.tar.gz |
Update Gnulib to v0.0-7509-g98a2286.
* Makefile.am (EXTRA_DIST): Add `m4/gnulib-cache.m4'.
* build-aux/git-version-gen: Keep unchanged.
Diffstat (limited to 'lib/binary-io.h')
-rw-r--r-- | lib/binary-io.h | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/lib/binary-io.h b/lib/binary-io.h index 00a78f029..77cbd4ec9 100644 --- a/lib/binary-io.h +++ b/lib/binary-io.h @@ -25,28 +25,41 @@ so we include it here first. */ #include <stdio.h> -/* SET_BINARY (fd); - changes the file descriptor fd to perform binary I/O. */ +/* set_binary_mode (fd, mode) + sets the binary/text I/O mode of file descriptor fd to the given mode + (must be O_BINARY or O_TEXT) and returns the previous mode. */ #if O_BINARY # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ # include <io.h> /* declares setmode() */ +# define set_binary_mode setmode # else -# define setmode _setmode +# define set_binary_mode _setmode # undef fileno # define fileno _fileno # endif -# ifdef __DJGPP__ -# include <unistd.h> /* declares isatty() */ - /* Avoid putting stdin/stdout in binary mode if it is connected to - the console, because that would make it impossible for the user - to interrupt the program through Ctrl-C or Ctrl-Break. */ -# define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)) -# else -# define SET_BINARY(fd) ((void) setmode (fd, O_BINARY)) -# endif #else - /* On reasonable systems, binary I/O is the default. */ -# define SET_BINARY(fd) /* do nothing */ ((void) 0) + /* On reasonable systems, binary I/O is the only choice. */ + /* Use an inline function rather than a macro, to avoid gcc warnings + "warning: statement with no effect". */ +static inline int +set_binary_mode (int fd, int mode) +{ + (void) fd; + (void) mode; + return O_BINARY; +} +#endif + +/* SET_BINARY (fd); + changes the file descriptor fd to perform binary I/O. */ +#ifdef __DJGPP__ +# include <unistd.h> /* declares isatty() */ + /* Avoid putting stdin/stdout in binary mode if it is connected to + the console, because that would make it impossible for the user + to interrupt the program through Ctrl-C or Ctrl-Break. */ +# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0)) +#else +# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY)) #endif #endif /* _BINARY_H */ |