[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug with gawk regex interval processing
From: |
Mike Kistler |
Subject: |
Bug with gawk regex interval processing |
Date: |
Mon, 21 Apr 2003 10:26:07 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202 |
Hello,
I think I have uncovered a bug in gawk regular expression interval
processing. Below is a script to reproduce the problem.
#!/bin/bash
# This script reproduces an apparent bug in regex processing in awk.
# The problem is that interval expressions are not handled properly.
# This problem occurs on RedHat 8.0. awk is packages in gawk-3.1.1-4
# The purpose of the awk script is to eliminate the first three space-delimited
fields from each
# input record and print the remaining contents.
cat > /tmp/awkbug.dat <<EOF
token1 token2 token3 token4
token1 token2 token3 token4 token5
token1 token2 token3 token4 token5 token6
token token token token4
token token token token4 token5 token6
EOF
# This awk script fails ... apparently because of the interval.
awk --posix '{sub(/^[ ]*([^ ]+[ ]+){3}/, "", $0); print $0}' /tmp/awkbug.dat
# This awk script succeeds, but is equivalent to the one that fails.
awk --posix '{sub(/^[ ]*([^ ]+[ ]+)([^ ]+[ ]+)([^ ]+[ ]+)/, "", $0); print $0}'
/tmp/awkbug.dat
Mike Kistler
- Bug with gawk regex interval processing,
Mike Kistler <=