Commit c5ee64a1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winegcc: Add support for @file arguments.

parent f42e4431
......@@ -1623,7 +1623,45 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++)
{
strarray_add( opts.args, argv[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] );
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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment