]> code.delx.au - gnu-emacs/blobdiff - lib-src/hexl.c
Typo fix.
[gnu-emacs] / lib-src / hexl.c
index 5ca7c2a5b8a4efc808b31db44491ecf26561e218..9e21ddf9de639aef1a0f0a7db83fdc1df0ca8d8f 100644 (file)
@@ -1,11 +1,14 @@
 /* Convert files for Emacs Hexl mode.
-   Copyright (C) 1989 Free Software Foundation, Inc
+   Copyright (C) 1989, 2001-2014 Free Software Foundation, Inc.
+
+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
+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
+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,
@@ -14,12 +17,10 @@ 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. */
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include <stdio.h>
 #include <ctype.h>
@@ -36,21 +37,15 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
 #define DEFAULT_GROUPING       0x01
 #define DEFAULT_BASE           16
 
-#undef TRUE
-#undef FALSE
-#define TRUE  (1)
-#define FALSE (0)
-
-int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
+int base = DEFAULT_BASE;
+bool un_flag = false, iso_flag = false, endian = true;
 int group_by = DEFAULT_GROUPING;
 char *progname;
 
-void usage();
+_Noreturn void usage (void);
 
 int
-main (argc, argv)
-     int argc;
-     char *argv[];
+main (int argc, char **argv)
 {
   register long address;
   char string[18];
@@ -84,7 +79,7 @@ main (argc, argv)
        }
       else if (!strcmp (*argv, "-un") || !strcmp (*argv, "-de"))
        {
-         un_flag = TRUE;
+         un_flag = true;
          --argc; argv++;
        }
       else if (!strcmp (*argv, "-hex"))
@@ -94,7 +89,7 @@ main (argc, argv)
        }
       else if (!strcmp (*argv, "-iso"))
        {
-         iso_flag = TRUE;
+         iso_flag = true;
          --argc; argv++;
        }
       else if (!strcmp (*argv, "-oct"))
@@ -104,12 +99,12 @@ main (argc, argv)
        }
       else if (!strcmp (*argv, "-big-endian"))
        {
-         endian = 1;
+         endian = true;
          --argc; argv++;
        }
       else if (!strcmp (*argv, "-little-endian"))
        {
-         endian = 0;
+         endian = false;
          --argc; argv++;
        }
       else if (!strcmp (*argv, "-group-by-8-bits"))
@@ -130,7 +125,7 @@ main (argc, argv)
       else if (!strcmp (*argv, "-group-by-64-bits"))
        {
          group_by = 0x07;
-         endian = 0;
+         endian = false;
          --argc; argv++;
        }
       else
@@ -173,11 +168,13 @@ main (argc, argv)
 #endif
          for (;;)
            {
-             register int i, c, d;
+             register int i, c = 0, d;
 
 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
 
-             fread (buf, 1, 10, fp); /* skip 10 bytes */
+             /* Skip 10 bytes.  */
+             if (fread (buf, 1, 10, fp) != 10)
+               break;
 
              for (i=0; i < 16; ++i)
                {
@@ -205,7 +202,9 @@ main (argc, argv)
                  if (i < 16)
                    break;
 
-                 fread (buf, 1, 18, fp); /* skip 18 bytes */
+                 /* Skip 18 bytes.  */
+                 if (fread (buf, 1, 18, fp) != 18)
+                   break;
                }
            }
        }
@@ -225,7 +224,7 @@ main (argc, argv)
          string[17] = '\0';
          for (;;)
            {
-             register int i, c;
+             register int i, c = 0;
 
              for (i=0; i < 16; ++i)
                {
@@ -274,13 +273,11 @@ main (argc, argv)
 }
 
 void
-usage ()
+usage (void)
 {
   fprintf (stderr, "usage: %s [-de] [-iso]\n", progname);
   exit (EXIT_FAILURE);
 }
 
-/* arch-tag: 20e04fb7-926e-4e48-be86-64fe869ecdaa
-   (do not change this comment) */
 
 /* hexl.c ends here */