diff options
| -rw-r--r-- | unicode/ChangeLog | 6 | ||||
| -rw-r--r-- | unicode/unicodebuf.c | 3 | ||||
| -rw-r--r-- | unicode/unicodetest.c | 19 | 
3 files changed, 27 insertions, 1 deletions
| diff --git a/unicode/ChangeLog b/unicode/ChangeLog index 8b4e8ce..01a1246 100644 --- a/unicode/ChangeLog +++ b/unicode/ChangeLog @@ -21,6 +21,12 @@  	* Add bidi property lookups. +2.1.1 + +2020-11-24  Sam Varshavchik  <mrsam@courier-mta.com> + +	* unicodebuf.c (unicode_buf_remove): Bug fix. +  2.1  2020-04-21  Sam Varshavchik  <mrsam@courier-mta.com> diff --git a/unicode/unicodebuf.c b/unicode/unicodebuf.c index eb64543..59b7522 100644 --- a/unicode/unicodebuf.c +++ b/unicode/unicodebuf.c @@ -89,7 +89,8 @@ void unicode_buf_remove(struct unicode_buf *p,  		cnt=p->len-pos;  	if (cnt) -		memmove(p->ptr+pos+cnt, p->ptr+pos, p->len-pos-cnt); +		memmove(p->ptr+pos, p->ptr+pos+cnt, +			(p->len-pos-cnt) * sizeof(char32_t));  	p->len -= cnt;  } diff --git a/unicode/unicodetest.c b/unicode/unicodetest.c index e9e4228..12a874f 100644 --- a/unicode/unicodetest.c +++ b/unicode/unicodetest.c @@ -123,11 +123,30 @@ static void test2()  	exit(1);  } +void testunicodebuf() +{ +	struct unicode_buf buf; + +	unicode_buf_init(&buf, -1); +	unicode_buf_append_char(&buf, "01234567", 8); +	unicode_buf_remove(&buf, 1, 6); + +	if (unicode_buf_len(&buf) != 2 || +	    unicode_buf_ptr(&buf)[0] != '0' || +	    unicode_buf_ptr(&buf)[1] != '7') +	{ +		fprintf(stderr, "unicode_buf_remove failed\n"); +		exit(1); +	} +	unicode_buf_deinit(&buf); +} +  int main(int argc, char **argv)  {  	const char *chset=unicode_x_imap_modutf7;  	int argn=1; +	testunicodebuf();  	if (argn < argc && strcmp(argv[argn], "--smap") == 0)  	{  		chset=unicode_x_imap_modutf7 " ./~:"; | 
