mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-22 22:58:33 +00:00
Only build QPDFTokenizer::val for name and string tokens
For all other token types val and raw_val are identical.
This commit is contained in:
parent
59191ebbc4
commit
a07d2b4190
@ -261,15 +261,11 @@ QPDFTokenizer::inBeforeToken(char ch)
|
||||
this->in_token = this->include_ignorable;
|
||||
if (this->include_ignorable) {
|
||||
this->state = st_in_space;
|
||||
this->val += ch;
|
||||
}
|
||||
} else if (ch == '%') {
|
||||
this->before_token = !this->include_ignorable;
|
||||
this->in_token = this->include_ignorable;
|
||||
this->state = st_in_comment;
|
||||
if (this->include_ignorable) {
|
||||
this->val += ch;
|
||||
}
|
||||
} else {
|
||||
this->before_token = false;
|
||||
this->in_token = true;
|
||||
@ -298,32 +294,27 @@ QPDFTokenizer::inTop(char ch)
|
||||
this->type = tt_bad;
|
||||
QTC::TC("qpdf", "QPDFTokenizer bad )");
|
||||
this->error_message = "unexpected )";
|
||||
this->val += ch;
|
||||
this->state = st_token_ready;
|
||||
return;
|
||||
|
||||
case '[':
|
||||
this->type = tt_array_open;
|
||||
this->state = st_token_ready;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
case ']':
|
||||
this->type = tt_array_close;
|
||||
this->val += ch;
|
||||
this->state = st_token_ready;
|
||||
return;
|
||||
|
||||
case '{':
|
||||
this->type = tt_brace_open;
|
||||
this->state = st_token_ready;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
case '}':
|
||||
this->type = tt_brace_close;
|
||||
this->state = st_token_ready;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
case '/':
|
||||
@ -342,23 +333,19 @@ QPDFTokenizer::inTop(char ch)
|
||||
case '8':
|
||||
case '9':
|
||||
this->state = st_number;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
case '+':
|
||||
case '-':
|
||||
this->state = st_sign;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
case '.':
|
||||
this->state = st_decimal;
|
||||
this->val += ch;
|
||||
return;
|
||||
|
||||
default:
|
||||
this->state = st_literal;
|
||||
this->val += ch;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -372,10 +359,6 @@ QPDFTokenizer::inSpace(char ch)
|
||||
this->in_token = false;
|
||||
this->char_to_unread = ch;
|
||||
this->state = st_token_ready;
|
||||
return;
|
||||
} else {
|
||||
this->val += ch;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,8 +374,6 @@ QPDFTokenizer::inComment(char ch)
|
||||
} else {
|
||||
this->state = st_before_token;
|
||||
}
|
||||
} else if (this->include_ignorable) {
|
||||
this->val += ch;
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,10 +508,8 @@ QPDFTokenizer::inSign(char ch)
|
||||
{
|
||||
if (QUtil::is_digit(ch)) {
|
||||
this->state = st_number;
|
||||
this->val += ch;
|
||||
} else if (ch == '.') {
|
||||
this->state = st_decimal;
|
||||
this->val += ch;
|
||||
} else {
|
||||
this->state = st_literal;
|
||||
inLiteral(ch);
|
||||
@ -542,7 +521,6 @@ QPDFTokenizer::inDecimal(char ch)
|
||||
{
|
||||
if (QUtil::is_digit(ch)) {
|
||||
this->state = st_real;
|
||||
this->val += ch;
|
||||
} else {
|
||||
this->state = st_literal;
|
||||
inLiteral(ch);
|
||||
@ -553,10 +531,8 @@ void
|
||||
QPDFTokenizer::inNumber(char ch)
|
||||
{
|
||||
if (QUtil::is_digit(ch)) {
|
||||
this->val += ch;
|
||||
} else if (ch == '.') {
|
||||
this->state = st_real;
|
||||
this->val += ch;
|
||||
} else if (isDelimiter(ch)) {
|
||||
this->type = tt_integer;
|
||||
this->state = st_token_ready;
|
||||
@ -564,7 +540,6 @@ QPDFTokenizer::inNumber(char ch)
|
||||
this->char_to_unread = ch;
|
||||
} else {
|
||||
this->state = st_literal;
|
||||
this->val += ch;
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,7 +547,6 @@ void
|
||||
QPDFTokenizer::inReal(char ch)
|
||||
{
|
||||
if (QUtil::is_digit(ch)) {
|
||||
this->val += ch;
|
||||
} else if (isDelimiter(ch)) {
|
||||
this->type = tt_real;
|
||||
this->state = st_token_ready;
|
||||
@ -580,7 +554,6 @@ QPDFTokenizer::inReal(char ch)
|
||||
this->char_to_unread = ch;
|
||||
} else {
|
||||
this->state = st_literal;
|
||||
this->val += ch;
|
||||
}
|
||||
}
|
||||
void
|
||||
@ -649,7 +622,6 @@ void
|
||||
QPDFTokenizer::inLt(char ch)
|
||||
{
|
||||
if (ch == '<') {
|
||||
this->val += "<<";
|
||||
this->type = tt_dict_open;
|
||||
this->state = st_token_ready;
|
||||
return;
|
||||
@ -663,11 +635,9 @@ void
|
||||
QPDFTokenizer::inGt(char ch)
|
||||
{
|
||||
if (ch == '>') {
|
||||
this->val += ">>";
|
||||
this->type = tt_dict_close;
|
||||
this->state = st_token_ready;
|
||||
} else {
|
||||
this->val += ">";
|
||||
this->type = tt_bad;
|
||||
QTC::TC("qpdf", "QPDFTokenizer bad >");
|
||||
this->error_message = "unexpected >";
|
||||
@ -692,11 +662,9 @@ QPDFTokenizer::inLiteral(char ch)
|
||||
this->in_token = false;
|
||||
this->char_to_unread = ch;
|
||||
this->state = st_token_ready;
|
||||
this->type = (this->val == "true") || (this->val == "false")
|
||||
this->type = (this->raw_val == "true") || (this->raw_val == "false")
|
||||
? tt_bool
|
||||
: (this->val == "null" ? tt_null : tt_word);
|
||||
} else {
|
||||
this->val += ch;
|
||||
: (this->raw_val == "null" ? tt_null : tt_word);
|
||||
}
|
||||
}
|
||||
|
||||
@ -783,8 +751,7 @@ QPDFTokenizer::inCharCode(char ch)
|
||||
void
|
||||
QPDFTokenizer::inInlineImage(char ch)
|
||||
{
|
||||
this->val += ch;
|
||||
if (this->val.length() == this->inline_image_bytes) {
|
||||
if ((this->raw_val.length() + 1) == this->inline_image_bytes) {
|
||||
QTC::TC("qpdf", "QPDFTokenizer found EI by byte count");
|
||||
this->type = tt_inline_image;
|
||||
this->inline_image_bytes = 0;
|
||||
@ -951,7 +918,7 @@ QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch)
|
||||
unread_char = !this->in_token && !this->before_token;
|
||||
ch = this->char_to_unread;
|
||||
if (ready) {
|
||||
token = (this->type == tt_bad)
|
||||
token = (!(this->type == tt_name || this->type == tt_string))
|
||||
? Token(
|
||||
this->type, this->raw_val, this->raw_val, this->error_message)
|
||||
: Token(this->type, this->val, this->raw_val, this->error_message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user