Fixed tokenizer not to strip CR from quoted string...

...because it would destroy images transfered over network
This commit is contained in:
Pauli Nieminen 2008-05-28 09:38:05 +00:00
parent ae289c84de
commit c61cc8fb1d
3 changed files with 32 additions and 7 deletions

View file

@ -24,6 +24,8 @@ Version 1.4.2+svn:
* Fixed a mememory leak in networking code
* fixed an alignement issue which caused a SIGBUS on a Sparc
(debian bug #426318)
* Fixed tokenizer not to strip CR from quoted string becaue it would destroy
images transfered over network
* added some includes to fix compilation problems with Sun Studio 12
(patch #1066)
* fixed null-pointer reference in network code

View file

@ -146,20 +146,23 @@ const token& tokenizer::next_token()
case '"':
token_.type = token::QSTRING;
while (1) {
next_char();
/** Have to use next_char_no_strip
* because we will break image ifwe do striping
**/
next_char_no_strip();
if(current_ == EOF) {
token_.type = token::UNTERMINATED_QSTRING;
break;
}
if(current_ == '"' && peek_char() != '"')
if(current_ == '"' && peek_char_no_strip() != '"')
break;
if(current_ == '"' && peek_char() == '"')
next_char_fast();
if(current_ == '"' && peek_char_no_strip() == '"')
next_char_fast_no_strip();
if (current_ == 254 &&
(peek_char() == 'l' || peek_char() == 't')) {
next_char_fast();
if ((current_ == 'l' && peek_char() == 'i') || (current_ == 't' && peek_char() == 'e'))
(peek_char_no_strip() == 'l' || peek_char_no_strip() == 't')) {
next_char_fast_no_strip();
if ((current_ == 'l' && peek_char_no_strip() == 'i') || (current_ == 't' && peek_char_no_strip() == 'e'))
{
skip_comment();
--lineno_;

View file

@ -71,6 +71,26 @@ protected:
int current_;
size_t lineno_;
inline void next_char_no_strip()
{
if (UNLIKELY(current_ == '\n'))
lineno_++;
this->next_char_fast_no_strip();
}
inline void next_char_fast_no_strip()
{
if (LIKELY(in_.good()))
{
current_ = in_.get();
}
else
{
current_ = EOF;
return;
}
}
inline void next_char()
{
if (UNLIKELY(current_ == '\n'))