diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-10-21 14:47:18 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-10-21 14:47:18 +0200 |
commit | f3d4d83ce5a921899775eb59997d9d954b2f423d (patch) | |
tree | bb4af3cf3eea8733efa7ffd29586e23b54f1ff23 /parse.c | |
parent | bb293ca32a1b9750d53e9d6fdcf21a9d6d7c697d (diff) | |
parent | 5d67d98c35da731eab933dbfd858a0e009aa58de (diff) | |
download | rsyslog-f3d4d83ce5a921899775eb59997d9d954b2f423d.tar.gz rsyslog-f3d4d83ce5a921899775eb59997d9d954b2f423d.tar.xz rsyslog-f3d4d83ce5a921899775eb59997d9d954b2f423d.zip |
Merge branch 'v5-stable' into beta
Conflicts:
ChangeLog
configure.ac
doc/manual.html
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 |