]> code.delx.au - gnu-emacs/blobdiff - lib-src/hexl.c
* cl-generic.el (cl-defmethod): Make docstring dynamic
[gnu-emacs] / lib-src / hexl.c
index b12646e50cfc1b40a2ddde792864c959719160ec..9a5ca7e1543d2560f8312d0bd0d9677dfd18efed 100644 (file)
@@ -1,15 +1,14 @@
 /* Convert files for Emacs Hexl mode.
-   Copyright (C) 1989, 2001-2015 Free Software Foundation, Inc.
+   Copyright (C) 1989, 2001-2016 Free Software Foundation, Inc.
 
-Author: Keith Gabryelski
-(according to authors.el)
+Author: Keith Gabryelski (according to authors.el)
 
 This file is not considered part of GNU Emacs.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,15 +23,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
 #include <ctype.h>
-#ifdef DOS_NT
-#include <fcntl.h>
-#if __DJGPP__ >= 2
-#include <io.h>
-#endif
-#endif
-#ifdef WINDOWSNT
-#include <io.h>
-#endif
+
+#include <binary-io.h>
 
 #define DEFAULT_GROUPING       0x01
 #define DEFAULT_BASE           16
@@ -155,20 +147,12 @@ main (int argc, char **argv)
 
       if (un_flag)
        {
-         char buf[18];
-
-#ifdef DOS_NT
-#if (__DJGPP__ >= 2) || (defined WINDOWSNT)
-          if (!isatty (fileno (stdout)))
-           setmode (fileno (stdout), O_BINARY);
-#else
-         (stdout)->_flag &= ~_IOTEXT; /* print binary */
-         _setmode (fileno (stdout), O_BINARY);
-#endif
-#endif
+         SET_BINARY (fileno (stdout));
+
          for (;;)
            {
-             register int i, c = 0, d;
+             int i, c = 0, d;
+             char buf[18];
 
 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
 
@@ -210,15 +194,7 @@ main (int argc, char **argv)
        }
       else
        {
-#ifdef DOS_NT
-#if (__DJGPP__ >= 2) || (defined WINDOWSNT)
-          if (!isatty (fileno (fp)))
-           setmode (fileno (fp), O_BINARY);
-#else
-         (fp)->_flag &= ~_IOTEXT; /* read binary */
-         _setmode (fileno (fp), O_BINARY);
-#endif
-#endif
+         SET_BINARY (fileno (fp));
          address = 0;
          string[0] = ' ';
          string[17] = '\0';
@@ -239,7 +215,7 @@ main (int argc, char **argv)
                  else
                    {
                      if (!i)
-                       printf ("%08lx: ", address);
+                       printf ("%08lx: ", address + 0ul);
 
                      if (iso_flag)
                        string[i+1] =
@@ -247,7 +223,7 @@ main (int argc, char **argv)
                      else
                        string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
 
-                     printf ("%02x", c);
+                     printf ("%02x", c + 0u);
                    }
 
                  if ((i&group_by) == group_by)