libgrapheme

unicode string library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | README | LICENSE

commit eee3a6e193f42bc9cb98e85920d194b800435ab8
parent 35e15b1196bd37a6a398102ae1966cc96fe8c8d2
Author: Laslo Hunhold <dev@frign.de>
Date:   Tue, 20 Oct 2020 23:52:17 +0200

Rename datafiles and tests

Unicode talks about "breaks" and has its datafiles still named after
them, but the standards have long changed to call the "breaks"
boundaries. I have already adapted this in the API, but the internal
files kept it for no reason other than being inspired by the Unicode
data directory.

When Unicode can't fix its names for backwards compatibility, we will do
it.

While at it, fix the order in the makefile.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
MMakefile | 38+++++++++++++++++++-------------------
Rdata/emo.c -> data/emoji.c | 0
Rdata/emo.txt -> data/emoji.txt | 0
Rdata/gbp.c -> data/grapheme_boundary.c | 0
Rdata/gbp.txt -> data/grapheme_boundary.txt | 0
Rdata/gbt.c -> data/grapheme_boundary_test.c | 0
Rdata/gbt.txt -> data/grapheme_boundary_test.txt | 0
Msrc/boundary.c | 4++--
Atest/grapheme_boundary.c | 41+++++++++++++++++++++++++++++++++++++++++
Dtest/grapheme_break.c | 41-----------------------------------------
10 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/Makefile b/Makefile @@ -5,43 +5,43 @@ include config.mk LIB = src/boundary src/codepoint src/grapheme -TEST = test/grapheme_break test/utf8-decode test/utf8-encode -DATA = data/gbp data/emo data/gbt +TEST = test/grapheme_boundary test/utf8-decode test/utf8-encode +DATA = data/emoji data/grapheme_boundary data/grapheme_boundary_test MAN3 = man/grapheme_bytelen.3 MAN7 = man/libgrapheme.7 all: libgrapheme.a libgrapheme.so -data/gbp.h: data/gbp.txt data/gbp -data/emo.h: data/emo.txt data/emo -data/gbt.h: data/gbt.txt data/gbt +data/emoji.h: data/emoji.txt data/emoji +data/grapheme_boundary.h: data/grapheme_boundary.txt data/grapheme_boundary +data/grapheme_boundary_test.h: data/grapheme_boundary_test.txt data/grapheme_boundary_test -data/gbp.o: data/gbp.c config.mk data/util.h -data/emo.o: data/emo.c config.mk data/util.h -data/gbt.o: data/gbt.c config.mk data/util.h +data/emoji.o: data/emoji.c config.mk data/util.h +data/grapheme_boundary.o: data/grapheme_boundary.c config.mk data/util.h +data/grapheme_boundary_test.o: data/grapheme_boundary_test.c config.mk data/util.h data/util.o: data/util.c config.mk data/util.h -src/boundary.o: src/boundary.c config.mk data/emo.h data/gbp.h grapheme.h +src/boundary.o: src/boundary.c config.mk data/emoji.h data/grapheme_boundary.h grapheme.h src/codepoint.o: src/codepoint.c config.mk grapheme.h src/grapheme.o: src/grapheme.c config.mk grapheme.h -test/grapheme_break.o: test/grapheme_break.c config.mk data/gbt.h grapheme.h +test/grapheme_boundary.o: test/grapheme_boundary.c config.mk data/grapheme_boundary_test.h grapheme.h test/utf8-encode.o: test/utf8-encode.c config.mk grapheme.h test/utf8-decode.o: test/utf8-decode.c config.mk grapheme.h -data/gbp: data/gbp.o data/util.o -data/emo: data/emo.o data/util.o -data/gbt: data/gbt.o data/util.o -test/grapheme_break: test/grapheme_break.o libgrapheme.a +data/emoji: data/emoji.o data/util.o +data/grapheme_boundary: data/grapheme_boundary.o data/util.o +data/grapheme_boundary_test: data/grapheme_boundary_test.o data/util.o +test/grapheme_boundary: test/grapheme_boundary.o libgrapheme.a test/utf8-encode: test/utf8-encode.o libgrapheme.a test/utf8-decode: test/utf8-decode.o libgrapheme.a -data/gbp.txt: - wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt - -data/emo.txt: +data/emoji.txt: wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/emoji/emoji-data.txt -data/gbt.txt: +data/grapheme_boundary.txt: + wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt + +data/grapheme_boundary_test.txt: wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakTest.txt $(DATA:=.h): diff --git a/data/emo.c b/data/emoji.c diff --git a/data/emo.txt b/data/emoji.txt diff --git a/data/gbp.c b/data/grapheme_boundary.c diff --git a/data/gbp.txt b/data/grapheme_boundary.txt diff --git a/data/gbt.c b/data/grapheme_boundary_test.c diff --git a/data/gbt.txt b/data/grapheme_boundary_test.txt diff --git a/src/boundary.c b/src/boundary.c @@ -3,8 +3,8 @@ #include <stdint.h> #include <stdlib.h> -#include "../data/emo.h" -#include "../data/gbp.h" +#include "../data/emoji.h" +#include "../data/grapheme_boundary.h" #define LEN(x) (sizeof(x) / sizeof(*x)) diff --git a/test/grapheme_boundary.c b/test/grapheme_boundary.c @@ -0,0 +1,41 @@ +/* See LICENSE file for copyright and license details. */ +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "../grapheme.h" +#include "../data/grapheme_boundary_test.h" + +#define LEN(x) (sizeof(x) / sizeof(*x)) + +int +main(void) +{ + int state; + size_t i, j, k, len, failed; + + /* grapheme break test */ + for (i = 0, failed = 0; i < LEN(t); i++) { + for (j = 0, k = 0, state = 0, len = 1; j < t[i].cplen; j++) { + if ((j + 1) == t[i].cplen || + grapheme_boundary(t[i].cp[j], t[i].cp[j + 1], + &state)) { + /* check if our resulting length matches */ + if (k == t[i].lenlen || len != t[i].len[k++]) { + fprintf(stderr, "Failed \"%s\"\n", + t[i].descr); + failed++; + break; + } + len = 1; + } else { + len++; + } + } + } + printf("Grapheme break test: Passed %zu out of %zu tests.\n", + LEN(t) - failed, LEN(t)); + + return (failed > 0) ? 1 : 0; +} diff --git a/test/grapheme_break.c b/test/grapheme_break.c @@ -1,41 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include "../grapheme.h" -#include "../data/gbt.h" - -#define LEN(x) (sizeof(x) / sizeof(*x)) - -int -main(void) -{ - int state; - size_t i, j, k, len, failed; - - /* grapheme break test */ - for (i = 0, failed = 0; i < LEN(t); i++) { - for (j = 0, k = 0, state = 0, len = 1; j < t[i].cplen; j++) { - if ((j + 1) == t[i].cplen || - grapheme_boundary(t[i].cp[j], t[i].cp[j + 1], - &state)) { - /* check if our resulting length matches */ - if (k == t[i].lenlen || len != t[i].len[k++]) { - fprintf(stderr, "Failed \"%s\"\n", - t[i].descr); - failed++; - break; - } - len = 1; - } else { - len++; - } - } - } - printf("Grapheme break test: Passed %zu out of %zu tests.\n", - LEN(t) - failed, LEN(t)); - - return (failed > 0) ? 1 : 0; -}