[buffer/deserialize] Do not clear() buffer upon content type mismatch

We return false. I don't see reason to clear buffer.
This commit is contained in:
Behdad Esfahbod 2020-10-09 21:26:09 -06:00
parent c396e1600f
commit b37edebfcb
4 changed files with 63 additions and 93 deletions

View File

@ -481,7 +481,7 @@ static const int deserialize_json_error = 0;
static const int deserialize_json_en_main = 1; static const int deserialize_json_en_main = 1;
#line 129 "hb-buffer-deserialize-json.rl" #line 125 "hb-buffer-deserialize-json.rl"
static hb_bool_t static hb_bool_t
@ -566,31 +566,27 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
} }
break; break;
case 21: case 21:
#line 67 "hb-buffer-deserialize-json.rl" #line 65 "hb-buffer-deserialize-json.rl"
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }
} }
break; break;
case 16: case 16:
#line 79 "hb-buffer-deserialize-json.rl" #line 75 "hb-buffer-deserialize-json.rl"
{ {
/* TODO Unescape \" and \\ if found. */ /* TODO Unescape \" and \\ if found. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -600,27 +596,27 @@ _resume:
} }
break; break;
case 18: case 18:
#line 87 "hb-buffer-deserialize-json.rl" #line 83 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.codepoint)) return false; } { if (!parse_uint (tok, p, &info.codepoint)) return false; }
break; break;
case 8: case 8:
#line 88 "hb-buffer-deserialize-json.rl" #line 84 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; } { if (!parse_uint (tok, p, &info.cluster )) return false; }
break; break;
case 10: case 10:
#line 89 "hb-buffer-deserialize-json.rl" #line 85 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_offset )) return false; } { if (!parse_int (tok, p, &pos.x_offset )) return false; }
break; break;
case 12: case 12:
#line 90 "hb-buffer-deserialize-json.rl" #line 86 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; } { if (!parse_int (tok, p, &pos.y_offset )) return false; }
break; break;
case 3: case 3:
#line 91 "hb-buffer-deserialize-json.rl" #line 87 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; } { if (!parse_int (tok, p, &pos.x_advance)) return false; }
break; break;
case 6: case 6:
#line 92 "hb-buffer-deserialize-json.rl" #line 88 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; } { if (!parse_int (tok, p, &pos.y_advance)) return false; }
break; break;
case 14: case 14:
@ -632,10 +628,8 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -646,21 +640,19 @@ _resume:
{ {
tok = p; tok = p;
} }
#line 67 "hb-buffer-deserialize-json.rl" #line 65 "hb-buffer-deserialize-json.rl"
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }
} }
break; break;
case 17: case 17:
#line 79 "hb-buffer-deserialize-json.rl" #line 75 "hb-buffer-deserialize-json.rl"
{ {
/* TODO Unescape \" and \\ if found. */ /* TODO Unescape \" and \\ if found. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -678,7 +670,7 @@ _resume:
} }
break; break;
case 19: case 19:
#line 87 "hb-buffer-deserialize-json.rl" #line 83 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.codepoint)) return false; } { if (!parse_uint (tok, p, &info.codepoint)) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -690,7 +682,7 @@ _resume:
} }
break; break;
case 9: case 9:
#line 88 "hb-buffer-deserialize-json.rl" #line 84 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; } { if (!parse_uint (tok, p, &info.cluster )) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -702,7 +694,7 @@ _resume:
} }
break; break;
case 11: case 11:
#line 89 "hb-buffer-deserialize-json.rl" #line 85 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_offset )) return false; } { if (!parse_int (tok, p, &pos.x_offset )) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -714,7 +706,7 @@ _resume:
} }
break; break;
case 13: case 13:
#line 90 "hb-buffer-deserialize-json.rl" #line 86 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; } { if (!parse_int (tok, p, &pos.y_offset )) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -726,7 +718,7 @@ _resume:
} }
break; break;
case 4: case 4:
#line 91 "hb-buffer-deserialize-json.rl" #line 87 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; } { if (!parse_int (tok, p, &pos.x_advance)) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -738,7 +730,7 @@ _resume:
} }
break; break;
case 7: case 7:
#line 92 "hb-buffer-deserialize-json.rl" #line 88 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; } { if (!parse_int (tok, p, &pos.y_advance)) return false; }
#line 43 "hb-buffer-deserialize-json.rl" #line 43 "hb-buffer-deserialize-json.rl"
{ {
@ -749,7 +741,7 @@ _resume:
*end_ptr = p; *end_ptr = p;
} }
break; break;
#line 753 "hb-buffer-deserialize-json.hh" #line 745 "hb-buffer-deserialize-json.hh"
} }
_again: _again:
@ -761,7 +753,7 @@ _again:
_out: {} _out: {}
} }
#line 157 "hb-buffer-deserialize-json.rl" #line 153 "hb-buffer-deserialize-json.rl"
*end_ptr = p; *end_ptr = p;

View File

@ -55,10 +55,8 @@ action tok {
action ensure_glyphs { action ensure_glyphs {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -67,10 +65,8 @@ action ensure_glyphs {
action ensure_unicode { action ensure_unicode {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }

View File

@ -401,7 +401,7 @@ static const int deserialize_text_error = 0;
static const int deserialize_text_en_main = 1; static const int deserialize_text_en_main = 1;
#line 135 "hb-buffer-deserialize-text.rl" #line 131 "hb-buffer-deserialize-text.rl"
static hb_bool_t static hb_bool_t
@ -472,31 +472,27 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
} }
break; break;
case 8: case 8:
#line 67 "hb-buffer-deserialize-text.rl" #line 65 "hb-buffer-deserialize-text.rl"
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }
} }
break; break;
case 18: case 18:
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -506,23 +502,23 @@ _resume:
} }
break; break;
case 9: case 9:
#line 87 "hb-buffer-deserialize-text.rl" #line 83 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; } {if (!parse_hex (tok, p, &info.codepoint )) return false; }
break; break;
case 21: case 21:
#line 89 "hb-buffer-deserialize-text.rl" #line 85 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; } { if (!parse_uint (tok, p, &info.cluster )) return false; }
break; break;
case 6: case 6:
#line 90 "hb-buffer-deserialize-text.rl" #line 86 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_offset )) return false; } { if (!parse_int (tok, p, &pos.x_offset )) return false; }
break; break;
case 23: case 23:
#line 91 "hb-buffer-deserialize-text.rl" #line 87 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; } { if (!parse_int (tok, p, &pos.y_offset )) return false; }
break; break;
case 20: case 20:
#line 92 "hb-buffer-deserialize-text.rl" #line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; } { if (!parse_int (tok, p, &pos.x_advance)) return false; }
break; break;
case 15: case 15:
@ -545,10 +541,8 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -559,21 +553,19 @@ _resume:
{ {
tok = p; tok = p;
} }
#line 67 "hb-buffer-deserialize-text.rl" #line 65 "hb-buffer-deserialize-text.rl"
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }
} }
break; break;
case 16: case 16:
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -591,7 +583,7 @@ _resume:
} }
break; break;
case 7: case 7:
#line 87 "hb-buffer-deserialize-text.rl" #line 83 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; } {if (!parse_hex (tok, p, &info.codepoint )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -603,7 +595,7 @@ _resume:
} }
break; break;
case 10: case 10:
#line 89 "hb-buffer-deserialize-text.rl" #line 85 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; } { if (!parse_uint (tok, p, &info.cluster )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -615,7 +607,7 @@ _resume:
} }
break; break;
case 22: case 22:
#line 91 "hb-buffer-deserialize-text.rl" #line 87 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; } { if (!parse_int (tok, p, &pos.y_offset )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -627,7 +619,7 @@ _resume:
} }
break; break;
case 19: case 19:
#line 92 "hb-buffer-deserialize-text.rl" #line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; } { if (!parse_int (tok, p, &pos.x_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -639,7 +631,7 @@ _resume:
} }
break; break;
case 24: case 24:
#line 93 "hb-buffer-deserialize-text.rl" #line 89 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; } { if (!parse_int (tok, p, &pos.y_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -664,10 +656,8 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -683,7 +673,7 @@ _resume:
{ {
tok = p; tok = p;
} }
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -693,7 +683,7 @@ _resume:
} }
break; break;
case 17: case 17:
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -705,10 +695,8 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -732,7 +720,7 @@ _resume:
{ {
tok = p; tok = p;
} }
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -759,7 +747,7 @@ _resume:
{ {
tok = p; tok = p;
} }
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -771,10 +759,8 @@ _resume:
{ {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -788,7 +774,7 @@ _resume:
*end_ptr = p; *end_ptr = p;
} }
break; break;
#line 792 "hb-buffer-deserialize-text.hh" #line 778 "hb-buffer-deserialize-text.hh"
} }
_again: _again:
@ -801,7 +787,7 @@ _again:
{ {
switch ( _deserialize_text_eof_actions[cs] ) { switch ( _deserialize_text_eof_actions[cs] ) {
case 16: case 16:
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -819,7 +805,7 @@ _again:
} }
break; break;
case 7: case 7:
#line 87 "hb-buffer-deserialize-text.rl" #line 83 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; } {if (!parse_hex (tok, p, &info.codepoint )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -831,7 +817,7 @@ _again:
} }
break; break;
case 10: case 10:
#line 89 "hb-buffer-deserialize-text.rl" #line 85 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; } { if (!parse_uint (tok, p, &info.cluster )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -843,7 +829,7 @@ _again:
} }
break; break;
case 22: case 22:
#line 91 "hb-buffer-deserialize-text.rl" #line 87 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; } { if (!parse_int (tok, p, &pos.y_offset )) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -855,7 +841,7 @@ _again:
} }
break; break;
case 19: case 19:
#line 92 "hb-buffer-deserialize-text.rl" #line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; } { if (!parse_int (tok, p, &pos.x_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -867,7 +853,7 @@ _again:
} }
break; break;
case 24: case 24:
#line 93 "hb-buffer-deserialize-text.rl" #line 89 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; } { if (!parse_int (tok, p, &pos.y_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl" #line 43 "hb-buffer-deserialize-text.rl"
{ {
@ -888,7 +874,7 @@ _again:
{ {
tok = p; tok = p;
} }
#line 79 "hb-buffer-deserialize-text.rl" #line 75 "hb-buffer-deserialize-text.rl"
{ {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */
if (!hb_font_glyph_from_string (font, if (!hb_font_glyph_from_string (font,
@ -905,14 +891,14 @@ _again:
*end_ptr = p; *end_ptr = p;
} }
break; break;
#line 909 "hb-buffer-deserialize-text.hh" #line 895 "hb-buffer-deserialize-text.hh"
} }
} }
_out: {} _out: {}
} }
#line 159 "hb-buffer-deserialize-text.rl" #line 155 "hb-buffer-deserialize-text.rl"
*end_ptr = p; *end_ptr = p;

View File

@ -55,10 +55,8 @@ action tok {
action ensure_glyphs { action ensure_glyphs {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
} }
@ -67,10 +65,8 @@ action ensure_glyphs {
action ensure_unicode { action ensure_unicode {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{ {
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) { if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
buffer->clear();
return false; return false;
}
assert (buffer->len == 0); assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
} }