From: Automatic source maintenance Date: Mon, 2 Jun 2014 00:15:10 +0000 (-0600) Subject: SourceFormat Enforcement X-Git-Tag: SQUID_3_5_0_1~215 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11bd437000fa5b5a035875a8b0a18a7ab25c3d4c;p=thirdparty%2Fsquid.git SourceFormat Enforcement --- diff --git a/src/parser/Tokenizer.cc b/src/parser/Tokenizer.cc index 6a664bafcf..a13e218ebe 100644 --- a/src/parser/Tokenizer.cc +++ b/src/parser/Tokenizer.cc @@ -107,7 +107,7 @@ Parser::Tokenizer::int64(int64_t & result, int base) } if (s >= end) return false; if (( base == 0 || base == 16) && *s == '0' && (s+1 <= end ) && - tolower(*(s+1)) == 'x') { + tolower(*(s+1)) == 'x') { s += 2; base = 16; } diff --git a/src/parser/Tokenizer.h b/src/parser/Tokenizer.h index 93796fb25b..71526881e8 100644 --- a/src/parser/Tokenizer.h +++ b/src/parser/Tokenizer.h @@ -5,7 +5,8 @@ #include "SBuf.h" /// Generic protocol-agnostic parsing tools -namespace Parser { +namespace Parser +{ /** * Lexical processor to tokenize a buffer. @@ -17,77 +18,78 @@ namespace Parser { * Methods returning true consume bytes from the buffer. * Methods returning false have no side-effects. */ -class Tokenizer { +class Tokenizer +{ public: - explicit Tokenizer(const SBuf &inBuf) : buf_(inBuf) {} - - // return a copy the current contents of the parse buffer - const SBuf buf() const { return buf_; } - - /// whether the end of the buffer has been reached - bool atEnd() const { return buf_.isEmpty(); } - - /// the remaining unprocessed section of buffer - const SBuf& remaining() const { return buf_; } - - /// reinitialize processing for a new buffer - void reset(const SBuf &newBuf) { buf_ = newBuf; } - - /** Basic strtok(3): - * Skips all leading delimiters (if any), - * accumulates all characters up to the next delimiter (a token), and - * skips all trailing delimiters. - * - * Want to extract delimiters? Use prefix() instead. - * - * At least one terminating delimiter is required. \0 may be passed - * as a delimiter to treat end of buffer content as the end of token. - * - * \return false if no terminal delimiter is found. - */ - bool token(SBuf &returnedToken, const CharacterSet &delimiters); - - /** Accumulates all sequential permitted characters up to an optional length limit. - * - * \retval true one or more characters were found, the sequence (string) is placed in returnedToken - * \retval false no characters from the permitted set were found - */ - bool prefix(SBuf &returnedToken, const CharacterSet &tokenChars, SBuf::size_type limit = SBuf::npos); - - /** skips all sequential characters from the set, in any order - * - * \return whether one or more characters in the set were found - */ - bool skip(const CharacterSet &tokenChars); - - /** skips a given character sequence (string) - * - * \return whether the exact character sequence was found and skipped - */ - bool skip(const SBuf &tokenToSkip); - - /** skips a given single character - * - * \return whether the character was found and skipped - */ - bool skip(const char tokenChar); - - /** parse an unsigned int64_t at the beginning of the buffer - * - * strtoll(3)-alike function: tries to parse unsigned 64-bit integer - * at the beginning of the parse buffer, in the base specified by the user - * or guesstimated; consumes the parsed characters. - * - * \param result Output value. Not touched if parsing is unsuccessful. - * \param base Specify base to do the parsing in, with the same restrictions - * as strtoll. Defaults to 0 (meaning guess) - * - * \return whether the parsing was successful - */ - bool int64(int64_t &result, int base = 0); + explicit Tokenizer(const SBuf &inBuf) : buf_(inBuf) {} + + // return a copy the current contents of the parse buffer + const SBuf buf() const { return buf_; } + + /// whether the end of the buffer has been reached + bool atEnd() const { return buf_.isEmpty(); } + + /// the remaining unprocessed section of buffer + const SBuf& remaining() const { return buf_; } + + /// reinitialize processing for a new buffer + void reset(const SBuf &newBuf) { buf_ = newBuf; } + + /** Basic strtok(3): + * Skips all leading delimiters (if any), + * accumulates all characters up to the next delimiter (a token), and + * skips all trailing delimiters. + * + * Want to extract delimiters? Use prefix() instead. + * + * At least one terminating delimiter is required. \0 may be passed + * as a delimiter to treat end of buffer content as the end of token. + * + * \return false if no terminal delimiter is found. + */ + bool token(SBuf &returnedToken, const CharacterSet &delimiters); + + /** Accumulates all sequential permitted characters up to an optional length limit. + * + * \retval true one or more characters were found, the sequence (string) is placed in returnedToken + * \retval false no characters from the permitted set were found + */ + bool prefix(SBuf &returnedToken, const CharacterSet &tokenChars, SBuf::size_type limit = SBuf::npos); + + /** skips all sequential characters from the set, in any order + * + * \return whether one or more characters in the set were found + */ + bool skip(const CharacterSet &tokenChars); + + /** skips a given character sequence (string) + * + * \return whether the exact character sequence was found and skipped + */ + bool skip(const SBuf &tokenToSkip); + + /** skips a given single character + * + * \return whether the character was found and skipped + */ + bool skip(const char tokenChar); + + /** parse an unsigned int64_t at the beginning of the buffer + * + * strtoll(3)-alike function: tries to parse unsigned 64-bit integer + * at the beginning of the parse buffer, in the base specified by the user + * or guesstimated; consumes the parsed characters. + * + * \param result Output value. Not touched if parsing is unsuccessful. + * \param base Specify base to do the parsing in, with the same restrictions + * as strtoll. Defaults to 0 (meaning guess) + * + * \return whether the parsing was successful + */ + bool int64(int64_t &result, int base = 0); private: - SBuf buf_; ///< yet unparsed input + SBuf buf_; ///< yet unparsed input }; } /* namespace Parser */ diff --git a/src/parser/testTokenizer.cc b/src/parser/testTokenizer.cc index 4e4dfa5ae6..ac4dec4bf0 100644 --- a/src/parser/testTokenizer.cc +++ b/src/parser/testTokenizer.cc @@ -6,9 +6,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION( testTokenizer ); SBuf text("GET http://resource.com/path HTTP/1.1\r\n" - "Host: resource.com\r\n" - "Cookie: laijkpk3422r j1noin \r\n" - "\r\n"); + "Host: resource.com\r\n" + "Cookie: laijkpk3422r j1noin \r\n" + "\r\n"); const CharacterSet alpha("alpha","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); const CharacterSet whitespace("whitespace"," \r\n"); const CharacterSet crlf("crlf","\r\n");