summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-04-27 09:55:11 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-04-27 09:55:11 +0200
commit9801893b29ea47ade4b915e3eac79bcdc5ce74aa (patch)
tree305e277ab9faa5941d151eae68f5d04fc41e9129 /template.c
parentfb5cd633e6f4852841354fcf55c971063cc6a871 (diff)
parent9c76723c5b048afe4009f0528a6201741fec234a (diff)
downloadrsyslog-9801893b29ea47ade4b915e3eac79bcdc5ce74aa.zip
rsyslog-9801893b29ea47ade4b915e3eac79bcdc5ce74aa.tar.gz
rsyslog-9801893b29ea47ade4b915e3eac79bcdc5ce74aa.tar.xz
Merge branch 'v5-stable-field-substring' into v5-beta
Diffstat (limited to 'template.c')
-rw-r--r--template.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/template.c b/template.c
index 54ca95a..e58623d 100644
--- a/template.c
+++ b/template.c
@@ -732,6 +732,13 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
pTpe->data.field.field_expand = 1;
p ++;
}
+ if(*p == ',') { /* real fromPos? */
+ ++p;
+ iNum = 0;
+ while(isdigit((int)*p))
+ iNum = iNum * 10 + *p++ - '0';
+ pTpe->data.field.iFromPos = iNum;
+ }
}
}
} else {
@@ -832,10 +839,24 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
/* fallthrough to "regular" ToPos code */
#endif /* #ifdef FEATURE_REGEXP */
- iNum = 0;
- while(isdigit((int)*p))
- iNum = iNum * 10 + *p++ - '0';
- pTpe->data.field.iToPos = iNum;
+ if(pTpe->data.field.has_fields == 1) {
+ iNum = 0;
+ while(isdigit((int)*p))
+ iNum = iNum * 10 + *p++ - '0';
+ pTpe->data.field.iFieldNr = iNum;
+ if(*p == ',') { /* get real toPos? */
+ ++p;
+ iNum = 0;
+ while(isdigit((int)*p))
+ iNum = iNum * 10 + *p++ - '0';
+ pTpe->data.field.iToPos = iNum;
+ }
+ } else {
+ iNum = 0;
+ while(isdigit((int)*p))
+ iNum = iNum * 10 + *p++ - '0';
+ pTpe->data.field.iToPos = iNum;
+ }
/* skip to next known good */
while(*p && *p != '%' && *p != ':') {
/* TODO: complain on extra characters */
@@ -847,7 +868,7 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
#endif /* #ifdef FEATURE_REGEXP */
}
- if((pTpe->data.field.has_fields == 0) && (pTpe->data.field.iToPos < pTpe->data.field.iFromPos)) {
+ if(pTpe->data.field.iToPos < pTpe->data.field.iFromPos) {
iNum = pTpe->data.field.iToPos;
pTpe->data.field.iToPos = pTpe->data.field.iFromPos;
pTpe->data.field.iFromPos = iNum;
@@ -1276,9 +1297,9 @@ void tplPrintList(void)
}
if(pTpe->data.field.has_fields == 1) {
dbgprintf("[substring, field #%d only (delemiter %d)] ",
- pTpe->data.field.iToPos, pTpe->data.field.field_delim);
- } else if(pTpe->data.field.iFromPos != 0 ||
- pTpe->data.field.iToPos != 0) {
+ pTpe->data.field.iFieldNr, pTpe->data.field.field_delim);
+ }
+ if(pTpe->data.field.iFromPos != 0 || pTpe->data.field.iToPos != 0) {
dbgprintf("[substring, from character %d to %d] ",
pTpe->data.field.iFromPos,
pTpe->data.field.iToPos);