2 # This file is part of the KDE libraries
4 # Copyright (C) 1998 Waldo Bastian (bastian@kde.org)
5 # 1999 Lars Knoll (knoll@kde.org)
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Library General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public License
18 # along with this library; see the file COPYING.LIB. If not, write to
19 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
22 #----------------------------------------------------------------------------
24 # KDE HTML Widget -- Script to generate htmltags.c and htmltags.h
26 open IN, "htmltags.in"
27 or die "Can't open in\n";
28 open header, ">htmltags.h"
29 or die "Can't open header\n";
30 open out, ">htmltags.gperf"
31 or die "Can't open out\n";
33 print out "%{\n/* This file is automatically generated from htmltags.in by maketags, do not edit */\n/* Copyright 1999 Lars Knoll */\n#include \"htmltags.h\"\n%}\n";
34 print out "struct tags {\n const char *name;\n int id;\n};\n%%\n";
36 print header "/* This file is automatically generated from
37 htmltags.in by maketags, do not edit */\n/* Copyright 1999 Lars Knoll */\n\n#ifndef KHTML_TAGS_H\n#define KHTML_TAGS_H\n\n#include \"dom/dom_string.h\"\n\n";
39 print header "DOM::DOMString getTagName(unsigned short id);\n";
47 push(@a, " \"$up\",");
48 push(@b, " \"/$up\",");
50 print out $attr . ", ID_" . $up . "\n";
51 print header "#define ID_" . $up . " " . $num . "\n";
53 print out "anchor, ID_A\n";
54 print out "image, ID_IMG\n";
55 print out "listing, ID_PRE\n";
57 print header "#define ID_TEXT $num\n";
59 print header "#define ID_COMMENT $num\n";
60 print header "#define ID_CLOSE_TAG $num\n";
61 print header "#define ID_LAST_TAG $num\n";
65 print header "\n#endif\n";
68 my $result = system("/bin/sh", "-c", "gperf -a -L 'ANSI-C' -D -E -C -l -o -t -k '*' -NfindTag -Hhash_tag -Wwordlist_tag htmltags.gperf > htmltags.c");
74 open(OUT, ">>htmltags.c");
75 print OUT "\n\nstatic const char * const tagList[] = {\n";
77 while(defined ($line = shift @a))
81 print OUT "\"TEXT\",\n";
82 print OUT "\"COMMENT\",\n";
83 while(defined ($line = shift @b))
88 print OUT "DOM::DOMString getTagName(unsigned short id)\n{\n";
89 print OUT " if(id > ID_CLOSE_TAG*2) id = ID_CLOSE_TAG+1;\n";
90 print OUT " return DOM::DOMString(tagList[id]);\n";