* bug with read-string!/partial
@ 2005-08-22 21:14 Han-Wen Nienhuys
2005-08-22 21:17 ` Han-Wen Nienhuys
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Han-Wen Nienhuys @ 2005-08-22 21:14 UTC (permalink / raw)
Hi,
what's the proper way to use read-string!/partial ?
If I read a file with fewer bytes than the arg of read-string!/partial,
I get problems down the line, when
char *
scm_to_locale_stringn (SCM str, size_t *lenp)
checks whether
memcpy (res, scm_i_string_chars (str), len);
if (lenp == NULL)
{
res[len] = '\0';
if (strlen (res) != len)
{
free (res);
scm_misc_error (NULL,
"string contains #\\nul character: ~S",
scm_list_1 (str));
}
}
In addition, I this error message isn't printed properly, but I get
Converting to PNG...throw from within critical section.
Geannuleerd
muurbloem:~/src/lilypond$
--
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bug with read-string!/partial
2005-08-22 21:14 bug with read-string!/partial Han-Wen Nienhuys
@ 2005-08-22 21:17 ` Han-Wen Nienhuys
2005-08-23 0:31 ` Kevin Ryde
2005-08-23 0:34 ` Kevin Ryde
2005-12-06 22:14 ` Marius Vollmer
2 siblings, 1 reply; 5+ messages in thread
From: Han-Wen Nienhuys @ 2005-08-22 21:17 UTC (permalink / raw)
Cc: guile-devel
Han-Wen Nienhuys wrote:
>
> Hi,
>
> what's the proper way to use read-string!/partial ?
>
> If I read a file with fewer bytes than the arg of read-string!/partial,
> I get problems down the line, when
>
> char *
> scm_to_locale_stringn (SCM str, size_t *lenp)
>
> checks whether
>
> memcpy (res, scm_i_string_chars (str), len);
> if (lenp == NULL)
> {
> res[len] = '\0';
> if (strlen (res) != len)
> {
> free (res);
> scm_misc_error (NULL,
> "string contains #\\nul character: ~S",
> scm_list_1 (str));
> }
> }
>
> In addition, I this error message isn't printed properly, but I get
>
> Converting to PNG...throw from within critical section.
> Geannuleerd
> muurbloem:~/src/lilypond$
>
>
additional information: this comes from regex-posix.c
c_str = scm_to_locale_string (substr);
status = regexec (SCM_RGX (rx), c_str, nmatches, matches,
scm_to_int (flags));
free (c_str);
why is this using null-delimited strings?
--
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bug with read-string!/partial
2005-08-22 21:17 ` Han-Wen Nienhuys
@ 2005-08-23 0:31 ` Kevin Ryde
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Ryde @ 2005-08-23 0:31 UTC (permalink / raw)
Cc: guile-devel
Han-Wen Nienhuys <hanwen@xs4all.nl> writes:
>
> why is this using null-delimited strings?
I think that's all posix provides. Separate regexp libraries might do
better. I was going to add a note about no nulls in the manual, but
never did.
Speaking of regexps, what I think I will do for the docs is put
someting like the following about locale chars. (I got into trouble
trying to match some shift-jis bytes when in a utf-8 locale.)
POSIX regexp functions interpret both regexps and input strings in
the locale character set. Since Guile strings are currently merely
bytes (*note Conversion to/from C::), care should be taken when working
with non-ASCII characters. If `setlocale' has been called and selects
a multibyte codeset (*note Locales::), then non-ASCII bytes may be
interpreted as a multibyte character.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bug with read-string!/partial
2005-08-22 21:14 bug with read-string!/partial Han-Wen Nienhuys
2005-08-22 21:17 ` Han-Wen Nienhuys
@ 2005-08-23 0:34 ` Kevin Ryde
2005-12-06 22:14 ` Marius Vollmer
2 siblings, 0 replies; 5+ messages in thread
From: Kevin Ryde @ 2005-08-23 0:34 UTC (permalink / raw)
Cc: guile-devel
Han-Wen Nienhuys <hanwen@xs4all.nl> writes:
>
> what's the proper way to use read-string!/partial ?
>
> If I read a file with fewer bytes than the arg of read-string!/partial,
> I get problems down the line,
It leaves the rest of the string with whatever was there before, I
think you normally have to do substring or substring/shared to get the
good portion.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bug with read-string!/partial
2005-08-22 21:14 bug with read-string!/partial Han-Wen Nienhuys
2005-08-22 21:17 ` Han-Wen Nienhuys
2005-08-23 0:34 ` Kevin Ryde
@ 2005-12-06 22:14 ` Marius Vollmer
2 siblings, 0 replies; 5+ messages in thread
From: Marius Vollmer @ 2005-12-06 22:14 UTC (permalink / raw)
Cc: guile-devel
Han-Wen Nienhuys <hanwen@xs4all.nl> writes:
> Hi,
>
> what's the proper way to use read-string!/partial ?
>
> If I read a file with fewer bytes than the arg of read-string!/partial,
> I get problems down the line [with scm_to_locale_stringn]
Do you pass the right length to scm_to_locale_stringn, i.e, the return
value of read-string!/partial?
Also, maybe there really are #\nul characters in the file and the
error message from scm_to_locale_stringn is entirely deserved.
> In addition, I this error message isn't printed properly, but I get
>
> Converting to PNG...throw from within critical section.
> Geannuleerd
> muurbloem:~/src/lilypond$
This message means that SCM_CRITICAL_SECTION_START/END is used
improperly. There are likely some improper uses in Guile itself (and
this issue is what is holding off the 1.8 release at the moment...),
so it would be good to know exactly what instance of
SCM_CRITICAL_SECTION_START/END is responsible for your abort.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-12-06 22:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-22 21:14 bug with read-string!/partial Han-Wen Nienhuys
2005-08-22 21:17 ` Han-Wen Nienhuys
2005-08-23 0:31 ` Kevin Ryde
2005-08-23 0:34 ` Kevin Ryde
2005-12-06 22:14 ` Marius Vollmer
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).