3 # This file is part of the KDE libraries
5 # Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
6 # Copyright (C) 2003 Dirk Mueller (mueller@kde.org)
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., 51 Franklin Street, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
23 #----------------------------------------------------------------------------
25 # KDE HTML Widget -- Script to generate khtmlattrs.c and khtmlattrs.h
27 open IN
, "htmlattrs.in"
28 or die "Can't open in\n";
29 open header
, ">htmlattrs.h"
30 or die "Can't open header\n";
31 open out
, ">htmlattrs.gperf"
32 or die "Can't open out\n";
34 print out
"%{\n/* This file is automatically generated from
35 #htmlattrs.in by makeattrs, do not edit */\n#include \"htmlattrs.h\"\n%}\n";
36 print out
"struct attrs {\n int name;\n int id;\n};\n%%\n";
38 print header
"/* This file is automatically generated from
39 htmlattrs.in by makeattrs, do not edit */\n/* Copyright 1999 Lars Knoll */\n\n#ifndef HTML_ATTRS_H\n#define HTML_ATTRS_H\n\n#include \"dom/dom_string.h\"\n#include <kdemacros.h>\nusing namespace DOM;\n\n";
47 /END_CI_ATTR/ and $last_ci_attr = $num and next;
57 print out
$attr . ", ATTR_" . $up . "\n";
59 print header
"#define ATTR_" . $up . " " . $num . "\n";
64 print header
"#define ATTR_LAST_ATTR $num\n";
65 print header
"#define ATTR_LAST_CI_ATTR $last_ci_attr\n";
70 print header
"const char* getAttrName(unsigned short id) KDE_NO_EXPORT;\n";
72 print header
"\n#endif\n";
75 my $result = system("/bin/sh", "-c", "gperf -c -a -L 'ANSI-C' -P -G -D -E -C -o -t -k '*' -NfindAttr -Hhash_attr -Wwordlist_attr -Qspool_attr -s 2 htmlattrs.gperf > htmlattrs.c");
80 system("/bin/sh", "-c", 'perl -pi -e "s/\"\"}/\"\", 0}/g" htmlattrs.c');
82 # read the hash mappings (is there a better way?)
84 open(IN
, "<htmlattrs.c");
86 if (/spool_attr_str(\d+), ATTR_([\w_]+)/) {
87 $hmap{$amap{$2}} = $1;
92 open(OUT
, ">>htmlattrs.c");
93 print OUT
"\n\nstatic const unsigned short attrList[] = {\n";
94 print OUT
" 65535,\n";
96 while(defined ($line = shift @a))
101 die if !length($hmap{$amap{$l}});
103 print OUT
" " .$hmap{$amap{$l}}.",\n";
105 print OUT
" 65535\n};\n\n";
106 print OUT
"const char* KDE_NO_EXPORT getAttrName(unsigned short id)\n{\n";
107 print OUT
" if (!id || id > TOTAL_KEYWORDS) return \"\";\n";
108 print OUT
" return spool_attr + wordlist_attr[attrList[id]].name;\n";