diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2009-11-02 15:21:07 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2009-11-02 15:21:07 -0800 |
commit | 69a1cbeccd0834937a46c95da08948d684868c17 (patch) | |
tree | 4e721dab2e2442d3e7a0f390d6679f46d7a55da1 | |
parent | 6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d (diff) | |
download | txr-69a1cbeccd0834937a46c95da08948d684868c17.tar.gz txr-69a1cbeccd0834937a46c95da08948d684868c17.tar.bz2 txr-69a1cbeccd0834937a46c95da08948d684868c17.zip |
Lazy string fix.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib.c | 3 |
2 files changed, 7 insertions, 1 deletions
@@ -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. @@ -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); } |