------------------------------------------------------------ revno: 13430 revision-id: squidadm@squid-cache.org-20140602001510-gpvob5v5jmrforrb parent: kinkie@squid-cache.org-20140601210431-b80nr634t42f2qdz committer: Automatic source maintenance branch nick: trunk timestamp: Sun 2014-06-01 18:15:10 -0600 message: SourceFormat Enforcement ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squidadm@squid-cache.org-20140602001510-\ # gpvob5v5jmrforrb # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 4ea6d101d404417cb08b9e23a8d61cf9d055c3bc # timestamp: 2014-06-02 00:54:03 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: kinkie@squid-cache.org-20140601210431-\ # b80nr634t42f2qdz # # Begin patch === modified file 'src/parser/Tokenizer.cc' --- src/parser/Tokenizer.cc 2014-06-01 21:04:31 +0000 +++ src/parser/Tokenizer.cc 2014-06-02 00:15:10 +0000 @@ -107,7 +107,7 @@ } 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; } === modified file 'src/parser/Tokenizer.h' --- src/parser/Tokenizer.h 2014-06-01 13:53:17 +0000 +++ src/parser/Tokenizer.h 2014-06-02 00:15:10 +0000 @@ -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 @@ * 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 */ === modified file 'src/parser/testTokenizer.cc' --- src/parser/testTokenizer.cc 2014-05-30 09:42:45 +0000 +++ src/parser/testTokenizer.cc 2014-06-02 00:15:10 +0000 @@ -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");