gas: remove use of PTR
[binutils-gdb.git] / binutils / strings.c
index f50badf983e897136937478f13a45ff91b715ff3..5f4e0ebfc27a54aefd98a3ae3b31646a9f3a924d 100644 (file)
@@ -1,5 +1,5 @@
 /* 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
@@ -32,7 +32,8 @@
    --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,
@@ -56,8 +57,8 @@
                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.
@@ -123,7 +124,7 @@ extern int errno;
 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;
@@ -272,7 +273,7 @@ main (int argc, char **argv)
 
        case 's':
          output_separator = optarg;
-          break;
+         break;
 
        case 'U':
          if (streq (optarg, "default") || streq (optarg, "d"))
@@ -677,7 +678,7 @@ is_valid_utf8 (const unsigned char * buffer, unsigned long buflen)
 
   if ((buffer[2] & 0xc0) != 0x80)
     return 0;
-  
+
   if ((buffer[0] & 0x10) == 0)
     return 3;
 
@@ -694,11 +695,11 @@ is_valid_utf8 (const unsigned char * buffer, unsigned long buflen)
    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)
     {
@@ -712,7 +713,7 @@ display_utf8_char (const unsigned char * buffer)
     default:
       utf8_len = 4;
     }
-      
+
   switch (unicode_display)
     {
     default:
@@ -728,7 +729,7 @@ display_utf8_char (const unsigned char * buffer)
        {
        case 2:
          printf ("\\u%02x%02x",
-                 ((buffer[0] & 0x1c) >> 2), 
+                 ((buffer[0] & 0x1c) >> 2),
                  ((buffer[0] & 0x03) << 6) | (buffer[1] & 0x3f));
          break;
 
@@ -857,7 +858,7 @@ print_unicode_buffer (const char *            filename,
     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)
@@ -888,7 +889,10 @@ print_unicode_buffer (const char *            filename,
 }
 
 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)
     {
@@ -912,7 +916,7 @@ print_unicode_stream_body (const char *     filename,
                           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
@@ -921,10 +925,10 @@ print_unicode_stream_body (const char *     filename,
      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
@@ -1064,7 +1068,7 @@ print_unicode_stream_body (const char *     filename,
 
       print_filename_and_address (filename, address + start_point);
 
-      uint i;
+      unsigned int i;
       for (i = 0; i < num_print;)
        {
          if (print_buf[i] < 127)
@@ -1075,7 +1079,7 @@ print_unicode_stream_body (const char *     filename,
 
       /* 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);
@@ -1213,7 +1217,7 @@ print_unicode_stream (const char * filename,
   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);
@@ -1250,7 +1254,7 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
   while (1)
     {
       file_ptr start;
-      uint i;
+      unsigned int i;
       long c;
 
       /* See if the next `string_min' chars are all graphic chars.  */
@@ -1320,8 +1324,8 @@ usage (FILE *stream, int status)
 
   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\
@@ -1329,7 +1333,7 @@ usage (FILE *stream, int status)
   -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\