Blame test/localenl.sh

Packit 575503
#! /bin/sh
Packit 575503
# From arnold@f7.net  Sun Apr 22 20:15:25 2007
Packit 575503
# Date: Thu, 19 Apr 2007 17:09:02 +0300
Packit 575503
# From: Pekka Pessi <Pekka.Pessi@nokia.com>
Packit 575503
# X-Face: #V(jdpv[lI!TNUU=2*oh:="#suS*ponXW"yr6G;~L}
Packit 575503
#  :9||1pew85O,WjiYA"6C7bW^zt^+.{b#B{lEE+4$9lrXL(55g}dU>uZ\JfD\"IG#G{j`hZI;=DmT\H
Packit 575503
#  pfDMyJ`i=:M;BM3R.`[>P^ER8+]i
Packit 575503
# Subject: UTF-8 locale and \n in regexps
Packit 575503
# To: bug-gawk@gnu.org
Packit 575503
# Cc: Pekka.Pessi@nokia.com
Packit 575503
# Message-id: <pvlkgoh2wx.fsf@nokia.com>
Packit 575503
# MIME-version: 1.0
Packit 575503
# Content-type: multipart/mixed; boundary="=-=-="
Packit 575503
# 
Packit 575503
# --=-=-=
Packit 575503
# 
Packit 575503
# Hello,
Packit 575503
# 
Packit 575503
# It looks like regexp with \n in [^] behaves badly if locale has
Packit 575503
# an UTF-8 ctype.
Packit 575503
# 
Packit 575503
# It looks like if there is \n and an range without \n, like /\n[^x\n]foo/,
Packit 575503
# and first \n ends an even-numbered line within the string, regexp
Packit 575503
# does not match.
Packit 575503
# 
Packit 575503
# Please see the attached script for an demonstration.
Packit 575503
# 
Packit 575503
# --Pekka Pessi
Packit 575503
# 
Packit 575503
# 
Packit 575503
# --=-=-=
Packit 575503
# Content-Disposition: inline; filename=gawk-test
Packit 575503
# 
Packit 575503
#! /bin/sh
Packit 575503
Packit 575503
AWK=${AWK:-../gawk}
Packit 575503
Packit 575503
# April 2010: Remove UNKNOWN, causes spurious failures on some systems
Packit 575503
for LC_ALL in C POSIX en_US.ISO-8859-1 en_US.UTF-8 #UNKNOWN 
Packit 575503
do
Packit 575503
export LC_ALL
Packit 575503
cat <
Packit 575503
line1
Packit 575503
line2
Packit 575503
line3
Packit 575503
line4 
Packit 575503
line5
Packit 575503
line6
Packit 575503
line7
Packit 575503
line8
Packit 575503
line9
Packit 575503
EOF
Packit 575503
$AWK --posix '
Packit 575503
BEGIN { RS="\0"; }
Packit 575503
{ 
Packit 575503
  if (match($0, /\n[^2\n]*2/)) { got2=1; } else { print "no match 2"; }
Packit 575503
  if (match($0, /\n[^3\n]*3/)) { got3=1; } else { print "no match 3"; }
Packit 575503
  if (match($0, /\n[^4\n]*4/)) { got4=1; } else { print "no match 4"; }
Packit 575503
  if (match($0, /\n[^5\t]*5/)) { got5=1; } else { print "no match 5"; }
Packit 575503
  if (match($0, /\n[^6\n]*6/)) { got6=1; } else { print "no match 6"; }
Packit 575503
  if (match($0, /\n[a-z]*7\n/)){ got7=1; } else { print "no match 7"; }
Packit 575503
  if (match($0, /\n[^8\n]*8/)) { got8=1; } else { print "no match 8"; }
Packit 575503
  if (match($0, /8.[^9\n]+9/)) { got9=1; } else { print "no match 9"; }
Packit 575503
}
Packit 575503
Packit 575503
END { exit(!(got2 && got3 && got4 && got5 && got6 && got7 && got8 && got9)); }
Packit 575503
' || { 
Packit 575503
  echo LC_ALL=$LC_ALL FAILED
Packit 575503
  exit 1
Packit 575503
}
Packit 575503
echo LC_ALL=$LC_ALL passed
Packit 575503
done
Packit 575503
# 
Packit 575503
# --=-=-=--
Packit 575503
#