Amalgamation script
Bjoern Hoehrmann <[email protected]> Wed, 02 Jul 2008 00:16:06 +0200
| Newsgroups | gmane.comp.web.html-tidy.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I made a crude script that, running from the src directory, combines
all source files into a single compilation unit. The result currently
will not compile due to name clashes with the hash table functions in
entities.c, attrs.c, and tags.c. Making this I also noticed iconvtc.c
and win32tc.c use `#include <tidy.h>` which they probably should not.
There is also a name clash in config.c (windows.h and config.c define
a macro `IN` incompatibly) that is addressed by the ordering below (if
you compile win32tc.c you probably have to move it before config.c).
It may be worthwhile to rename the hash functions, fix the inclusion
issue, and possibly #undef the config.c macros after their use. I'd
also be very nice if we could consolidate the public header files so
we only have tidy.h (and optionally empty platform.h, etc. files) in
some way, then we could integrate a script like the one below into the
build system so embedders can just download tidyall.c, console.c, and
tidy.h and just drop them into their build system. This is the script:
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::File;
my %seen;
my @cont = map {
("/* begin $_ */\n",
IO::File->new('<' . $_)->getlines,
"/* end $_ */\n")
} qw/
fileio.c
buffio.c
mappedio.c
access.c
alloc.c
attrask.c
attrdict.c
attrget.c
attrs.c
charsets.c
clean.c
config.c
entities.c
istack.c
lexer.c
localize.c
parser.c
pprint.c
streamio.c
tagask.c
tags.c
tidylib.c
tmbstr.c
utf8.c
iconvtc.c
win32tc.c
/;
for (my $i = 0; $i < @cont; ++$i) {
$_ = $cont[$i];
next unless /^#include "(.*)"/;
if ($seen{$1}++) {
$cont[$i] = "";
next;
}
next unless -f $1;
my $file = IO::File->new("<$1") or die $!;
my @new = ("/* begin $1 */\n",
$file->getlines,
"/* end $1 */\n");
splice @cont, $i--, 1, @new;
}
print @cont;
regards,
--
Björn Höhrmann · mailto:[email protected] · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08