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 cssvalues.c and cssvalues.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 values from HTML CSS 0033 NS=$1 0034 fi 0035 0036 prefix=`echo $NS | awk '{ do { print tolower($0) } while (getline) }'` 0037 0038 grep "^[^\#]" "$prefix"cssvalues.in > "$prefix"cssvalues.strip 0039 0040 echo -e '%{\n/* This file is automatically generated from '$prefix'cssvalues.in by makevalues, do not edit */\n/* Copyright 1999 W. Bastian */\n#include "'$prefix'cssvalues.h"\n%}\nstruct css_value'$prefix' {\n const char *name;\n int id;\n};\n\nstatic const css_value'$prefix' * findValue'$NS' (register const char *str, register unsigned int len);\n\n%%' > "$prefix"cssvalues.gperf 0041 cat "$prefix"cssvalues.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", '$NS'CSS_VAL_" toupper($0) } while (getline) }' >> "$prefix"cssvalues.gperf 0042 echo '%%' >> "$prefix"cssvalues.gperf 0043 echo -e '/* This file is automatically generated from '$prefix'cssvalues.in by makevalues, do not edit */\n/* Copyright 1998 W. Bastian */\n\n#ifndef '$NS'CSSVALUES_H\n#define '$NS'CSSVALUES_H\n\nDOM::DOMString get'$NS'ValueName(unsigned short id) KHTML_NO_EXPORT;\n' > "$prefix"cssvalues.h 0044 cat "$prefix"cssvalues.strip | awk '{ \ 0045 i='$num'; \ 0046 print "#define '$NS'CSS_VAL_INVALID 0"; \ 0047 print "#define '$NS'CSS_VAL_MIN '$num'"; \ 0048 do { gsub("-", "_"); print "#define '$NS'CSS_VAL_" toupper($0) " " i; i = i + 1 } while (getline); \ 0049 print ""; \ 0050 print "#define '$NS'CSS_VAL_TOTAL " (i + 1 - '$num') \ 0051 }' >> "$prefix"cssvalues.h 0052 gperf -L 'ANSI-C' -E -c -C -n -o -t -k '*' -NfindValue"$NS" -Hhash_val"$prefix" -Wwordlist_value"$prefix" -D "$prefix"cssvalues.gperf > "$prefix"cssvalues.c || exit 1 0053 echo -e '#endif\n' >> "$prefix"cssvalues.h 0054 cat "$prefix"cssvalues.strip | awk '{ \ 0055 i=1; \ 0056 print "static const char * const valueList'$NS'[] = {"; \ 0057 print "\"\","; \ 0058 do { print "\"" $0 "\", "; i = i + 1 } while (getline); \ 0059 print " 0"; \ 0060 print "};"; \ 0061 print "DOMString get'$NS'ValueName(unsigned short id)"; \ 0062 print "{"; \ 0063 print " if(id >= '$NS'CSS_VAL_TOTAL || id == 0)"; \ 0064 print " return DOMString();";\ 0065 print " else";\ 0066 print " return DOMString(valueList'$NS'[id - "('$num' - 1)"]);"; \ 0067 print "}"; \ 0068 print ""; \ 0069 }' >> "$prefix"cssvalues.c 0070 0071 perl -pi -e "s/id\ -\ 0/id/" "$prefix"cssvalues.c 0072 perl -pi -e "s/TOTAL_KEYWORDS/${NS}TOTAL_KEYWORDS/g" "$prefix"cssvalues.c 0073 perl -pi -e "s/MIN_WORD_LENGTH/${NS}MIN_WORD_LENGTH/g" "$prefix"cssvalues.c 0074 perl -pi -e "s/MAX_WORD_LENGTH/${NS}MAX_WORD_LENGTH/g" "$prefix"cssvalues.c 0075 perl -pi -e "s/MIN_HASH_VALUE/${NS}MIN_HASH_VALUE/g" "$prefix"cssvalues.c 0076 perl -pi -e "s/MAX_HASH_VALUE/${NS}MAX_HASH_VALUE/g" "$prefix"cssvalues.c