bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-devel] document bug: missing offset in script


From: Steffen Schuler
Subject: [gawk-devel] document bug: missing offset in script
Date: Sat, 17 Jan 2009 02:06:39 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Greetings.

I found the following bug in subsection 3.8.1 in gawk.texi of gawk-devel 
and earlier:

If you apply the script to a text with a one-line C-comment, the closing
comment-delimiter is not removed from the output.

Fix: use an offset (marked by: # FIX)

{
  t = index($0, "/*")
  if (t != 0) {
    # value of `t?? will be "" if t is 1
    tmp = substr($0, 1, t - 1)
    u = index(substr($0, t + 2), "*/")
    offset = t + 2                       # FIX
    while (u == 0) {
      if (getline <= 0) {
        m = "unexpected EOF or error"
        m = m ":" ERRNO
        print m > "/dev/stderr"
        exit
      }
      u = index($0, "*/")
      offset = 0                         # FIX
    }
    # substr expression will be "" if */
    # occured at end of line
    $0 = tmp substr($0, offset + u + 2)  # FIX
  }
  print
}

-- 
Steffen Schuler (goedel) <address@hidden>

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]