summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-11 17:33:13 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-11 17:33:13 +0200
commit890f782323849b2ae01cd705312d54a4a0e348fe (patch)
tree220604babca36e229cc64e9926ff9ebb44f694cd /parse.c
parenta7860f4dab1afcf94698bc2f52413e94eed64b52 (diff)
downloadrsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.tar.gz
rsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.tar.xz
rsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.zip
some cleanup
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/parse.c b/parse.c
index 5239b540..171e5355 100644
--- a/parse.c
+++ b/parse.c
@@ -244,7 +244,7 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrim
{
DEFiRet;
register unsigned char *pC;
- cstr_t *pCStr;
+ cstr_t *pCStr = NULL;
rsCHECKVALIDOBJECT(pThis, OIDrsPars);
@@ -255,12 +255,8 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrim
pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos;
- while(pThis->iCurrPos < rsCStrLen(pThis->pCStr)
- && *pC != cDelim) {
- if((iRet = rsCStrAppendChar(pCStr, bConvLower ? tolower(*pC) : *pC)) != RS_RET_OK) {
- rsCStrDestruct(&pCStr);
- FINALIZE;
- }
+ while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != cDelim) {
+ CHKiRet(rsCStrAppendChar(pCStr, bConvLower ? tolower(*pC) : *pC));
++pThis->iCurrPos;
++pC;
}
@@ -272,22 +268,21 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrim
/* We got the string, now take it and see if we need to
* remove anything at its end.
*/
- if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
- rsCStrDestruct (&pCStr);
- FINALIZE;
- }
+ CHKiRet(rsCStrFinish(pCStr));
if(bTrimTrailing) {
- if((iRet = rsCStrTrimTrailingWhiteSpace(pCStr))
- != RS_RET_OK) {
- rsCStrDestruct (&pCStr);
- FINALIZE;
- }
+ CHKiRet(rsCStrTrimTrailingWhiteSpace(pCStr));
}
/* done! */
*ppCStr = pCStr;
+
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pCStr != NULL)
+ rsCStrDestruct(&pCStr);
+ }
+
RETiRet;
}
@@ -309,13 +304,12 @@ finalize_it:
rsRetVal parsQuotedCStr(rsParsObj *pThis, cstr_t **ppCStr)
{
register unsigned char *pC;
- cstr_t *pCStr;
+ cstr_t *pCStr = NULL;
DEFiRet;
rsCHECKVALIDOBJECT(pThis, OIDrsPars);
- if((iRet = parsSkipAfterChar(pThis, '"')) != RS_RET_OK)
- FINALIZE;
+ CHKiRet(parsSkipAfterChar(pThis, '"'));
pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos;
/* OK, we most probably can obtain a value... */
@@ -332,16 +326,10 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, cstr_t **ppCStr)
* to the output buffer (but do not rely on this,
* we might later introduce other things, like \007!
*/
- if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct(&pCStr);
- FINALIZE;
- }
+ CHKiRet(rsCStrAppendChar(pCStr, *pC));
}
} else { /* regular character */
- if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct (&pCStr);
- FINALIZE;
- }
+ CHKiRet(rsCStrAppendChar(pCStr, *pC));
}
++pThis->iCurrPos;
++pC;
@@ -351,19 +339,22 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, cstr_t **ppCStr)
++pThis->iCurrPos; /* 'eat' trailing quote */
} else {
/* error - improperly quoted string! */
- rsCStrDestruct (&pCStr);
+ rsCStrDestruct(&pCStr);
ABORT_FINALIZE(RS_RET_MISSING_TRAIL_QUOTE);
}
/* We got the string, let's finish it... */
- if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
- rsCStrDestruct (&pCStr);
- FINALIZE;
- }
+ CHKiRet(rsCStrFinish(pCStr));
/* done! */
*ppCStr = pCStr;
+
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pCStr != NULL)
+ rsCStrDestruct(&pCStr);
+ }
+
RETiRet;
}