aboutsummaryrefslogtreecommitdiff
path: root/binutils/strings.c
diff options
context:
space:
mode:
authorErik Ackermann <kurterikackermann@gmail.com>2015-09-10 09:29:13 +0100
committerNick Clifton <nickc@redhat.com>2015-09-10 09:29:13 +0100
commit55edd97b4b2fb373e7895c449ff439efb6de1509 (patch)
treed8a4301add54a7923b043c059eb823749c0c0bf3 /binutils/strings.c
parent3f263e4b5a20fb8c1818306c845564b2aea0fe50 (diff)
downloadgdb-55edd97b4b2fb373e7895c449ff439efb6de1509.zip
gdb-55edd97b4b2fb373e7895c449ff439efb6de1509.tar.gz
gdb-55edd97b4b2fb373e7895c449ff439efb6de1509.tar.bz2
Adds an option to the strings program to specify a separator between the emitted pieces of text.
* strings.c: Add -s/--output-separator option to specify custom separator string. * NEWS: Mention the new feature. * doc/binutils.text (strings): Document the new command line option.
Diffstat (limited to 'binutils/strings.c')
-rw-r--r--binutils/strings.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/binutils/strings.c b/binutils/strings.c
index 6b77c31..2c6f0eb 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -55,6 +55,10 @@
-T {bfdname}
Specify a non-default object file format.
+ --output-separator=sep_string
+ -s sep_string String used to separate parsed strings in output.
+ Default is newline.
+
--help
-h Print the usage message on the standard output.
@@ -114,6 +118,9 @@ static char *target;
static char encoding;
static int encoding_bytes;
+/* Output string used to separate parsed strings */
+static char *output_separator;
+
static struct option long_options[] =
{
{"all", no_argument, NULL, 'a'},
@@ -124,6 +131,7 @@ static struct option long_options[] =
{"include-all-whitespace", required_argument, NULL, 'w'},
{"encoding", required_argument, NULL, 'e'},
{"target", required_argument, NULL, 'T'},
+ {"output-separator", required_argument, NULL, 's'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
@@ -178,8 +186,9 @@ main (int argc, char **argv)
datasection_only = TRUE;
target = NULL;
encoding = 's';
+ output_separator = NULL;
- while ((optc = getopt_long (argc, argv, "adfhHn:wot:e:T:Vv0123456789",
+ while ((optc = getopt_long (argc, argv, "adfhHn:wot:e:T:s:Vv0123456789",
long_options, (int *) 0)) != EOF)
{
switch (optc)
@@ -248,6 +257,10 @@ main (int argc, char **argv)
encoding = optarg[0];
break;
+ case 's':
+ output_separator = optarg;
+ break;
+
case 'V':
case 'v':
print_version ("strings");
@@ -650,7 +663,10 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
putchar (c);
}
- putchar ('\n');
+ if (output_separator)
+ fputs (output_separator, stdout);
+ else
+ putchar ('\n');
}
free (buf);
}
@@ -681,6 +697,7 @@ usage (FILE *stream, int status)
-T --target=<BFDNAME> Specify the binary file format\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\
+ -s --output-separator=<string> String used to separate strings in output.\n\
@<file> Read options from <file>\n\
-h --help Display this information\n\
-v -V --version Print the program's version number\n"));