|
@@ -28,20 +28,20 @@
|
|
SDL_FriBidi *SDL_FriBidi_Create(void) {
|
|
SDL_FriBidi *SDL_FriBidi_Create(void) {
|
|
SDL_FriBidi *fribidi;
|
|
SDL_FriBidi *fribidi;
|
|
|
|
|
|
- fribidi = (SDL_FriBidi *)SDL_malloc(sizeof(SDL_FriBidi));
|
|
|
|
|
|
+ fribidi = (SDL_FriBidi *)SDL_malloc(sizeof(SDL_FriBidi));
|
|
if (!fribidi) {
|
|
if (!fribidi) {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef SDL_FRIBIDI_DYNAMIC
|
|
|
|
|
|
+#ifdef SDL_FRIBIDI_DYNAMIC
|
|
#define SDL_FRIBIDI_LOAD_SYM(x, n, t) x = ((t)SDL_LoadFunction(fribidi->lib, n)); if (!x) { SDL_UnloadObject(fribidi->lib); SDL_free(fribidi); return NULL; }
|
|
#define SDL_FRIBIDI_LOAD_SYM(x, n, t) x = ((t)SDL_LoadFunction(fribidi->lib, n)); if (!x) { SDL_UnloadObject(fribidi->lib); SDL_free(fribidi); return NULL; }
|
|
|
|
|
|
fribidi->lib = SDL_LoadObject(SDL_FRIBIDI_DYNAMIC);
|
|
fribidi->lib = SDL_LoadObject(SDL_FRIBIDI_DYNAMIC);
|
|
if (!fribidi->lib) {
|
|
if (!fribidi->lib) {
|
|
SDL_free(fribidi);
|
|
SDL_free(fribidi);
|
|
- return NULL;
|
|
|
|
|
|
+ return NULL;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->unicode_to_charset, "fribidi_unicode_to_charset", SDL_FriBidiUnicodeToCharset);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->unicode_to_charset, "fribidi_unicode_to_charset", SDL_FriBidiUnicodeToCharset);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->charset_to_unicode, "fribidi_charset_to_unicode", SDL_FriBidiCharsetToUnicode);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->charset_to_unicode, "fribidi_charset_to_unicode", SDL_FriBidiCharsetToUnicode);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->get_bidi_types, "fribidi_get_bidi_types", SDL_FriBidiGetBidiTypes);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->get_bidi_types, "fribidi_get_bidi_types", SDL_FriBidiGetBidiTypes);
|
|
@@ -51,7 +51,7 @@ SDL_FriBidi *SDL_FriBidi_Create(void) {
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->join_arabic, "fribidi_join_arabic", SDL_FriBidiJoinArabic);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->join_arabic, "fribidi_join_arabic", SDL_FriBidiJoinArabic);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->shape, "fribidi_shape", SDL_FriBidiShape);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->shape, "fribidi_shape", SDL_FriBidiShape);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->reorder_line, "fribidi_reorder_line", SDL_FriBidiReorderLine);
|
|
SDL_FRIBIDI_LOAD_SYM(fribidi->reorder_line, "fribidi_reorder_line", SDL_FriBidiReorderLine);
|
|
-#else
|
|
|
|
|
|
+#else
|
|
fribidi->unicode_to_charset = fribidi_unicode_to_charset;
|
|
fribidi->unicode_to_charset = fribidi_unicode_to_charset;
|
|
fribidi->charset_to_unicode = fribidi_charset_to_unicode;
|
|
fribidi->charset_to_unicode = fribidi_charset_to_unicode;
|
|
fribidi->get_bidi_types = fribidi_get_bidi_types;
|
|
fribidi->get_bidi_types = fribidi_get_bidi_types;
|
|
@@ -91,7 +91,7 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
|
|
}
|
|
}
|
|
str = SDL_calloc(SDL_utf8strnlen(utf8, utf8_len), sizeof(FriBidiChar));
|
|
str = SDL_calloc(SDL_utf8strnlen(utf8, utf8_len), sizeof(FriBidiChar));
|
|
len = fribidi->charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, utf8, utf8_len, str);
|
|
len = fribidi->charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, utf8, utf8_len, str);
|
|
-
|
|
|
|
|
|
+
|
|
/* Setup various BIDI structures */
|
|
/* Setup various BIDI structures */
|
|
direction = FRIBIDI_PAR_LTR;
|
|
direction = FRIBIDI_PAR_LTR;
|
|
types = NULL;
|
|
types = NULL;
|
|
@@ -109,7 +109,7 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
|
|
fribidi->join_arabic(types, len, levels, props);
|
|
fribidi->join_arabic(types, len, levels, props);
|
|
fribidi->shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC, levels, len, props, str);
|
|
fribidi->shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC, levels, len, props, str);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/* BIDI */
|
|
/* BIDI */
|
|
for (end = 0, start = 0; end < len; end++) {
|
|
for (end = 0, start = 0; end < len; end++) {
|
|
if (str[end] == '\n' || str[end] == '\r' || str[end] == '\f' || str[end] == '\v' || end == len - 1) {
|
|
if (str[end] == '\n' || str[end] == '\r' || str[end] == '\f' || str[end] == '\v' || end == len - 1) {
|
|
@@ -117,10 +117,10 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
|
|
start = end + 1;
|
|
start = end + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/* Silence warning */
|
|
/* Silence warning */
|
|
(void)max_level;
|
|
(void)max_level;
|
|
-
|
|
|
|
|
|
+
|
|
/* Remove fillers */
|
|
/* Remove fillers */
|
|
for (i = 0, c = 0; i < len; i++) {
|
|
for (i = 0, c = 0; i < len; i++) {
|
|
if (str[i] != FRIBIDI_CHAR_FILL) {
|
|
if (str[i] != FRIBIDI_CHAR_FILL) {
|
|
@@ -137,10 +137,10 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
|
|
SDL_free(levels);
|
|
SDL_free(levels);
|
|
SDL_free(props);
|
|
SDL_free(props);
|
|
SDL_free(types);
|
|
SDL_free(types);
|
|
-
|
|
|
|
|
|
+
|
|
/* Return */
|
|
/* Return */
|
|
if (out_par_type) {
|
|
if (out_par_type) {
|
|
- *out_par_type = str_direction;
|
|
|
|
|
|
+ *out_par_type = str_direction;
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -149,9 +149,9 @@ void SDL_FriBidi_Destroy(SDL_FriBidi *fribidi) {
|
|
if (!fribidi) {
|
|
if (!fribidi) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
-#ifdef SDL_FRIBIDI_DYNAMIC
|
|
|
|
- SDL_UnloadObject(fribidi->lib);
|
|
|
|
|
|
+
|
|
|
|
+#ifdef SDL_FRIBIDI_DYNAMIC
|
|
|
|
+ SDL_UnloadObject(fribidi->lib);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
SDL_free(fribidi);
|
|
SDL_free(fribidi);
|