Handle ) in command line interface filename

SWIG now handles an interface filename specified on the command line
which contains a closing parenthesis `)`, and more generally with
attributes to `%include` and `%import` which are quoted and contain
parentheses.

Fixes #1006
This commit is contained in:
Olly Betts 2022-03-08 18:15:18 +13:00
commit f8a766295c
3 changed files with 36 additions and 7 deletions

View file

@ -741,14 +741,35 @@ static String *get_options(String *str) {
opt = NewString("(");
while (((c = Getc(str)) != EOF)) {
Putc(c, opt);
if (c == ')') {
level--;
if (!level)
return opt;
switch (c) {
case ')':
level--;
if (!level)
return opt;
break;
case '(':
level++;
break;
case '"':
/* Skip over quoted strings */
while (1) {
c = Getc(str);
if (c == EOF)
goto bad;
Putc(c, opt);
if (c == '"')
break;
if (c == '\\') {
c = Getc(str);
if (c == EOF)
goto bad;
Putc(c, opt);
}
}
break;
}
if (c == '(')
level++;
}
bad:
Delete(opt);
return 0;
} else {