Blame test/rsstart1.awk

Packit 575503
# From arnold@f7.net  Wed Dec 15 11:32:46 2004
Packit 575503
# Date: Tue, 14 Dec 2004 14:48:58 +0100
Packit 575503
# From: Stepan Kasal <kasal@ucw.cz>
Packit 575503
# Subject: gawk bug with RS="^..."
Packit 575503
# To: bug-gawk@gnu.org
Packit 575503
# Message-id: <20041214134858.GA15490@matsrv.math.cas.cz>
Packit 575503
# 
Packit 575503
# Hello,
Packit 575503
#   I've noticed a problem with "^" in RS in gawk.  In most cases, it seems
Packit 575503
# to match only the beginning of the file.  But in fact it matches the
Packit 575503
# beginning of gawk's internal buffer.
Packit 575503
# 
Packit 575503
# Observe the following example:
Packit 575503
# 
Packit 575503
# $ gawk 'BEGIN{for(i=1;i<=100;i++) print "Axxxxxx"}' >file
Packit 575503
# $ gawk 'BEGIN{RS="^A"} END{print NR}' file
Packit 575503
# 2
Packit 575503
# $ gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' file
Packit 575503
# 100
Packit 575503
# $ head file | gawk 'BEGIN{RS="^Ax*\n"} END{print NR}'
Packit 575503
# 10
Packit 575503
# $
Packit 575503
# 
Packit 575503
# I think this calls for some clarification/fix.  But I don't have any
Packit 575503
# fixed opinion how the solution should look like.
Packit 575503
# 
Packit 575503
# Have a nice day,
Packit 575503
#         Stepan Kasal
Packit 575503
# 
Packit 575503
# PS: See also the discussion of the issue in the comp.lang.awk newsgroup.
Packit 575503
BEGIN { RS = "^A" }
Packit 575503
END { print NR }