| 1 |
# Message-ID: <[email protected]> |
| 2 |
# Date: Wed, 3 Aug 2011 17:58:02 -0700 (PDT) |
| 3 |
# From: "T. X. G." <[email protected]> |
| 4 |
# To: "[email protected]" <[email protected]> |
| 5 |
# Subject: [bug-gawk] two bugs in gawk 4.0.0 with FPAT and pty |
| 6 |
# |
| 7 |
# $ gawk --version |
| 8 |
# GNU Awk 4.0.0 |
| 9 |
# Copyright (C) 1989, 1991-2011 Free Software Foundation. |
| 10 |
# |
| 11 |
# # bug due to trying to make field splitting more efficient by not parse all fields |
| 12 |
# $ echo a,b,,c |gawk '{for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*' |
| 13 |
# 1 a |
| 14 |
# 2 |
| 15 |
# 3 b |
| 16 |
# 4 |
| 17 |
# |
| 18 |
# # work around |
| 19 |
# $ echo a,b,,c |gawk '{NF;for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*' |
| 20 |
# 1 a |
| 21 |
# 2 b |
| 22 |
# 3 |
| 23 |
# 4 c |
| 24 |
# |
| 25 |
# This bug, as you commented in function fpat_parse_field, is subtle. The null matches of previous call should be remembered across calls. You could make the auto variable non_empty static, but then any calls to patsplit between references of fields will cause it to be wrong. I guess you can either forgo the field splitting optimization by always parse all field in the case of FPAT or make a separate function for splitting $0 only (or pass an extra arg to it?) I am sure you will find the best fix. |
| 26 |
# |
| 27 |
# |
| 28 |
# The next bug is with pty: |
| 29 |
# |
| 30 |
# $ gawk 'BEGIN{ |
| 31 |
# c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\"" |
| 32 |
# PROCINFO[c, "pty"] = 1 |
| 33 |
# c |& getline;print |
| 34 |
# print "abc" |& c |
| 35 |
# c |& getline;print |
| 36 |
# }' |
| 37 |
# 123 |
| 38 |
# ^C |
| 39 |
# |
| 40 |
# Adding a call to setsid() in the function two_way_open right after fork in the child process seems to fix it. |
| 41 |
# |
| 42 |
# One request for feature: |
| 43 |
# Currently the format for mktime is not configurable. Could you please make it configurable just like strftime through PROCINFO["mktime"]? In fact I have already done it myself. But I don't think you would like my style. It should be pretty simple for you to implement. |
| 44 |
# |
| 45 |
# Thank you, Arnold. Again as I have said before, I enjoy your writings and appreciate your contributions to the FSF. |
| 46 |
# W. G. |
| 47 |
# |
| 48 |
BEGIN { |
| 49 |
c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\"" |
| 50 |
PROCINFO[c, "pty"] = 1 |
| 51 |
c |& getline; print |
| 52 |
print "abc" |& c |
| 53 |
c |& getline; print |
| 54 |
} |