1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Output command-line options with argument delimiters if necessary.

This commit is contained in:
Bruno Haible
2000-08-19 13:25:52 +00:00
parent 2efcd453ef
commit 574127cfd5
2 changed files with 47 additions and 1 deletions

View File

@@ -1,5 +1,8 @@
2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr> 2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
* src/options.cc (Options::print_options): Escape the arguments which
contain special characters.
* tests/c-parse.gperf: Updated from gcc-2.95.2/gcc/c-parse.gperf. * tests/c-parse.gperf: Updated from gcc-2.95.2/gcc/c-parse.gperf.
* tests/objc.gperf: New file, from gcc-2.95.2/gcc/objc/objc.gperf. * tests/objc.gperf: New file, from gcc-2.95.2/gcc/objc/objc.gperf.
* tests/chill.gperf: New file, from gcc-2.95.2/gcc/ch/gperf. * tests/chill.gperf: New file, from gcc-2.95.2/gcc/ch/gperf.

View File

@@ -229,7 +229,50 @@ Options::print_options (void)
printf ("/* Command-line: "); printf ("/* Command-line: ");
for (i = 0; i < argument_count; i++) for (i = 0; i < argument_count; i++)
printf ("%s ", argument_vector[i]); {
const char *arg = argument_vector[i];
/* Escape arg if it contains shell metacharacters. */
if (*arg == '-')
{
putchar (*arg);
arg++;
if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z')
{
putchar (*arg);
arg++;
}
}
if (strpbrk (arg, "\t\n !\"#$&'()*;<>?[\\]`{|}~") != NULL)
{
if (strchr (arg, '\'') != NULL)
{
putchar ('"');
for (; *arg; arg++)
{
if (*arg == '\"' || *arg == '\\' || *arg == '$')
putchar ('\\');
putchar (*arg);
}
putchar ('"');
}
else
{
putchar ('\'');
for (; *arg; arg++)
{
if (*arg == '\\')
putchar ('\\');
putchar (*arg);
}
putchar ('\'');
}
}
else
printf ("%s", arg);
printf (" ");
}
printf (" */"); printf (" */");
} }