File indexing completed on 2024-04-28 15:22:49
0001 #!/bin/bash 0002 # 0003 # This file is part of the KDE libraries 0004 # 0005 # Copyright (C) 1999 Waldo Bastian (bastian@kde.org) 0006 # (c) 2006 Nikolas Zimmermann <zimmermann@kde.org> 0007 # 0008 # This library is free software; you can redistribute it and/or 0009 # modify it under the terms of the GNU Library General Public 0010 # License as published by the Free Software Foundation; either 0011 # version 2 of the License, or (at your option) any later version. 0012 # 0013 # This library is distributed in the hope that it will be useful, 0014 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 # Library General Public License for more details. 0017 # 0018 # You should have received a copy of the GNU Library General Public License 0019 # along with this library; see the file COPYING.LIB. If not, write to 0020 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 # Boston, MA 02110-1301, USA. 0022 # 0023 #---------------------------------------------------------------------------- 0024 # 0025 # KDE HTML Widget -- Script to generate cssproperties.c and cssproperties.h 0026 # 0027 num=1 0028 NS="" 0029 0030 if [ -n "$1" ] # Eventually specified namespace prefix (ie. SVG) 0031 then 0032 num=10001 # Bigger than all properties from HTML CSS 0033 NS=$1 0034 fi 0035 0036 prefix=`echo $NS | awk '{ do { print tolower($0) } while (getline) }'` 0037 0038 grep "^[^\#]" "$prefix"cssproperties.in > "$prefix"cssproperties.strip 0039 0040 echo -e '%{\n/* This file is automatically generated from '$prefix'cssproperties.in by makeprop, do not edit */\n/* Copyright 1999 W. Bastian */\n#include "'$prefix'cssproperties.h"\n%}\nstruct css_prop'$prefix' {\n const char *name;\n int id;\n};\n\nstatic const struct css_prop'$prefix' * findProp'$NS' (register const char *str, register unsigned int len);\n\n%%' > "$prefix"cssproperties.gperf 0041 cat "$prefix"cssproperties.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", '$NS'CSS_PROP_" toupper($0) } while (getline) }' >> "$prefix"cssproperties.gperf 0042 echo '%%' >> "$prefix"cssproperties.gperf 0043 echo -e '/* This file is automatically generated from '$prefix'cssproperties.in by makeprop, do not edit */\n/* Copyright 1998 W. Bastian */\n\n#ifndef '$NS'CSSPROPERTIES_H\n#define '$NS'CSSPROPERTIES_H\n\nDOM::DOMString get'$NS'PropertyName(unsigned short id) KHTML_NO_EXPORT;\n' > "$prefix"cssproperties.h 0044 cat "$prefix"cssproperties.strip | awk '{ \ 0045 i='$num'; \ 0046 print "#define '$NS'CSS_PROP_INVALID 0"; \ 0047 print "#define '$NS'CSS_PROP_MIN '$num'"; \ 0048 do { gsub("-", "_"); print "#define '$NS'CSS_PROP_" toupper($0) " " i; i = i + 1 } while (getline); \ 0049 print ""; \ 0050 print "#define '$NS'CSS_PROP_TOTAL " (i + 1 - '$num') \ 0051 }' >> "$prefix"cssproperties.h 0052 perl -e 'my $max = 0; while (<>) { chomp; $max = length if $max < length; } print "const size_t max'$NS'CSSPropertyNameLength = $max;\n"' < "$prefix"cssproperties.strip >> "$prefix"cssproperties.h 0053 0054 gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindProp"$NS" -Hhash_prop"$prefix" -Wwordlist_prop"$prefix" -D -s 2 "$prefix"cssproperties.gperf > "$prefix"cssproperties.c || exit 1 0055 echo -e '#endif\n' >> "$prefix"cssproperties.h 0056 0057 cat "$prefix"cssproperties.strip | awk '{ \ 0058 i=1; \ 0059 print "static const char * const propertyList'$NS'[] = {"; \ 0060 print "\"\","; \ 0061 do { print "\"" $0 "\", "; i = i + 1 } while (getline); \ 0062 print " 0"; \ 0063 print "};"; \ 0064 print "DOMString get'$NS'PropertyName(unsigned short id)"; \ 0065 print "{"; \ 0066 print " if(id >= '$NS'CSS_PROP_TOTAL || id == 0)"; \ 0067 print " return DOMString();";\ 0068 print " else";\ 0069 print " return DOMString(propertyList'$NS'[id - "('$num' - 1)"]);"; \ 0070 print "}"; \ 0071 print ""; \ 0072 }' >> "$prefix"cssproperties.c 0073 0074 perl -pi -e "s/id\ -\ 0/id/" "$prefix"cssproperties.c 0075 perl -pi -e "s/TOTAL_KEYWORDS/${NS}TOTAL_KEYWORDS/g" "$prefix"cssproperties.c 0076 perl -pi -e "s/MIN_WORD_LENGTH/${NS}MIN_WORD_LENGTH/g" "$prefix"cssproperties.c 0077 perl -pi -e "s/MAX_WORD_LENGTH/${NS}MAX_WORD_LENGTH/g" "$prefix"cssproperties.c 0078 perl -pi -e "s/MIN_HASH_VALUE/${NS}MIN_HASH_VALUE/g" "$prefix"cssproperties.c 0079 perl -pi -e "s/MAX_HASH_VALUE/${NS}MAX_HASH_VALUE/g" "$prefix"cssproperties.c