1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Update Lexbor (#16288)
This commit is contained in:
Niels Dossche
2024-10-08 19:16:30 +02:00
9 changed files with 2201 additions and 2097 deletions

View File

@@ -59,6 +59,35 @@ lexbor_swar_seek4(const lxb_char_t *data, const lxb_char_t *end,
return data;
}
lxb_inline const lxb_char_t *
lexbor_swar_seek3(const lxb_char_t *data, const lxb_char_t *end,
lxb_char_t c1, lxb_char_t c2, lxb_char_t c3)
{
size_t bytes, matches, t1, t2, t3;
if (LEXBOR_SWAR_IS_LITTLE_ENDIAN) {
while (data + sizeof(size_t) <= end) {
memcpy(&bytes, data, sizeof(size_t));
t1 = bytes ^ LEXBOR_SWAR_REPEAT(c1);
t2 = bytes ^ LEXBOR_SWAR_REPEAT(c2);
t3 = bytes ^ LEXBOR_SWAR_REPEAT(c3);
matches = LEXBOR_SWAR_HAS_ZERO(t1) | LEXBOR_SWAR_HAS_ZERO(t2)
| LEXBOR_SWAR_HAS_ZERO(t3);
if (matches) {
data += ((((matches - 1) & LEXBOR_SWAR_ONES) * LEXBOR_SWAR_ONES)
>> (sizeof(size_t) * 8 - 8)) - 1;
break;
} else {
data += sizeof(size_t);
}
}
}
return data;
}
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Alexander Borisov
* Copyright (C) 2024 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/

View File

@@ -2955,6 +2955,77 @@ lxb_encoding_decode_valid_utf_8_single(const lxb_char_t **data,
return cp;
}
lxb_codepoint_t
lxb_encoding_decode_valid_utf_8_single_reverse(const lxb_char_t **end,
const lxb_char_t *begin)
{
lxb_codepoint_t cp;
const lxb_char_t *p = *end;
while (p > begin) {
p -= 1;
if (*p < 0x80){
cp = (lxb_codepoint_t) *p;
(*end) = p;
return cp;
}
else if ((*p & 0xe0) == 0xc0) {
/* 110xxxxx 10xxxxxx */
if (*end - p < 2) {
*end = p;
return LXB_ENCODING_DECODE_ERROR;
}
cp = (p[0] ^ (0xC0 & p[0])) << 6;
cp |= (p[1] ^ (0x80 & p[1]));
(*end) = p;
return cp;
}
else if ((*p & 0xf0) == 0xe0) {
/* 1110xxxx 10xxxxxx 10xxxxxx */
if (*end - p < 3) {
*end = p;
return LXB_ENCODING_DECODE_ERROR;
}
cp = (p[0] ^ (0xE0 & p[0])) << 12;
cp |= (p[1] ^ (0x80 & p[1])) << 6;
cp |= (p[2] ^ (0x80 & p[2]));
(*end) = p;
return cp;
}
else if ((*p & 0xf8) == 0xf0) {
/* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
if (*end - p < 4) {
*end = p;
return LXB_ENCODING_DECODE_ERROR;
}
cp = (p[0] ^ (0xF0 & p[0])) << 18;
cp |= (p[1] ^ (0x80 & p[1])) << 12;
cp |= (p[2] ^ (0x80 & p[2])) << 6;
cp |= (p[3] ^ (0x80 & p[3]));
(*end) = p;
return cp;
}
else if (*end - p >= 4) {
break;
}
}
*end = p;
return LXB_ENCODING_DECODE_ERROR;
}
uint8_t
lxb_encoding_decode_utf_8_length(lxb_char_t data)
{

View File

@@ -306,6 +306,10 @@ LXB_API lxb_codepoint_t
lxb_encoding_decode_valid_utf_8_single(const lxb_char_t **data,
const lxb_char_t *end);
LXB_API lxb_codepoint_t
lxb_encoding_decode_valid_utf_8_single_reverse(const lxb_char_t **end,
const lxb_char_t *begin);
LXB_API uint8_t
lxb_encoding_decode_utf_8_length(lxb_char_t data);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Alexander Borisov
* Copyright (C) 2024 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Alexander Borisov
* Copyright (C) 2024 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Alexander Borisov
* Copyright (C) 2024 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Alexander Borisov
* Copyright (C) 2024 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/