Fix gb_utf8_decode

This commit is contained in:
gingerBill 2018-06-15 20:01:05 +01:00 committed by GitHub
parent 296198c81b
commit cf6132dbf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

8
gb.h
View File

@ -1,4 +1,4 @@
/* gb.h - v0.32 - Ginger Bill's C Helper Library - public domain /* gb.h - v0.33 - Ginger Bill's C Helper Library - public domain
- no warranty implied; use at your own risk - no warranty implied; use at your own risk
This is a single header file with a bunch of useful stuff This is a single header file with a bunch of useful stuff
@ -58,6 +58,7 @@ TODOS
- More date & time functions - More date & time functions
VERSION HISTORY VERSION HISTORY
0.33 - Minor fixes
0.32 - Minor fixes 0.32 - Minor fixes
0.31 - Add gb_file_remove 0.31 - Add gb_file_remove
0.30 - Changes to gbThread (and gbMutex on Windows) 0.30 - Changes to gbThread (and gbMutex on Windows)
@ -6884,8 +6885,6 @@ gb_global gbUtf8AcceptRange const gb__utf8_accept_ranges[] = {
isize gb_utf8_decode(u8 const *str, isize str_len, Rune *codepoint_out) { isize gb_utf8_decode(u8 const *str, isize str_len, Rune *codepoint_out) {
isize width = 0; isize width = 0;
Rune codepoint = GB_RUNE_INVALID; Rune codepoint = GB_RUNE_INVALID;
@ -6894,7 +6893,7 @@ isize gb_utf8_decode(u8 const *str, isize str_len, Rune *codepoint_out) {
u8 x = gb__utf8_first[s0], sz; u8 x = gb__utf8_first[s0], sz;
u8 b1, b2, b3; u8 b1, b2, b3;
gbUtf8AcceptRange accept; gbUtf8AcceptRange accept;
if (x > 0xf0) { if (x >= 0xf0) {
Rune mask = (cast(Rune)x >> 31) << 31; Rune mask = (cast(Rune)x >> 31) << 31;
codepoint = (cast(Rune)s0 & (~mask)) | (GB_RUNE_INVALID & mask); codepoint = (cast(Rune)s0 & (~mask)) | (GB_RUNE_INVALID & mask);
width = 1; width = 1;
@ -10816,4 +10815,3 @@ GB_COMPARE_PROC(gb_video_mode_dsc_cmp) {
#endif #endif
#endif // GB_IMPLEMENTATION #endif // GB_IMPLEMENTATION