/* strings -- print the strings of printable characters in files
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
+ Copyright (C) 1993-2022 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
--bytes=min-len
-n min-len
-min-len Print graphic char sequences, MIN-LEN or more bytes long,
- that are followed by a NUL or a newline. Default is 4.
+ that are followed by a NUL or a non-displayable character.
+ Default is 4.
--radix={o,x,d}
-t {o,x,d} Print the offset within the file before each string,
Specify a non-default object file format.
--unicode={default|locale|invalid|hex|escape|highlight}
- -u {d|l|i|x|e|h}
- Determine how to handle UTF-8 unicode characters. The default
+ -U {d|l|i|x|e|h}
+ Determine how to handle UTF-8 unicode characters. The default
is no special treatment. All other versions of this option
only apply if the encoding is valid and enabling the option
implies --encoding=S.
static int address_radix;
/* Minimum length of sequence of graphic chars to trigger output. */
-static uint string_min;
+static unsigned int string_min;
/* Whether or not we include all whitespace as a graphic char. */
static bool include_all_whitespace;
case 's':
output_separator = optarg;
- break;
+ break;
case 'U':
if (streq (optarg, "default") || streq (optarg, "d"))
if ((buffer[2] & 0xc0) != 0x80)
return 0;
-
+
if ((buffer[0] & 0x10) == 0)
return 3;
of unicode_display. The character is known to be valid.
Returns the number of bytes consumed. */
-static uint
+static unsigned int
display_utf8_char (const unsigned char * buffer)
{
- uint j;
- uint utf8_len;
+ unsigned int j;
+ unsigned int utf8_len;
switch (buffer[0] & 0x30)
{
default:
utf8_len = 4;
}
-
+
switch (unicode_display)
{
default:
{
case 2:
printf ("\\u%02x%02x",
- ((buffer[0] & 0x1c) >> 2),
+ ((buffer[0] & 0x1c) >> 2),
((buffer[0] & 0x03) << 6) | (buffer[1] & 0x3f));
break;
return;
print_filename_and_address (filename, address + start_point);
-
+
/* We have found string_min characters. Display them and any
more that follow. */
for (i = start_point; i < buflen; i += char_len)
}
static int
-get_unicode_byte (FILE * stream, unsigned char * putback, uint * num_putback, uint * num_read)
+get_unicode_byte (FILE * stream,
+ unsigned char * putback,
+ unsigned int * num_putback,
+ unsigned int * num_read)
{
if (* num_putback > 0)
{
file_ptr address,
FILE * stream,
unsigned char * putback_buf,
- uint num_putback,
+ unsigned int num_putback,
unsigned char * print_buf)
{
/* It would be nice if we could just read the stream into a buffer
we go one byte at a time... */
file_ptr start_point = 0;
- uint num_read = 0;
- uint num_chars = 0;
- uint num_print = 0;
- int c;
+ unsigned int num_read = 0;
+ unsigned int num_chars = 0;
+ unsigned int num_print = 0;
+ int c = 0;
/* Find a series of string_min characters. Put them into print_buf. */
do
print_filename_and_address (filename, address + start_point);
- uint i;
+ unsigned int i;
for (i = 0; i < num_print;)
{
if (print_buf[i] < 127)
/* OK so now we have to start read unchecked bytes. */
- /* Find a series of string_min characters. Put them into print_buf. */
+ /* Find a series of string_min characters. Put them into print_buf. */
do
{
c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
unsigned char * print_buf = xmalloc ((4 * string_min) + 1);
/* We should never have to put back more than 4 bytes. */
unsigned char putback_buf[5];
- uint num_putback = 0;
+ unsigned int num_putback = 0;
print_unicode_stream_body (filename, address, stream, putback_buf, num_putback, print_buf);
free (print_buf);
while (1)
{
file_ptr start;
- uint i;
+ unsigned int i;
long c;
/* See if the next `string_min' chars are all graphic chars. */
fprintf (stream, _("\
-f --print-file-name Print the name of the file before each string\n\
- -n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\
- -<number> least [number] characters (default 4).\n\
+ -n <number> Locate & print any sequence of at least <number>\n\
+ --bytes=<number> displayable characters. (The default is 4).\n\
-t --radix={o,d,x} Print the location of the string in base 8, 10 or 16\n\
-w --include-all-whitespace Include all whitespace as valid string characters\n\
-o An alias for --radix=o\n\
-e --encoding={s,S,b,l,B,L} Select character size and endianness:\n\
s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit\n\
--unicode={default|show|invalid|hex|escape|highlight}\n\
- -u {d|s|i|x|e|h} Specify how to treat UTF-8 encoded unicode characters\n\
+ -U {d|s|i|x|e|h} Specify how to treat UTF-8 encoded unicode characters\n\
-s --output-separator=<string> String used to separate strings in output.\n\
@<file> Read options from <file>\n\
-h --help Display this information\n\