summaryrefslogtreecommitdiffstats
path: root/tdehtml/css/makevalues
blob: 3ca0a82ea01f86bfedd069ec81f8e00d46b89e3f (plain)
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
#!/bin/sh
#   This file is part of the KDE libraries
#
#   Copyright (C) 1999 Waldo Bastian (bastian@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 cssvalues.c and cssvalues.h
#
grep "^[^\#]" cssvalues.in > cssvalues.strip

echo -e '%{\n/* This file is automatically generated from cssvalues.in by makevalues, do not edit */\n/* Copyright 1999 W. Bastian */\n#include "cssvalues.h"\n%}\nstruct css_value {\n    const char *name;\n    int id;\n};\n\nstatic const css_value* findValue (const char *str, unsigned int len);\n\n%%' > cssvalues.gperf
cat cssvalues.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", CSS_VAL_" toupper($0) } while (getline) }' >> cssvalues.gperf
echo '%%' >> cssvalues.gperf
echo -e '/* This file is automatically generated from cssvalues.in by
#makevalues, do not edit */\n/* Copyright 1998 W. Bastian */\n\n#ifndef CSSVALUES_H\n#define CSSVALUES_H\n\nDOM::DOMString getValueName(unsigned short id) KDE_NO_EXPORT;\n' > cssvalues.h
cat cssvalues.strip | awk '{ \
i=1; \
print "#define CSS_VAL_INVALID 0"; \
print "#define CSS_VAL_MIN 1"; \
do { gsub("-", "_"); print "#define CSS_VAL_" toupper($0) " " i; i = i + 1 } while (getline); \
print ""; \
print "#define CSS_VAL_TOTAL " i \
}' >> cssvalues.h
gperf -L 'ANSI-C' -E -c -C -n -o -t -k '*' -NfindValue -Hhash_val -Wwordlist_value -D cssvalues.gperf > cssvalues.c || exit 1
echo -e '#endif\n' >> cssvalues.h

cat cssvalues.strip | awk '{ \
i=1; \
print "static const char * const valueList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print "    0"; \
print "};"; \
print "DOMString getValueName(unsigned short id)"; \
print "{"; \
print "    if(id >= CSS_VAL_TOTAL || id == 0)"; \
print "      return DOMString();";\
print "    else";\
print "      return DOMString(valueList[id]);"; \
print "}"; \
print ""; \
}' >> cssvalues.c