From 1eff9c2f70d6995b7010d1e6239dfed073f30bf1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 22 Sep 2004 14:21:52 +0000 Subject: (scm_regexp_exec): Convert string to zero-temrinated locale string before matching against it. --- libguile/regex-posix.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libguile/regex-posix.c') 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; -- cgit v1.2.3