blob: ed87c42809e90bfa8bbd66ad77bf360091cd019e [file] [log] [blame]
# 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., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#----------------------------------------------------------------------------
#
# KDE HTML Widget -- Script to generate CSSPropertyNames.c and CSSPropertyNames.h
#
grep "^[^\#]" CSSPropertyNames.in > CSSPropertyNames.strip
echo '%{' > CSSPropertyNames.gperf
echo '/* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */' >> CSSPropertyNames.gperf
echo '/* Copyright 1999 W. Bastian */' >> CSSPropertyNames.gperf
echo '#include "CSSPropertyNames.h"' >> CSSPropertyNames.gperf
echo '%}' >> CSSPropertyNames.gperf
echo 'struct props {' >> CSSPropertyNames.gperf
echo ' const char *name;' >> CSSPropertyNames.gperf
echo ' int id;' >> CSSPropertyNames.gperf
echo '};' >> CSSPropertyNames.gperf
echo '%%' >> CSSPropertyNames.gperf
cat CSSPropertyNames.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", CSS_PROP_" toupper($0) } while (getline) }' >> CSSPropertyNames.gperf
echo '%%' >> CSSPropertyNames.gperf
echo '/* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */' > CSSPropertyNames.h
echo '/* Copyright 1998 W. Bastian */' >> CSSPropertyNames.h
echo '#ifndef CSSPROPERTIES_H' >> CSSPropertyNames.h
echo '#define CSSPROPERTIES_H' >> CSSPropertyNames.h
cat CSSPropertyNames.strip | awk '{ \
i=1; \
print "#define CSS_PROP_INVALID 0"; \
print "#define CSS_PROP_MIN 1"; \
do { gsub("-", "_"); print "#define CSS_PROP_" toupper($0) " " i; i = i + 1 } while (getline); \
print ""; \
print "#define CSS_PROP_MAX CSS_PROP_Z_INDEX"; \
print "#define CSS_PROP_TOTAL " i \
}' >> CSSPropertyNames.h
perl -e 'my $max = 0; while (<>) { chomp; $max = length if $max < length; } print "const size_t maxCSSPropertyNameLength = $max;\n"' < CSSPropertyNames.strip >> CSSPropertyNames.h
echo '#endif' >> CSSPropertyNames.h
gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 CSSPropertyNames.gperf > CSSPropertyNames.c || exit 1
cat CSSPropertyNames.strip | awk '{ \
i=1; \
print "static const char * const propertyList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print " 0"; \
print "};"; \
print "String getPropertyName(unsigned short id)"; \
print "{"; \
print " if(id >= CSS_PROP_TOTAL || id == 0)"; \
print " return String();";\
print " else";\
print " return String(propertyList[id]);"; \
print "};"; \
print ""; \
}' >> CSSPropertyNames.c