Closed GoogleCodeExporter closed 9 years ago
Sorry for the duplicate - the server was misbehaving briefly.
Original comment by roger.a....@gmail.com
on 10 Oct 2007 at 6:11
Hmm, I'm unable to reproduce this, but it does seem likely that the awk command
is
using some features that are not present in every awk. What operating system
are you
running on? What does 'awk --version' say?
Original comment by csilv...@gmail.com
on 10 Oct 2007 at 6:13
FWIW, let me add that the awk command doesn't "fail", it just produces no
output.
I've tried this on two different platforms:
Mac OS X 10.4.10, with a vanilla awk that doesn't seem to support any kind of
version
query. (!)
Ubuntu 7.04 x86_64 server, with mawk 1.3.3. (The version query here is "awk -W
version".)
Both are the default awk for the platform - I haven't tried to install alternate
versions.
I can test modified awk scripts on these two for you if you like.
Original comment by roger.a....@gmail.com
on 10 Oct 2007 at 6:27
Ah, good to know. I've only tested on GNU awk, not mawk, on ubuntu. I've just
verified I also get an empty file on my mac platform. But the unittests pass
anyway!
I guess they don't use this config script, which is a flaw in the testing.
It would be great if you could play around with awk and find something that
work on
the platforms you use. I'll also see what I can figure out.
Original comment by csilv...@gmail.com
on 10 Oct 2007 at 7:18
Yes, I noticed that the unit tests passed too. :)
It's been a while since I touched awk, but I'll give it a shot and let you
know.
Might not be in the next few minutes though.
Original comment by roger.a....@gmail.com
on 10 Oct 2007 at 7:22
Apparently most awks - including BSD, mawk, Solaris, AIX and others - don't
support
ARGIND.
All I can think of at the moment, if you want to keep using awk, is to put a
sentry
line at the end of config.h.include and use that to detect when you've
exhausted the
file.
For instance, I put "__EOF__" at the end of config.h.include, and then the
following
awk works on both of my test platforms:
awk '/__EOF__/ {x=1; next}; {if (x != 1) {if ($0 !~ /^ *$/) {inc[$0]=0};
next}}; {
for (i in inc) {if (index($0, i) != 0) {print "\n"prevline"\n"$0; delete
inc[i]} };
prevline=$0; };'
(I added the /__EOF__/ block, and an if statement in your first block.)
Original comment by roger.a....@gmail.com
on 10 Oct 2007 at 8:21
This is a good idea, but I think we can use a marker already in the text. See
how
well the following command works for you:
awk '/^#/ {in_second_file=1;} ! in_second_file {if ($0 !~ /^ *$/) {inc[$0]=0}};
in_second_file { for (i in inc) { if (index($0, i) != 0) {print
"\n"prevline"\n"$0;
delete inc[i]} }; }; { prevline=$0; }' src/config.h.include src/config.h
If it works on all your platforms, I'll change it to this for the next release.
Original comment by csilv...@gmail.com
on 10 Oct 2007 at 10:23
Sorry for the delay - this works great on both of my platforms. I like it. I
especially like the "in_second_file" addresses - I didn't remember if that was
legal.
Obviously so.
Original comment by roger.a....@gmail.com
on 11 Oct 2007 at 1:43
I've made a bugfix release, 0.9.1, that has the fixed awk in it, and a new test
that
sparseconfig has some useful data in it. :-)
Original comment by csilv...@gmail.com
on 12 Oct 2007 at 7:24
Original issue reported on code.google.com by
roger.a....@gmail.com
on 10 Oct 2007 at 6:10