mirror of
https://github.com/janet-lang/janet
synced 2025-10-30 07:03:02 +00:00
Fix error in string.replace-all
This commit is contained in:
@@ -245,10 +245,7 @@ static void janet_deinit_block(JanetGCMemoryHeader *block) {
|
||||
break;
|
||||
case JANET_MEMORY_ABSTRACT:
|
||||
if (h->type->gc) {
|
||||
if (h->type->gc((void *)(h + 1), h->size)) {
|
||||
/* finalizer failed. try again later? Panic? For now do nothing. */
|
||||
;
|
||||
}
|
||||
janet_assert(!h->type->gc((void *)(h + 1), h->size), "finalizer failed");
|
||||
}
|
||||
break;
|
||||
case JANET_MEMORY_FUNCENV:
|
||||
|
||||
@@ -605,6 +605,11 @@ static void kmp_deinit(struct kmp_state *state) {
|
||||
free(state->lookup);
|
||||
}
|
||||
|
||||
static void kmp_seti(struct kmp_state *state, int32_t i) {
|
||||
state->i = i;
|
||||
state->j = 0;
|
||||
}
|
||||
|
||||
static int32_t kmp_next(struct kmp_state *state) {
|
||||
int32_t i = state->i;
|
||||
int32_t j = state->j;
|
||||
@@ -880,6 +885,7 @@ static int cfun_replaceall(JanetArgs args) {
|
||||
janet_buffer_push_bytes(&b, s.kmp.text + lastindex, result - lastindex);
|
||||
janet_buffer_push_bytes(&b, s.subst, s.substlen);
|
||||
lastindex = result + s.kmp.patlen;
|
||||
kmp_seti(&s.kmp, lastindex);
|
||||
}
|
||||
janet_buffer_push_bytes(&b, s.kmp.text + lastindex, s.kmp.textlen - lastindex);
|
||||
ret = janet_string(b.data, b.count);
|
||||
|
||||
@@ -167,10 +167,12 @@ extern "C" {
|
||||
* To turn of nanboxing, for debugging purposes or for certain
|
||||
* architectures (Nanboxing only tested on x86 and x64), comment out
|
||||
* the JANET_NANBOX define.*/
|
||||
#ifndef JANET_NO_NANBOX
|
||||
#define JANET_NANBOX
|
||||
|
||||
/* Further refines the type of nanboxing to use. */
|
||||
#define JANET_NANBOX_47
|
||||
#endif
|
||||
|
||||
/* Alignment for pointers */
|
||||
#ifdef JANET_32
|
||||
|
||||
Reference in New Issue
Block a user