winegcc: Add support for @file arguments.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f42e4431fb
commit
c5ee64a101
|
@ -1622,8 +1622,46 @@ int main(int argc, char **argv)
|
||||||
else if (strendswith(argv[0], "++")) opts.processor = proc_cxx;
|
else if (strendswith(argv[0], "++")) opts.processor = proc_cxx;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
char *input_buffer = NULL, *iter, *opt, *out;
|
||||||
|
struct stat st;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (argv[i][0] != '@' || (fd = open( argv[i] + 1, O_RDONLY | O_BINARY )) == -1)
|
||||||
{
|
{
|
||||||
strarray_add( opts.args, argv[i] );
|
strarray_add( opts.args, argv[i] );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((fstat( fd, &st ) == -1)) error( "Cannot stat %s", argv[i] + 1 );
|
||||||
|
if (st.st_size)
|
||||||
|
{
|
||||||
|
input_buffer = xmalloc( st.st_size + 1 );
|
||||||
|
if (read( fd, input_buffer, st.st_size ) != st.st_size) error( "Cannot read %s\n", argv[i] + 1 );
|
||||||
|
}
|
||||||
|
close( fd );
|
||||||
|
for (iter = input_buffer; iter < input_buffer + st.st_size; iter++)
|
||||||
|
{
|
||||||
|
char quote = 0;
|
||||||
|
while (iter < input_buffer + st.st_size && isspace(*iter)) iter++;
|
||||||
|
if (iter == input_buffer + st.st_size) break;
|
||||||
|
opt = out = iter;
|
||||||
|
while (iter < input_buffer + st.st_size && (quote || !isspace(*iter)))
|
||||||
|
{
|
||||||
|
if (*iter == quote)
|
||||||
|
{
|
||||||
|
iter++;
|
||||||
|
quote = 0;
|
||||||
|
}
|
||||||
|
else if (*iter == '\'' || *iter == '"') quote = *iter++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (*iter == '\\' && iter + 1 < input_buffer + st.st_size) iter++;
|
||||||
|
*out++ = *iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*out = 0;
|
||||||
|
strarray_add( opts.args, opt );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse options */
|
/* parse options */
|
||||||
|
|
Loading…
Reference in New Issue