diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-08 12:58:04 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-08 12:58:04 +0200 |
commit | baea074f524676a889043779c80fb17cdd38f30d (patch) | |
tree | 4609684954145d092ed684ac38e94b8b04ecd79a /src/unicode-sse4_1.c | |
parent | 4f698ec642547534bac2b37f96de045dd828fd58 (diff) |
Do some lexer work
Diffstat (limited to 'src/unicode-sse4_1.c')
-rw-r--r-- | src/unicode-sse4_1.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/unicode-sse4_1.c b/src/unicode-sse4_1.c index 17a46a8..0f5f4e5 100644 --- a/src/unicode-sse4_1.c +++ b/src/unicode-sse4_1.c @@ -1,3 +1,29 @@ +/* + * MIT License + * + * Copyright © 2019 Yibo Cai + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Source: https://github.com/cyb70289/utf8 + */ + #include <stddef.h> #include <stdint.h> #include <x86intrin.h> @@ -32,9 +58,8 @@ static const int8_t _ef_fe_tbl[] = { /* Return 0 on success, -1 on error */ bool -utf8_validate_simd(const char *data, size_t len) +utf8_validate_simd(const unsigned char *s, size_t len) { - const unsigned char *s = data; if (len >= 32) { __m128i prev_input = _mm_set1_epi8(0); __m128i prev_first_len = _mm_set1_epi8(0); |