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)
6 # Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public License
19 # along with this library; see the file COPYING.LIB. If not, write to
20 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
23 #----------------------------------------------------------------------------
25 # KDE HTML Widget -- Script to generate htmltags.c and htmltags.h
30 open IN, "htmltags.in"
31 or die "Can't open in\n";
32 open header, ">htmltags.h"
33 or die "Can't open header\n";
34 open out, ">htmltags.gperf"
35 or die "Can't open out\n";
37 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";
38 print out "struct tags {\n const char *name;\n int id;\n};\n%%\n";
40 print header "/* This file is automatically generated from
41 htmltags.in by maketags, do not edit */\n/* Copyright 1999 Lars Knoll */\n/* Copyright 2004 Apple Computer, Inc. */\n\n#ifndef KHTML_TAGS_H\n#define KHTML_TAGS_H\n\n#include \"dom/dom_string.h\"\n\n";
43 print header "DOM::DOMString getTagName(unsigned short id);\n\n";
53 $openTags .= " \"$up\",\n";
54 $closeTags .= " \"/$up\",\n";
56 print out $attr . ", ID_" . $up . "\n";
57 print header "const unsigned short ID_$up = $num;\n";
59 print out "anchor, ID_A\n";
60 print out "image, ID_IMG\n";
61 print out "listing, ID_PRE\n";
63 print header "const unsigned short ID_TEXT = $num;\n";
65 print header "const unsigned short ID_COMMENT = $num;\n";
66 print header "const unsigned short ID_LAST_TAG = $num;\n";
67 print header "const unsigned short ID_CLOSE_TAG = 32000;\n";
71 print header "\n#endif\n";
74 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");
80 open IN, "htmltags.c" or die;
91 open OUT, ">>htmltags.c" or die;
93 #line $numLines "htmltags.c"
97 static const char * const openTagNames[] = {
104 static const char * const closeTagNames[] = {
109 DOMString getTagName(unsigned short id)
111 if (id > ID_CLOSE_TAG) {
112 int index = id - ID_CLOSE_TAG;
113 if (index >= ID_TEXT)
115 return closeTagNames[index];
117 if (id > ID_LAST_TAG)
119 return openTagNames[id];