diff options
| author | Sam Varshavchik | 2021-02-23 19:18:13 -0500 | 
|---|---|---|
| committer | Sam Varshavchik | 2021-02-23 19:18:13 -0500 | 
| commit | a6e6ff2e38a390e66982210eb56972f9e3c00477 (patch) | |
| tree | da9eafa6f4f9c324c08f7cee3527cda572f611c7 /unicode/unicode_bidi.c | |
| parent | 8327472b2c20a2e2466e5f4224f2910dda66950c (diff) | |
| download | courier-libs-a6e6ff2e38a390e66982210eb56972f9e3c00477.tar.bz2 | |
courier-unicode: unicode_bidi_cleaned_size, unicode::bidi_override
Diffstat (limited to 'unicode/unicode_bidi.c')
| -rw-r--r-- | unicode/unicode_bidi.c | 39 | 
1 files changed, 31 insertions, 8 deletions
| diff --git a/unicode/unicode_bidi.c b/unicode/unicode_bidi.c index b97ec25..1aa4a88 100644 --- a/unicode/unicode_bidi.c +++ b/unicode/unicode_bidi.c @@ -2063,12 +2063,14 @@ void unicode_bidi_reorder(char32_t *p,  	level_run_layers_deinit(&layers);  } -size_t unicode_bidi_cleanup(char32_t *string, -			    unicode_bidi_level_t *levels, -			    size_t n, -			    int cleanup_options, -			    void (*removed_callback)(size_t, void *), -			    void *arg) +static size_t unicode_bidi_count_or_cleanup(const char32_t *string, +					    char32_t *dest, +					    unicode_bidi_level_t *levels, +					    size_t n, +					    int cleanup_options, +					    void (*removed_callback)(size_t, +								     void *), +					    void *arg)  {  	size_t i=0;  	for (size_t j=0; j<n; ++j) @@ -2090,13 +2092,34 @@ size_t unicode_bidi_cleanup(char32_t *string,  		if (levels)  			levels[i]=levels[j] & 1; -		string[i]=(cleanup_options & UNICODE_BIDI_CLEANUP_BNL) -			&& cl == UNICODE_BIDI_TYPE_B ? '\n' : string[j]; +		if (dest) +			dest[i]=(cleanup_options & UNICODE_BIDI_CLEANUP_BNL) +				&& cl == UNICODE_BIDI_TYPE_B ? '\n' : string[j];  		++i;  	}  	return i;  } +size_t unicode_bidi_cleanup(char32_t *string, +			    unicode_bidi_level_t *levels, +			    size_t n, +			    int cleanup_options, +			    void (*removed_callback)(size_t, void *), +			    void *arg) +{ +	return unicode_bidi_count_or_cleanup(string, string, levels, n, +					     cleanup_options, removed_callback, +					     arg); +} + +size_t unicode_bidi_cleaned_size(const char32_t *string, +				 size_t n, +				 int cleanup_options) +{ +	return unicode_bidi_count_or_cleanup(string, NULL, NULL, n, +					     cleanup_options, NULL, NULL); +} +  void unicode_bidi_logical_order(char32_t *string,  				unicode_bidi_level_t *levels,  				size_t n, | 
