X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fstrings.c;h=5d3aa6d4fa7f8dab802360c8aadd3619ea45413c;hb=198ce79b6b8e11c56a270eb3686574b87b0e7c75;hp=8ffe6a166257dfb1e2cb2c0116fa1aa9ae634d55;hpb=30727aa6d12fb866494020c0b62ab265a2bdcdfe;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/strings.c b/binutils/strings.c index 8ffe6a1662..5d3aa6d4fa 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -1,5 +1,6 @@ /* strings -- print the strings of printable characters in files - Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. 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 @@ -58,10 +59,30 @@ #include "bucomm.h" #include "libiberty.h" -#ifdef isascii -#define isgraphic(c) (isascii (c) && isprint (c)) +/* Some platforms need to put stdin into binary mode, to read + binary files. */ +#ifdef HAVE_SETMODE +#ifndef O_BINARY +#ifdef _O_BINARY +#define O_BINARY _O_BINARY +#define setmode _setmode #else -#define isgraphic(c) (isprint (c)) +#define O_BINARY 0 +#endif +#endif +#if O_BINARY +#include +#define SET_BINARY(f) do { if (!isatty(f)) setmode(f,O_BINARY); } while (0) +#endif +#endif + +/* Not all printable characters have ASCII codes (depending upon the + LOCALE set) but on some older systems it is not safe to test isprint + without first testing isascii... */ +#if defined isascii && !defined HAVE_LOCALE_H +#define isgraphic(c) (isascii (c) && (isprint (c) || (c) == '\t')) +#else +#define isgraphic(c) (isprint (c) || (c) == '\t') #endif #ifndef errno @@ -123,7 +144,7 @@ main (argc, argv) boolean files_given = false; #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) - setlocale (LC_MESSAGES, ""); + setlocale (LC_ALL, ""); #endif bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -156,9 +177,7 @@ main (argc, argv) string_min = integer_arg (optarg); if (string_min < 1) { - fprintf (stderr, _("%s: invalid number %s\n"), - program_name, optarg); - exit (1); + fatal (_("invalid number %s"), optarg); } break; @@ -203,7 +222,7 @@ main (argc, argv) default: if (string_min < 0) - string_min = optc; + string_min = optc - '0'; else string_min = string_min * 10 + optc - '0'; break; @@ -219,6 +238,9 @@ main (argc, argv) if (optind >= argc) { datasection_only = false; +#ifdef SET_BINARY + SET_BINARY (fileno (stdin)); +#endif print_strings ("{standard input}", stdin, 0, 0, 0, (char *) NULL); files_given = true; } @@ -491,8 +513,7 @@ integer_arg (s) if (*p) { - fprintf (stderr, _("%s: invalid integer argument %s\n"), program_name, s); - exit (1); + fatal (_("invalid integer argument %s"), s); } return value; } @@ -509,6 +530,6 @@ Usage: %s [-afov] [-n min-len] [-min-len] [-t {o,x,d}] [-]\n\ program_name); list_supported_targets (program_name, stream); if (status == 0) - fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n")); + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); exit (status); }