Fix returning strings from variadic functions.
This commit is contained in:
@ -5230,6 +5230,18 @@ static symbol *fetchlab(char *name)
|
||||
return sym;
|
||||
}
|
||||
|
||||
static int is_variadic(symbol *sym)
|
||||
{
|
||||
assert(sym->ident==iFUNCTN);
|
||||
arginfo *arg = sym->dim.arglist;
|
||||
while (arg->ident) {
|
||||
if (arg->ident == iVARARGS)
|
||||
return TRUE;
|
||||
arg++;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* doreturn
|
||||
*
|
||||
* Global references: rettype (altered)
|
||||
@ -5329,7 +5341,11 @@ static void doreturn(void)
|
||||
* it stays on the heap for the moment, and it is removed -usually- at
|
||||
* the end of the expression/statement, see expression() in SC3.C)
|
||||
*/
|
||||
address(sub,sALT); /* ALT = destination */
|
||||
if (is_variadic(curfunc)) {
|
||||
load_hidden_arg();
|
||||
} else {
|
||||
address(sub,sALT); /* ALT = destination */
|
||||
}
|
||||
arraysize=calc_arraysize(dim,numdim,0);
|
||||
memcopy(arraysize*sizeof(cell)); /* source already in PRI */
|
||||
/* moveto1(); is not necessary, callfunction() does a popreg() */
|
||||
|
Reference in New Issue
Block a user