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., 51 Franklin Street, Fifth Floor,
20 # Boston, MA 02110-1301, 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 int name;\n int id;\n};\n%%\n";
37 /* This file is automatically generated from htmltags.in by maketags, do not edit */
38 /* Copyright 1999 Lars Knoll */
43 #include "dom/dom_string.h"
46 KDE_NO_EXPORT const char* getTagName(unsigned short id);
57 push(@a, " \"$attr\",");
58 push(@b, " \"/$attr\",");
61 print out
$attr . ", ID_" . $up . "\n";
62 print header
"#define ID_" . $up . " " . $num . "\n";
64 print out
"anchor, ID_A\n";
65 print out
"image, ID_IMG\n";
66 print out
"listing, ID_PRE\n";
68 print header
"#define ID_TEXT $num\n";
70 print header
"#define ID_COMMENT $num\n";
71 print header
"#define ID_LAST_TAG $num\n";
72 print header
"#define ID_CLOSE_TAG 16384\n";
76 print header
"\n#endif\n";
79 my $result = system("/bin/sh", "-c", "gperf -a -L 'ANSI-C' -P -D -E -C -l -o -t -k '*' -NfindTag -Hhash_tag -Wwordlist_tag -Qspool_Tag htmltags.gperf > htmltags.c");
85 open(OUT
, ">>htmltags.c");
86 print OUT
"\n\nstatic const char tagStable[] = {\n \"";
88 push (@tags, "comment");
92 foreach my $k(@tags) {
97 #print OUT " \"\\000/$k\"\n";
100 $l += length($k) + 2;
101 $line += length($k) + 5;
103 print OUT
"\\000\"\n};\n";
105 print OUT
"\nstatic const unsigned short tagSList[] = {\n";
108 foreach my $line (@tags)
110 printf OUT
"\n " if (($c % 12) == 0);
111 printf OUT
"%4d,", ($stable{$line}+1) ;
114 foreach my $line (@tags)
116 printf OUT
"\n " if (($c % 12) == 0);
117 printf OUT
"%4d,", ($stable{$line}) ;
120 print OUT
" 0\n};\n\n";
121 print OUT
"const char* KDE_NO_EXPORT getTagName(unsigned short id)\n{\n";
122 print OUT
" if(id > ID_CLOSE_TAG*2) id = ID_CLOSE_TAG+1;\n";
123 print OUT
" return &tagStable[tagSList[id]];\n}\n";