Yaroslav Kavenchuk <kavenchuk@...> writes:
> > /* Pass core filename into Lisp */
> > SetSymbolValue(CORE_STRING, alloc_base_string(core),0);
> > SHOW("freeing core");
> > free(core);
> > /* Convert remaining argv values to something that Lisp can grok. */
> > SHOW("setting POSIX-ARGV symbol value");
> > SetSymbolValue(POSIX_ARGV, alloc_base_string_list(sbcl_argv),0);
> > free(sbcl_argv);
> Function "SetSymbolValue" work with base_string only.
Surely SetSymbolValue doesn't care about what the second argument is,
as long as it's valid Lisp data?
> My offer: pass to "toplevel-init" the pointers of 'core' and
> 'sbcl_argv', and convert it in sbcl strings with aliens functions.
That seems like a better plan than trying to do the conversion in C.
> Question: how pass pointers to "toplevel-init"? With global variables?
You shouldn't be passing raw pointers around, but SAPs (you can
allocate them C-side with alloc_sap). So instead of creating a list of
base-strings and assigning it into *POSIX-ARGV* in that code, create a
list of SAPs.
Also, converting the SAPs to strings with the appropriate locale
during initialization should be done from REINIT (or some function
called from REINIT), not in TOPLEVEL-INIT. Otherwise people who
replace the toplevel function when saving a core will get an invalid
*POSIX-ARGV* / *CORE-STRING*.