From 69a1cbeccd0834937a46c95da08948d684868c17 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 2 Nov 2009 15:21:07 -0800 Subject: Lazy string fix. --- ChangeLog | 5 +++++ lib.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0f4b2de1..314b26a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-20 Kaz Kylheku + + * lib.c (sub_str): Avoid invoking c_str which forces the + lazy string. + 2009-10-20 Kaz Kylheku Start of implementation for freestyle matching. diff --git a/lib.c b/lib.c index c5a066d1..8bb72dc1 100644 --- a/lib.c +++ b/lib.c @@ -836,7 +836,8 @@ obj_t *sub_str(obj_t *str_in, obj_t *from, obj_t *to) } else { size_t size = c_num(to) - c_num(from) + 1; char *sub = chk_malloc(size); - strncpy(sub, c_str(str_in) + c_num(from), size); + const char *str = c_str(lazy_stringp(str_in) ? str_in->ls.prefix : str_in); + strncpy(sub, str + c_num(from), size); sub[size-1] = 0; return string_own(sub); } -- cgit v1.2.3