Debian Codegraph @

tests/pcre-utf8

raw
1 #! /bin/sh
2 # Ensure that, with -P, Unicode \p{} symbols are correctly matched.
3 #
4 # Copyright (C) 2012-2025 Free Software Foundation, Inc.
5 #
6 # Copying and distribution of this file, with or without modification,
7 # are permitted in any medium without royalty provided the copyright
8 # notice and this notice are preserved.
9
10 . "${srcdir=.}/init.sh"; path_prepend_ ../src
11 require_en_utf8_locale_
12 LC_ALL=en_US.UTF-8 require_pcre_
13
14 fail=0
15
16 echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' \
17 || skip_ 'PCRE unicode support is compiled out'
18
19 euro='\342\202\254 euro'
20 printf "$euro\\n" > in || framework_failure_
21
22 # The euro sign has the unicode "Symbol" property, so this must match:
23 LC_ALL=en_US.UTF-8 grep -P '^\p{S}' in > out || fail=1
24 compare in out || fail=1
25
26 # This RE must *not* match in the C locale, because the first
27 # byte is not a "Symbol".
28 LC_ALL=C grep -P '^\p{S}' in > out && fail=1
29 compare /dev/null out || fail=1
30
31 LC_ALL=en_US.UTF-8 grep -P '^. euro$' in > out2 || fail=1
32 compare in out2 || fail=1
33
34 LC_ALL=en_US.UTF-8 grep -oP '. euro' in > out3 || fail=1
35 compare in out3 || fail=1
36
37 LC_ALL=en_US.UTF-8 grep -P '^\P{S}' in > out4
38 compare /dev/null out4 || fail=1
39
40 Exit $fail