summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-05-30 15:18:03 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-05-30 15:18:03 +0200
commit6a815063f37e7126f63fa00038f2d050574a6d52 (patch)
tree236a11b836b3a591dcb72056d56888875ef521d2 /runtime
parent99f18190a1f911224d45ca61706ae3fbc9ad7a80 (diff)
downloadrsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.tar.gz
rsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.tar.xz
rsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.zip
capability for replacement text in no match regex case added
implemented in property replacer: if a regular expression does not match, it can now either return "**NO MATCH** (default, as before), a blank property or the full original property text
Diffstat (limited to 'runtime')
-rw-r--r--runtime/msg.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 2798b7be..a90416ff 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -1844,25 +1844,30 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) {
if (0 != regexp.regexec(&pTpe->data.field.re, pRes, nmatch, pmatch, 0)) {
/* we got no match! */
- if (*pbMustBeFreed == 1) {
- free(pRes);
- *pbMustBeFreed = 0;
+ if(pTpe->data.field.nomatchAction != TPL_REGEX_NOMATCH_USE_WHOLE_FIELD) {
+ if (*pbMustBeFreed == 1) {
+ free(pRes);
+ *pbMustBeFreed = 0;
+ }
+ if(pTpe->data.field.nomatchAction == TPL_REGEX_NOMATCH_USE_DFLTSTR)
+ return "**NO MATCH**";
+ else
+ return "";
}
- return "**NO MATCH**";
} else {
-{int i; for(i = 0 ; i < 10 ; ++i) {
-dbgprintf("rqtd regex match (nmatch %d) # %d, idx %d: so %d, eo %d\n", nmatch, pTpe->data.field.iMatchToUse, i,
-pmatch[i].rm_so,
-pmatch[i].rm_eo);
-}}
/* Match- but did it match the one we wanted? */
/* we got no match! */
if(pmatch[pTpe->data.field.iMatchToUse].rm_so == -1) {
- if (*pbMustBeFreed == 1) {
- free(pRes);
- *pbMustBeFreed = 0;
+ if(pTpe->data.field.nomatchAction != TPL_REGEX_NOMATCH_USE_WHOLE_FIELD) {
+ if (*pbMustBeFreed == 1) {
+ free(pRes);
+ *pbMustBeFreed = 0;
+ }
+ if(pTpe->data.field.nomatchAction == TPL_REGEX_NOMATCH_USE_DFLTSTR)
+ return "**NO MATCH**";
+ else
+ return "";
}
- return "**NO MATCH**";
}
/* OK, we have a usable match - we now need to malloc pB */
int iLenBuf;