@@ -35,54 +35,54 @@ SDL_ELF_NOTE_DLOPEN(
3535#endif
3636
3737SDL_FriBidi * SDL_FriBidi_Create (void ) {
38- SDL_FriBidi * fribidi ;
38+ SDL_FriBidi * fribidi ;
3939
40- fribidi = (SDL_FriBidi * )SDL_malloc (sizeof (SDL_FriBidi ));
41- if (!fribidi ) {
42- return NULL ;
43- }
40+ fribidi = (SDL_FriBidi * )SDL_malloc (sizeof (SDL_FriBidi ));
41+ if (!fribidi ) {
42+ return NULL ;
43+ }
4444
4545#ifdef SDL_FRIBIDI_DYNAMIC
46- #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; }
47-
48- fribidi -> lib = SDL_LoadObject (SDL_FRIBIDI_DYNAMIC );
49- if (!fribidi -> lib ) {
50- SDL_free (fribidi );
51- return NULL ;
52- }
53-
54- SDL_FRIBIDI_LOAD_SYM (fribidi -> unicode_to_charset , "fribidi_unicode_to_charset" , SDL_FriBidiUnicodeToCharset );
55- SDL_FRIBIDI_LOAD_SYM (fribidi -> charset_to_unicode , "fribidi_charset_to_unicode" , SDL_FriBidiCharsetToUnicode );
56- SDL_FRIBIDI_LOAD_SYM (fribidi -> get_bidi_types , "fribidi_get_bidi_types" , SDL_FriBidiGetBidiTypes );
57- SDL_FRIBIDI_LOAD_SYM (fribidi -> get_par_direction , "fribidi_get_par_direction" , SDL_FriBidiGetParDirection );
58- SDL_FRIBIDI_LOAD_SYM (fribidi -> get_par_embedding_levels , "fribidi_get_par_embedding_levels" , SDL_FriBidiGetParEmbeddingLevels );
59- SDL_FRIBIDI_LOAD_SYM (fribidi -> get_joining_types , "fribidi_get_joining_types" , SDL_FriBidiGetJoiningTypes );
60- SDL_FRIBIDI_LOAD_SYM (fribidi -> join_arabic , "fribidi_join_arabic" , SDL_FriBidiJoinArabic );
61- SDL_FRIBIDI_LOAD_SYM (fribidi -> shape , "fribidi_shape" , SDL_FriBidiShape );
62- SDL_FRIBIDI_LOAD_SYM (fribidi -> reorder_line , "fribidi_reorder_line" , SDL_FriBidiReorderLine );
46+ #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; }
47+
48+ fribidi -> lib = SDL_LoadObject (SDL_FRIBIDI_DYNAMIC );
49+ if (!fribidi -> lib ) {
50+ SDL_free (fribidi );
51+ return NULL ;
52+ }
53+
54+ SDL_FRIBIDI_LOAD_SYM (fribidi -> unicode_to_charset , "fribidi_unicode_to_charset" , SDL_FriBidiUnicodeToCharset );
55+ SDL_FRIBIDI_LOAD_SYM (fribidi -> charset_to_unicode , "fribidi_charset_to_unicode" , SDL_FriBidiCharsetToUnicode );
56+ SDL_FRIBIDI_LOAD_SYM (fribidi -> get_bidi_types , "fribidi_get_bidi_types" , SDL_FriBidiGetBidiTypes );
57+ SDL_FRIBIDI_LOAD_SYM (fribidi -> get_par_direction , "fribidi_get_par_direction" , SDL_FriBidiGetParDirection );
58+ SDL_FRIBIDI_LOAD_SYM (fribidi -> get_par_embedding_levels , "fribidi_get_par_embedding_levels" , SDL_FriBidiGetParEmbeddingLevels );
59+ SDL_FRIBIDI_LOAD_SYM (fribidi -> get_joining_types , "fribidi_get_joining_types" , SDL_FriBidiGetJoiningTypes );
60+ SDL_FRIBIDI_LOAD_SYM (fribidi -> join_arabic , "fribidi_join_arabic" , SDL_FriBidiJoinArabic );
61+ SDL_FRIBIDI_LOAD_SYM (fribidi -> shape , "fribidi_shape" , SDL_FriBidiShape );
62+ SDL_FRIBIDI_LOAD_SYM (fribidi -> reorder_line , "fribidi_reorder_line" , SDL_FriBidiReorderLine );
6363#else
64- fribidi -> unicode_to_charset = fribidi_unicode_to_charset ;
65- fribidi -> charset_to_unicode = fribidi_charset_to_unicode ;
66- fribidi -> get_bidi_types = fribidi_get_bidi_types ;
67- fribidi -> get_par_direction = fribidi_get_par_direction ;
68- fribidi -> get_par_embedding_levels = fribidi_get_par_embedding_levels ;
69- fribidi -> get_joining_types = fribidi_get_joining_types ;
70- fribidi -> join_arabic = fribidi_join_arabic ;
71- fribidi -> shape = fribidi_shape ;
72- fribidi -> reorder_line = fribidi_reorder_line ;
64+ fribidi -> unicode_to_charset = fribidi_unicode_to_charset ;
65+ fribidi -> charset_to_unicode = fribidi_charset_to_unicode ;
66+ fribidi -> get_bidi_types = fribidi_get_bidi_types ;
67+ fribidi -> get_par_direction = fribidi_get_par_direction ;
68+ fribidi -> get_par_embedding_levels = fribidi_get_par_embedding_levels ;
69+ fribidi -> get_joining_types = fribidi_get_joining_types ;
70+ fribidi -> join_arabic = fribidi_join_arabic ;
71+ fribidi -> shape = fribidi_shape ;
72+ fribidi -> reorder_line = fribidi_reorder_line ;
7373#endif
7474
75- return fribidi ;
75+ return fribidi ;
7676}
7777
7878char * SDL_FriBidi_Process (SDL_FriBidi * fribidi , char * utf8 , ssize_t utf8_len , bool shaping , FriBidiParType * out_par_type ) {
7979 FriBidiCharType * types ;
8080 FriBidiLevel * levels ;
8181 FriBidiArabicProp * props ;
82- FriBidiChar * str ;
83- char * result ;
82+ FriBidiChar * str ;
83+ char * result ;
8484 FriBidiStrIndex len ;
85- FriBidiLevel max_level ;
85+ FriBidiLevel max_level ;
8686 FriBidiLevel start ;
8787 FriBidiLevel end ;
8888 FriBidiParType direction ;
@@ -94,10 +94,10 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
9494 return NULL ;
9595 }
9696
97- /* Convert to UTF32 */
98- if (utf8_len < 0 ) {
99- utf8_len = SDL_strlen (utf8 );
100- }
97+ /* Convert to UTF32 */
98+ if (utf8_len < 0 ) {
99+ utf8_len = SDL_strlen (utf8 );
100+ }
101101 str = SDL_calloc (SDL_utf8strnlen (utf8 , utf8_len ), sizeof (FriBidiChar ));
102102 len = fribidi -> charset_to_unicode (FRIBIDI_CHAR_SET_UTF8 , utf8 , utf8_len , str );
103103
@@ -109,61 +109,61 @@ char *SDL_FriBidi_Process(SDL_FriBidi *fribidi, char *utf8, ssize_t utf8_len, bo
109109 levels = SDL_calloc (len + 1 , sizeof (FriBidiLevel ));
110110 types = SDL_calloc (len + 1 , sizeof (FriBidiCharType ));
111111
112- /* Shape */
112+ /* Shape */
113113 fribidi -> get_bidi_types (str , len , types );
114- str_direction = fribidi -> get_par_direction (types , len );
115- max_level = fribidi -> get_par_embedding_levels (types , len , & direction , levels );
116- if (shaping ) {
117- fribidi -> get_joining_types (str , len , props );
118- fribidi -> join_arabic (types , len , levels , props );
119- fribidi -> shape (FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC , levels , len , props , str );
120- }
121-
122- /* BIDI */
114+ str_direction = fribidi -> get_par_direction (types , len );
115+ max_level = fribidi -> get_par_embedding_levels (types , len , & direction , levels );
116+ if (shaping ) {
117+ fribidi -> get_joining_types (str , len , props );
118+ fribidi -> join_arabic (types , len , levels , props );
119+ fribidi -> shape (FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC , levels , len , props , str );
120+ }
121+
122+ /* BIDI */
123123 for (end = 0 , start = 0 ; end < len ; end ++ ) {
124124 if (str [end ] == '\n' || str [end ] == '\r' || str [end ] == '\f' || str [end ] == '\v' || end == len - 1 ) {
125125 max_level = fribidi -> reorder_line (FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC , types , end - start + 1 , start , direction , levels , str , NULL );
126126 start = end + 1 ;
127127 }
128128 }
129129
130- /* Silence warning */
131- (void )max_level ;
130+ /* Silence warning */
131+ (void )max_level ;
132132
133- /* Remove fillers */
133+ /* Remove fillers */
134134 for (i = 0 , c = 0 ; i < len ; i ++ ) {
135135 if (str [i ] != FRIBIDI_CHAR_FILL ) {
136136 str [c ++ ] = str [i ];
137137 }
138138 }
139139 len = c ;
140140
141- /* Convert back to UTF8 */
141+ /* Convert back to UTF8 */
142142 result = SDL_malloc (len * 4 + 1 );
143143 fribidi -> unicode_to_charset (FRIBIDI_CHAR_SET_UTF8 , str , len , result );
144144
145- /* Cleanup */
145+ /* Cleanup */
146146 SDL_free (levels );
147147 SDL_free (props );
148148 SDL_free (types );
149149
150- /* Return */
151- if (out_par_type ) {
152- * out_par_type = str_direction ;
153- }
154- return result ;
150+ /* Return */
151+ if (out_par_type ) {
152+ * out_par_type = str_direction ;
153+ }
154+ return result ;
155155}
156156
157157void SDL_FriBidi_Destroy (SDL_FriBidi * fribidi ) {
158- if (!fribidi ) {
159- return ;
160- }
158+ if (!fribidi ) {
159+ return ;
160+ }
161161
162162#ifdef SDL_FRIBIDI_DYNAMIC
163- SDL_UnloadObject (fribidi -> lib );
163+ SDL_UnloadObject (fribidi -> lib );
164164#endif
165165
166- SDL_free (fribidi );
166+ SDL_free (fribidi );
167167}
168168
169169#endif
0 commit comments