diffutils/tests/side-by-side
Paul Eggert a542ab269a diff: support multi-byte comparison
* bootstrap.conf (gnulib_modules): Add c32isspace, c32tolower.
* lib/Makefile.am (noinst_HEADERS): Add mbcel.h.
(libdiffutils_a_SOURCES): Add mbcel.c
* lib/mbcel.c, lib/mbcel.h: New files.
* src/io.c: Include mbcel.h, uchar.h.
(hash): 2nd arg is now hash_value, not merely unsigned char,
since the caller might pass a char32_t now.
(find_and_hash_each_line): Support multi-byte input.
* src/util.c: Include mbcel.h, uchar.h.
(lines_differ): New args S1LEN, S2LEN, needed for mbcel_scan.
Caller changed.  Support multi-byte input.
* tests/ignore-case: New file.
* tests/Makefile.am (TESTS): Add it.
* tests/ignore-tab-expansion: Add UTF-8 test.
* tests/init.cfg (require_utf8_locale_): New function.
* tests/side-by-side: Use it.  Add a column-counting test.
2023-07-09 01:19:45 -07:00

53 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Test side-by-side output with non-ASCII characters.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_utf8_locale_
fail=0
cat >in1 <<\EOF || framework_failure_
a
ab
abc
[一天早上,當格雷戈爾·薩姆沙從不安的夢中醒來時,
他發現自己在床上變成了一隻可怕的害蟲。
]
EOF
cat >in2 <<\EOF || framework_failure_
ab
abcd
<一天早上,當格雷戈爾·薩姆沙從不安的夢中醒來時,
他發現自己在床上變成了一隻可怕的害蟲。
>
EOF
tr '_@' ' \t' >exp <<'EOF' || framework_failure_
a@@_____<
ab@@@ab
abc@@_____|@abcd
[一天早上當格雷戈__|@<一天早上,當格雷戈
_他發現自己在床上變@_他發現自己在床上變
]@@_____|@>
EOF
returns_ 1 diff -y -W 44 in1 in2 >out 2>err || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1
cat >exp <<'EOF' || framework_failure_
a <
ab ab
abc | abcd
[一天早上,當格雷戈 | <一天早上,當格雷戈
他發現自己在床上變 他發現自己在床上變
] | >
EOF
returns_ 1 diff --expand-tabs -y -W 44 in1 in2 >out 2>err || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1
Exit $fail