1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/usr/bin/perl
# This file is part of the KDE libraries
#
# Copyright (C) 1998 Waldo Bastian (bastian@kde.org)
# 1999 Lars Knoll (knoll@kde.org)
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
#----------------------------------------------------------------------------
#
# KDE HTML Widget -- Script to generate htmltags.c and htmltags.h
#
open IN, "htmltags.in"
or die "Can't open in\n";
open header, ">htmltags.h"
or die "Can't open header\n";
open out, ">htmltags.gperf"
or die "Can't open out\n";
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";
print out "struct tags {\n int name;\n int id;\n};\n%%\n";
print header <<EOF;
/* This file is automatically generated from htmltags.in by maketags, do not edit */
/* Copyright 1999 Lars Knoll */
#ifndef TDEHTML_TAGS_H
#define TDEHTML_TAGS_H
#include "dom/dom_string.h"
#include <tdeglobal.h>
TDE_NO_EXPORT const char* getTagName(unsigned short id);
EOF
my @tags = ();
$num = 0;
while (<IN>) {
chomp;
$attr = $_;
$num = $num + 1;
push(@tags, $attr);
push(@a, " \"$attr\",");
push(@b, " \"/$attr\",");
$up = uc($attr);
$up =~ s/-/_/;
print out $attr . ", ID_" . $up . "\n";
print header "#define ID_" . $up . " " . $num . "\n";
}
print out "anchor, ID_A\n";
print out "image, ID_IMG\n";
print out "listing, ID_PRE\n";
$num = $num+1;
print header "#define ID_TEXT $num\n";
$num = $num+1;
print header "#define ID_COMMENT $num\n";
print header "#define ID_CLOSE_TAG $num\n";
print header "#define ID_LAST_TAG $num\n";
print out "%%\n";
close out;
print header "\n#endif\n";
close header;
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");
if ($result) {
unlink "htmltags.c";
exit $result;
}
open(OUT, ">>htmltags.c");
print OUT "\n\nstatic const char tagStable[] = {\n \"";
push (@tags, "text");
push (@tags, "comment");
my %stable = ();
my $l = 1;
my $line = 5;
foreach my $k(@tags) {
if ($line > 65) {
print OUT "\"\n \"";
$line = 5;
}
#print OUT " \"\\000/$k\"\n";
print OUT "\\000/$k";
$stable{$k} = $l;
$l += length($k) + 2;
$line += length($k) + 5;
}
print OUT "\\000\"\n};\n";
print OUT "\nstatic const unsigned short tagSList[] = {\n";
print OUT " 0,\n";
my $c = 0;
foreach my $line (@tags)
{
printf OUT "\n " if (($c % 12) == 0);
printf OUT "%4d,", ($stable{$line}+1) ;
++$c;
}
foreach my $line (@tags)
{
printf OUT "\n " if (($c % 12) == 0);
printf OUT "%4d,", ($stable{$line}) ;
++$c;
}
print OUT " 0\n};\n\n";
print OUT "const char* TDE_NO_EXPORT getTagName(unsigned short id)\n{\n";
print OUT " if(id > ID_CLOSE_TAG*2) id = ID_CLOSE_TAG+1;\n";
print OUT " return &tagStable[tagSList[id]];\n}\n";
|