mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Sync to lexbor/lexbor@0eac579f (#18882)
This commit is contained in:
@@ -25,7 +25,6 @@ extern "C" {
|
||||
# define LXB_NONSTRING
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
lxb_char_t key;
|
||||
|
||||
|
||||
@@ -99,13 +99,6 @@ lxb_css_syntax_state_consume_numeric(lxb_css_syntax_tokenizer_t *tkz,
|
||||
const lxb_char_t *data,
|
||||
const lxb_char_t *end);
|
||||
|
||||
static const lxb_char_t *
|
||||
lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *data, const lxb_char_t *end,
|
||||
lxb_char_t *buf, lxb_char_t *buf_p,
|
||||
const lxb_char_t *buf_end);
|
||||
|
||||
static const lxb_char_t *
|
||||
lxb_css_syntax_state_consume_numeric_name_start(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
@@ -706,8 +699,6 @@ lxb_css_syntax_state_plus(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *data, const lxb_char_t *end)
|
||||
{
|
||||
lxb_char_t buf[128];
|
||||
|
||||
/* Skip U+002B PLUS SIGN (+). */
|
||||
data += 1;
|
||||
|
||||
@@ -732,8 +723,8 @@ lxb_css_syntax_state_plus(lxb_css_syntax_tokenizer_t *tkz,
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
if (*data >= 0x30 && *data <= 0x39) {
|
||||
lxb_css_syntax_token_number(token)->have_sign = true;
|
||||
return lxb_css_syntax_state_decimal(tkz, token, data, end,
|
||||
buf, buf, buf + sizeof(buf));
|
||||
return lxb_css_syntax_state_consume_numeric(tkz, token,
|
||||
data - 1, end);
|
||||
}
|
||||
|
||||
data -= 1;
|
||||
@@ -804,6 +795,7 @@ lxb_css_syntax_state_full_stop(lxb_css_syntax_tokenizer_t *tkz,
|
||||
const lxb_char_t *data, const lxb_char_t *end)
|
||||
{
|
||||
if (lxb_css_syntax_state_start_number(data, end)) {
|
||||
lxb_css_syntax_token_number(token)->have_sign = false;
|
||||
return lxb_css_syntax_state_consume_numeric(tkz, token, data, end);
|
||||
}
|
||||
|
||||
@@ -935,37 +927,26 @@ lxb_css_syntax_state_rc_bracket(lxb_css_syntax_tokenizer_t *tkz, lxb_css_syntax_
|
||||
* Numeric
|
||||
*/
|
||||
lxb_inline void
|
||||
lxb_css_syntax_consume_numeric_set_int(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *start, const lxb_char_t *end)
|
||||
{
|
||||
double num = lexbor_strtod_internal(start, (end - start), 0);
|
||||
|
||||
token->type = LXB_CSS_SYNTAX_TOKEN_NUMBER;
|
||||
|
||||
lxb_css_syntax_token_number(token)->is_float = false;
|
||||
lxb_css_syntax_token_number(token)->num = num;
|
||||
}
|
||||
|
||||
lxb_inline void
|
||||
lxb_css_syntax_consume_numeric_set_float(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *start, const lxb_char_t *end,
|
||||
bool e_is_negative, int exponent, int e_digit)
|
||||
lxb_css_syntax_consume_numeric_set(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *start, const lxb_char_t *end,
|
||||
bool is_float, bool e_is_negative,
|
||||
int exponent, int e_digit)
|
||||
{
|
||||
if (e_is_negative) {
|
||||
exponent -= e_digit;
|
||||
exponent = e_digit - exponent;
|
||||
exponent = -exponent;
|
||||
}
|
||||
else {
|
||||
exponent += e_digit;
|
||||
exponent = e_digit + exponent;
|
||||
}
|
||||
|
||||
double num = lexbor_strtod_internal(start, (end - start), exponent);
|
||||
|
||||
token->type = LXB_CSS_SYNTAX_TOKEN_NUMBER;
|
||||
|
||||
lxb_css_syntax_token_number(token)->is_float = is_float;
|
||||
lxb_css_syntax_token_number(token)->num = num;
|
||||
lxb_css_syntax_token_number(token)->is_float = true;
|
||||
}
|
||||
|
||||
const lxb_char_t *
|
||||
@@ -985,72 +966,22 @@ lxb_css_syntax_state_consume_numeric(lxb_css_syntax_tokenizer_t *tkz,
|
||||
const lxb_char_t *data,
|
||||
const lxb_char_t *end)
|
||||
{
|
||||
lxb_char_t *buf_p;
|
||||
const lxb_char_t *buf_end;
|
||||
bool e_is_negative, is_float;
|
||||
int exponent, e_digit;
|
||||
lxb_char_t ch, *buf_p;
|
||||
const lxb_char_t *begin, *buf_end;
|
||||
lxb_css_syntax_token_t *t_str;
|
||||
lxb_css_syntax_token_string_t *str;
|
||||
lxb_char_t buf[128];
|
||||
|
||||
buf_p = buf;
|
||||
buf_end = buf + sizeof(buf);
|
||||
|
||||
do {
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
if (*data < 0x30 || *data > 0x39) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf_p != buf_end) {
|
||||
*buf_p++ = *data;
|
||||
}
|
||||
|
||||
data += 1;
|
||||
|
||||
if (data >= end) {
|
||||
lxb_css_syntax_consume_numeric_set_int(tkz, token, buf, buf_p);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
|
||||
/* U+002E FULL STOP (.) */
|
||||
if (*data != 0x2E) {
|
||||
lxb_css_syntax_consume_numeric_set_int(tkz, token, buf, buf_p);
|
||||
|
||||
return lxb_css_syntax_state_consume_numeric_name_start(tkz, token,
|
||||
data, end);
|
||||
}
|
||||
|
||||
data += 1;
|
||||
|
||||
if (data >= end || *data < 0x30 || *data > 0x39) {
|
||||
lxb_css_syntax_consume_numeric_set_int(tkz, token, buf, buf_p);
|
||||
return data - 1;
|
||||
}
|
||||
|
||||
return lxb_css_syntax_state_decimal(tkz, token, data, end,
|
||||
buf, buf_p, buf_end);
|
||||
}
|
||||
|
||||
static const lxb_char_t *
|
||||
lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
lxb_css_syntax_token_t *token,
|
||||
const lxb_char_t *data, const lxb_char_t *end,
|
||||
lxb_char_t *buf, lxb_char_t *buf_p,
|
||||
const lxb_char_t *buf_end)
|
||||
{
|
||||
bool e_is_negative;
|
||||
int exponent, e_digit;
|
||||
lxb_char_t ch;
|
||||
const lxb_char_t *begin;
|
||||
lxb_css_syntax_token_t *t_str;
|
||||
lxb_css_syntax_token_string_t *str;
|
||||
|
||||
begin = data;
|
||||
|
||||
str = lxb_css_syntax_token_dimension_string(token);
|
||||
t_str = (lxb_css_syntax_token_t *) (void *) str;
|
||||
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
do {
|
||||
while (*data >= 0x30 && *data <= 0x39) {
|
||||
if (buf_p != buf_end) {
|
||||
*buf_p++ = *data;
|
||||
}
|
||||
@@ -1058,22 +989,54 @@ lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
data += 1;
|
||||
|
||||
if (data >= end) {
|
||||
exponent = 0 - (int) (data - begin);
|
||||
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf,
|
||||
buf_p, 0, exponent, 0);
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
false, false, 0, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
exponent = 0;
|
||||
is_float = false;
|
||||
|
||||
/* U+002E FULL STOP (.) */
|
||||
if (*data == 0x2E) {
|
||||
data += 1;
|
||||
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
if (data >= end || *data < 0x30 || *data > 0x39) {
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
false, false, 0, 0);
|
||||
return data - 1;
|
||||
}
|
||||
|
||||
begin = buf_p;
|
||||
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
do {
|
||||
if (buf_p != buf_end) {
|
||||
*buf_p++ = *data;
|
||||
}
|
||||
|
||||
data += 1;
|
||||
}
|
||||
while (data < end && *data >= 0x30 && *data <= 0x39);
|
||||
|
||||
exponent = -(int) (buf_p - begin);
|
||||
is_float = true;
|
||||
|
||||
if (data >= end) {
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
true, false, exponent, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
while (*data >= 0x30 && *data <= 0x39);
|
||||
|
||||
ch = *data;
|
||||
exponent = 0 - (int) (data - begin);
|
||||
|
||||
/* U+0045 Latin Capital Letter (E) or U+0065 Latin Small Letter (e) */
|
||||
if (ch != 0x45 && ch != 0x65) {
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf,
|
||||
buf_p, 0, exponent, 0);
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
is_float, false, exponent, 0);
|
||||
|
||||
return lxb_css_syntax_state_consume_numeric_name_start(tkz, token,
|
||||
data, end);
|
||||
@@ -1087,11 +1050,10 @@ lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
data -= 1;
|
||||
|
||||
lxb_css_syntax_token_base(t_str)->length = 1;
|
||||
|
||||
lxb_css_syntax_buffer_append_m(tkz, data, 1);
|
||||
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf,
|
||||
buf_p, 0, exponent, 0);
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
is_float, false, exponent, 0);
|
||||
|
||||
token->type = LXB_CSS_SYNTAX_TOKEN_DIMENSION;
|
||||
|
||||
@@ -1122,8 +1084,8 @@ lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
data -= 1;
|
||||
}
|
||||
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf,
|
||||
buf_p, 0, exponent, 0);
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
is_float, false, exponent, 0);
|
||||
|
||||
token->type = LXB_CSS_SYNTAX_TOKEN_DIMENSION;
|
||||
|
||||
@@ -1135,7 +1097,6 @@ lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
return begin;
|
||||
}
|
||||
|
||||
begin = data;
|
||||
e_digit = 0;
|
||||
|
||||
/* U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9) */
|
||||
@@ -1145,16 +1106,17 @@ lxb_css_syntax_state_decimal(lxb_css_syntax_tokenizer_t *tkz,
|
||||
data += 1;
|
||||
|
||||
if (data >= end) {
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf, buf_p,
|
||||
e_is_negative, exponent,
|
||||
e_digit);
|
||||
return data;
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
true, e_is_negative,
|
||||
exponent, e_digit);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
while(*data >= 0x30 && *data <= 0x39);
|
||||
|
||||
lxb_css_syntax_consume_numeric_set_float(tkz, token, buf, buf_p,
|
||||
e_is_negative, exponent, e_digit);
|
||||
lxb_css_syntax_consume_numeric_set(tkz, token, buf, buf_p,
|
||||
true, e_is_negative,
|
||||
exponent, e_digit);
|
||||
|
||||
return lxb_css_syntax_state_consume_numeric_name_start(tkz, token,
|
||||
data, end);
|
||||
|
||||
@@ -24,7 +24,7 @@ LXB_API const lxb_css_data_t *
|
||||
lxb_css_unit_relative_by_name(const lxb_char_t *name, size_t length);
|
||||
|
||||
LXB_API const lxb_css_data_t *
|
||||
lxb_css_unit_angel_by_name(const lxb_char_t *name, size_t length);
|
||||
lxb_css_unit_angle_by_name(const lxb_char_t *name, size_t length);
|
||||
|
||||
LXB_API const lxb_css_data_t *
|
||||
lxb_css_unit_frequency_by_name(const lxb_char_t *name, size_t length);
|
||||
|
||||
@@ -58,14 +58,14 @@ typedef enum {
|
||||
lxb_css_unit_relative_t;
|
||||
|
||||
typedef enum {
|
||||
LXB_CSS_UNIT_ANGEL__BEGIN = 0x0016,
|
||||
LXB_CSS_UNIT_ANGLE__BEGIN = 0x0016,
|
||||
LXB_CSS_UNIT_DEG = 0x0016,
|
||||
LXB_CSS_UNIT_GRAD = 0x0017,
|
||||
LXB_CSS_UNIT_RAD = 0x0018,
|
||||
LXB_CSS_UNIT_TURN = 0x0019,
|
||||
LXB_CSS_UNIT_ANGEL__LAST_ENTRY = 0x001a
|
||||
LXB_CSS_UNIT_ANGLE__LAST_ENTRY = 0x001a
|
||||
}
|
||||
lxb_css_unit_angel_t;
|
||||
lxb_css_unit_angle_t;
|
||||
|
||||
typedef enum {
|
||||
LXB_CSS_UNIT_FREQUENCY__BEGIN = 0x001a,
|
||||
|
||||
@@ -246,7 +246,7 @@ static const lexbor_shs_entry_t lxb_css_unit_relative_shs[64] =
|
||||
{NULL, NULL, 0, 0}
|
||||
};
|
||||
|
||||
static const lexbor_shs_entry_t lxb_css_unit_angel_shs[7] =
|
||||
static const lexbor_shs_entry_t lxb_css_unit_angle_shs[7] =
|
||||
{
|
||||
{NULL, NULL, 6, 0},
|
||||
{"turn", (void *) &lxb_css_unit_data[LXB_CSS_UNIT_TURN], 4, 0},
|
||||
|
||||
@@ -109,7 +109,7 @@ lxb_css_value_length_percentage_type_t;
|
||||
typedef struct {
|
||||
double num;
|
||||
bool is_float;
|
||||
lxb_css_unit_angel_t unit;
|
||||
lxb_css_unit_angle_t unit;
|
||||
}
|
||||
lxb_css_value_angle_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user