[ccache] [PATCH] add support for '@' parameters

Joel Rosdahl joel at rosdahl.net
Sun Jul 29 15:51:52 MDT 2012


On 27 July 2012 23:45, Andrew Boie <andrew.p.boie at intel.com> wrote:
> These indicate to the compiler that additional command line options
> should be read from a text file. If encountered, read the file,
> tokenize any arguments, and if any are found, do an in-place replacement
> of the '@' parameter with the arguments within the file.

Thanks for working on this!

> +                       file_args = args_init_from_string(argdata);

Isn't args_init_from_string too simplistic for parsing the contents?
According to GCC documentation, "Options in file are separated by
whitespace. A whitespace character may be included in an option by
surrounding the entire option in either single or double quotes. Any
character (including a backslash) may be included by prefixing the
character to be included with a backslash.The file may itself contain
additional @file options; any such options will be processed
recursively."

> +                       /* Expand argv to hold both current and file
> +                        * arguments */
> +                       orig_args->argv = (char**)x_realloc(orig_args->argv,
> +                                       (orig_args->argc + file_args->argc) *
> +                                       sizeof(char *));
> +                       /* Move all unprocessed arguments to the end of the
> +                        * new list */
> +                       for (j = orig_args->argc; j > i; j--) {
> +                               orig_args->argv[j + file_args->argc - 1] =
> +                                       orig_args->argv[j];
> +                       }
> +                       /* Fill in the space we just made with the
> +                        * new arguments. Current '@' argument gets
> +                        * replaced */
> +                       for (j = 0; j < file_args->argc; j++) {
> +                               orig_args->argv[j + i] =
> +                                       x_strdup(file_args->argv[j]);
> +                       }

It would be nice if this code could be extracted to a new
args_insert(struct args *args, struct args *to_insert, int pos)
function or so. (There's a test suite for args_* in test/test_args.c.)

-- Joel


More information about the ccache mailing list