diff options
author | Steven G. Johnson <stevenj@mit.edu> | 2015-05-29 21:58:21 -0400 |
---|---|---|
committer | Steven G. Johnson <stevenj@mit.edu> | 2015-05-29 21:58:21 -0400 |
commit | 35ec8e32e7e9ccbc7bc12da6eec5b11e72a9e674 (patch) | |
tree | 4652dafe789ee6a8ac76154dad6a7d14c2778df1 /test/graphemetest.c | |
parent | 7c14ef5f8371e463a01e0f1de971caa600384390 (diff) | |
parent | 6a229a6776b154b1906b6a1f282b72b38322e36b (diff) | |
download | libutf8proc-35ec8e32e7e9ccbc7bc12da6eec5b11e72a9e674.tar.gz libutf8proc-35ec8e32e7e9ccbc7bc12da6eec5b11e72a9e674.tar.bz2 |
Merge pull request #35 from ScottPJones/spj/valid
Fix #34 handle 66 Unicode non-characters and surrogates correctly
Diffstat (limited to 'test/graphemetest.c')
-rw-r--r-- | test/graphemetest.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/graphemetest.c b/test/graphemetest.c index a05b6e2..eb3645b 100644 --- a/test/graphemetest.c +++ b/test/graphemetest.c @@ -6,6 +6,7 @@ int main(int argc, char **argv) size_t bufsize = 0; FILE *f = argc > 1 ? fopen(argv[1], "r") : NULL; utf8proc_uint8_t src[1024]; + int len; check(f != NULL, "error opening GraphemeBreakTest.txt"); while (getline(&buf, &bufsize, f) > 0) { @@ -29,9 +30,10 @@ int main(int argc, char **argv) else if (buf[bi] == '#') { /* start of comments */ break; } - else { /* hex-encoded codepoint */ - bi += encode((char*) (src + si), buf + bi) - 1; + else { /* hex-encoded codepoint */ + len = encode((char*) (src + si), buf + bi) - 1; while (src[si]) ++si; /* advance to NUL termination */ + bi += len; } } if (si && src[si-1] == '/') @@ -59,7 +61,7 @@ int main(int argc, char **argv) utf8proc_errmsg(glen)); for (i = 0; i <= glen; ++i) if (g[i] == 0xff) - g[i] = '/'; /* easier-to-read output (/ is not in test strings) */ + g[i] = '/'; /* easier-to-read output (/ is not in test strings) */ check(!strcmp((char*)g, (char*)src), "grapheme mismatch: \"%s\" instead of \"%s\"", (char*)g, (char*)src); } |