]> code.delx.au - gnu-emacs/blobdiff - lib-src/hexl.c
2002-08-04 Andrew Choi <akochoi@shaw.ca>
[gnu-emacs] / lib-src / hexl.c
index b090dae335be4b52037095c78b736fe9bfafc8d9..cbab66a2a1789d870c2b17268f279931d2f6fea5 100644 (file)
@@ -1,7 +1,36 @@
+/* Convert files for Emacs Hexl mode.
+   Copyright (C) 1989 Free Software Foundation, Inc
+
+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 2 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
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
-#ifdef MSDOS
+#ifdef DOS_NT
 #include <fcntl.h>
+#if __DJGPP__ >= 2
+#include <io.h>
+#endif
+#endif
+#ifdef WINDOWSNT
+#include <io.h>
 #endif
 
 #define DEFAULT_GROUPING       0x01
@@ -44,7 +73,7 @@ main (argc, argv)
    ** <filename>       dump filename
    ** -                (as filename == stdin)
    */
-    
+
   while (*argv && *argv[0] == '-' && (*argv)[1])
     {
       /* A switch! */
@@ -133,9 +162,14 @@ main (argc, argv)
        {
          char buf[18];
 
-#ifdef MSDOS
+#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
          for (;;)
            {
@@ -177,9 +211,14 @@ main (argc, argv)
        }
       else
        {
-#ifdef MSDOS
+#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
          address = 0;
          string[0] = ' ';
@@ -201,7 +240,7 @@ main (argc, argv)
                  else
                    {
                      if (!i)
-                       printf ("%08x: ", address);
+                       printf ("%08lx: ", address);
 
                      if (iso_flag)
                        string[i+1] =