bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] Empty output line when using -o/-p in combination with -l/@lo


From: Hermann Peifer
Subject: [bug-gawk] Empty output line when using -o/-p in combination with -l/@load
Date: Sun, 31 Mar 2013 17:50:58 -0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

Hi,

I just noted that an additional empty output line is generated when using -o/-p in combination with -l/@load. I found this issue when loading the xml extension for processing some GPX data, see [1].

The same behaviour occurs when loading the ordchr extension, see [2] for an example.

Regards, Hermann


[1]

$ awk -f test.awk data.gpx
-29.498221 -51.646213 -29.498362 -51.646196
-29.498362 -51.646196 -29.498435 -51.646128
$ awk -p -f test.awk data.gpx
-29.498221 -51.646213 -29.498362 -51.646196
-29.498362 -51.646196 -29.498435 -51.646128

$ cat test.awk
# gawk profile, created Sun Mar 31 13:28:21 2013

# Loaded extensions (-l and/or @load)

@load "xml"
# Rule(s)

XMLSTARTELEM == "trkseg" {
        lat1 = lon1 = ""
}

XMLSTARTELEM == "trkpt" {
        if (lat1 lon1) {
                print lat1, lon1, XMLATTR["lat"], XMLATTR["lon"]
        }
        lat1 = XMLATTR["lat"]
        lon1 = XMLATTR["lon"]
}

$ cat data.gpx
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"; creator="Nuvi" version="1.1">
  <trk>
    <trkseg>
      <trkpt lat="-29.498221" lon="-51.646213">
        <ele>307.308044</ele>
        <time>2013-03-30T11:51:26</time>
      </trkpt>
      <trkpt lat="-29.498362" lon="-51.646196">
        <ele>316.246582</ele>
        <time>2013-03-30T11:51:33</time>
      </trkpt>
      <trkpt lat="-29.498435" lon="-51.646128">
        <ele>321.724426</ele>
        <time>2013-03-30T11:51:41</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>


[2]

$ awk -lordchr 'BEGIN{ printf("The numeric value of ’A’ is %d\n", ord("A")) }'
The numeric value of ’A’ is 65
$ awk -o -lordchr 'BEGIN{ printf("The numeric value of ’A’ is %d\n", ord("A")) }'
The numeric value of ’A’ is 65

$



reply via email to

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