diff options
author | Michael Biebl <biebl@debian.org> | 2011-10-21 17:03:33 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2011-10-21 17:03:33 +0200 |
commit | a7a3afdd81c8809fbc4927b360e1cb59e2e16b2e (patch) | |
tree | 87efee7c0a74d351e4d88e52a5b84fbd4b3b191d /parse.c | |
parent | ae82a633a4d42dfdc942d8f0f4f5e6470f13797e (diff) | |
download | rsyslog-a7a3afdd81c8809fbc4927b360e1cb59e2e16b2e.tar.gz |
Imported Upstream version 5.8.6upstream/5.8.6
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. @@ -252,7 +262,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; @@ -383,7 +393,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 |