home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / utils / bug / 2470 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  2.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!physik.tu-muenchen.DE!Peer.Stritzinger
  2. From: Peer.Stritzinger@physik.tu-muenchen.DE
  3. Newsgroups: gnu.utils.bug
  4. Subject: Bug with NUL character in FS regexp in gawk 2.14
  5. Date: 25 Jan 1993 21:15:59 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 64
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-gnu-utils@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301252057.AA08150@axon.t30.physik.tu-muenchen.de>
  12.  
  13. Environment: 
  14. gawk 2.14, patchlevel 0
  15.  
  16. Intel 386 running SYSVR3.2 from Interactive.
  17. Sparc Sun running SUNOS 4.1x
  18. DEC 5000-25 running ULTRIX 4.2
  19.  
  20. Problem:
  21. There is no possibilty to use the NUL character (written as
  22. ^@ in the examples) in the FS variable as part of a regular
  23. expression.  
  24.  
  25. For the tests below this input file was used:
  26.  
  27. tst.in:
  28. ------------------------------------------------------------
  29. 100 ^@ 200 ^@ 300
  30. 400  500 600
  31. ------------------------------------------------------------
  32.  
  33. Normaly this should work, but the string is cut off at the
  34. NUL character.  The problem could be the usage of 'strlen'
  35. in function 'set_FS' but I did not investigate further.
  36. ------------------------------------------------------------
  37. gawk 'BEGIN {FS = "[ \t\0]+"}
  38. {for (i = 1; i <= NF; i++) {
  39.     print i, $i }}' <tst.in
  40. ------------------------------------------------------------
  41. gawk: cmd. line:1: fatal: Premature end of regular expression: /[     /
  42. ------------------------------------------------------------
  43.  
  44. I tried this as a workaround, but this separates fields at
  45. blanks, tabs, backslashes, and '0'
  46. ------------------------------------------------------------
  47. gawk 'BEGIN {FS = "[ \t\\0]+"}
  48. {for (i = 1; i <= NF; i++) {
  49.     print i, $i }}' <tst.in
  50. ------------------------------------------------------------
  51. 1 1
  52. 2 ^@
  53. 3 2
  54. 4 ^@
  55. 5 3
  56. 1 4
  57. 2 5
  58. 3 6
  59. ------------------------------------------------------------
  60.  
  61. The NUL character is preserved in the string variable but
  62. the effect remains the same.
  63. ------------------------------------------------------------
  64. gawk 'BEGIN {tmp = "[ \t\0]+"; print tmp; FS = tmp}
  65. {for (i = 1; i <= NF; i++) { 
  66.     print i, $i }}' <tst.in
  67. ------------------------------------------------------------
  68. [     ^@]+
  69. gawk: cmd. line:1: fatal: Premature end of regular expression: /[     /
  70. ------------------------------------------------------------
  71.  
  72. Peer Stritzinger
  73. stritzi@physik.tu-muenchen.de
  74.  
  75.