* guile 2.0.1 working on cygwin (probably 2.0.0 also)
@ 2011-05-23 1:59 objc
2011-05-25 12:40 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: objc @ 2011-05-23 1:59 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 8638 bytes --]
Hi Guilers,
I've got guile 2.0.1 to work on cygwin with a nasty "test hack".
in scm_to_stringn function:
ret = mem_iconveh (jrgbuf, ilen,
"ISO-8859-1"
//??????????
, enc,//"ANSI_X3.4-1968" "ISO-8859-1" "UTF-8"
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);
The mem_iconveh function fails.
re-trying with "ANSI_X3.4-1968" or "UTF-8" in the //?????????? gets it work.
I've got guile 2.0.1 to work on cygwin, but have not investigated how or why it works.
Any thoughts of a fix ?
Cheers,
objcjohn
libguile/strings.c (orig.)
=================
char *
scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
scm_t_string_failed_conversion_handler handler)
{
char *buf;
size_t ilen, len, i;
int ret;
const char *enc;
if (!scm_is_string (str))
scm_wrong_type_arg_msg (NULL, 0, str, "string");
ilen = scm_i_string_length (str);
if (ilen == 0)
{
buf = scm_malloc (1);
buf[0] = '\0';
if (lenp)
*lenp = 0;
return buf;
}
if (lenp == NULL)
for (i = 0; i < ilen; i++)
if (scm_i_string_ref (str, i) == '\0')
scm_misc_error (NULL,
"string contains #\\nul character: ~S",
scm_list_1 (str));
if (scm_i_is_narrow_string (str) && (encoding == NULL))
{
/* If using native Latin-1 encoding, just copy the string
contents. */
if (lenp)
{
buf = scm_malloc (ilen);
memcpy (buf, scm_i_string_chars (str), ilen);
*lenp = ilen;
return buf;
}
else
{
buf = scm_malloc (ilen + 1);
memcpy (buf, scm_i_string_chars (str), ilen);
buf[ilen] = '\0';
return buf;
}
}
buf = NULL;
len = 0;
enc = encoding;
if (enc == NULL)
enc = "ISO-8859-1";
if (scm_i_is_narrow_string (str))
{
ret = mem_iconveh (scm_i_string_chars (str), ilen,
"ISO-8859-1", enc,
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);
if (ret != 0)
scm_encoding_error (__func__, errno,
"cannot convert narrow string to output locale",
SCM_BOOL_F,
/* FIXME: Faulty character unknown. */
SCM_BOOL_F);
}
else
{
buf = u32_conv_to_encoding (enc,
(enum iconv_ilseq_handler) handler,
(scm_t_uint32 *) scm_i_string_wide_chars (str),
ilen,
NULL,
NULL, &len);
if (buf == NULL)
scm_encoding_error (__func__, errno,
"cannot convert wide string to output locale",
SCM_BOOL_F,
/* FIXME: Faulty character unknown. */
SCM_BOOL_F);
}
if (handler == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE)
{
if (SCM_R6RS_ESCAPES_P)
{
/* The worst case is if the input string contains all 4-digit
hex escapes. "\uXXXX" (six characters) becomes "\xXXXX;"
(seven characters). Make BUF large enough to hold
that. */
buf = scm_realloc (buf, (len * 7) / 6 + 1);
unistring_escapes_to_r6rs_escapes (buf, &len);
}
else
unistring_escapes_to_guile_escapes (buf, &len);
buf = scm_realloc (buf, len);
}
if (lenp)
*lenp = len;
else
{
buf = scm_realloc (buf, len + 1);
buf[len] = '\0';
}
scm_remember_upto_here_1 (str);
return buf;
}
libguile/strings.c (test)
================
char *
scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
scm_t_string_failed_conversion_handler handler)
{
char *buf;
const char *jrgbuf;//jrg
size_t ilen, len, i;
int ret;
const char *enc;
if (!scm_is_string (str))
scm_wrong_type_arg_msg (NULL, 0, str, "string");
ilen = scm_i_string_length (str);
if (ilen == 0)
{
buf = scm_malloc (1);
buf[0] = '\0';
if (lenp)
*lenp = 0;
return buf;
}
if (lenp == NULL)
for (i = 0; i < ilen; i++)
if (scm_i_string_ref (str, i) == '\0')
scm_misc_error (NULL,
"string contains #\\nul character: ~S",
scm_list_1 (str));
if (scm_i_is_narrow_string (str) && (encoding == NULL))
{
/* If using native Latin-1 encoding, just copy the string
contents. */
if (lenp)
{
buf = scm_malloc (ilen);
memcpy (buf, scm_i_string_chars (str), ilen);
*lenp = ilen;
return buf;
}
else
{
buf = scm_malloc (ilen + 1);
memcpy (buf, scm_i_string_chars (str), ilen);
buf[ilen] = '\0';
return buf;
}
}
buf = NULL;
jrgbuf = NULL;
len = 0;
enc = encoding;
//jrg if (enc == NULL) enc = "ISO-8859-1";
if (enc == NULL) enc = "ANSI_X3.4-1968";
if (scm_i_is_narrow_string (str))
{
jrgbuf = scm_i_string_chars (str); //jrg
// fprintf (stderr,"jrgbuf [%s]ilen[%d]encoding[%s]enc[%s]lenp[%d]\n",jrgbuf,ilen,encoding,enc,(int)(size_t )lenp);//jrg
ret = mem_iconveh (jrgbuf, ilen,
"ANSI_X3.4-1968", enc,//"ANSI_X3.4-1968" "ISO-8859-1" "UTF-8"
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);
if (ret != 0)
{//jrg
//try another one !!
// fprintf (stderr,"try ISO-8859-1 jrgbuf [%s]ilen[%d]encoding[%s]enc[%s]lenp[%d]\n",jrgbuf,ilen,encoding,enc,(int)(size_t )lenp);//jrg
ret = mem_iconveh (jrgbuf, ilen,
"ISO-8859-1", enc,//"ANSI_X3.4-1968" "ISO-8859-1" "UTF-8"
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);
}
if (ret != 0)
{//jrg
//try another one !!
// fprintf (stderr,"try UTF-8jrgbuf [%s]ilen[%d]encoding[%s]enc[%s]lenp[%d]\n",jrgbuf,ilen,encoding,enc,(int)(size_t )lenp);//jrg
ret = mem_iconveh (jrgbuf, ilen,
"UTF-8", enc,//"ANSI_X3.4-1968" "ISO-8859-1" "UTF-8"
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);
}
if (ret != 0)
{//jrg
printf("(ret != 0) jrgbuf [%s] buf[%s]\n",jrgbuf,buf);//jrg
fprintf (stderr,"failed return jrgbuf jrgbuf [%s]ilen[%d]encoding[%s]enc[%s]lenp[%d]\n",jrgbuf,ilen,encoding,enc,(int)(size_t )lenp);//jrg
return (char*)jrgbuf;//hmmm
scm_encoding_error (__func__, errno,
"cannot convert narrow string to output locale",
SCM_BOOL_F,
/* FIXME: Faulty character unknown. */
SCM_BOOL_F);
}//jrg
}
else
{
jrgbuf = (char *)(scm_t_uint32 *) scm_i_string_wide_chars (str); //jrg
fprintf (stderr,"jrgbuf [%s]ilen[%d]encoding[%s]enc[%s]lenp[%d]\n",jrgbuf,ilen,encoding,enc,(int)(size_t )lenp);//jrg
buf = u32_conv_to_encoding (enc,
(enum iconv_ilseq_handler) handler,
(scm_t_uint32 *) scm_i_string_wide_chars (str),
ilen,
NULL,
NULL, &len);
if (buf == NULL)
{//jrg
printf("(buf == NULL) jrgbuf [%s] buf [%s]\n",jrgbuf,buf);//jrg
scm_encoding_error (__func__, errno,
"cannot convert wide string to output locale",
SCM_BOOL_F,
/* FIXME: Faulty character unknown. */
SCM_BOOL_F);
}
}
if (handler == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE)
{
if (SCM_R6RS_ESCAPES_P)
{
/* The worst case is if the input string contains all 4-digit
hex escapes. "\uXXXX" (six characters) becomes "\xXXXX;"
(seven characters). Make BUF large enough to hold
that. */
buf = scm_realloc (buf, (len * 7) / 6 + 1);
unistring_escapes_to_r6rs_escapes (buf, &len);
}
else
unistring_escapes_to_guile_escapes (buf, &len);
buf = scm_realloc (buf, len);
}
if (lenp)
*lenp = len;
else
{
buf = scm_realloc (buf, len + 1);
buf[len] = '\0';
}
scm_remember_upto_here_1 (str);
return buf;
}
[-- Attachment #2: Type: text/html, Size: 20553 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: guile 2.0.1 working on cygwin (probably 2.0.0 also)
2011-05-23 1:59 guile 2.0.1 working on cygwin (probably 2.0.0 also) objc
@ 2011-05-25 12:40 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2011-05-25 12:40 UTC (permalink / raw)
To: guile-user
Hi,
"objc" <objcjohn@hotmail.com> skribas:
> I've got guile 2.0.1 to work on cygwin with a nasty "test hack".
>
> in scm_to_stringn function:
>
> ret = mem_iconveh (jrgbuf, ilen,
> "ISO-8859-1"
> //??????????
> , enc,//"ANSI_X3.4-1968" "ISO-8859-1" "UTF-8"
> (enum iconv_ilseq_handler) handler, NULL,
> &buf, &len);
>
> The mem_iconveh function fails.
> re-trying with "ANSI_X3.4-1968" or "UTF-8" in the //?????????? gets it work.
You mean “ISO-8859-1” is not considered a valid encoding name?
Did you install GNU libiconv before installing GNU libunistring?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-25 12:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-23 1:59 guile 2.0.1 working on cygwin (probably 2.0.0 also) objc
2011-05-25 12:40 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).