summaryrefslogtreecommitdiff
path: root/libguile/regex-posix.c
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2004-09-22 14:21:52 +0000
committerMarius Vollmer <mvo@zagadka.de>2004-09-22 14:21:52 +0000
commit1eff9c2f70d6995b7010d1e6239dfed073f30bf1 (patch)
tree1868d142ca06817f95794f0673c2996cb7c010fd /libguile/regex-posix.c
parentec82b7c251e0d6e3dfa199d74ffa814906b3c4b5 (diff)
downloadguile-1eff9c2f70d6995b7010d1e6239dfed073f30bf1.tar.gz
(scm_regexp_exec): Convert string to zero-temrinated locale string
before matching against it.
Diffstat (limited to 'libguile/regex-posix.c')
-rw-r--r--libguile/regex-posix.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libguile/regex-posix.c b/libguile/regex-posix.c
index 9587dfa0e..754f28904 100644
--- a/libguile/regex-posix.c
+++ b/libguile/regex-posix.c
@@ -218,6 +218,7 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
{
int status, nmatches, offset;
regmatch_t *matches;
+ char *c_str;
SCM mvec = SCM_BOOL_F;
SCM_VALIDATE_RGXP (1, rx);
@@ -226,7 +227,10 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
if (SCM_UNBNDP (start))
offset = 0;
else
- offset = scm_to_signed_integer (start, 0, scm_i_string_length (str));
+ {
+ str = scm_substring (str, start, SCM_UNDEFINED);
+ offset = scm_to_int (start);
+ }
if (SCM_UNBNDP (flags))
flags = SCM_INUM0;
@@ -237,9 +241,11 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
nmatches = SCM_RGX(rx)->re_nsub + 1;
SCM_DEFER_INTS;
matches = scm_malloc (sizeof (regmatch_t) * nmatches);
- status = regexec (SCM_RGX (rx), scm_i_string_chars (str) + offset,
- nmatches, matches,
+ c_str = scm_to_locale_string (str);
+ status = regexec (SCM_RGX (rx), c_str, nmatches, matches,
scm_to_int (flags));
+ free (c_str);
+
if (!status)
{
int i;