Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bug in gawk 3.1.1?

3 views
Skip to first unread message

LorenzAtWork

unread,
Aug 28, 2002, 4:34:50 AM8/28/02
to
hello all,

I'm using the following script

BEGIN {RS="ti1\n(dwv,)?"; s=0; i=0}
{if ($1 != "") s = $1; print ++i, s}

to extract values from a file of the form

ti1
dwv,98.22
ti1
dwv,103.08
ti1
ti1
dwv,196.25
ti1
dwv,210.62
ti1
dwv,223.53

The desired result for this example looks like

1 0
2 98.22
3 103.08
4 103.08
5 196.25
6 210.62
7 223.53

The script work fine the most time, but when run on the attached file
(sorry for the size, but the error would not appear with less data) I
get some (three with the attached file) lines that look like

1262 dwv,212.97
1277 dwv,174.33
1279 dwv,151.79

I can't think of a other reason for this than a bug in gawk!

I'm running gawk 3.1.1 on winnt 4.0

best regards
Lorenz

LorenzAtWork

unread,
Aug 28, 2002, 4:54:30 AM8/28/02
to
ups, forgot the file 8-)

<<<<< begin input file >>>>>
ti1
dwv,214.59
ti1
dwv,230.31
ti1
dwv,242.64
ti1
dwv,253.94
ti1
dwv,264.33
ti1
dwv,270.94
ti1
dwv,273.52
ti1
dwv,270.08
ti1
dwv,263.19
ti1
dwv,254.45
ti1
dwv,244.91
ti1
dwv,234.55
ti1
dwv,222.49
ti1
dwv,209.94
ti1
dwv,197.17
ti1
dwv,182.89
ti1
dwv,169.76
ti1
dwv,158.59
ti1
dwv,145.37
ti1
dwv,135.46
ti1
dwv,124.77
ti1
dwv,115.98
ti1
dwv,108.77
ti1
dwv,101.12
ti1
dwv,94.45
ti1
dwv,89.08
ti1
dwv,84.63
ti1
dwv,81.05
ti1
dwv,78.93
ti1
dwv,76.65
ti1
dwv,75.59
ti1
ti1
ti1
dwv,77.47
ti1
dwv,80.17
ti1
dwv,83.90
ti1
dwv,88.56
ti1
dwv,95.69
ti1
dwv,97.48
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,203.08
ti1
dwv,218.22
ti1
dwv,229.37
ti1
dwv,238.49
ti1
dwv,247.43
ti1
dwv,255.22
ti1
dwv,261.31
ti1
dwv,262.36
ti1
dwv,260.66
ti1
dwv,256.33
ti1
dwv,249.34
ti1
dwv,240.03
ti1
dwv,228.55
ti1
dwv,215.42
ti1
dwv,203.37
ti1
dwv,190.01
ti1
dwv,177.81
ti1
dwv,165.44
ti1
dwv,152.92
ti1
dwv,142.03
ti1
dwv,132.91
ti1
dwv,124.48
ti1
dwv,116.45
ti1
dwv,109.06
ti1
dwv,103.27
ti1
dwv,98.87
ti1
dwv,94.95
ti1
dwv,92.56
ti1
dwv,90.47
ti1
dwv,89.48
ti1
ti1
dwv,90.53
ti1
dwv,93.07
ti1
dwv,97.12
ti1
dwv,101.82
ti1
dwv,108.18
ti1
dwv,109.73
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,202.97
ti1
dwv,217.38
ti1
dwv,231.73
ti1
dwv,243.11
ti1
dwv,255.37
ti1
dwv,264.12
ti1
dwv,269.64
ti1
dwv,270.98
ti1
dwv,269.65
ti1
dwv,264.55
ti1
dwv,257.16
ti1
dwv,246.01
ti1
dwv,232.88
ti1
dwv,219.85
ti1
dwv,208.79
ti1
dwv,197.00
ti1
dwv,183.93
ti1
dwv,172.00
ti1
dwv,160.55
ti1
dwv,150.59
ti1
dwv,141.47
ti1
dwv,133.02
ti1
dwv,126.21
ti1
dwv,120.64
ti1
dwv,115.79
ti1
dwv,111.62
ti1
dwv,108.41
ti1
dwv,106.41
ti1
ti1
ti1
dwv,109.08
ti1
dwv,113.23
ti1
dwv,118.57
ti1
dwv,122.57
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,208.07
ti1
dwv,224.14
ti1
dwv,236.28
ti1
dwv,248.12
ti1
dwv,258.97
ti1
dwv,267.74
ti1
dwv,272.47
ti1
dwv,271.52
ti1
dwv,266.80
ti1
dwv,258.61
ti1
dwv,249.30
ti1
dwv,239.19
ti1
dwv,228.28
ti1
dwv,215.79
ti1
dwv,203.86
ti1
dwv,190.08
ti1
dwv,177.40
ti1
dwv,163.81
ti1
dwv,152.60
ti1
dwv,141.33
ti1
dwv,130.98
ti1
dwv,121.98
ti1
dwv,114.08
ti1
dwv,106.61
ti1
dwv,99.75
ti1
dwv,93.10
ti1
dwv,86.57
ti1
dwv,80.62
ti1
dwv,76.05
ti1
dwv,71.52
ti1
dwv,68.85
ti1
dwv,67.46
ti1
dwv,66.86
ti1
dwv,67.51
ti1
dwv,69.75
ti1
dwv,72.85
ti1
dwv,76.23
ti1
dwv,82.85
ti1
dwv,89.33
ti1
dwv,93.39
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,188.37
ti1
dwv,204.42
ti1
dwv,217.16
ti1
dwv,228.89
ti1
dwv,238.83
ti1
dwv,247.70
ti1
dwv,253.59
ti1
dwv,257.17
ti1
ti1
dwv,254.00
ti1
dwv,248.24
ti1
dwv,240.14
ti1
dwv,229.42
ti1
dwv,218.97
ti1
dwv,205.09
ti1
dwv,192.61
ti1
dwv,179.74
ti1
dwv,166.76
ti1
dwv,155.36
ti1
dwv,143.58
ti1
dwv,131.40
ti1
dwv,121.84
ti1
dwv,112.46
ti1
dwv,105.41
ti1
dwv,97.15
ti1
dwv,90.09
ti1
dwv,84.79
ti1
dwv,80.52
ti1
dwv,75.58
ti1
dwv,72.59
ti1
dwv,69.39
ti1
dwv,67.51
ti1
dwv,66.42
ti1
ti1
ti1
dwv,67.82
ti1
dwv,69.76
ti1
dwv,73.19
ti1
dwv,77.35
ti1
dwv,82.36
ti1
dwv,87.82
ti1
dwv,93.30
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,190.58
ti1
dwv,203.43
ti1
dwv,216.48
ti1
dwv,228.89
ti1
dwv,241.91
ti1
dwv,251.60
ti1
dwv,257.78
ti1
dwv,262.18
ti1
dwv,263.13
ti1
dwv,260.91
ti1
dwv,255.34
ti1
dwv,247.17
ti1
dwv,236.85
ti1
dwv,225.24
ti1
dwv,213.39
ti1
dwv,201.46
ti1
dwv,187.77
ti1
dwv,175.31
ti1
dwv,162.95
ti1
dwv,152.55
ti1
dwv,142.56
ti1
dwv,132.94
ti1
dwv,125.00
ti1
dwv,117.69
ti1
dwv,110.96
ti1
dwv,105.02
ti1
dwv,101.78
ti1
dwv,98.48
ti1
dwv,97.06
ti1
dwv,96.50
ti1
ti1
dwv,98.48
ti1
dwv,101.18
ti1
dwv,104.56
ti1
dwv,109.67
ti1
dwv,115.86
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,200.02
ti1
dwv,217.51
ti1
dwv,233.21
ti1
dwv,245.72
ti1
dwv,258.21
ti1
dwv,267.24
ti1
dwv,273.79
ti1
dwv,273.20
ti1
dwv,270.38
ti1
dwv,260.76
ti1
dwv,250.05
ti1
dwv,241.32
ti1
dwv,231.14
ti1
dwv,219.83
ti1
dwv,206.13
ti1
dwv,193.24
ti1
dwv,180.73
ti1
dwv,167.82
ti1
dwv,156.94
ti1
dwv,144.13
ti1
dwv,134.40
ti1
dwv,125.23
ti1
dwv,116.13
ti1
dwv,107.34
ti1
dwv,99.71
ti1
dwv,94.11
ti1
dwv,88.91
ti1
dwv,84.51
ti1
dwv,81.50
ti1
dwv,78.66
ti1
dwv,76.57
ti1
dwv,75.82
ti1
ti1
dwv,76.88
ti1
dwv,79.03
ti1
dwv,82.12
ti1
dwv,85.73
ti1
dwv,91.05
ti1
dwv,96.31
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,184.18
ti1
dwv,201.10
ti1
dwv,214.21
ti1
dwv,226.18
ti1
dwv,237.72
ti1
dwv,247.57
ti1
dwv,254.36
ti1
dwv,258.34
ti1
dwv,259.80
ti1
dwv,257.76
ti1
dwv,253.17
ti1
dwv,246.51
ti1
dwv,237.92
ti1
dwv,227.09
ti1
dwv,214.13
ti1
dwv,202.20
ti1
dwv,189.21
ti1
dwv,177.65
ti1
dwv,166.18
ti1
dwv,154.03
ti1
dwv,142.21
ti1
dwv,131.51
ti1
dwv,121.28
ti1
dwv,111.80
ti1
dwv,104.47
ti1
dwv,98.80
ti1
dwv,94.76
ti1
dwv,91.81
ti1
dwv,89.17
ti1
dwv,88.00
ti1
ti1
ti1
dwv,89.20
ti1
dwv,91.17
ti1
dwv,94.35
ti1
dwv,99.00
ti1
dwv,105.43
ti1
dwv,109.34
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,194.84
ti1
dwv,212.05
ti1
dwv,226.30
ti1
dwv,239.03
ti1
dwv,250.94
ti1
dwv,259.73
ti1
dwv,266.64
ti1
dwv,269.67
ti1
dwv,269.03
ti1
dwv,265.03
ti1
dwv,258.23
ti1
dwv,249.32
ti1
dwv,238.03
ti1
dwv,226.20
ti1
dwv,213.46
ti1
dwv,200.53
ti1
dwv,187.65
ti1
dwv,174.89
ti1
dwv,163.22
ti1
dwv,152.47
ti1
dwv,142.65
ti1
dwv,133.97
ti1
dwv,126.59
ti1
dwv,120.52
ti1
dwv,115.57
ti1
dwv,111.49
ti1
dwv,108.03
ti1
dwv,106.01
ti1
dwv,105.28
ti1
ti1
dwv,106.91
ti1
dwv,109.73
ti1
dwv,114.91
ti1
dwv,120.66
ti1
dwv,123.74
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,211.57
ti1
dwv,227.06
ti1
dwv,240.57
ti1
dwv,252.26
ti1
dwv,262.67
ti1
dwv,270.66
ti1
dwv,273.40
ti1
dwv,270.25
ti1
dwv,263.76
ti1
dwv,256.03
ti1
dwv,246.87
ti1
dwv,237.10
ti1
dwv,225.11
ti1
dwv,211.53
ti1
dwv,197.77
ti1
dwv,185.75
ti1
dwv,173.00
ti1
dwv,159.31
ti1
dwv,147.18
ti1
dwv,134.84
ti1
dwv,125.07
ti1
dwv,115.82
ti1
dwv,107.33
ti1
dwv,100.07
ti1
dwv,93.55
ti1
dwv,87.60
ti1
dwv,81.75
ti1
dwv,77.03
ti1
dwv,73.39
ti1
dwv,70.97
ti1
dwv,67.94
ti1
dwv,66.64
ti1
dwv,65.80
ti1
ti1
dwv,66.85
ti1
dwv,68.78
ti1
dwv,71.47
ti1
dwv,74.20
ti1
dwv,78.68
ti1
dwv,85.08
ti1
dwv,87.47
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,185.81
ti1
dwv,201.66
ti1
dwv,215.07
ti1
dwv,227.26
ti1
dwv,238.00
ti1
dwv,247.64
ti1
dwv,255.03
ti1
dwv,257.12
ti1
dwv,256.17
ti1
dwv,253.47
ti1
dwv,248.93
ti1
dwv,241.39
ti1
dwv,231.45
ti1
dwv,220.49
ti1
dwv,208.48
ti1
dwv,196.04
ti1
dwv,182.73
ti1
dwv,169.40
ti1
dwv,157.24
ti1
dwv,145.56
ti1
dwv,133.54
ti1
dwv,124.01
ti1
dwv,114.55
ti1
dwv,105.75
ti1
dwv,98.32
ti1
dwv,91.91
ti1
dwv,86.08
ti1
dwv,81.35
ti1
dwv,77.78
ti1
dwv,73.85
ti1
dwv,71.12
ti1
dwv,68.53
ti1
dwv,67.09
ti1
dwv,66.34
ti1
ti1
ti1
dwv,67.92
ti1
dwv,70.08
ti1
dwv,73.78
ti1
dwv,78.68
ti1
dwv,84.33
ti1
dwv,90.25
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,183.19
ti1
dwv,198.96
ti1
dwv,213.55
ti1
dwv,225.91
ti1
dwv,237.33
ti1
dwv,246.66
ti1
dwv,254.98
ti1
dwv,259.46
ti1
dwv,261.02
ti1
dwv,260.02
ti1
dwv,255.96
ti1
dwv,249.08
ti1
dwv,240.15
ti1
dwv,229.51
ti1
dwv,217.21
ti1
dwv,205.06
ti1
dwv,192.62
ti1
dwv,177.43
ti1
dwv,165.06
ti1
dwv,152.36
ti1
dwv,142.35
ti1
dwv,134.58
ti1
dwv,126.20
ti1
dwv,119.86
ti1
dwv,113.67
ti1
dwv,108.20
ti1
dwv,104.71
ti1
dwv,100.83
ti1
dwv,98.96
ti1
dwv,98.38
ti1
ti1
dwv,100.29
ti1
dwv,103.47
ti1
dwv,107.73
ti1
dwv,113.04
ti1
dwv,118.90
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,200.70
ti1
dwv,217.77
ti1
dwv,232.45
ti1
dwv,244.28
ti1
dwv,256.61
ti1
dwv,265.93
ti1
dwv,272.01
ti1
ti1
dwv,268.67
ti1
dwv,260.53
ti1
dwv,252.09
ti1
dwv,243.72
ti1
dwv,232.68
ti1
dwv,220.49
ti1
dwv,206.88
ti1
dwv,193.98
ti1
dwv,181.33
ti1
dwv,168.61
ti1
dwv,156.50
ti1
dwv,145.54
ti1
dwv,136.43
ti1
dwv,125.95
ti1
dwv,117.26
ti1
dwv,109.81
ti1
dwv,103.36
ti1
dwv,97.15
ti1
dwv,92.86
ti1
dwv,89.02
ti1
dwv,86.39
ti1
dwv,84.44
ti1
dwv,83.72
ti1
ti1
dwv,85.89
ti1
dwv,88.39
ti1
dwv,92.31
ti1
dwv,96.00
ti1
dwv,100.24
ti1
dwv,102.55
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,197.15
ti1
dwv,212.33
ti1
dwv,225.48
ti1
dwv,236.75
ti1
dwv,247.52
ti1
dwv,255.21
ti1
dwv,260.74
ti1
dwv,262.81
ti1
dwv,262.09
ti1
dwv,258.08
ti1
dwv,250.83
ti1
dwv,242.39
ti1
dwv,230.86
ti1
dwv,219.62
ti1
dwv,206.80
ti1
dwv,193.41
ti1
dwv,180.60
ti1
dwv,168.20
ti1
dwv,157.77
ti1
dwv,145.25
ti1
dwv,136.23
ti1
dwv,126.28
ti1
dwv,118.10
ti1
dwv,110.74
ti1
dwv,105.29
ti1
dwv,99.75
ti1
dwv,95.61
ti1
dwv,92.16
ti1
dwv,89.93
ti1
dwv,88.45
ti1
ti1
dwv,89.11
ti1
dwv,90.87
ti1
dwv,94.21
ti1
dwv,98.16
ti1
dwv,104.24
ti1
dwv,108.98
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,195.81
ti1
dwv,211.95
ti1
dwv,226.36
ti1
dwv,240.61
ti1
dwv,251.93
ti1
dwv,259.13
ti1
dwv,265.36
ti1
dwv,269.71
ti1
dwv,270.27
ti1
dwv,266.44
ti1
dwv,260.44
ti1
dwv,251.94
ti1
dwv,240.79
ti1
dwv,228.95
ti1
dwv,215.90
ti1
dwv,203.25
ti1
dwv,190.01
ti1
dwv,177.92
ti1
dwv,165.60
ti1
dwv,155.49
ti1
dwv,144.32
ti1
dwv,136.07
ti1
dwv,127.64
ti1
dwv,120.28
ti1
dwv,114.57
ti1
dwv,109.99
ti1
dwv,106.36
ti1
dwv,104.49
ti1
dwv,103.84
ti1
ti1
dwv,105.77
ti1
dwv,107.83
ti1
dwv,112.41
ti1
dwv,117.71
ti1
dwv,120.66
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,210.13
ti1
dwv,225.03
ti1
dwv,238.76
ti1
dwv,250.50
ti1
dwv,261.18
ti1
dwv,269.22
ti1
dwv,274.18
ti1
dwv,272.28
ti1
dwv,266.66
ti1
dwv,258.68
ti1
dwv,249.88
ti1
dwv,239.94
ti1
dwv,227.14
ti1
dwv,213.22
ti1
dwv,197.58
ti1
dwv,184.86
ti1
dwv,172.52
ti1
dwv,160.19
ti1
dwv,149.20
ti1
dwv,137.49
ti1
dwv,127.86
ti1
dwv,118.91
ti1
dwv,110.49
ti1
dwv,102.73
ti1
dwv,96.33
ti1
dwv,90.95
ti1
dwv,86.38
ti1
dwv,82.72
ti1
dwv,79.65
ti1
dwv,77.61
ti1
dwv,75.70
ti1
dwv,74.49
ti1
ti1
ti1
dwv,76.48
ti1
dwv,79.14
ti1
dwv,82.84
ti1
dwv,87.86
ti1
dwv,92.69
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,181.33
ti1
dwv,196.86
ti1
dwv,210.98
ti1
dwv,223.13
ti1
dwv,233.90
ti1
dwv,243.19
ti1
dwv,250.57
ti1
dwv,255.00
ti1
dwv,256.36
ti1
dwv,255.16
ti1
dwv,250.15
ti1
dwv,242.80
ti1
dwv,233.82
ti1
dwv,223.41
ti1
dwv,210.81
ti1
dwv,199.04
ti1
dwv,187.39
ti1
dwv,174.14
ti1
dwv,162.62
ti1
dwv,151.39
ti1
dwv,139.59
ti1
dwv,128.71
ti1
dwv,119.17
ti1
dwv,111.02
ti1
dwv,103.91
ti1
dwv,96.78
ti1
dwv,91.56
ti1
dwv,87.13
ti1
dwv,83.22
ti1
dwv,80.50
ti1
dwv,76.83
ti1
dwv,74.24
ti1
dwv,70.80
ti1
dwv,69.04
ti1
dwv,67.12
ti1
dwv,66.51
ti1
ti1
dwv,68.77
ti1
dwv,72.19
ti1
dwv,77.34
ti1
dwv,84.04
ti1
dwv,88.55
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,190.51
ti1
dwv,207.14
ti1
dwv,220.57
ti1
dwv,232.51
ti1
dwv,243.35
ti1
dwv,252.41
ti1
dwv,258.62
ti1
dwv,262.18
ti1
ti1
dwv,259.10
ti1
dwv,253.54
ti1
dwv,245.44
ti1
dwv,235.55
ti1
dwv,223.43
ti1
dwv,209.91
ti1
dwv,197.52
ti1
dwv,185.90
ti1
dwv,172.13
ti1
dwv,161.09
ti1
dwv,150.58
ti1
dwv,140.37
ti1
dwv,130.27
ti1
dwv,122.13
ti1
dwv,114.99
ti1
dwv,108.76
ti1
dwv,104.67
ti1
dwv,100.36
ti1
dwv,97.61
ti1
dwv,95.48
ti1
dwv,94.83
ti1
dwv,95.45
ti1
dwv,97.15
ti1
dwv,100.73
ti1
dwv,105.10
ti1
dwv,111.46
ti1
dwv,118.27
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,202.92
ti1
dwv,220.25
ti1
dwv,233.35
ti1
dwv,243.48
ti1
dwv,254.85
ti1
dwv,265.75
ti1
dwv,272.62
ti1
ti1
dwv,269.36
ti1
dwv,261.82
ti1
dwv,252.85
ti1
dwv,244.08
ti1
dwv,232.96
ti1
dwv,219.59
ti1
dwv,207.32
ti1
dwv,193.87
ti1
dwv,181.77
ti1
dwv,168.60
ti1
dwv,155.76
ti1
dwv,144.03
ti1
dwv,134.07
ti1
dwv,123.46
ti1
dwv,114.47
ti1
dwv,107.64
ti1
dwv,100.46
ti1
dwv,94.53
ti1
dwv,89.28
ti1
dwv,84.59
ti1
dwv,80.96
ti1
dwv,78.54
ti1
dwv,76.28
ti1
dwv,75.51
ti1
ti1
dwv,76.55
ti1
dwv,78.55
ti1
dwv,81.57
ti1
dwv,85.18
ti1
dwv,90.61
ti1
dwv,96.01
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,184.51
ti1
dwv,201.57
ti1
dwv,216.33
ti1
dwv,228.69
ti1
dwv,239.90
ti1
dwv,250.41
ti1
dwv,257.91
ti1
dwv,262.29
ti1
dwv,263.41
ti1
dwv,261.70
ti1
dwv,256.75
ti1
dwv,246.82
ti1
dwv,236.35
ti1
dwv,225.17
ti1
dwv,212.90
ti1
dwv,201.61
ti1
dwv,188.42
ti1
dwv,175.92
ti1
dwv,163.70
ti1
dwv,153.18
ti1
dwv,142.89
ti1
dwv,132.95
ti1
dwv,125.18
ti1
dwv,117.61
ti1
dwv,110.36
ti1
dwv,104.56
ti1
dwv,100.13
ti1
dwv,96.64
ti1
dwv,93.52
ti1
dwv,91.91
ti1
ti1
ti1
dwv,93.84
ti1
dwv,97.13
ti1
dwv,101.08
ti1
dwv,107.19
ti1
dwv,111.89
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,195.89
ti1
dwv,212.65
ti1
dwv,226.60
ti1
dwv,239.28
ti1
dwv,251.28
ti1
dwv,259.92
ti1
dwv,266.03
ti1
dwv,269.76
ti1
ti1
dwv,265.55
ti1
dwv,258.92
ti1
dwv,250.42
ti1
dwv,240.04
ti1
dwv,229.03
ti1
dwv,216.69
ti1
dwv,204.21
ti1
dwv,191.25
ti1
dwv,178.40
ti1
dwv,168.31
ti1
dwv,157.47
ti1
dwv,148.62
ti1
dwv,139.12
ti1
dwv,129.54
ti1
dwv,121.65
ti1
dwv,114.59
ti1
dwv,109.30
ti1
dwv,106.39
ti1
dwv,104.71
ti1
ti1
dwv,106.41
ti1
dwv,109.22
ti1
dwv,113.62
ti1
dwv,118.31
ti1
dwv,124.34
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,205.67
ti1
dwv,221.25
ti1
dwv,235.02
ti1
dwv,247.47
ti1
dwv,258.37
ti1
dwv,267.42
ti1
dwv,272.60
ti1
dwv,272.00
ti1
dwv,267.91
ti1
dwv,260.38
ti1
dwv,251.10
ti1
dwv,241.32
ti1
dwv,230.96
ti1
dwv,217.34
ti1
dwv,204.99
ti1
dwv,191.24
ti1
dwv,178.58
ti1
dwv,164.79
ti1
dwv,153.07
ti1
dwv,141.06
ti1
dwv,129.86
ti1
dwv,119.79
ti1
dwv,111.13
ti1
dwv,103.53
ti1
dwv,96.95
ti1
dwv,89.42
ti1
dwv,85.22
ti1
dwv,80.54
ti1
dwv,76.85
ti1
dwv,74.41
ti1
dwv,72.12
ti1
dwv,71.21
ti1
ti1
ti1
dwv,72.13
ti1
dwv,74.22
ti1
dwv,76.95
ti1
dwv,80.65
ti1
dwv,85.36
ti1
dwv,90.60
ti1
dwv,92.36
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,191.27
ti1
dwv,205.03
ti1
dwv,218.89
ti1
dwv,230.87
ti1
dwv,241.63
ti1
dwv,249.83
ti1
dwv,255.42
ti1
dwv,257.98
ti1
dwv,257.33
ti1
dwv,252.87
ti1
dwv,245.90
ti1
dwv,237.78
ti1
dwv,227.14
ti1
dwv,214.67
ti1
dwv,202.31
ti1
dwv,188.68
ti1
dwv,175.96
ti1
dwv,163.25
ti1
dwv,151.43
ti1
dwv,139.79
ti1
dwv,130.40
ti1
dwv,118.92
ti1
dwv,110.88
ti1
dwv,101.92
ti1
dwv,94.45
ti1
dwv,88.13
ti1
dwv,83.19
ti1
dwv,79.11
ti1
dwv,74.60
ti1
dwv,71.86
ti1
dwv,68.77
ti1
dwv,66.57
ti1
dwv,65.24
ti1
dwv,64.41
ti1
ti1
dwv,64.92
ti1
dwv,66.62
ti1
dwv,68.93
ti1
dwv,72.77
ti1
dwv,77.76
ti1
dwv,83.41
ti1
dwv,89.19
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,182.68
ti1
dwv,199.88
ti1
dwv,214.62
ti1
dwv,227.29
ti1
dwv,238.62
ti1
dwv,249.01
ti1
dwv,256.68
ti1
dwv,262.71
ti1
dwv,263.44
ti1
dwv,259.87
ti1
dwv,254.66
ti1
dwv,248.11
ti1
dwv,240.01
ti1
dwv,229.30
ti1
dwv,216.52
ti1
dwv,205.15
ti1
dwv,192.49
ti1
dwv,179.70
ti1
dwv,167.51
ti1
dwv,156.31
ti1
dwv,145.97
ti1
dwv,135.93
ti1
dwv,128.06
ti1
dwv,119.45
ti1
dwv,113.01
ti1
dwv,108.31
ti1
dwv,103.79
ti1
dwv,100.92
ti1
dwv,98.90
ti1
dwv,98.28
ti1
ti1
dwv,100.12
ti1
dwv,102.38
ti1
dwv,106.07
ti1
dwv,111.06
ti1
dwv,117.00
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,202.42
ti1
dwv,217.46
ti1
dwv,232.83
ti1
dwv,245.05
ti1
dwv,256.39
ti1
dwv,265.28
ti1
dwv,271.80
ti1
ti1
dwv,268.63
ti1
dwv,261.21
ti1
dwv,253.57
ti1
dwv,244.41
ti1
dwv,233.79
ti1
dwv,220.80
ti1
dwv,209.24
ti1
dwv,196.54
ti1
dwv,183.38
ti1
dwv,170.14
ti1
dwv,157.79
ti1
dwv,144.31
ti1
dwv,131.53
ti1
dwv,122.20
ti1
dwv,113.46
ti1
dwv,106.57
ti1
dwv,100.93
ti1
dwv,96.80
ti1
dwv,92.10
ti1
dwv,88.77
ti1
dwv,86.07
ti1
dwv,83.75
ti1
dwv,82.40
ti1
ti1
ti1
ti1
ti1
dwv,84.82
ti1
dwv,88.34
ti1
dwv,92.06


ti1
dwv,98.22
ti1
dwv,103.08
ti1
ti1

ti1
ti1


ti1
ti1
dwv,196.25
ti1
dwv,210.62
ti1
dwv,223.53

ti1
dwv,235.01
ti1
dwv,245.30
ti1
dwv,253.56
ti1
dwv,259.86
ti1
dwv,261.87
ti1
ti1
dwv,257.71
ti1
dwv,251.10
ti1
dwv,242.25
ti1
dwv,232.00
ti1
dwv,219.62
ti1
dwv,207.54
ti1
dwv,194.54
ti1
dwv,182.85
ti1
dwv,170.49
ti1
dwv,158.24
ti1
dwv,147.54
ti1
dwv,137.40
ti1
dwv,129.81
ti1
dwv,121.07
ti1
dwv,114.39
ti1
dwv,109.32
ti1
dwv,103.67
ti1
dwv,99.51
ti1
dwv,96.53
ti1
dwv,94.67
ti1
dwv,93.79
ti1
ti1
dwv,95.31
ti1
dwv,98.43
ti1
dwv,102.95
ti1
dwv,109.01
ti1
dwv,115.86
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,209.63
ti1
dwv,224.03
ti1
dwv,236.93
ti1
dwv,249.17
ti1
dwv,259.34
ti1
dwv,267.41
ti1
dwv,271.07
ti1
dwv,270.51
ti1
dwv,263.93
ti1
dwv,255.80
ti1
dwv,246.03
ti1
dwv,235.96
ti1
dwv,223.79
ti1
dwv,209.68
ti1
dwv,196.98
ti1
dwv,184.70
ti1
dwv,171.16
ti1
dwv,157.06
ti1
dwv,145.05
ti1
dwv,133.80
ti1
dwv,123.45
ti1
dwv,114.06
ti1
dwv,106.78
ti1
dwv,98.12
ti1
dwv,91.19
ti1
dwv,84.78
ti1
dwv,80.10
ti1
dwv,74.95
ti1
dwv,71.88
ti1
dwv,68.51
ti1
dwv,66.13
ti1
dwv,64.64
ti1
dwv,63.65
ti1
dwv,63.06
ti1
ti1
dwv,64.29
ti1
dwv,66.41
ti1
dwv,68.95
ti1
dwv,73.12
ti1
dwv,78.00
ti1
dwv,83.67
ti1
dwv,85.55
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,187.86
ti1
dwv,202.65
ti1
dwv,216.23
ti1
dwv,228.24
ti1
dwv,239.81
ti1
dwv,248.77
ti1
dwv,252.97
ti1
dwv,254.72
ti1
ti1
dwv,253.22
ti1
dwv,247.80
ti1
dwv,239.99
ti1
dwv,229.87
ti1
dwv,218.26
ti1
dwv,205.99
ti1
dwv,193.09
ti1
dwv,180.59
ti1
dwv,167.42
ti1
dwv,154.33
ti1
dwv,142.32
ti1
dwv,131.88
ti1
dwv,122.32
ti1
dwv,112.84
ti1
dwv,104.07
ti1
dwv,96.62
ti1
dwv,90.02
ti1
dwv,84.43
ti1
dwv,79.90
ti1
dwv,74.59
ti1
dwv,71.27
ti1
dwv,67.37
ti1
dwv,64.97
ti1
dwv,62.82
ti1
dwv,61.60
ti1
ti1
ti1
dwv,62.99
ti1
dwv,64.80
ti1
dwv,68.51
ti1
dwv,72.70
ti1
dwv,77.97
ti1
dwv,84.10
ti1
dwv,88.07
ti1
ti1
ti1
ti1
ti1
ti1
ti1
ti1
dwv,184.25
ti1
dwv,199.56
ti1
dwv,212.97
ti1
dwv,226.37
ti1
dwv,237.23
ti1
dwv,247.66
ti1
dwv,254.97
ti1
dwv,259.77
ti1
dwv,261.89
ti1
dwv,260.39
ti1
dwv,255.67
ti1
dwv,248.49
ti1
dwv,238.75
ti1
dwv,228.34
ti1
dwv,215.95
ti1
dwv,201.71
ti1
dwv,187.12
ti1
dwv,174.33
ti1
dwv,162.05
ti1
dwv,151.79
ti1
dwv,142.67
ti1
dwv,134.03
ti1
dwv,126.03
ti1
dwv,118.64
ti1
dwv,112.00
ti1
dwv,107.16
ti1
dwv,103.71
ti1
dwv,100.06
ti1
dwv,98.59
ti1
dwv,97.68
ti1
ti1
<<<<< end input file >>>>>

<<<<< begin output file >>>>>
1 0
2 214.59
3 230.31
4 242.64
5 253.94
6 264.33
7 270.94
8 273.52
9 270.08
10 263.19
11 254.45
12 244.91
13 234.55
14 222.49
15 209.94
16 197.17
17 182.89
18 169.76
19 158.59
20 145.37
21 135.46
22 124.77
23 115.98
24 108.77
25 101.12
26 94.45
27 89.08
28 84.63
29 81.05
30 78.93
31 76.65
32 75.59
33 75.59
34 75.59
35 77.47
36 80.17
37 83.90
38 88.56
39 95.69
40 97.48
41 97.48
42 97.48
43 97.48
44 97.48
45 97.48
46 97.48
47 97.48
48 203.08
49 218.22
50 229.37
51 238.49
52 247.43
53 255.22
54 261.31
55 262.36
56 260.66
57 256.33
58 249.34
59 240.03
60 228.55
61 215.42
62 203.37
63 190.01
64 177.81
65 165.44
66 152.92
67 142.03
68 132.91
69 124.48
70 116.45
71 109.06
72 103.27
73 98.87
74 94.95
75 92.56
76 90.47
77 89.48
78 89.48
79 90.53
80 93.07
81 97.12
82 101.82
83 108.18
84 109.73
85 109.73
86 109.73
87 109.73
88 109.73
89 109.73
90 109.73
91 202.97
92 217.38
93 231.73
94 243.11
95 255.37
96 264.12
97 269.64
98 270.98
99 269.65
100 264.55
101 257.16
102 246.01
103 232.88
104 219.85
105 208.79
106 197.00
107 183.93
108 172.00
109 160.55
110 150.59
111 141.47
112 133.02
113 126.21
114 120.64
115 115.79
116 111.62
117 108.41
118 106.41
119 106.41
120 106.41
121 109.08
122 113.23
123 118.57
124 122.57
125 122.57
126 122.57
127 122.57
128 122.57
129 122.57
130 122.57
131 208.07
132 224.14
133 236.28
134 248.12
135 258.97
136 267.74
137 272.47
138 271.52
139 266.80
140 258.61
141 249.30
142 239.19
143 228.28
144 215.79
145 203.86
146 190.08
147 177.40
148 163.81
149 152.60
150 141.33
151 130.98
152 121.98
153 114.08
154 106.61
155 99.75
156 93.10
157 86.57
158 80.62
159 76.05
160 71.52
161 68.85
162 67.46
163 66.86
164 67.51
165 69.75
166 72.85
167 76.23
168 82.85
169 89.33
170 93.39
171 93.39
172 93.39
173 93.39
174 93.39
175 93.39
176 93.39
177 93.39
178 188.37
179 204.42
180 217.16
181 228.89
182 238.83
183 247.70
184 253.59
185 257.17
186 257.17
187 254.00
188 248.24
189 240.14
190 229.42
191 218.97
192 205.09
193 192.61
194 179.74
195 166.76
196 155.36
197 143.58
198 131.40
199 121.84
200 112.46
201 105.41
202 97.15
203 90.09
204 84.79
205 80.52
206 75.58
207 72.59
208 69.39
209 67.51
210 66.42
211 66.42
212 66.42
213 67.82
214 69.76
215 73.19
216 77.35
217 82.36
218 87.82
219 93.30
220 93.30
221 93.30
222 93.30
223 93.30
224 93.30
225 93.30
226 93.30
227 190.58
228 203.43
229 216.48
230 228.89
231 241.91
232 251.60
233 257.78
234 262.18
235 263.13
236 260.91
237 255.34
238 247.17
239 236.85
240 225.24
241 213.39
242 201.46
243 187.77
244 175.31
245 162.95
246 152.55
247 142.56
248 132.94
249 125.00
250 117.69
251 110.96
252 105.02
253 101.78
254 98.48
255 97.06
256 96.50
257 96.50
258 98.48
259 101.18
260 104.56
261 109.67
262 115.86
263 115.86
264 115.86
265 115.86
266 115.86
267 115.86
268 115.86
269 200.02
270 217.51
271 233.21
272 245.72
273 258.21
274 267.24
275 273.79
276 273.20
277 270.38
278 260.76
279 250.05
280 241.32
281 231.14
282 219.83
283 206.13
284 193.24
285 180.73
286 167.82
287 156.94
288 144.13
289 134.40
290 125.23
291 116.13
292 107.34
293 99.71
294 94.11
295 88.91
296 84.51
297 81.50
298 78.66
299 76.57
300 75.82
301 75.82
302 76.88
303 79.03
304 82.12
305 85.73
306 91.05
307 96.31
308 96.31
309 96.31
310 96.31
311 96.31
312 96.31
313 96.31
314 96.31
315 184.18
316 201.10
317 214.21
318 226.18
319 237.72
320 247.57
321 254.36
322 258.34
323 259.80
324 257.76
325 253.17
326 246.51
327 237.92
328 227.09
329 214.13
330 202.20
331 189.21
332 177.65
333 166.18
334 154.03
335 142.21
336 131.51
337 121.28
338 111.80
339 104.47
340 98.80
341 94.76
342 91.81
343 89.17
344 88.00
345 88.00
346 88.00
347 89.20
348 91.17
349 94.35
350 99.00
351 105.43
352 109.34
353 109.34
354 109.34
355 109.34
356 109.34
357 109.34
358 109.34
359 194.84
360 212.05
361 226.30
362 239.03
363 250.94
364 259.73
365 266.64
366 269.67
367 269.03
368 265.03
369 258.23
370 249.32
371 238.03
372 226.20
373 213.46
374 200.53
375 187.65
376 174.89
377 163.22
378 152.47
379 142.65
380 133.97
381 126.59
382 120.52
383 115.57
384 111.49
385 108.03
386 106.01
387 105.28
388 105.28
389 106.91
390 109.73
391 114.91
392 120.66
393 123.74
394 123.74
395 123.74
396 123.74
397 123.74
398 123.74
399 123.74
400 211.57
401 227.06
402 240.57
403 252.26
404 262.67
405 270.66
406 273.40
407 270.25
408 263.76
409 256.03
410 246.87
411 237.10
412 225.11
413 211.53
414 197.77
415 185.75
416 173.00
417 159.31
418 147.18
419 134.84
420 125.07
421 115.82
422 107.33
423 100.07
424 93.55
425 87.60
426 81.75
427 77.03
428 73.39
429 70.97
430 67.94
431 66.64
432 65.80
433 65.80
434 66.85
435 68.78
436 71.47
437 74.20
438 78.68
439 85.08
440 87.47
441 87.47
442 87.47
443 87.47
444 87.47
445 87.47
446 87.47
447 87.47
448 185.81
449 201.66
450 215.07
451 227.26
452 238.00
453 247.64
454 255.03
455 257.12
456 256.17
457 253.47
458 248.93
459 241.39
460 231.45
461 220.49
462 208.48
463 196.04
464 182.73
465 169.40
466 157.24
467 145.56
468 133.54
469 124.01
470 114.55
471 105.75
472 98.32
473 91.91
474 86.08
475 81.35
476 77.78
477 73.85
478 71.12
479 68.53
480 67.09
481 66.34
482 66.34
483 66.34
484 67.92
485 70.08
486 73.78
487 78.68
488 84.33
489 90.25
490 90.25
491 90.25
492 90.25
493 90.25
494 90.25
495 90.25
496 90.25
497 183.19
498 198.96
499 213.55
500 225.91
501 237.33
502 246.66
503 254.98
504 259.46
505 261.02
506 260.02
507 255.96
508 249.08
509 240.15
510 229.51
511 217.21
512 205.06
513 192.62
514 177.43
515 165.06
516 152.36
517 142.35
518 134.58
519 126.20
520 119.86
521 113.67
522 108.20
523 104.71
524 100.83
525 98.96
526 98.38
527 98.38
528 100.29
529 103.47
530 107.73
531 113.04
532 118.90
533 118.90
534 118.90
535 118.90
536 118.90
537 118.90
538 118.90
539 200.70
540 217.77
541 232.45
542 244.28
543 256.61
544 265.93
545 272.01
546 272.01
547 268.67
548 260.53
549 252.09
550 243.72
551 232.68
552 220.49
553 206.88
554 193.98
555 181.33
556 168.61
557 156.50
558 145.54
559 136.43
560 125.95
561 117.26
562 109.81
563 103.36
564 97.15
565 92.86
566 89.02
567 86.39
568 84.44
569 83.72
570 83.72
571 85.89
572 88.39
573 92.31
574 96.00
575 100.24
576 102.55
577 102.55
578 102.55
579 102.55
580 102.55
581 102.55
582 102.55
583 102.55
584 197.15
585 212.33
586 225.48
587 236.75
588 247.52
589 255.21
590 260.74
591 262.81
592 262.09
593 258.08
594 250.83
595 242.39
596 230.86
597 219.62
598 206.80
599 193.41
600 180.60
601 168.20
602 157.77
603 145.25
604 136.23
605 126.28
606 118.10
607 110.74
608 105.29
609 99.75
610 95.61
611 92.16
612 89.93
613 88.45
614 88.45
615 89.11
616 90.87
617 94.21
618 98.16
619 104.24
620 108.98
621 108.98
622 108.98
623 108.98
624 108.98
625 108.98
626 108.98
627 195.81
628 211.95
629 226.36
630 240.61
631 251.93
632 259.13
633 265.36
634 269.71
635 270.27
636 266.44
637 260.44
638 251.94
639 240.79
640 228.95
641 215.90
642 203.25
643 190.01
644 177.92
645 165.60
646 155.49
647 144.32
648 136.07
649 127.64
650 120.28
651 114.57
652 109.99
653 106.36
654 104.49
655 103.84
656 103.84
657 105.77
658 107.83
659 112.41
660 117.71
661 120.66
662 120.66
663 120.66
664 120.66
665 120.66
666 120.66
667 120.66
668 210.13
669 225.03
670 238.76
671 250.50
672 261.18
673 269.22
674 274.18
675 272.28
676 266.66
677 258.68
678 249.88
679 239.94
680 227.14
681 213.22
682 197.58
683 184.86
684 172.52
685 160.19
686 149.20
687 137.49
688 127.86
689 118.91
690 110.49
691 102.73
692 96.33
693 90.95
694 86.38
695 82.72
696 79.65
697 77.61
698 75.70
699 74.49
700 74.49
701 74.49
702 76.48
703 79.14
704 82.84
705 87.86
706 92.69
707 92.69
708 92.69
709 92.69
710 92.69
711 92.69
712 92.69
713 92.69
714 181.33
715 196.86
716 210.98
717 223.13
718 233.90
719 243.19
720 250.57
721 255.00
722 256.36
723 255.16
724 250.15
725 242.80
726 233.82
727 223.41
728 210.81
729 199.04
730 187.39
731 174.14
732 162.62
733 151.39
734 139.59
735 128.71
736 119.17
737 111.02
738 103.91
739 96.78
740 91.56
741 87.13
742 83.22
743 80.50
744 76.83
745 74.24
746 70.80
747 69.04
748 67.12
749 66.51
750 66.51
751 68.77
752 72.19
753 77.34
754 84.04
755 88.55
756 88.55
757 88.55
758 88.55
759 88.55
760 88.55
761 88.55
762 88.55
763 190.51
764 207.14
765 220.57
766 232.51
767 243.35
768 252.41
769 258.62
770 262.18
771 262.18
772 259.10
773 253.54
774 245.44
775 235.55
776 223.43
777 209.91
778 197.52
779 185.90
780 172.13
781 161.09
782 150.58
783 140.37
784 130.27
785 122.13
786 114.99
787 108.76
788 104.67
789 100.36
790 97.61
791 95.48
792 94.83
793 95.45
794 97.15
795 100.73
796 105.10
797 111.46
798 118.27
799 118.27
800 118.27
801 118.27
802 118.27
803 118.27
804 118.27
805 202.92
806 220.25
807 233.35
808 243.48
809 254.85
810 265.75
811 272.62
812 272.62
813 269.36
814 261.82
815 252.85
816 244.08
817 232.96
818 219.59
819 207.32
820 193.87
821 181.77
822 168.60
823 155.76
824 144.03
825 134.07
826 123.46
827 114.47
828 107.64
829 100.46
830 94.53
831 89.28
832 84.59
833 80.96
834 78.54
835 76.28
836 75.51
837 75.51
838 76.55
839 78.55
840 81.57
841 85.18
842 90.61
843 96.01
844 96.01
845 96.01
846 96.01
847 96.01
848 96.01
849 96.01
850 96.01
851 184.51
852 201.57
853 216.33
854 228.69
855 239.90
856 250.41
857 257.91
858 262.29
859 263.41
860 261.70
861 256.75
862 246.82
863 236.35
864 225.17
865 212.90
866 201.61
867 188.42
868 175.92
869 163.70
870 153.18
871 142.89
872 132.95
873 125.18
874 117.61
875 110.36
876 104.56
877 100.13
878 96.64
879 93.52
880 91.91
881 91.91
882 91.91
883 93.84
884 97.13
885 101.08
886 107.19
887 111.89
888 111.89
889 111.89
890 111.89
891 111.89
892 111.89
893 111.89
894 195.89
895 212.65
896 226.60
897 239.28
898 251.28
899 259.92
900 266.03
901 269.76
902 269.76
903 265.55
904 258.92
905 250.42
906 240.04
907 229.03
908 216.69
909 204.21
910 191.25
911 178.40
912 168.31
913 157.47
914 148.62
915 139.12
916 129.54
917 121.65
918 114.59
919 109.30
920 106.39
921 104.71
922 104.71
923 106.41
924 109.22
925 113.62
926 118.31
927 124.34
928 124.34
929 124.34
930 124.34
931 124.34
932 124.34
933 124.34
934 205.67
935 221.25
936 235.02
937 247.47
938 258.37
939 267.42
940 272.60
941 272.00
942 267.91
943 260.38
944 251.10
945 241.32
946 230.96
947 217.34
948 204.99
949 191.24
950 178.58
951 164.79
952 153.07
953 141.06
954 129.86
955 119.79
956 111.13
957 103.53
958 96.95
959 89.42
960 85.22
961 80.54
962 76.85
963 74.41
964 72.12
965 71.21
966 71.21
967 71.21
968 72.13
969 74.22
970 76.95
971 80.65
972 85.36
973 90.60
974 92.36
975 92.36
976 92.36
977 92.36
978 92.36
979 92.36
980 92.36
981 92.36
982 191.27
983 205.03
984 218.89
985 230.87
986 241.63
987 249.83
988 255.42
989 257.98
990 257.33
991 252.87
992 245.90
993 237.78
994 227.14
995 214.67
996 202.31
997 188.68
998 175.96
999 163.25
1000 151.43
1001 139.79
1002 130.40
1003 118.92
1004 110.88
1005 101.92
1006 94.45
1007 88.13
1008 83.19
1009 79.11
1010 74.60
1011 71.86
1012 68.77
1013 66.57
1014 65.24
1015 64.41
1016 64.41
1017 64.92
1018 66.62
1019 68.93
1020 72.77
1021 77.76
1022 83.41
1023 89.19
1024 89.19
1025 89.19
1026 89.19
1027 89.19
1028 89.19
1029 89.19
1030 89.19
1031 182.68
1032 199.88
1033 214.62
1034 227.29
1035 238.62
1036 249.01
1037 256.68
1038 262.71
1039 263.44
1040 259.87
1041 254.66
1042 248.11
1043 240.01
1044 229.30
1045 216.52
1046 205.15
1047 192.49
1048 179.70
1049 167.51
1050 156.31
1051 145.97
1052 135.93
1053 128.06
1054 119.45
1055 113.01
1056 108.31
1057 103.79
1058 100.92
1059 98.90
1060 98.28
1061 98.28
1062 100.12
1063 102.38
1064 106.07
1065 111.06
1066 117.00
1067 117.00
1068 117.00
1069 117.00
1070 117.00
1071 117.00
1072 117.00
1073 202.42
1074 217.46
1075 232.83
1076 245.05
1077 256.39
1078 265.28
1079 271.80
1080 271.80
1081 268.63
1082 261.21
1083 253.57
1084 244.41
1085 233.79
1086 220.80
1087 209.24
1088 196.54
1089 183.38
1090 170.14
1091 157.79
1092 144.31
1093 131.53
1094 122.20
1095 113.46
1096 106.57
1097 100.93
1098 96.80
1099 92.10
1100 88.77
1101 86.07
1102 83.75
1103 82.40
1104 82.40
1105 82.40
1106 82.40
1107 82.40
1108 84.82
1109 88.34
1110 92.06
1111 98.22
1112 103.08
1113 103.08
1114 103.08
1115 103.08
1116 103.08
1117 103.08
1118 196.25
1119 210.62
1120 223.53
1121 235.01
1122 245.30
1123 253.56
1124 259.86
1125 261.87
1126 261.87
1127 257.71
1128 251.10
1129 242.25
1130 232.00
1131 219.62
1132 207.54
1133 194.54
1134 182.85
1135 170.49
1136 158.24
1137 147.54
1138 137.40
1139 129.81
1140 121.07
1141 114.39
1142 109.32
1143 103.67
1144 99.51
1145 96.53
1146 94.67
1147 93.79
1148 93.79
1149 95.31
1150 98.43
1151 102.95
1152 109.01
1153 115.86
1154 115.86
1155 115.86
1156 115.86
1157 115.86
1158 115.86
1159 115.86
1160 115.86
1161 209.63
1162 224.03
1163 236.93
1164 249.17
1165 259.34
1166 267.41
1167 271.07
1168 270.51
1169 263.93
1170 255.80
1171 246.03
1172 235.96
1173 223.79
1174 209.68
1175 196.98
1176 184.70
1177 171.16
1178 157.06
1179 145.05
1180 133.80
1181 123.45
1182 114.06
1183 106.78
1184 98.12
1185 91.19
1186 84.78
1187 80.10
1188 74.95
1189 71.88
1190 68.51
1191 66.13
1192 64.64
1193 63.65
1194 63.06
1195 63.06
1196 64.29
1197 66.41
1198 68.95
1199 73.12
1200 78.00
1201 83.67
1202 85.55
1203 85.55
1204 85.55
1205 85.55
1206 85.55
1207 85.55
1208 85.55
1209 85.55
1210 187.86
1211 202.65
1212 216.23
1213 228.24
1214 239.81
1215 248.77
1216 252.97
1217 254.72
1218 254.72
1219 253.22
1220 247.80
1221 239.99
1222 229.87
1223 218.26
1224 205.99
1225 193.09
1226 180.59
1227 167.42
1228 154.33
1229 142.32
1230 131.88
1231 122.32
1232 112.84
1233 104.07
1234 96.62
1235 90.02
1236 84.43
1237 79.90
1238 74.59
1239 71.27
1240 67.37
1241 64.97
1242 62.82
1243 61.60
1244 61.60
1245 61.60
1246 62.99
1247 64.80
1248 68.51
1249 72.70
1250 77.97
1251 84.10
1252 88.07
1253 88.07
1254 88.07
1255 88.07
1256 88.07
1257 88.07
1258 88.07
1259 88.07
1260 184.25
1261 199.56
1262 dwv,212.97
1263 226.37
1264 237.23
1265 247.66
1266 254.97
1267 259.77
1268 261.89
1269 260.39
1270 255.67
1271 248.49
1272 238.75
1273 228.34
1274 215.95
1275 201.71
1276 187.12
1277 dwv,174.33
1278 162.05
1279 dwv,151.79
1280 142.67
1281 134.03
1282 126.03
1283 118.64
1284 112.00
1285 107.16
1286 103.71
1287 100.06
1288 98.59
1289 97.68
1290 97.68
<<<<< end input file >>>>>

best regards
Lorenz

Dan Haygood

unread,
Aug 28, 2002, 10:43:51 AM8/28/02
to
"LorenzAtWork" <familie....@epost.de> wrote in message
news:7g1pmukv07c56ep3q...@4ax.com...

I am running gawk 3.1.0 on Win98. I see similar anomolies, but in different
places--mostly in chains where "(dwv,)?" doesn't occur. I thought it was a
problem with greed past newlines, so I changed all the "\n" to "a" (one big
line).

Since the field parser no longer has an "\n" to eat, but rather, an "a", I
get a whole bunch of records with a trailing "a", as I would expect. But, I
see similar anomolies in this case too, in dfferent places than Lorenzo;
e.g.
1109 88.34a
1110 92.06a
1111 98.22a
1112 103.08a
1113 103.08a
1114 103.08a
1115 103.08a
1116 103.08a
1117 103.08a
1118 196.25a
1119 210.62a
1120 dwv,223.53a
1121 235.01a
1122 245.30a
There are far fewer of these when a newline isn't involved. And, without
the newline, there don't seem to be problems with fulfillment of the
optional clause after a chain of non-fulfillments.

I don't see any coding anomolies (other than the unnecessary initialization
of "i"), or any irregularities in the data that would account for this. So
maybe it really is a bug?

- Dan

LorenzAtWork

unread,
Aug 28, 2002, 11:29:53 AM8/28/02
to
"Dan Haygood" <reply...@you.read.it> wrote:
> "LorenzAtWork" <familie....@epost.de> wrote in message
> [original post and answer reporting similar results sniped]

in the meantime I experimented a little bit, adding + deleting lines
at the begin of the file.
In most cases this shifted the errors by the numbers of
inserted/deleted lines, but not always.
I have not found a rule yet 8-(

best regards
Lorenz

Peter S Tillier

unread,
Aug 30, 2002, 4:54:42 PM8/30/02
to
"LorenzAtWork" <familie....@epost.de> wrote in message
news:aoqpmuklb5feha0cp...@4ax.com...

Lorenz,

The problem with posting your data files (although they are text)
embedded in the posting is that mail programs and news readers may
reformat the data, including changing end of line characters, etc.. If
you would like to email me the source file as an attachment I'll take a
look at it and see if I can find where the problem lies.

Have you tried moving the data to a UNIX box by ftp and running the same
code there? There could be a problem with the Windows port of gawk.

I have also (many years ago) experienced a problem on multi-user CP/M
systems where the C compiler's read routines got confused where a CRLF
crossed a sector boundary on disk. Something similar may be happening
here.

Peter
--
Peter S Tillier
"Who needs perl when you can write dc and sokoban in sed?"
peter{dot}tillier<at>btinternet[dot]com
To reply direct to me please use the above address
not the "Reply To" which activates a spam trap.


Kenny McCormack

unread,
Aug 30, 2002, 5:59:19 PM8/30/02
to
In article <akom55$eit$1$830f...@news.demon.co.uk>,
Peter S Tillier <pet...@deadspam.com> wrote:
...

>Lorenz,
>
>The problem with posting your data files (although they are text)
>embedded in the posting is that mail programs and news readers may
>reformat the data, including changing end of line characters, etc.. If
>you would like to email me the source file as an attachment I'll take a
>look at it and see if I can find where the problem lies.
>
>Have you tried moving the data to a UNIX box by ftp and running the same
>code there? There could be a problem with the Windows port of gawk.

I think the problem is real.

I was able to take his file from the NG post and the script and replicate
the problem (under Solaris, GAWK 3.1.0). Here are some comments:
1) It strikes me as a "Doctor, it hurts when I do this" sort of
thing - there are certainly more straightforward ways of achieving the
result (just do a few subs on the input lines to get rid of the text you
don't want).
2) TAWK doesn't have the problem (running the same AWK code on the
same input file).

Dan Haygood

unread,
Aug 30, 2002, 10:11:09 PM8/30/02
to
"Kenny McCormack" <gaz...@yin.interaccess.com> wrote in message
news:akopr6$5r5$1...@yin.interaccess.com...

Kenny -

I see your point with the "It strikes me as a 'Doctor, it hurts when I do
this' sort of thing," but on the other hand, it's not so good for the GNU
folks to have to go around saying "Yeah, our regular expression engine
mostly works."

A friend of mine had an MSSQL problem...a query's column that should clearly
have evaluated to "true" was coming back "false". Finally, 20 of us, from
different departments, had a conference call, and none of us could see
anything wrong with the code, and all agreed SQL wasn't acting like it
should. My friend approached MS, and after three weeks, they came back with
"Yep, it's broken. We fixed it by adding the clause ' and (1=1)' to your
expression."

That definitely left us with the dreaded "mostly works" issue. How many
columns were we computing with boolean expressions that mostly worked? Did
we have to plow through tens of thousands of queries, view definition,
stored procedures, and all of the code that created such things, just to add
"and (1=1)" to all of them?

Now that Lorenz has discovered an R/E bug that occurs on the order of 1 in
1000 evaluations, all regular expressions that have not been tested to that
extent are now suspect--until the bug is identified, or, at least, until
more research is done to discover what aspect of his R/E causes the failure.

So Lorenz's technique is just part of the issue.

- Dan


Peter S Tillier

unread,
Aug 31, 2002, 3:35:36 AM8/31/02
to
"Kenny McCormack" <gaz...@yin.interaccess.com> wrote in message
news:akopr6$5r5$1...@yin.interaccess.com...
> In article <akom55$eit$1$830f...@news.demon.co.uk>,
> Peter S Tillier <pet...@deadspam.com> wrote:
> ...
> >Lorenz,
> >
> >The problem with posting your data files (although they are text)
> >embedded in the posting is that mail programs and news readers may
> >reformat the data, including changing end of line characters, etc..
If
> >you would like to email me the source file as an attachment I'll take
a
> >look at it and see if I can find where the problem lies.
> >
> >Have you tried moving the data to a UNIX box by ftp and running the
same
> >code there? There could be a problem with the Windows port of gawk.
>
> I think the problem is real.
>

So do I, but my comment still stands. Dan has found "similar anomalies"
to Lorenz, but they're not the same which suggests to me that what is in
the post may not be exactly what is in Lorenz's original file. Until an
independent test is performed on a copy of that file then "all bets are
off" IMO.

Using the posted data I found 4 identifiable errors (i.e., where the
output contains "dwv,") using gawk-3.1.1 (Cygwin, Win98SE) on lines 240,
638, 1120, and 1279 of the output (not the same as Lorenz's results).
If these aren't the same as yours and Dan's then I think we need the
original file to test.

Interestingly, mawk-1.3.3 also has problems with the data from the post,
but only on output lines 638 and 1279.

Perhaps there's a buffering problem when malloc'ing buffer space when
searching for the RE.

> I was able to take his file from the NG post and the script and
replicate
> the problem (under Solaris, GAWK 3.1.0).

Did you get _exactly_ the same results as Lorenz? If you did, but Dan
didn't then there may still be a diff problem between the post and the
original file.

> Here are some comments:
> 1) It strikes me as a "Doctor, it hurts when I do this" sort of
> thing - there are certainly more straightforward ways of achieving the
> result (just do a few subs on the input lines to get rid of the text
you
> don't want).

Granted. I wouldn't have coded the program in that way, but it ought to
work.

> 2) TAWK doesn't have the problem (running the same AWK code on the
> same input file).
>

I guess it's had longer to mature with RS as RE than gawk.

Kenny McCormack

unread,
Aug 31, 2002, 8:10:02 AM8/31/02
to
In article <akprkd$j59$1$830f...@news.demon.co.uk>,

Peter S Tillier <pet...@deadspam.com> wrote:
...
>> I think the problem is real.
>>
>
>So do I, but my comment still stands. Dan has found "similar anomalies"
>to Lorenz, but they're not the same which suggests to me that what is in
>the post may not be exactly what is in Lorenz's original file. Until an
>independent test is performed on a copy of that file then "all bets are
>off" IMO.

Well, OK. For whatever it may or may not be worth, I think the results
vary slightly based on (exact) version of GAWK, platform, compiler, and
phase of the moon (perhaps other factors are also involved). As you say,
it is probably related to some internal thing (e.g., with the particular
system's implementation of malloc or whatever).

>> I was able to take his file from the NG post and the script and
>> replicate the problem (under Solaris, GAWK 3.1.0).
>
>Did you get _exactly_ the same results as Lorenz? If you did, but Dan
>didn't then there may still be a diff problem between the post and the
>original file.

No (I didn't check it very carefully). As I've said, I see it as a
random-ish sort of thing. The point of my post was to say, as Dan H had
already said, that it didn't look like a programmer error (as most things
in this NG are). On this, I think we agree.

>> Here are some comments:
>> 1) It strikes me as a "Doctor, it hurts when I do this" sort of thing
>>- there are certainly more straightforward ways of achieving the
>>result (just do a few subs on the input lines to get rid of the text
>>you don't want).
>
>Granted. I wouldn't have coded the program in that way, but it ought to
>work.

Of course. There is a general principle that it often takes obscure coding
practices to unearth obscure bugs.

>> 2) TAWK doesn't have the problem (running the same AWK code on the
>> same input file).
>>
>
>I guess it's had longer to mature with RS as RE than gawk.

Quite possibly so.

Kenny McCormack

unread,
Aug 31, 2002, 3:02:43 PM8/31/02
to
In article <1BVb9.29982$Ic7.2...@news2.west.cox.net>,
Dan Haygood <reply...@you.read.it> wrote:
...

>I see your point with the "It strikes me as a 'Doctor, it hurts when I do
>this' sort of thing," but on the other hand, it's not so good for the GNU
>folks to have to go around saying "Yeah, our regular expression engine
>mostly works."

See my other post - I'm certainly not saying that it isn't interesting.
(I'm as much of a bug hunter as anyone)

But, more to the point, I don't think we've established yet whether it is a
"regular expression engine" problem or an RS (and/or "RS as an RE") problem.

The next step should be for us to try to replicate Lorenzo's problem
outside of the RS context.

Dan Haygood

unread,
Sep 1, 2002, 2:07:31 PM9/1/02
to
"Kenny McCormack" <gaz...@yin.interaccess.com> wrote in message
news:akr3s8$nit$1...@yin.interaccess.com...

I see what you're saying. Yes, I agree.
Maybe set RS to "\0", then
1) try split(),
2) try match()
3) try "~"
?
Maybe also try /(...)*/ instead of /(...)?/ to see if it is an operator
problem? And then maybe try /(...)+/ instead of /(...)*/ (which will mangle
output) to see if it is an operation problem. ("Does it know what to do?"
vs. "Does it do it correctly?")

I should also re-run my implementation, because some of the line numbers
Peter reported sound familiar.

I did try eliminating "\n" from the mix, replacing it with "a" so it was one
long line, and still observed the problem.

- Dan


LorenzAtWork

unread,
Sep 2, 2002, 4:21:19 AM9/2/02
to
"Peter S Tillier" <pet...@deadspam.com> wrote:
> "LorenzAtWork" <familie....@epost.de> wrote in message
> The problem with posting your data files [...]

well I first tried to attach the zipped file, but my news server
reminded me that c.l.a is no binary group 8-)

I going to mail you the files.
If anyone else wants them, ...

> Have you tried moving the data to a UNIX box by ftp and running the same
> code there? There could be a problem with the Windows port of gawk.

I have no access to unix in the moment

I have found some interesting effects.
I'm able to delete up to 9 pairs of lines form the top of the file
without changing the line numbers where the error occurs (in my case
1262, 1277 & 1279).
But deleting only on digit in the second line will leave me with only
one error in line 1262.

best regards
Lorenz

LorenzAtWork

unread,
Sep 2, 2002, 5:23:12 AM9/2/02
to
Hi all,

as everyone here seems to agree that my skript is "obscure" and no
good solution, can someone please point out what's wrong with it?

Any other solution I could think of would have needed (much) more
coding.

best regards
Lorenz

Stepan Kasal

unread,
Sep 2, 2002, 7:14:07 AM9/2/02
to
Hello,

On Mon, 02 Sep 2002 11:23:12 +0200, LorenzAtWork wrote:
> as everyone here seems to agree that my skript is "obscure" and no
> good solution, can someone please point out what's wrong with it?
>
> Any other solution I could think of would have needed (much) more
> coding.

we (as awk fans), surely think that awk is the best tool for the job ;-)

Your script is correct, so technically there is nothing wrong and
gawk should work. We are glad that you helped us to find the bug
and be sure the bug will be fixed sooner or later.

Back to your problem. With the data looking like this:

ti1
dwv,98.22
ti1
dwv,103.08
ti1
ti1
dwv,196.25
ti1
dwv,210.62

we'd use for example this program:

BEGIN {FS=","; s=0; i=0}
$0 == "ti1" {print ++i, s; next}
$1 == "dwv" {s = $2}

Fell free to ask us/me if there appears a problem when extending this
approach to the real-life situation.

HTH,
Stepan

Dan Haygood

unread,
Sep 2, 2002, 1:50:16 PM9/2/02
to
"Stepan Kasal" <ka...@matsrv.math.cas.cz> wrote in message
news:slrnan6hvv...@matsrv.math.cas.cz...

Unless there is a trailing "ti1", the last value put into "s" won't be
output, unless you add...

END {print ++i, s}

(Also, "i" doesn't have to be initialized, because it is pre-incremented
("s" does, because otherwise it would be blank on the first output line,
instead of 0.))

- Dan


LorenzAtWork

unread,
Sep 3, 2002, 4:41:54 AM9/3/02
to
"Dan Haygood" <reply...@you.read.it> wrote:
> "Stepan Kasal" <ka...@matsrv.math.cas.cz> wrote in message
> (Also, "i" doesn't have to be initialized, because it is pre-incremented

defensive C programming 8-)


Lorenz

Peter S Tillier

unread,
Sep 3, 2002, 5:35:28 PM9/3/02
to
"LorenzAtWork" <familie....@epost.de> wrote in message
news:ir76nu8rkb4c7av6s...@4ax.com...

> "Peter S Tillier" <pet...@deadspam.com> wrote:
> > "LorenzAtWork" <familie....@epost.de> wrote in message
> > The problem with posting your data files [...]
>
> well I first tried to attach the zipped file, but my news server
> reminded me that c.l.a is no binary group 8-)
>
> I going to mail you the files.
> If anyone else wants them, ...
>

Lorenz has sent me the file in question and I have cross-checked it
against the cut and paste version from the postings. On my system, at
least, these are identical, so one possible source of error has been
eliminated to my satisfaction.

> > Have you tried moving the data to a UNIX box by ftp and running the
same
> > code there? There could be a problem with the Windows port of gawk.
>
> I have no access to unix in the moment
>
>

I'll move that data file onto a UNIX system and try out some tests there
too.

>
> I have found some interesting effects.
> I'm able to delete up to 9 pairs of lines form the top of the file
> without changing the line numbers where the error occurs (in my case
> 1262, 1277 & 1279).
> But deleting only on digit in the second line will leave me with only
> one error in line 1262.
>

This is looking increasingly like a buffering problem somewhere, but
where? Windows cache? Malloc? Bad counts somewhere?

> best regards
> Lorenz

I am making some more detailed tests and will post again once I have
more to report.

Aharon Robbins

unread,
Sep 4, 2002, 7:01:49 AM9/4/02
to
Greetings. Re this:

In article <7g1pmukv07c56ep3q...@4ax.com>,

First and formost, let me emphasize, reiterate, and remind:

PLEASE SEND BUG REPORTS TO bug-...@gnu.org !!!!!!!!!

Posting and discussing bugs in comp.lang.awk is lot of fun, but a
terribly unreliable way to get anything done about them. My attention
to the group varies, to say the least.

Now, on to the problem. I was able to reproduce the problem with the
posted data file on my GNU/Linux system. Interestingly, mawk didn't
have a problem, although others reported mawk showing the same thing on
different systems.

I just finished well over 4 hours of work tracing this down. The fix
is below, and at least solves the problem for this case. I'm not sure
there's a general solution.

The bug is an issue of regular expression matching across buffer
boundaries. This is why different platforms got different results.
Look at the regex involved:

RS = "ti1\n(dwv,)?"

Now, consider the case of the input file, in the input buffer like so:


---+---+---+----+---+
...| t | 1 | \n | d | <--- last character in buffer
---+---+---+----+---+

With the "wv," still waiting to be read in from the file.

In this case, the regex matcher *successfully* matches the RS regex,
since the "dwv," part is optional.

I fixed this basically by using a heuristic. If the RS regex
ends in ?, *, or +, and the end of the regex match is within
a few bytes of the end of the buffer, then read in some more
text and try again. This solves the problem for the particular
program and test data, but as I said, isn't necessarily a
complete and general fix.

(I think the only complete fix would be to suck the entire file into
memory. This I'm unwilling to do, and don't suggest using mmap, I've
been down that road already.)

In any case, the following patch fixes this on my system, without
breaking anything else in the test suite.

Enjoy,

Arnold
------------------------------------------------------------------
*** io.c.save Wed Aug 21 15:21:05 2002
--- io.c Wed Sep 4 13:17:37 2002
***************
*** 355,367 ****
--- 355,383 ----
{
IOBUF *iop;
extern int exiting;
+ int rval1, rval2, rval3;

(void) setjmp(filebuf); /* for `nextfile' */

while ((iop = nextfile(FALSE)) != NULL) {
+ /*
+ * This was:
if (inrec(iop) == 0)
while (interpret(expression_value) && inrec(iop) == 0)
continue;
+ * Now expand it out for ease of debugging.
+ */
+ rval1 = inrec(iop);
+ if (rval1 == 0) {
+ for (;;) {
+ rval2 = rval3 = -1; /* for debugging */
+ rval2 = interpret(expression_value);
+ if (rval2 != 0)
+ rval3 = inrec(iop);
+ if (rval2 == 0 || rval3 != 0)
+ break;
+ }
+ }
if (exiting)
break;
}
***************
*** 2447,2452 ****
--- 2463,2469 ----
bufend = iop->buf + iop->size + iop->secsiz;
*bufend = rs;
}
+
if (len > 0) {
char *newsplit = iop->buf + iop->secsiz;

***************
*** 2551,2579 ****
*/
continuing = FALSE;
if (rsre != NULL) {
! again:
! /* cases 1 and 2 are simple, just keep going */
! if (research(rsre, start, 0, iop->end - start, TRUE) == -1
! || RESTART(rsre, start) == REEND(rsre, start)) {
/*
! * Leading newlines at the beginning of the file
! * should be ignored. Whew!
*/
! if (RS_is_null && *start == '\n'
! && start < iop->end) {
! /*
! * have to catch the case of a
! * single newline at the front of
! * the record, which the regex
! * doesn't. gurr.
! */
! while (*start == '\n' && start < iop->end)
! start++;
! goto again;
}
bp = iop->end;
continue;
}
/* case 3, regex match at exact end */
if (start + REEND(rsre, start) >= iop->end) {
if (iop->cnt != EOF) {
--- 2568,2606 ----
*/
continuing = FALSE;
if (rsre != NULL) {
! /*
! * Leading newlines at the beginning of the file
! * should be ignored. Whew!
! */
! if (RS_is_null && *start == '\n'
! && start < iop->end) {
/*
! * have to catch the case of a
! * single newline at the front of
! * the record, which the regex
! * doesn't. gurr.
*/
! while (*start == '\n' && start < iop->end)
! start++;
! if (start == iop->end) {
! bp = iop->end;
! continue;
}
+ }
+
+ again:
+ /* case 1 is simple, just keep going */
+ if (research(rsre, start, 0, iop->end - start, TRUE) == -1) {
+ bp = iop->end;
+ continue;
+ }
+
+ /* case 2 is simple, just keep going */
+ if (RESTART(rsre, start) == REEND(rsre, start)) {
bp = iop->end;
continue;
}
+
/* case 3, regex match at exact end */
if (start + REEND(rsre, start) >= iop->end) {
if (iop->cnt != EOF) {
***************
*** 2591,2596 ****
--- 2618,2657 ----
}
}
}
+
+ /*
+ * case 4, match succeeded, but there may be more in
+ * the next input buffer.
+ *
+ * Consider an RS of xyz(abc)? where the
+ * exact end of the buffer is xyza and the
+ * next two, unread characters, are ab.
+
+ * This matches the "xyz" and ends up putting the
+ * "abc" into the front of the next record. Ooops.
+ *
+ * The test for a *, +, or ? at the end of the RE
+ * is a heuristic (spelled k l u d g e).
+ */
+ /* succession of tests is easier to trace in GDB. */
+ if (iop->cnt != EOF) {
+ if (strchr("+*?", RS->stptr[RS->stlen-1]) != NULL) {
+ if ((iop->end - (start+REEND(rsre,start))) < RS->stlen) {
+ bp = iop->end;
+ continuing = TRUE;
+ continue;
+ }
+ }
+ }
+
+ /*
+ * iop->cnt could be set to EOF from extra scanning but
+ * there may still be characters left in the buffer.
+ * Ugh.
+ */
+ if (iop->cnt == EOF && iop->end > iop->off)
+ iop->cnt = iop->end - iop->off;
+
/* got a match! */
/*
* Leading newlines at the beginning of the file
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd. arn...@skeeve.com
P.O. Box 354 Home Phone: +972 8 979-0381 Fax: +1 928 569 9018
Nof Ayalon Cell Phone: +972 51 297-545
D.N. Shimshon 99785 ISRAEL

Stepan Kasal

unread,
Sep 4, 2002, 8:44:08 AM9/4/02
to
Hello Aharon,

On Wed, 04 Sep 2002 11:01:49 GMT, Aharon Robbins <arn...@skeeve.com> wrote:
>
> PLEASE SEND BUG REPORTS TO bug-...@gnu.org !!!!!!!!!

OK, next time I encounter a bug report here, I'll forward it to bug-gawk.
I'm sure you are more happy to receive the same bugreport seven times
then to miss it ;-).

But since


> Posting and discussing bugs in comp.lang.awk is lot of fun,

we can continue. :-)

First, I admire the excellent explanation of the cause of the bug:

> RS = "t1\n(dwv,)?"
[...]


> ---+---+---+----+---+
> ...| t | 1 | \n | d | <--- last character in buffer
> ---+---+---+----+---+
>
> With the "wv," still waiting to be read in from the file.
>
> In this case, the regex matcher *successfully* matches the RS regex,
> since the "dwv," part is optional.

I also had an intuition that the buffer boundary has something to do with
this but I thought the actual bug will be more sort of technical detail.
(This is so logical that one could even have deduced it without debugging.)

Thank you Aharon, very nice.

> I fixed this basically by using a heuristic. If the RS regex
> ends in ?, *, or +, and the end of the regex match is within
> a few bytes of the end of the buffer, then read in some more

> text and try again. [...]

I can think of another fix: enhance the regex routines so that they can
say whether this is the longest match.

IOW, the regex routine would be told that the string is incomplete and
it will be required to find the leftmost longest match if possible, or
say that there is not enough information.

For most regexes, this makes no difference. For regexes like the one in
the example above, this should invoke one buffer read, exactly in the
right cases.

For a silly RS, like "x.*x", this would cause reading whole file into
memory, buffer by buffer, requiring quadratic time for the whole series
of uncomplete matches. But those who use such regexes deserve this!
(This could be fixed by saving the state of the regex machine before
reading another buffer, but it's not worth the effort.)

But the implementation of this idea won't be easy.

Aharon has recently moved to regex implementation from IBM Japan, taken
from the GNU libc cvs tree.
So if anyone wants to play with this, they shouldn't use regex.c from
3.1.1 sources, they should rather retrieve the latest glibc sources:
(cvs -z9 -d:pserver:ano...@sources.redhat.com:/cvs/glibc co libc)
and then look at files libc/posix/reg* .

For now, the Aharon's heuristics is enough.

Stepan

Dan Haygood

unread,
Sep 4, 2002, 10:37:56 AM9/4/02
to
> First and formost, let me emphasize, reiterate, and remind:
> PLEASE SEND BUG REPORTS TO bug-...@gnu.org !!!!!!!!!

Jeez, we were still just trying to get enough information together to file a
useful bug report :) And then you go and solve the problem before we even
have a chance to gather the pitchforks, torches, and mob--oh, wait, no,
that's a witch hunt, not a bug hunt, nevermind.

- Dan

"Aharon Robbins" <arn...@skeeve.com> wrote in message
news:newscache$0wuw1h$pdm$1...@lnews.actcom.co.il...

LorenzAtWork

unread,
Sep 4, 2002, 11:15:45 AM9/4/02
to
Hi Aharon,

arn...@skeeve.com (Aharon Robbins) wrote:
> Greetings. Re this:
> LorenzAtWork <lo...@epost.de> wrote:
>>
>> [description of a possible gawk bug snipped]


>
> First and formost, let me emphasize, reiterate, and remind:
>
> PLEASE SEND BUG REPORTS TO bug-...@gnu.org !!!!!!!!!

I wasn't sure at all that I really had found a bug.
So I thought I discuss it with the nice people here first.

May I suggest to mention the problems of trailing optional parts in
regex and the restrictions of your solution in the documentation?


An last but not least, thank you very much for the quick reaction and
the excellent explanation of what had happened.

Lorenz

LorenzAtWork

unread,
Sep 4, 2002, 11:58:27 AM9/4/02
to
Hi Aharon,

arn...@skeeve.com (Aharon Robbins) wrote:
> [...]


> I fixed this basically by using a heuristic. If the RS regex
> ends in ?, *, or +, and the end of the regex match is within
> a few bytes of the end of the buffer, then read in some more
> text and try again.

> [...]

What about a regex of the form

/a(b+c)*bc/

This normally would match the complete string "abbbcbbcbcbcbbbbcbc".
But if the buffer boundary falls within this string, only the part up
to the last "bc" in the buffer will be matched.

Lorenz

Stepan Kasal

unread,
Sep 5, 2002, 5:21:43 AM9/5/02
to
Hello Lorenzo,

On Wed, 04 Sep 2002 17:58:27 +0200, LorenzAtWork wrote:
> arn...@skeeve.com (Aharon Robbins) wrote:
> > [...]
> > I fixed this basically by using a heuristic. If the RS regex
> > ends in ?, *, or +, and the end of the regex match is within
> > a few bytes of the end of the buffer, then read in some more
> > text and try again.
> > [...]

> /a(b+c)*bc/

Or:
/a(|bcbbc)bc/

Thank you very much, I guess you are right and the heuristics should
be applied in each case the regex _contains_ any of the following chars:

? * + |

Extending the heuristics this way should not break anything, it has the
same properties as the original Aharon's:

1) it catches some of the problem cases (though not all, of course,
consider "a.*Z" with an occurence of "Z" at the end of file)

2) it doesn't represent any problem except slight memory inefficiency
when non-trivial RE's are used as RS.

Have a nice day,
Stepan Kasal

Aharon Robbins

unread,
Sep 5, 2002, 6:39:44 AM9/5/02
to
In article <slrnane8h6...@matsrv.math.cas.cz>,

Stepan Kasal <ka...@matsrv.math.cas.cz> wrote:
>Hello Lorenzo,
>
>On Wed, 04 Sep 2002 17:58:27 +0200, LorenzAtWork wrote:
>> arn...@skeeve.com (Aharon Robbins) wrote:
>> > [...]
>> > I fixed this basically by using a heuristic. If the RS regex
>> > ends in ?, *, or +, and the end of the regex match is within
>> > a few bytes of the end of the buffer, then read in some more
>> > text and try again.
>> > [...]
>
>> /a(b+c)*bc/
>
>Or:
> /a(|bcbbc)bc/

Yeah, I was hoping no-one would notice. Oh well.

>Thank you very much, I guess you are right and the heuristics should
>be applied in each case the regex _contains_ any of the following chars:
>
> ? * + |
>
>Extending the heuristics this way should not break anything, it has the
>same properties as the original Aharon's:
>
>1) it catches some of the problem cases (though not all, of course,
>consider "a.*Z" with an occurence of "Z" at the end of file)
>
>2) it doesn't represent any problem except slight memory inefficiency
>when non-trivial RE's are used as RS.
>
>Have a nice day,
> Stepan Kasal

Here's a patch, relative to yesterday's. Have fun.

Arnold
------------------------------------------
*** awk.h.save Wed Aug 21 15:40:04 2002
--- awk.h Thu Sep 5 13:07:46 2002
***************
*** 1002,1007 ****
--- 1002,1008 ----
extern void resyntax P((int syntax));
extern void resetup P((void));
extern int reisstring P((char *text, size_t len, Regexp *re, char *buf));
+ extern int remaybelong P((char *text, size_t len));

/* strncasecmp.c */
#ifndef BROKEN_STRNCASECMP
*** re.c.save Wed Aug 21 13:52:10 2002
--- re.c Thu Sep 5 13:07:22 2002
***************
*** 284,308 ****
{
static char metas[] = ".*+(){}[]|?^$\\";
int i;
- int has_meta = FALSE;
int res;
char *matched;

/* simple checking for has meta characters in re */
for (i = 0; i < len; i++) {
if (strchr(metas, text[i]) != NULL) {
! has_meta = TRUE;
! break;
}
}

/* make accessable to gdb */
matched = &buf[RESTART(re, buf)];

- if (has_meta)
- return FALSE; /* give up early, can't be string match */
-
res = STREQN(text, matched, len);

return res;
}
--- 284,317 ----
{
static char metas[] = ".*+(){}[]|?^$\\";
int i;
int res;
char *matched;

/* simple checking for has meta characters in re */
for (i = 0; i < len; i++) {
if (strchr(metas, text[i]) != NULL) {
! return FALSE; /* give up early, can't be string match */
}
}

/* make accessable to gdb */
matched = &buf[RESTART(re, buf)];

res = STREQN(text, matched, len);

return res;
}
+
+ /* remaybelong --- return TRUE if the RE contains * ? | + */
+
+ int
+ remaybelong(char *text, size_t len)
+ {
+ while (len--) {
+ if (strchr("*+|?", *text++) != NULL) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
*** io.c.fix1 Wed Sep 4 13:17:37 2002
--- io.c Thu Sep 5 13:23:41 2002
***************
*** 2630,2642 ****


* This matches the "xyz" and ends up putting the

* "abc" into the front of the next record. Ooops.

*
! * The test for a *, +, or ? at the end of the RE
! * is a heuristic (spelled k l u d g e).
*/


/* succession of tests is easier to trace in GDB. */

if (iop->cnt != EOF) {

! if (strchr("+*?", RS->stptr[RS->stlen-1]) != NULL) {
! if ((iop->end - (start+REEND(rsre,start))) < RS->stlen) {
bp = iop->end;
continuing = TRUE;
continue;
--- 2630,2647 ----


* This matches the "xyz" and ends up putting the

* "abc" into the front of the next record. Ooops.

*
! * The remaybelong() function looks to see if the
! * regex contains one of: + * ? |. This is a very
! * simple heuristic, but in combination with the
! * "end of match within a few bytes of end of buffer"
! * check, should keep things reasonable.
*/


/* succession of tests is easier to trace in GDB. */

if (iop->cnt != EOF) {

! if (remaybelong(RS->stptr, RS->stlen)) {
! char *matchend = start + REEND(rsre, start);
!
! if (iop->end - matchend < RS->stlen) {
bp = iop->end;
continuing = TRUE;
continue;

Aharon Robbins

unread,
Sep 5, 2002, 6:51:27 AM9/5/02
to
In article <397cnu08l4bq6d5kg...@4ax.com>,

LorenzAtWork <lo...@epost.de> wrote:
>Hi Aharon,
>
>arn...@skeeve.com (Aharon Robbins) wrote:
>> Greetings. Re this:
>> LorenzAtWork <lo...@epost.de> wrote:
>>>
>>> [description of a possible gawk bug snipped]
>>
>> First and formost, let me emphasize, reiterate, and remind:
>>
>> PLEASE SEND BUG REPORTS TO bug-...@gnu.org !!!!!!!!!
>
>I wasn't sure at all that I really had found a bug.
>So I thought I discuss it with the nice people here first.

I don't mind getting bug reports that may not be real bugs.
You had a short program and a data file to reproduce the problem,
which is what I need. I'd have either said "yes it's a bug" or
explained why it wasn't. But if I hadn't bothered to look at
comp.lang.awk yesterday -- after a multi-month hiatus, I may add --
everyone would still be guessing at what the problem is for who
knows how much longer ... :-)

>May I suggest to mention the problems of trailing optional parts in
>regex and the restrictions of your solution in the documentation?

I'll try to add something. Today's new patch should generalize things
somewhat.

>An last but not least, thank you very much for the quick reaction and
>the excellent explanation of what had happened.

You're welcome. Bugs like that are very annoying. It took me about
5 minutes to figure out what the problem was, and almost 4 hours to
fix it. Sigh.

I find it interesting that on my system mawk did not have the problem
but on other systems it did. To me this indicates the same subtle
problem exists there, masked by different buffer handling, since his
code is substantially similar to what I was doing.

Arnold

Stepan Kasal

unread,
Sep 5, 2002, 8:19:49 AM9/5/02
to
Hello,

On Thu, 05 Sep 2002 10:39:44 GMT, Aharon Robbins <arn...@skeeve.com> wrote:
> > /a(|bcbbc)bc/
> Yeah, I was hoping no-one would notice. Oh well.

;-)

> Here's a patch, relative to yesterday's. Have fun.

Thank you, Arnold, for both of the patches and for the promptness
of your solutions.

Since I have experienced minor problems with applying your patch, I've
prepared a version which should apply to 3.1.1 smoothly. It's available
at http://www.math.cas.cz/~kasal/gawk/gawk-3.1.1-heur.patch .

Perhaps it saves a few seconds to someone.

Stepan Kasal

0 new messages