jirzynek / sparsehash

Automatically exported from code.google.com/p/sparsehash
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

sparseconfig.h is empty. #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The updated build in 0.9 produces an empty sparseconfig.h file, which
prevents use of any of the collections.

To reproduce:
1. Extract the 0.9 source.
2. Run configure in the source directory.
3. Run make in the source directory.
4. Examine src/google/sparsehash/sparseconfig.h.  It will be empty.

I suspect there is some problem with the awk command in the Makefile that
replaces the grep/fgrep commands in previous versions.  I have not
attempted to debug the awk command myself.

Replacing the awk command with the grep/fgrep pipe from the 0.8 package
(with a couple of path fixups) fixes the problem, and sparseconfig.h is
created correctly.

This bug happens both when building in place and when building in a
separate build directory.

Original issue reported on code.google.com by roger.a....@gmail.com on 10 Oct 2007 at 6:10

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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