Blame tests/pcre-utf8

Packit 709fb3
#! /bin/sh
Packit 709fb3
# Ensure that, with -P, Unicode \p{} symbols are correctly matched.
Packit 709fb3
#
Packit 709fb3
# Copyright (C) 2012-2017 Free Software Foundation, Inc.
Packit 709fb3
#
Packit 709fb3
# Copying and distribution of this file, with or without modification,
Packit 709fb3
# are permitted in any medium without royalty provided the copyright
Packit 709fb3
# notice and this notice are preserved.
Packit 709fb3
Packit 709fb3
. "${srcdir=.}/init.sh"; path_prepend_ ../src
Packit 709fb3
require_en_utf8_locale_
Packit 709fb3
LC_ALL=en_US.UTF-8 require_pcre_
Packit 709fb3
Packit 709fb3
fail=0
Packit 709fb3
Packit 709fb3
echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' \
Packit 709fb3
  || skip_ 'PCRE support is compiled out, or it does not support properties'
Packit 709fb3
Packit 709fb3
euro='\342\202\254 euro'
Packit 709fb3
printf "$euro\\n" > in || framework_failure_
Packit 709fb3
Packit 709fb3
# The euro sign has the unicode "Symbol" property, so this must match:
Packit 709fb3
LC_ALL=en_US.UTF-8 grep -P '^\p{S}' in > out || fail=1
Packit 709fb3
compare in out || fail=1
Packit 709fb3
Packit 709fb3
# This RE must *not* match in the C locale, because the first
Packit 709fb3
# byte is not a "Symbol".
Packit 709fb3
LC_ALL=C grep -P '^\p{S}' in > out && fail=1
Packit 709fb3
compare /dev/null out || fail=1
Packit 709fb3
Packit 709fb3
LC_ALL=en_US.UTF-8 grep -P '^. euro$' in > out2 || fail=1
Packit 709fb3
compare in out2 || fail=1
Packit 709fb3
Packit 709fb3
LC_ALL=en_US.UTF-8 grep -oP '. euro' in > out3 || fail=1
Packit 709fb3
compare in out3 || fail=1
Packit 709fb3
Packit 709fb3
LC_ALL=en_US.UTF-8 grep -P '^\P{S}' in > out4
Packit 709fb3
compare /dev/null out4 || fail=1
Packit 709fb3
Packit 709fb3
Exit $fail