mirror of
https://github.com/raysan5/raylib.git
synced 2026-11-25 09:01:47 -05:00
Compare commits
7 Commits
5181a2260d
...
bbd4af6bee
| Author | SHA1 | Date | |
|---|---|---|---|
| bbd4af6bee | |||
| 73100d0c0e | |||
| 7e626d6577 | |||
| 8b26664f26 | |||
| a2c3e86da0 | |||
| f91d166b3c | |||
| 8d45ce6810 |
@ -61,6 +61,7 @@ This is a set of recommendations and guidelines for binding authors, meant to he
|
|||||||
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
|
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
|
||||||
| [h-raylib](https://github.com/Anut-py/h-raylib) | **6.1-dev** | [Haskell](https://haskell.org) | Apache-2.0 |
|
| [h-raylib](https://github.com/Anut-py/h-raylib) | **6.1-dev** | [Haskell](https://haskell.org) | Apache-2.0 |
|
||||||
| [raylib-hx](https://github.com/foreignsasquatch/raylib-hx) | 5.5 | [Haxe](https://haxe.org) | Zlib |
|
| [raylib-hx](https://github.com/foreignsasquatch/raylib-hx) | 5.5 | [Haxe](https://haxe.org) | Zlib |
|
||||||
|
| [HolyRay](https://github.com/Iarlasa/HolyRay) | **6.5-dev** | [HolyC](https://holyc-lang.com/) | GPL-3.0 |
|
||||||
| [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT |
|
| [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT |
|
||||||
| [jaylib](https://github.com/electronstudio/jaylib/) | **6.0** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE |
|
| [jaylib](https://github.com/electronstudio/jaylib/) | **6.0** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE |
|
||||||
| [raylib-j](https://github.com/CreedVI/Raylib-J) | 4.2 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib |
|
| [raylib-j](https://github.com/CreedVI/Raylib-J) | 4.2 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib |
|
||||||
|
|||||||
33
src/external/rlsw.h
vendored
33
src/external/rlsw.h
vendored
@ -288,6 +288,7 @@ typedef double GLclampd;
|
|||||||
|
|
||||||
#define GL_REPEAT 0x2901
|
#define GL_REPEAT 0x2901
|
||||||
#define GL_CLAMP 0x2900
|
#define GL_CLAMP 0x2900
|
||||||
|
#define GL_CLAMP_TO_EDGE 0x812F
|
||||||
|
|
||||||
#define GL_TEXTURE_MAG_FILTER 0x2800
|
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||||
#define GL_TEXTURE_MIN_FILTER 0x2801
|
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||||
@ -770,6 +771,7 @@ SWAPI void swGetFramebufferAttachmentParameteriv(SWattachment attachment, SWatta
|
|||||||
#include <stdlib.h> // Required for: malloc(), free()
|
#include <stdlib.h> // Required for: malloc(), free()
|
||||||
#include <stddef.h> // Required for: NULL, size_t, uint8_t, uint16_t, uint32_t...
|
#include <stddef.h> // Required for: NULL, size_t, uint8_t, uint16_t, uint32_t...
|
||||||
#include <math.h> // Required for: sinf(), cosf(), floorf(), fabsf(), sqrtf(), roundf()
|
#include <math.h> // Required for: sinf(), cosf(), floorf(), fabsf(), sqrtf(), roundf()
|
||||||
|
#include <string.h> // Required for: memcpy()
|
||||||
|
|
||||||
// Simple log system to avoid printf() calls if required
|
// Simple log system to avoid printf() calls if required
|
||||||
// NOTE: Avoiding those calls, also avoids const strings memory usage
|
// NOTE: Avoiding those calls, also avoids const strings memory usage
|
||||||
@ -1403,12 +1405,16 @@ static SW_INLINE void sw_color8_to_color(float *SW_RESTRICT dst, const uint8_t *
|
|||||||
float32x4_t fvals = vmulq_f32(vcvtq_f32_u32(dwords), vdupq_n_f32(SW_INV_255));
|
float32x4_t fvals = vmulq_f32(vcvtq_f32_u32(dwords), vdupq_n_f32(SW_INV_255));
|
||||||
vst1q_f32(dst, fvals);
|
vst1q_f32(dst, fvals);
|
||||||
#elif defined(SW_HAS_SSE41)
|
#elif defined(SW_HAS_SSE41)
|
||||||
__m128i bytes = _mm_loadu_si32(src);
|
int packedColor = 0;
|
||||||
|
memcpy(&packedColor, src, sizeof(int));
|
||||||
|
__m128i bytes = _mm_cvtsi32_si128(packedColor);
|
||||||
__m128 fvals = _mm_mul_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(bytes)), _mm_set1_ps(SW_INV_255));
|
__m128 fvals = _mm_mul_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(bytes)), _mm_set1_ps(SW_INV_255));
|
||||||
_mm_storeu_ps(dst, fvals);
|
_mm_storeu_ps(dst, fvals);
|
||||||
#elif defined(SW_HAS_SSE2)
|
#elif defined(SW_HAS_SSE2)
|
||||||
__m128i zero = _mm_setzero_si128();
|
__m128i zero = _mm_setzero_si128();
|
||||||
__m128i bytes = _mm_loadu_si32(src);
|
int packedColor = 0;
|
||||||
|
memcpy(&packedColor, src, sizeof(int));
|
||||||
|
__m128i bytes = _mm_cvtsi32_si128(packedColor);
|
||||||
__m128i words = _mm_unpacklo_epi8(bytes, zero);
|
__m128i words = _mm_unpacklo_epi8(bytes, zero);
|
||||||
__m128i dwords = _mm_unpacklo_epi16(words, zero);
|
__m128i dwords = _mm_unpacklo_epi16(words, zero);
|
||||||
__m128 fvals = _mm_mul_ps(_mm_cvtepi32_ps(dwords), _mm_set1_ps(SW_INV_255));
|
__m128 fvals = _mm_mul_ps(_mm_cvtepi32_ps(dwords), _mm_set1_ps(SW_INV_255));
|
||||||
@ -1441,13 +1447,15 @@ static SW_INLINE void sw_color_to_color8(uint8_t *SW_RESTRICT dst, const float *
|
|||||||
__m128i i32 = _mm_cvttps_epi32(fvals);
|
__m128i i32 = _mm_cvttps_epi32(fvals);
|
||||||
__m128i i16 = _mm_packus_epi32(i32, i32);
|
__m128i i16 = _mm_packus_epi32(i32, i32);
|
||||||
__m128i i8 = _mm_packus_epi16(i16, i16);
|
__m128i i8 = _mm_packus_epi16(i16, i16);
|
||||||
_mm_storeu_si32(dst, i8);
|
int packedColor = _mm_cvtsi128_si32(i8);
|
||||||
|
memcpy(dst, &packedColor, sizeof(int));
|
||||||
#elif defined(SW_HAS_SSE2)
|
#elif defined(SW_HAS_SSE2)
|
||||||
__m128 fvals = _mm_mul_ps(_mm_loadu_ps(src), _mm_set1_ps(255.0f));
|
__m128 fvals = _mm_mul_ps(_mm_loadu_ps(src), _mm_set1_ps(255.0f));
|
||||||
__m128i i32 = _mm_cvttps_epi32(fvals);
|
__m128i i32 = _mm_cvttps_epi32(fvals);
|
||||||
__m128i i16 = _mm_packs_epi32(i32, i32);
|
__m128i i16 = _mm_packs_epi32(i32, i32);
|
||||||
__m128i i8 = _mm_packus_epi16(i16, i16);
|
__m128i i8 = _mm_packus_epi16(i16, i16);
|
||||||
_mm_storeu_si32(dst, i8);
|
int packedColor = _mm_cvtsi128_si32(i8);
|
||||||
|
memcpy(dst, &packedColor, sizeof(int));
|
||||||
#elif defined(SW_HAS_RVV)
|
#elif defined(SW_HAS_RVV)
|
||||||
// TODO: Implement RVV intrinsics
|
// TODO: Implement RVV intrinsics
|
||||||
// NOTE: RVV 1.0 specs define the use of __riscv_ prefix for instrinsic functions
|
// NOTE: RVV 1.0 specs define the use of __riscv_ prefix for instrinsic functions
|
||||||
@ -2373,16 +2381,16 @@ static void sw_texture_sample_nearest(float *SW_RESTRICT color, const sw_texture
|
|||||||
|
|
||||||
#if RLSW_SUPPORT_NPOT_TEXTURE
|
#if RLSW_SUPPORT_NPOT_TEXTURE
|
||||||
if (tex->sWrap == SW_REPEAT) x = (int)(sw_fract(u)*tex->width);
|
if (tex->sWrap == SW_REPEAT) x = (int)(sw_fract(u)*tex->width);
|
||||||
else x = (int)(sw_saturate(u)*tex->width);
|
else x = sw_clamp_int((int)(sw_saturate(u)*tex->width), 0, tex->wMinus1);
|
||||||
|
|
||||||
if (tex->tWrap == SW_REPEAT) y = (int)(sw_fract(v)*tex->height);
|
if (tex->tWrap == SW_REPEAT) y = (int)(sw_fract(v)*tex->height);
|
||||||
else y = (int)(sw_saturate(v)*tex->height);
|
else y = sw_clamp_int((int)(sw_saturate(v)*tex->height), 0, tex->hMinus1);
|
||||||
#else
|
#else
|
||||||
if (tex->sWrap == SW_REPEAT) x = (int)(u*tex->width) & tex->wMinus1;
|
if (tex->sWrap == SW_REPEAT) x = (int)(u*tex->width) & tex->wMinus1;
|
||||||
else x = (int)(sw_saturate(u)*tex->width);
|
else x = sw_clamp_int((int)(sw_saturate(u)*tex->width), 0, tex->wMinus1);
|
||||||
|
|
||||||
if (tex->tWrap == SW_REPEAT) y = (int)(v*tex->height) & tex->hMinus1;
|
if (tex->tWrap == SW_REPEAT) y = (int)(v*tex->height) & tex->hMinus1;
|
||||||
else y = (int)(sw_saturate(v)*tex->height);
|
else y = sw_clamp_int((int)(sw_saturate(v)*tex->height), 0, tex->hMinus1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tex->readColor(color, tex->pixels, y*tex->width + x);
|
tex->readColor(color, tex->pixels, y*tex->width + x);
|
||||||
@ -4083,9 +4091,9 @@ void swGetIntegerv(SWget name, int *v)
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case SW_MODELVIEW_STACK_DEPTH: *v = SW_MODELVIEW_STACK_DEPTH; break;
|
case SW_MODELVIEW_STACK_DEPTH: *v = RLSW.stackModelviewCounter; break;
|
||||||
case SW_PROJECTION_STACK_DEPTH: *v = SW_PROJECTION_STACK_DEPTH; break;
|
case SW_PROJECTION_STACK_DEPTH: *v = RLSW.stackProjectionCounter; break;
|
||||||
case SW_TEXTURE_STACK_DEPTH: *v = SW_TEXTURE_STACK_DEPTH; break;
|
case SW_TEXTURE_STACK_DEPTH: *v = RLSW.stackTextureCounter; break;
|
||||||
case SW_DRAW_FRAMEBUFFER_BINDING: *v = RLSW.boundFramebufferId; break;
|
case SW_DRAW_FRAMEBUFFER_BINDING: *v = RLSW.boundFramebufferId; break;
|
||||||
default: RLSW.errCode = SW_INVALID_ENUM; break;
|
default: RLSW.errCode = SW_INVALID_ENUM; break;
|
||||||
}
|
}
|
||||||
@ -5058,6 +5066,9 @@ void swTexParameteri(int param, int value)
|
|||||||
|
|
||||||
if (RLSW.boundTexture == NULL) return;
|
if (RLSW.boundTexture == NULL) return;
|
||||||
|
|
||||||
|
// Treat GL_CLAMP_TO_EDGE as GL_CLAMP
|
||||||
|
if (value == GL_CLAMP_TO_EDGE) value = GL_CLAMP;
|
||||||
|
|
||||||
switch (param)
|
switch (param)
|
||||||
{
|
{
|
||||||
case SW_TEXTURE_MIN_FILTER:
|
case SW_TEXTURE_MIN_FILTER:
|
||||||
|
|||||||
@ -724,10 +724,15 @@ void SetWindowMinSize(int width, int height)
|
|||||||
CORE.Window.screenMin.width = width;
|
CORE.Window.screenMin.width = width;
|
||||||
CORE.Window.screenMin.height = height;
|
CORE.Window.screenMin.height = height;
|
||||||
|
|
||||||
int minWidth = (CORE.Window.screenMin.width == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMin.width;
|
Vector2 scaleDpi = { 1.0f, 1.0f };
|
||||||
int minHeight = (CORE.Window.screenMin.height == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMin.height;
|
#if !defined(__APPLE__)
|
||||||
int maxWidth = (CORE.Window.screenMax.width == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMax.width;
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND)) scaleDpi = GetWindowScaleDPI();
|
||||||
int maxHeight = (CORE.Window.screenMax.height == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMax.height;
|
#endif
|
||||||
|
|
||||||
|
int minWidth = (CORE.Window.screenMin.width == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMin.width*scaleDpi.x);
|
||||||
|
int minHeight = (CORE.Window.screenMin.height == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMin.height*scaleDpi.y);
|
||||||
|
int maxWidth = (CORE.Window.screenMax.width == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMax.width*scaleDpi.x);
|
||||||
|
int maxHeight = (CORE.Window.screenMax.height == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMax.height*scaleDpi.y);
|
||||||
|
|
||||||
glfwSetWindowSizeLimits(platform.handle, minWidth, minHeight, maxWidth, maxHeight);
|
glfwSetWindowSizeLimits(platform.handle, minWidth, minHeight, maxWidth, maxHeight);
|
||||||
}
|
}
|
||||||
@ -738,10 +743,15 @@ void SetWindowMaxSize(int width, int height)
|
|||||||
CORE.Window.screenMax.width = width;
|
CORE.Window.screenMax.width = width;
|
||||||
CORE.Window.screenMax.height = height;
|
CORE.Window.screenMax.height = height;
|
||||||
|
|
||||||
int minWidth = (CORE.Window.screenMin.width == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMin.width;
|
Vector2 scaleDpi = { 1.0f, 1.0f };
|
||||||
int minHeight = (CORE.Window.screenMin.height == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMin.height;
|
#if !defined(__APPLE__)
|
||||||
int maxWidth = (CORE.Window.screenMax.width == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMax.width;
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND)) scaleDpi = GetWindowScaleDPI();
|
||||||
int maxHeight = (CORE.Window.screenMax.height == 0)? GLFW_DONT_CARE : (int)CORE.Window.screenMax.height;
|
#endif
|
||||||
|
|
||||||
|
int minWidth = (CORE.Window.screenMin.width == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMin.width*scaleDpi.x);
|
||||||
|
int minHeight = (CORE.Window.screenMin.height == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMin.height*scaleDpi.y);
|
||||||
|
int maxWidth = (CORE.Window.screenMax.width == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMax.width*scaleDpi.x);
|
||||||
|
int maxHeight = (CORE.Window.screenMax.height == 0)? GLFW_DONT_CARE : (int)roundf(CORE.Window.screenMax.height*scaleDpi.y);
|
||||||
|
|
||||||
glfwSetWindowSizeLimits(platform.handle, minWidth, minHeight, maxWidth, maxHeight);
|
glfwSetWindowSizeLimits(platform.handle, minWidth, minHeight, maxWidth, maxHeight);
|
||||||
}
|
}
|
||||||
@ -752,6 +762,15 @@ void SetWindowSize(int width, int height)
|
|||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
||||||
|
#if !defined(__APPLE__)
|
||||||
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND))
|
||||||
|
{
|
||||||
|
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||||
|
width = (int)roundf((float)width*scaleDpi.x);
|
||||||
|
height = (int)roundf((float)height*scaleDpi.y);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
glfwSetWindowSize(platform.handle, width, height);
|
glfwSetWindowSize(platform.handle, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
src/rcore.c
23
src/rcore.c
@ -2578,7 +2578,8 @@ const char *GetDirectoryPath(const char *filePath)
|
|||||||
|
|
||||||
// In case provided path does not contain a root drive letter (C:\, D:\)
|
// In case provided path does not contain a root drive letter (C:\, D:\)
|
||||||
// nor leading path separator (\, /), add the current directory path to dirPath
|
// nor leading path separator (\, /), add the current directory path to dirPath
|
||||||
if ((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/'))
|
bool isRelative = (filePath[0] != '\\') && (filePath[0] != '/') && ((filePath[0] == '\0') || (filePath[1] != ':'));
|
||||||
|
if (isRelative)
|
||||||
{
|
{
|
||||||
// For security, set starting path to current directory,
|
// For security, set starting path to current directory,
|
||||||
// obtained path will be concatenated to this
|
// obtained path will be concatenated to this
|
||||||
@ -2597,10 +2598,19 @@ const char *GetDirectoryPath(const char *filePath)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *dirPathPtr = dirPath;
|
int dirPathOffset = isRelative? 2 : 0; // Skip "./" added for relative paths
|
||||||
if ((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/')) dirPathPtr += 2; // Skip drive letter, "C:"
|
int dirPathLength = (int)(lastSlash - filePath);
|
||||||
memcpy(dirPathPtr, filePath, strlen(filePath) - (strlen(lastSlash) - 1));
|
|
||||||
dirPath[strlen(filePath) - strlen(lastSlash) + (((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/'))? 2 : 0)] = '\0'; // Add '\0' manually
|
if ((dirPathOffset + dirPathLength) < MAX_FILEPATH_LENGTH)
|
||||||
|
{
|
||||||
|
memcpy(dirPath + dirPathOffset, filePath, dirPathLength);
|
||||||
|
dirPath[dirPathOffset + dirPathLength] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_WARNING, "FILEIO: Directory path too long");
|
||||||
|
dirPath[0] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2629,7 +2639,8 @@ const char *GetPrevDirectoryPath(const char *dirPath)
|
|||||||
|
|
||||||
if (!isFile)
|
if (!isFile)
|
||||||
{
|
{
|
||||||
memcpy(prevDirPath, dirPath, i);
|
if (i < MAX_FILEPATH_LENGTH) memcpy(prevDirPath, dirPath, i);
|
||||||
|
else TRACELOG(LOG_WARNING, "FILEIO: Directory path too long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else isFile = false;
|
else isFile = false;
|
||||||
|
|||||||
16
src/rtext.c
16
src/rtext.c
@ -2464,7 +2464,7 @@ int GetCodepoint(const char *text, int *codepointSize)
|
|||||||
// [0]xC2-DF [1]UTF8-tail(x80-BF)
|
// [0]xC2-DF [1]UTF8-tail(x80-BF)
|
||||||
unsigned char octet1 = text[1];
|
unsigned char octet1 = text[1];
|
||||||
|
|
||||||
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) return codepoint; // Unexpected sequence
|
||||||
|
|
||||||
if ((octet >= 0xc2) && (octet <= 0xdf))
|
if ((octet >= 0xc2) && (octet <= 0xdf))
|
||||||
{
|
{
|
||||||
@ -2478,11 +2478,11 @@ int GetCodepoint(const char *text, int *codepointSize)
|
|||||||
unsigned char octet1 = text[1];
|
unsigned char octet1 = text[1];
|
||||||
unsigned char octet2 = '\0';
|
unsigned char octet2 = '\0';
|
||||||
|
|
||||||
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) return codepoint; // Unexpected sequence
|
||||||
|
|
||||||
octet2 = text[2];
|
octet2 = text[2];
|
||||||
|
|
||||||
if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *codepointSize = 3; return codepoint; } // Unexpected sequence
|
if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
||||||
|
|
||||||
// [0]xE0 [1]xA0-BF [2]UTF8-tail(x80-BF)
|
// [0]xE0 [1]xA0-BF [2]UTF8-tail(x80-BF)
|
||||||
// [0]xE1-EC [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
// [0]xE1-EC [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
||||||
@ -2490,7 +2490,7 @@ int GetCodepoint(const char *text, int *codepointSize)
|
|||||||
// [0]xEE-EF [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
// [0]xEE-EF [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
||||||
|
|
||||||
if (((octet == 0xe0) && !((octet1 >= 0xa0) && (octet1 <= 0xbf))) ||
|
if (((octet == 0xe0) && !((octet1 >= 0xa0) && (octet1 <= 0xbf))) ||
|
||||||
((octet == 0xed) && !((octet1 >= 0x80) && (octet1 <= 0x9f)))) { *codepointSize = 2; return codepoint; }
|
((octet == 0xed) && !((octet1 >= 0x80) && (octet1 <= 0x9f)))) return codepoint;
|
||||||
|
|
||||||
if ((octet >= 0xe0) && (octet <= 0xef))
|
if ((octet >= 0xe0) && (octet <= 0xef))
|
||||||
{
|
{
|
||||||
@ -2507,22 +2507,22 @@ int GetCodepoint(const char *text, int *codepointSize)
|
|||||||
unsigned char octet2 = '\0';
|
unsigned char octet2 = '\0';
|
||||||
unsigned char octet3 = '\0';
|
unsigned char octet3 = '\0';
|
||||||
|
|
||||||
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
if ((octet1 == '\0') || ((octet1 >> 6) != 2)) return codepoint; // Unexpected sequence
|
||||||
|
|
||||||
octet2 = text[2];
|
octet2 = text[2];
|
||||||
|
|
||||||
if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *codepointSize = 3; return codepoint; } // Unexpected sequence
|
if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
||||||
|
|
||||||
octet3 = text[3];
|
octet3 = text[3];
|
||||||
|
|
||||||
if ((octet3 == '\0') || ((octet3 >> 6) != 2)) { *codepointSize = 4; return codepoint; } // Unexpected sequence
|
if ((octet3 == '\0') || ((octet3 >> 6) != 2)) { *codepointSize = 3; return codepoint; } // Unexpected sequence
|
||||||
|
|
||||||
// [0]xF0 [1]x90-BF [2]UTF8-tail [3]UTF8-tail
|
// [0]xF0 [1]x90-BF [2]UTF8-tail [3]UTF8-tail
|
||||||
// [0]xF1-F3 [1]UTF8-tail [2]UTF8-tail [3]UTF8-tail
|
// [0]xF1-F3 [1]UTF8-tail [2]UTF8-tail [3]UTF8-tail
|
||||||
// [0]xF4 [1]x80-8F [2]UTF8-tail [3]UTF8-tail
|
// [0]xF4 [1]x80-8F [2]UTF8-tail [3]UTF8-tail
|
||||||
|
|
||||||
if (((octet == 0xf0) && !((octet1 >= 0x90) && (octet1 <= 0xbf))) ||
|
if (((octet == 0xf0) && !((octet1 >= 0x90) && (octet1 <= 0xbf))) ||
|
||||||
((octet == 0xf4) && !((octet1 >= 0x80) && (octet1 <= 0x8f)))) { *codepointSize = 2; return codepoint; } // Unexpected sequence
|
((octet == 0xf4) && !((octet1 >= 0x80) && (octet1 <= 0x8f)))) return codepoint; // Unexpected sequence
|
||||||
|
|
||||||
if (octet >= 0xf0)
|
if (octet >= 0xf0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user