Blame extension/README.fts

Packit 575503
Wed Aug 29 22:34:24 IDT 2012
Packit 575503
============================
Packit 575503
Packit 575503
Portability is a myth, a chimera. Like the pot of gold at the end of
Packit 575503
the rainbow, it's always looks like it is just within your reach, but
Packit 575503
in fact, it is seldom, if ever, truly acheivable.
Packit 575503
Packit 575503
It all started when trying to get the extensions to work on my aged
Packit 575503
PowerPC Macbook G4 running Mac OS X 10.5.  That machine is wonderful,
Packit 575503
since it is neither an Intel architecture machine nor is it GNU/Linux;
Packit 575503
two criteria that are becoming increasingly harder to meet over 10%
Packit 575503
into the 21st century.
Packit 575503
Packit 575503
The readdir extension didn't work. Furthermore, GDB showed that in gawk
Packit 575503
itself, struct stat had one size and layout, while inside the readdir
Packit 575503
code, it had another.
Packit 575503
Packit 575503
This turned out to be due to the large file nonsense foisted off upon
Packit 575503
us by POSIX. The main gawk configure.ac had AC_SYS_LARGEFILE but the
Packit 575503
extensions' configure.ac did not.  OK - a one line fix, rebuild, and
Packit 575503
everything is OK.  Right?
Packit 575503
Packit 575503
Of course not.
Packit 575503
Packit 575503
Everything was OK on my 64-bit GNU/Linux Intel system, but lo and behold,
Packit 575503
I compiled on a 32-bit GNU/Linux system and suddenly the fts tests
Packit 575503
stopped working. A look at the config.log reveals:
Packit 575503
Packit 575503
	<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64
Packit 575503
Packit 575503
Why? Who knows. The comment in the file itself is cryptic:
Packit 575503
Packit 575503
	/* The fts interface is incompatible with the LFS interface which
Packit 575503
	   transparently uses the 64-bit file access functions.  */
Packit 575503
	#ifdef __USE_FILE_OFFSET64
Packit 575503
	# error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
Packit 575503
	#endif
Packit 575503
Packit 575503
It purports to be English, but says nothing intelligible, and the man
Packit 575503
page sheds no light, either.
Packit 575503
Packit 575503
Fortunately, the source for fts from NetBSD is reasonably legible,
Packit 575503
freely available, and has a usable license.
Packit 575503
Packit 575503
So, I try to just plug it in directly.  Everything compiles, nothing
Packit 575503
works. There is shared library / weird linker dark voodoo crap going on.
Packit 575503
Packit 575503
*I* am not a powerful enough Jedi to get around it, and I think it has
Packit 575503
more to do with the Dark Side of the Force than with the Light Side. So
Packit 575503
gawkfts.h now has:
Packit 575503
Packit 575503
	#define fts_children gawk_fts_children
Packit 575503
	#define fts_close gawk_fts_close
Packit 575503
	#define fts_open gawk_fts_open
Packit 575503
	#define fts_read gawk_fts_read
Packit 575503
	#define fts_set gawk_fts_set
Packit 575503
Packit 575503
to rename things, and it all compiles and works.
Packit 575503
Packit 575503
The Plan 9 guys got it right when they threw eveything out and started
Packit 575503
over again. I sure wish I could.
Packit 575503
Packit 575503
On the bright side, this is stuff that would have had to be done anyway
Packit 575503
for at least MinGW, and maybe for some other systems. So it's not wasted
Packit 575503
effort. But it sure is sad that it's necessary.
Packit 575503
Packit 575503
Arnold Robbins
Packit 575503
arnold@skeeve.com