[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:
parent
e2376dbd15
commit
496a28f197
|
@ -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 */
|
||||
|
|
|
@ -887,6 +887,7 @@ static liHandlerResult core_handle_log_write(liVRequest *vr, gpointer param, gpo
|
|||
UNUSED(context);
|
||||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in New Issue