Fork 0

[core] truncate temp string before evaluating pattern. add comment to pattern.h that li_eval_pattern() does not truncate the string for you

This commit is contained in:
Thomas Porzelt 2011-07-20 20:48:30 +02:00
parent e2376dbd15
commit 496a28f197
2 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,7 @@ typedef void (*liPatternCB) (GString *pattern_result, guint from, guint to, gpoi
LI_API liPattern *li_pattern_new(liServer *srv, const gchar* str);
LI_API void li_pattern_free(liPattern *pattern);
/* you can use vr->wrk->tmp_str as dest! */
/* appends the result to "dest". use (and truncate) vr->wrk->tmp_str as "dest" if possible */
LI_API void li_pattern_eval(liVRequest *vr, GString *dest, liPattern *pattern, liPatternCB nth_callback, gpointer nth_data, liPatternCB nth_prev_callback, gpointer nth_prev_data);
/* default array callback, expects a GArray* containing GString* elements */

View File

@ -887,6 +887,7 @@ static liHandlerResult core_handle_log_write(liVRequest *vr, gpointer param, gpo
/* eval pattern, ignore $n */
g_string_truncate(vr->wrk->tmp_str, 0);
li_pattern_eval(vr, vr->wrk->tmp_str, pattern, NULL, NULL, li_pattern_regex_cb, match_info);
VR_INFO(vr, "%s", vr->wrk->tmp_str->str);