- SilcStack support compile/match without real memory allocations
*/
-#include "silc.h"
+#include "silcruntime.h"
#define RE_NREGS 128 /* number of registers available */
regexp->rstack = silc_stack_alloc(512, regexp->rstack);
/* Compile */
- ret = silc_re_compile_pattern((char *)regex, strlen(regex), regexp);
+ ret = silc_re_compile_pattern((unsigned char *)regex, strlen(regex), regexp);
if (ret != SILC_OK)
silc_set_errno(ret);
f |= RE_NOTEOL;
/* Search */
- ret = silc_re_search(regexp, (char *)string, string_len, 0, string_len,
- num_match ? ®s : NULL, f);
+ ret = silc_re_search(regexp, (unsigned char *)string, string_len, 0,
+ string_len, num_match ? ®s : NULL, f);
if (ret < 0) {
if (ret == -1)
silc_set_errno(SILC_ERR_NOT_FOUND);
silc_regex_free(®);
return FALSE;
}
+ silc_buffer_set(match, NULL, 0);
rets[c++] = match;
while ((buf = va_arg(va, SilcBuffer))) {
silc_regex_free(®);
return FALSE;
}
+ silc_buffer_set(buf, NULL, 0);
rets[c++] = buf;
}
/* Return matches */
for (i = 0; i < c; i++) {
- if (m[i].start == -1) {
- silc_buffer_set(rets[i], NULL, 0);
+ if (m[i].start == -1)
continue;
- }
silc_buffer_set(rets[i], (unsigned char *)string + m[i].start,
m[i].end - m[i].start);
}