diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-10-21 15:03:53 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-10-21 15:03:53 +0200 |
commit | e7701775553a60efb050b0df497bb4df5df46d62 (patch) | |
tree | 5e8183f6bbb33e106624e8c9d9c3eab7a7006de9 /parse.c | |
parent | 359ddad3c5dce82ab48964c1d8b804c4155ea39c (diff) | |
parent | 12102199c4b3a042fb91e1d52eb274f06e62213e (diff) | |
download | rsyslog-e7701775553a60efb050b0df497bb4df5df46d62.tar.gz rsyslog-e7701775553a60efb050b0df497bb4df5df46d62.tar.xz rsyslog-e7701775553a60efb050b0df497bb4df5df46d62.zip |
Merge branch 'v5-devel'
Conflicts:
ChangeLog
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -210,22 +210,32 @@ rsRetVal parsSkipAfterChar(rsParsObj *pThis, char c) /* Skip whitespace. Often used to trim parsable entries. * Returns with ParsePointer set to first non-whitespace * character (or at end of string). + * If bRequireOne is set to true, at least one whitespace + * must exist, else an error is returned. */ -rsRetVal parsSkipWhitespace(rsParsObj *pThis) +rsRetVal parsSkipWhitespace(rsParsObj *pThis, sbool bRequireOne) { register unsigned char *pC; + int numSkipped; + DEFiRet; + rsCHECKVALIDOBJECT(pThis, OIDrsPars); pC = rsCStrGetBufBeg(pThis->pCStr); + numSkipped = 0; while(pThis->iCurrPos < rsCStrLen(pThis->pCStr)) { if(!isspace((int)*(pC+pThis->iCurrPos))) break; ++pThis->iCurrPos; + ++numSkipped; } - return RS_RET_OK; + if(bRequireOne && numSkipped == 0) + iRet = RS_RET_MISSING_WHITESPACE; + + RETiRet; } /* Parse string up to a delimiter. @@ -253,7 +263,7 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrim CHKiRet(rsCStrConstruct(&pCStr)); if(bTrimLeading) - parsSkipWhitespace(pThis); + parsSkipWhitespace(pThis, 0); pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos; @@ -384,7 +394,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits) CHKiRet(cstrConstruct(&pCStr)); - parsSkipWhitespace(pThis); + parsSkipWhitespace(pThis, 0); pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos; /* we parse everything until either '/', ',' or |