From: Pekka Riikonen Date: Sun, 21 Sep 2008 12:32:04 +0000 (+0300) Subject: SilcRegex: Fixed silc_regex to return correct value for optional args X-Git-Tag: 1.2.beta5~3 X-Git-Url: http://git.silc.fi/gitweb/?p=runtime.git;a=commitdiff_plain;h=296e4d08e79816ef1474596e81857b9261500f22 SilcRegex: Fixed silc_regex to return correct value for optional args In grouped expressions, optional, non-matched arguments didn't have their value set to NULL as documented. Set all arguments by default to NULL. --- diff --git a/lib/silcutil/silcregex.c b/lib/silcutil/silcregex.c index 84449695..3c83ed78 100644 --- a/lib/silcutil/silcregex.c +++ b/lib/silcutil/silcregex.c @@ -2411,6 +2411,7 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, silc_regex_free(®); return FALSE; } + silc_buffer_set(match, NULL, 0); rets[c++] = match; while ((buf = va_arg(va, SilcBuffer))) { @@ -2421,6 +2422,7 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, silc_regex_free(®); return FALSE; } + silc_buffer_set(buf, NULL, 0); rets[c++] = buf; } @@ -2444,10 +2446,8 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, /* 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); }