diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-04 11:11:52 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-04 11:11:52 +0200 |
commit | eddaca33a81206aab7c6627e5c91d22232445adf (patch) | |
tree | 2aafa6d745db2b2e51ef5d616ca11ee44b2e5d54 /template.c | |
parent | 99e97dadf1d03c9db33d49e91b26ceb28a39ed1a (diff) | |
download | rsyslog-eddaca33a81206aab7c6627e5c91d22232445adf.tar.gz rsyslog-eddaca33a81206aab7c6627e5c91d22232445adf.tar.xz rsyslog-eddaca33a81206aab7c6627e5c91d22232445adf.zip |
enhanced property replacer to support multiple regex matches
Diffstat (limited to 'template.c')
-rw-r--r-- | template.c | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -534,14 +534,14 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl) } /* now check for submatch ID */ - pTpe->data.field.iMatchToUse = 0; + pTpe->data.field.iSubMatchToUse = 0; if(*p == ',') { /* in this case a number follows, which indicates which match * shall be used. This must be a single digit. */ ++p; /* eat ',' */ if(isdigit((int) *p)) { - pTpe->data.field.iMatchToUse = *p - '0'; + pTpe->data.field.iSubMatchToUse = *p - '0'; ++p; /* eat digit */ } } @@ -561,12 +561,30 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl) && (p[5] == ',' || p[5] == ':')) { pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_WHOLE_FIELD; p += 5; /* eat indicator sequence */ + } else if(p[0] == ',') { /* empty, use default */ + pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_DFLTSTR; + /* do NOT eat indicator sequence, as this was already eaten - the + * comma itself is already part of the next field. + */ } else { errmsg.LogError(NO_ERRCODE, "error: invalid regular expression type, rest of line %s", (char*) p); } } + /* now check for match ID */ + pTpe->data.field.iMatchToUse = 0; + if(*p == ',') { + /* in this case a number follows, which indicates which match + * shall be used. This must be a single digit. + */ + ++p; /* eat ',' */ + if(isdigit((int) *p)) { + pTpe->data.field.iMatchToUse = *p - '0'; + ++p; /* eat digit */ + } + } + if(*p != ':') { /* There is something more than an R , this is invalid ! */ /* Complain on extra characters */ @@ -574,8 +592,8 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl) (char*) *pp); } else { pTpe->data.field.has_regex = 1; - dbgprintf("we have a regexp and use match #%d\n", - pTpe->data.field.iMatchToUse); + dbgprintf("we have a regexp and use match #%d, submatch #%d\n", + pTpe->data.field.iMatchToUse, pTpe->data.field.iSubMatchToUse); } } else { /* now we fall through the "regular" FromPos code */ |