For the record, because I've found people asking this before, here's
what I did:
#>
char **make_strings(C_word lst)
{
int len, i;
C_word tmp;
char **hlist;
len = C_unfix(C_i_length(lst));
hlist = (char**) malloc(sizeof(char*) * (len + 1));
for(i = 0, tmp = lst; i < len; i++, tmp = C_u_i_cdr(tmp)) {
char *sstring;
char *cstring;
unsigned int slength=C_unfix(C_i_string_length(C_u_i_car(tmp)));
cstring = (char *)malloc( (slength + 1) * sizeof( char ));
strncpy( cstring, C_c_string(C_u_i_car(tmp)), slength );
cstring[slength] = 0;
hlist[i] = cstring;
}
hlist[i] = NULL;
return hlist;
}
<#
The unfortunate part is that C_i_string_length isn't documented at
all; I'll see if I can find some time to do that.
-Robin
On Mon, Jul 09, 2007 at 09:57:58PM -0500, Zbigniew wrote:
> $ pwd
> ~/build/chicken
> $ grep string-length library.scm
> (define (string-length s) (##core#inline "C_i_string_length" s))
> $ grep C_i_string_length runtime.c
> C_regparm C_word C_fcall C_i_string_length(C_word s)
>
> Hope that helps.
> Zb
>
> On 7/9/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote:
> >Except: Problem: no way to get the length of the Scheme string!
>
>
> _______________________________________________
> Chicken-users mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/chicken-users
--
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
Reason #237 To Learn Lojban: "Homonyms: Their Grate!"
Proud Supporter of the Singularity Institute - http://singinst.org/
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users