/* Convert files for Emacs Hexl mode.
- Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1989, 2001-2014 Free Software Foundation, Inc.
Author: Keith Gabryelski
(according to authors.el)
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>
#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(void) NO_RETURN;
+_Noreturn void usage (void);
int
main (int argc, char **argv)
}
else if (!strcmp (*argv, "-un") || !strcmp (*argv, "-de"))
{
- un_flag = TRUE;
+ un_flag = true;
--argc; argv++;
}
else if (!strcmp (*argv, "-hex"))
}
else if (!strcmp (*argv, "-iso"))
{
- iso_flag = TRUE;
+ iso_flag = true;
--argc; argv++;
}
else if (!strcmp (*argv, "-oct"))
}
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"))
else if (!strcmp (*argv, "-group-by-64-bits"))
{
group_by = 0x07;
- endian = 0;
+ endian = false;
--argc; argv++;
}
else
#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)
{
if (i < 16)
break;
- fread (buf, 1, 18, fp); /* skip 18 bytes */
+ /* Skip 18 bytes. */
+ if (fread (buf, 1, 18, fp) != 18)
+ break;
}
}
}