Mercurial > hg > xemacs-beta
diff lib-src/hexl.c @ 5491:06dd936cde16
Merge some stuff in lib-src
-------------------- ChangeLog entries follow: --------------------
lib-src/ChangeLog addition:
2010-02-19 Ben Wing <ben@xemacs.org>
* digest-doc.c:
* digest-doc.c (main):
* emacs.csh:
* hexl.c:
* hexl.c (Gabryelski):
* hexl.c (main):
* hexl.c (usage):
* sorted-doc.c:
* sorted-doc.c (fatal):
* sorted-doc.c (xstrdup):
* sorted-doc.c (main):
* vcdiff:
Merge up to FSF 23.1.92.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 19 Feb 2010 22:13:17 -0600 |
parents | abe6d1db359e |
children |
line wrap: on
line diff
--- a/lib-src/hexl.c Thu Feb 11 19:33:50 2010 -0500 +++ b/lib-src/hexl.c Fri Feb 19 22:13:17 2010 -0600 @@ -1,6 +1,32 @@ -/* Synched up with: FSF 19.28. */ +/* Convert files for Emacs Hexl mode. + Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2010 Ben Wing. + +Author: Keith Gabryelski +(according to authors.el) + +This file is not considered part of XEmacs. + +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. +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, see <http://www.gnu.org/licenses/>. */ + +/* Synced up with: GNU 23.1.92. */ +/* Synced by: Ben Wing, 2-17-10. */ + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include <stdio.h> #include <ctype.h> @@ -37,25 +63,25 @@ register long address; char string[18]; FILE *fp; - + progname = *argv++; --argc; - + /* - ** -hex hex dump - ** -oct Octal dump - ** -group-by-8-bits - ** -group-by-16-bits - ** -group-by-32-bits - ** -group-by-64-bits - ** -iso iso character set. - ** -big-endian Big Endian - ** -little-endian Little Endian - ** -un || -de from hexl format to binary. - ** -- End switch list. - ** <filename> dump filename - ** - (as filename == stdin) - */ - + ** -hex hex dump + ** -oct Octal dump + ** -group-by-8-bits + ** -group-by-16-bits + ** -group-by-32-bits + ** -group-by-64-bits + ** -iso iso character set. + ** -big-endian Big Endian + ** -little-endian Little Endian + ** -un || -de from hexl format to binary. + ** -- End switch list. + ** <filename> dump filename + ** - (as filename == stdin) + */ + while (*argv && *argv[0] == '-' && (*argv)[1]) { /* A switch! */ @@ -117,7 +143,7 @@ } else { - (void) fprintf (stderr, "%s: invalid switch: \"%s\".\n", progname, + fprintf (stderr, "%s: invalid switch: \"%s\".\n", progname, *argv); usage (); } @@ -145,7 +171,8 @@ char buf[18]; #ifdef WIN32_NATIVE - _setmode (_fileno (stdout), O_BINARY); + if (!isatty (_fileno (stdout))) + _setmode (_fileno (stdout), O_BINARY); #endif for (;;) { @@ -188,7 +215,8 @@ else { #ifdef WIN32_NATIVE - _setmode (_fileno (fp), O_BINARY); + if (!isatty (_fileno (stdout))) + _setmode (_fileno (stdout), O_BINARY); #endif address = 0; string[0] = ' '; @@ -210,7 +238,7 @@ else { if (!i) - (void) printf ("%08lx: ", address); + printf ("%08lx: ", address); if (iso_flag) string[i+1] = @@ -218,7 +246,7 @@ else string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c; - (void) printf ("%02x", c); + printf ("%02x", c); } if ((i&group_by) == group_by) @@ -237,15 +265,20 @@ } if (fp != stdin) - (void) fclose (fp); + fclose (fp); } while (*argv != NULL); - return 0; + return EXIT_SUCCESS; } void usage (void) { fprintf (stderr, "Usage: %s [-de] [-iso]\n", progname); - exit (1); + exit (EXIT_FAILURE); } + +/* arch-tag: 20e04fb7-926e-4e48-be86-64fe869ecdaa + (do not change this comment) */ + +/* hexl.c ends here */