bug in guile-iii (gscm_cstr?)

Achim Oppelt (aoppelt@scr.siemens.com)
Wed, 6 Sep 1995 18:30:04 -0400

I never had any luck using gscm_eval_{file,string}. I always got an empty
result string. I think I have found the problem in gscm_cstr (in
guile-src/libguile/gscm.c):

--- guile-src/libguile/gscm.c~ Wed Aug 16 18:59:02 1995
+++ guile-src/libguile/gscm.c Wed Sep 6 16:12:59 1995
@@ -528,6 +528,8 @@
SCM sstr;
GSCM_status stat;

+ gscm_strprint_obj(&sstr,obj);
+
*answer = (char *)malloc (LENGTH (sstr));
stat = GSCM_OK;
if (!*answer)

sstr was being used uninitialized here. The call to gscm_strprint_obj seems to
fix part of the problem. A textual representation of obj does get written into
answer, but it doesn't get terminated properly. Does anyone have a fix for
this?

Achim

P.S.: Here is a short program to demonstrate the bug (the calls to gscm_*
do return GSCM_OK, I just removed the error handling to make it shorter):

#include <stdio.h>
#include <guile/gscm.h>

GSCM_top_level _guile_toplevel;

GSCM_status _guile_init_fn(void)
{
return GSCM_OK;
}

int main(int argc, char*argv[])
{
char* answer;

gscm_run_scm(argc,argv,NULL,stdout,stderr,_guile_init_fn,NULL,"#t");
gscm_create_top_level(&_guile_toplevel))!=GSCM_OK);
gscm_eval_str(&answer,_guile_toplevel,"#t"))!=GSCM_OK);
printf(answer);
free(answer);
return 0;
}

With the above addition to gscm.c, it produces the following output, part of
which seems to be from lib/gls/Gmodules.scm (either in module-symbol-binding
or in module-symbol-local-binding):

"#tif (not (null? opt-val))
(car opt-val)
(guile:error "le-mak