summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f4b2de1..314b26a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-10-20 Kaz Kylheku <kkylheku@gmail.com>
+ * lib.c (sub_str): Avoid invoking c_str which forces the
+ lazy string.
+
+2009-10-20 Kaz Kylheku <kkylheku@gmail.com>
+
Start of implementation for freestyle matching.
Lazy strings implemented, incompletely.
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);
}