From 97b8365cafc3a344a22d3980b8ed885f5c6d8357 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 9 Jan 2007 19:58:05 +0000 Subject: Merged gcj-eclipse branch to trunk. From-SVN: r120621 --- libjava/classpath/scripts/.cvsignore | 3 + libjava/classpath/scripts/Makefile.in | 11 +- libjava/classpath/scripts/build_mathnamespace | 6 + libjava/classpath/scripts/check_jni_methods.sh | 3 - libjava/classpath/scripts/checkstyle-config.xml | 132 ++++ libjava/classpath/scripts/checkstyle-header.regex | 38 + .../classpath/scripts/checkstyle-suppressions.xml | 34 + libjava/classpath/scripts/checkstyle.css | 42 + libjava/classpath/scripts/checkstyle2html.xsl | 102 +++ libjava/classpath/scripts/classpath-build | 68 ++ libjava/classpath/scripts/classpath-daily | 17 + libjava/classpath/scripts/classpath.spec.in | 2 +- libjava/classpath/scripts/eclipse-gnu.xml | 246 ++++++ libjava/classpath/scripts/jalopy-gnu.xml | 378 +++++++++ libjava/classpath/scripts/japi | 135 ++++ libjava/classpath/scripts/kissme-mauve | 346 ++++++++ libjava/classpath/scripts/loc | 44 ++ libjava/classpath/scripts/math_symbols | 69 ++ libjava/classpath/scripts/patches.pl | 164 ++++ libjava/classpath/scripts/sanitize-jsr166 | 6 + libjava/classpath/scripts/timezones.pl | 366 +++++++++ libjava/classpath/scripts/tzabbrevs | 40 + libjava/classpath/scripts/unicode-blocks.pl | 364 +++++++++ libjava/classpath/scripts/unicode-muncher.pl | 868 +++++++++++++++++++++ 24 files changed, 3476 insertions(+), 8 deletions(-) create mode 100644 libjava/classpath/scripts/.cvsignore create mode 100644 libjava/classpath/scripts/build_mathnamespace create mode 100644 libjava/classpath/scripts/checkstyle-config.xml create mode 100644 libjava/classpath/scripts/checkstyle-header.regex create mode 100644 libjava/classpath/scripts/checkstyle-suppressions.xml create mode 100644 libjava/classpath/scripts/checkstyle.css create mode 100644 libjava/classpath/scripts/checkstyle2html.xsl create mode 100755 libjava/classpath/scripts/classpath-build create mode 100755 libjava/classpath/scripts/classpath-daily create mode 100644 libjava/classpath/scripts/eclipse-gnu.xml create mode 100644 libjava/classpath/scripts/jalopy-gnu.xml create mode 100755 libjava/classpath/scripts/japi create mode 100755 libjava/classpath/scripts/kissme-mauve create mode 100755 libjava/classpath/scripts/loc create mode 100644 libjava/classpath/scripts/math_symbols create mode 100755 libjava/classpath/scripts/patches.pl create mode 100755 libjava/classpath/scripts/sanitize-jsr166 create mode 100755 libjava/classpath/scripts/timezones.pl create mode 100644 libjava/classpath/scripts/tzabbrevs create mode 100755 libjava/classpath/scripts/unicode-blocks.pl create mode 100755 libjava/classpath/scripts/unicode-muncher.pl (limited to 'libjava/classpath/scripts') diff --git a/libjava/classpath/scripts/.cvsignore b/libjava/classpath/scripts/.cvsignore new file mode 100644 index 0000000..190036b --- /dev/null +++ b/libjava/classpath/scripts/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +classpath.spec diff --git a/libjava/classpath/scripts/Makefile.in b/libjava/classpath/scripts/Makefile.in index 2c4ff90..d8ad93b 100644 --- a/libjava/classpath/scripts/Makefile.in +++ b/libjava/classpath/scripts/Makefile.in @@ -42,12 +42,14 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \ $(top_srcdir)/../../config/lead-dot.m4 \ + $(top_srcdir)/../../config/no-executables.m4 \ $(top_srcdir)/../../libtool.m4 $(top_srcdir)/m4/acattribute.m4 \ $(top_srcdir)/m4/accross.m4 $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/ax_create_stdint_h.m4 \ - $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -158,6 +160,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@ +JAVA_MAINTAINER_MODE_FALSE = @JAVA_MAINTAINER_MODE_FALSE@ +JAVA_MAINTAINER_MODE_TRUE = @JAVA_MAINTAINER_MODE_TRUE@ JAY = @JAY@ JAY_SKELETON = @JAY_SKELETON@ JIKES = @JIKES@ @@ -279,7 +283,6 @@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ -toolexeclibdir = @toolexeclibdir@ vm_classes = @vm_classes@ EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh import-cacerts.sh all: all-am diff --git a/libjava/classpath/scripts/build_mathnamespace b/libjava/classpath/scripts/build_mathnamespace new file mode 100644 index 0000000..a2e53a3 --- /dev/null +++ b/libjava/classpath/scripts/build_mathnamespace @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "/* Warning ! This is a generated file. Use build_mathnamespace to regenerate it */" +while read fun;do + echo "#define ${fun} ClasspathMath_${fun}" +done diff --git a/libjava/classpath/scripts/check_jni_methods.sh b/libjava/classpath/scripts/check_jni_methods.sh index 4cc00cc..b46e378 100755 --- a/libjava/classpath/scripts/check_jni_methods.sh +++ b/libjava/classpath/scripts/check_jni_methods.sh @@ -35,9 +35,6 @@ cat > $TMPFILE3 << EOF -Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose -Java_java_lang_VMSystem_arraycopy -Java_java_lang_VMSystem_identityHashCode --Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class --Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache --Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class EOF # Compare again silently. diff --git a/libjava/classpath/scripts/checkstyle-config.xml b/libjava/classpath/scripts/checkstyle-config.xml new file mode 100644 index 0000000..498e7fa --- /dev/null +++ b/libjava/classpath/scripts/checkstyle-config.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libjava/classpath/scripts/checkstyle-header.regex b/libjava/classpath/scripts/checkstyle-header.regex new file mode 100644 index 0000000..15eb29a --- /dev/null +++ b/libjava/classpath/scripts/checkstyle-header.regex @@ -0,0 +1,38 @@ +^/\* .*$ +^ .*$ +^ (Copyright \(C\) .*|Free Software Foundation, Inc.)$ +^$ +^This file is part of GNU Classpath.$ +^$ +^GNU Classpath is free software; you can redistribute it and/or modify$ +^it under the terms of the GNU General Public License as published by$ +^the Free Software Foundation; either version 2, or \(at your option\)$ +^any later version.$ +^ *$ +^GNU Classpath 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$ +^General Public License for more details.$ +^$ +^You should have received a copy of the GNU General Public License$ +^along with GNU Classpath; see the file COPYING. If not, write to the$ +^Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA$ +^02110-1301 USA.$ +^$ +^Linking this library statically or dynamically with other modules is$ +^making a combined work based on this library. Thus, the terms and$ +^conditions of the GNU General Public License cover the whole$ +^combination.$ +^$ +^As a special exception, the copyright holders of this library give you$ +^permission to link this library with independent modules to produce an$ +^executable, regardless of the license terms of these independent$ +^modules, and to copy and distribute the resulting executable under$ +^terms of your choice, provided that you also meet, for each linked$ +^independent module, the terms and conditions of the license of that$ +^module. An independent module is a module which is not derived from$ +^or based on this library. If you modify this library, you may extend$ +^this exception to your version of the library, but you are not$ +^obligated to do so. If you do not wish to do so, delete this$ +^exception statement from your version. \*/$ +^ *$ diff --git a/libjava/classpath/scripts/checkstyle-suppressions.xml b/libjava/classpath/scripts/checkstyle-suppressions.xml new file mode 100644 index 0000000..68c620c --- /dev/null +++ b/libjava/classpath/scripts/checkstyle-suppressions.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/libjava/classpath/scripts/checkstyle.css b/libjava/classpath/scripts/checkstyle.css new file mode 100644 index 0000000..9d1fd8b --- /dev/null +++ b/libjava/classpath/scripts/checkstyle.css @@ -0,0 +1,42 @@ +body { + color: black; + font-family: sans-serif; +} +h1 { + color: #990000; + border-width: 1px; + border-style: solid; + border-color: black; + padding: 0.2em; + background-color: #cccccc; + width: 100%; +} +h2 { + color: #990000; + border-width: 1px; + border-style: solid; + border-color: black; + padding: 0.2em; + background-color: #cccccc; + width: 100%; +} +h3 { + color: #990000; + border-width: 1px; + border-style: solid; + border-color: black; + padding: 0.2em; + background-color: #cccccc; + width: 100%; +} +table { + width: 100%; +} +th { + color: white; + background-color: #999999; + text-align: left; +} +td { + background-color: #cccccc; +} diff --git a/libjava/classpath/scripts/checkstyle2html.xsl b/libjava/classpath/scripts/checkstyle2html.xsl new file mode 100644 index 0000000..8963987 --- /dev/null +++ b/libjava/classpath/scripts/checkstyle2html.xsl @@ -0,0 +1,102 @@ + + + + + + + + + + + + Checkstyle results + + + +

Checkstyle results

+
The following document contains the results of + Checkstyle.
+ +

Summary

+ + + + + + + + + + +
FilesInfosWarningsErrors
+ +

Files

+ + + + + + + + +
FileIWE
+ + + + + + + +
+ + + + + + + + + # + + + + + + + + + + + + + + +

+ + + + + + +

+ + + + + +
ErrorLine
+
+
+ + + + + + + + + +
diff --git a/libjava/classpath/scripts/classpath-build b/libjava/classpath/scripts/classpath-build new file mode 100755 index 0000000..cd0e7d6 --- /dev/null +++ b/libjava/classpath/scripts/classpath-build @@ -0,0 +1,68 @@ +#!/bin/sh + +# cvs may timeout ... +set -e + +export CVS_RSH=ssh + +CLASSPATH_CVSSRCDIR=$HOME/src/cvs/classpath +CLASSPATH_SRCDIR=$HOME/src/classpath +CLASSPATH_BUILDDIR=$HOME/src/classpath/build + +DATE=`date +"%Y%m%d"` +OUTPUTDIR=$HOME/public_html/classpath/daily +LOGFILE=$OUTPUTDIR/classpath-$DATE.log + +echo -n > $LOGFILE + +if [ -d $CLASSPATH_CVSSRCDIR ] ; then + echo "update cvs source tree" >> $LOGFILE + cd $CLASSPATH_CVSSRCDIR + cvs -z 3 update >> $LOGFILE 2>&1 +fi + +if [ -d $CLASSPATH_SRCDIR ] ; then + + # delete old sources + echo "delete old source tree" >> $LOGFILE + + # workaround for automake safety behaviour with umask + chmod u+w -R $CLASSPATH_SRCDIR + + rm -rf $CLASSPATH_SRCDIR + +fi + +echo "copy cvs tree to source tree" >> $LOGFILE +cp -a $CLASSPATH_CVSSRCDIR $CLASSPATH_SRCDIR +cd $CLASSPATH_SRCDIR + +# patch version in configure.ac +if [ -f configure.ac ] ; then + mv configure.ac configure.ac.orig + sed "s/, \[.*cvs\]/, [$DATE]/" < configure.ac.orig > configure.ac +fi + +# generate autofriends stuff +./autogen.sh >> $LOGFILE 2>&1 + +# create build directory +mkdir build +cd build + +# configure and build classpath +export LD_LIBRARY_PATH=/usr/local/lib +../configure --prefix=$HOME/local/classpath --with-jikes=/usr/bin/jikes --enable-glibj=both --enable-jni --enable-gtk-peer --enable-regen-headers >> $LOGFILE 2>&1 +make >> $LOGFILE 2>&1 +make install >> $LOGFILE 2>&1 + +make dist >> $LOGFILE 2>&1 +#make distcheck >> $LOGFILE 2>&1 +cp classpath-$DATE.tar.gz $OUTPUTDIR + +cd $OUTPUTDIR +ln -sf classpath-$DATE.tar.gz LATEST-SNAPSHOT +ln -sf classpath-$DATE.log LATEST-BUILDLOG + +exit 0 + diff --git a/libjava/classpath/scripts/classpath-daily b/libjava/classpath/scripts/classpath-daily new file mode 100755 index 0000000..c740527 --- /dev/null +++ b/libjava/classpath/scripts/classpath-daily @@ -0,0 +1,17 @@ +#!/bin/sh + +DATE=`date +"%Y%m%d"` +OUTPUTDIR=$HOME/public_html/classpath/daily +LOGFILE=$OUTPUTDIR/classpath-$DATE.log +FAILEDLOG=$OUTPUTDIR/classpath-failed-$DATE.log +MAIL="konqueror@gmx.de" + +/home/mkoch/bin/classpath-build + +if test "$?" = "1" ; then + tail --lines=100 $LOGFILE > $FAILEDLOG + + mail $MAIL -s "classpath daily snapshot $DATE FAILED" < $FAILEDLOG +else + mail $MAIL -s "classpath daily snapshot $DATE SUCCESSFUL" < /dev/null > /dev/null +fi diff --git a/libjava/classpath/scripts/classpath.spec.in b/libjava/classpath/scripts/classpath.spec.in index 80522748..4120d25 100644 --- a/libjava/classpath/scripts/classpath.spec.in +++ b/libjava/classpath/scripts/classpath.spec.in @@ -1,4 +1,4 @@ -# $Id: classpath.spec.in,v 1.2 2005/07/04 14:31:01 ziga Exp $ +# $Id: classpath.spec.in,v 1.3 2006/12/10 20:25:50 gnu_andrew Exp $ %define version_num @PACKAGE_VERSION@ %define release_num 1 diff --git a/libjava/classpath/scripts/eclipse-gnu.xml b/libjava/classpath/scripts/eclipse-gnu.xml new file mode 100644 index 0000000..60a1082 --- /dev/null +++ b/libjava/classpath/scripts/eclipse-gnu.xml @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libjava/classpath/scripts/jalopy-gnu.xml b/libjava/classpath/scripts/jalopy-gnu.xml new file mode 100644 index 0000000..ad5c5ab --- /dev/null +++ b/libjava/classpath/scripts/jalopy-gnu.xml @@ -0,0 +1,378 @@ + + + + + 14 + + + + + false + + + [A-Z][a-zA-Z0-9]+ + [A-Z][a-zA-Z0-9]+ + + + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + + [A-Z][a-zA-Z0-9]+ + \w+ + + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + + [a-z]+(?:\.[a-z]+)* + + [a-z][\w]+ + [a-z][\w]+ + + [a-z][\w]* + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + 6 + + + + 30000 + 30000 + 30000 + 30000 + 30000 + 30000 + + true + + + 1 + + + + true + false + true + false + false + + + bak + 0 + + + + 0 + 0 + 1 + 0 +
1
+
1
+ 1 + 1 + 1 + 1 +
+ + 0 + 0 + 0 + + 1 + 0 + 0 + + 0 + 0 +
0
+
0
+ 2 +
+ 1 +
+ + + false + false + + + false + false + false + false + + + true + true + true + true + true + + + true + false + + + + true + true + + + + false + + + + false + false + false + + false + + 0 + 0 + 0 + 0 + + false + + + + + + + */ + * @throws $exceptionType$ DOCUMENT ME! + * @param $paramType$ DOCUMENT ME! + * @return DOCUMENT ME! + /**| * DOCUMENT ME! + + + + + false + false + false + + + - + false + false + + Inner Classes + Constructors + Instance fields + Instance initializers + Inner Interfaces + Methods + Static fields/initializers + + + + +
+ + 0 + false +
+
+ + 0 + false +
+ + disabled + + + + 1 + *:0|gnu:1|java:1|javax:1|org:1 + + disabled + true + + + true + + true + true + + false + + + true + + + 1 + 2 + 2 + 0 + 0 + 55 + -1 + 2 + -1 + 0 + 8 + 2 + 1 + + + true + true + + + + false + false + false + false + true + false + + + + false + false + false + false + false + static|field|initializer|constructor|method|interface|class + false + + + true + public|protected|private|abstract|static|final|synchronized|transient|volatile|native|strictfp + + + + + true + true + true + + + true + false + false + false + + true + + + false + false + true + + + + true + false + + true + true + true + true + true + true + + false + false + + + + + + 0 + true + false + false + + false + + false + false + + false + + + true + false + false + false + + + false + false + false + + + + true + true + 79 + + + + false + false + false + + false + false + false + + + + false + + false + + +
+
+ diff --git a/libjava/classpath/scripts/japi b/libjava/classpath/scripts/japi new file mode 100755 index 0000000..52bcbc4 --- /dev/null +++ b/libjava/classpath/scripts/japi @@ -0,0 +1,135 @@ +#!/bin/sh + +CLASSPATH_CVS=~/japi/classpath +JAPIZE_DIR=~/japitools-0.9 +FTPROOT=~alpha/pub/gnu/classpath/nightly/tests +LOG=/tmp/japi.log +export PATH=${PATH}:/usr/java/j2sdk1.4.1/bin + +rm -f /tmp/japi.log > /dev/null 2>&1 + +classpath_checkout () +{ + if [ ! -d "${CLASSPATH_CVS}" ]; then + mkdir --parents ${CLASSPATH_CVS} + local dir=`dirname "${CLASSPATH_CVS}"` + cd "${dir}" + cvs -z3 -d :pserver:anoncvs@subversions.gnu.org:/cvsroot/classpath co classpath >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out classpath" + exit 1 + fi + fi +} + +classpath_update () +{ + cd "${CLASSPATH_CVS}" && cvs update -d -P . >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out classpath" + exit 1 + fi +} + +classpath_clean () +{ + if [ -d "${CLASSPATH_CVS}/build" ]; then + rm -rf "${CLASSPATH_CVS}/build" + fi +# if [ -d "${CLASSPATH_PREFIX}" ]; then +# rm -rf "${CLASSPATH_PREFIX}" +# fi + mkdir --parents "${CLASSPATH_CVS}/build" +# mkdir --parents "${CLASSPATH_PREFIX}" +} + +classpath_configure () +{ + cd "${CLASSPATH_CVS}" + aclocal >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running aclocal" + exit 1 + fi + autoheader >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running autoheader" + exit 1 + fi + automake >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running automake" + exit 1 + fi + autoconf >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running autoconf" + exit 1 + fi + cd "${CLASSPATH_CVS}/build" && ../configure --with-gcj >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error configuring" + exit 1 + fi +} + +classpath_build () +{ + cd "${CLASSPATH_CVS}/build" && make >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error during make" + exit 1 + fi +} + + +japize_classpath () +{ + cd "${JAPIZE_DIR}/bin" && ./japize as classpath packages "${CLASSPATH_CVS}/build/lib/glibj.zip" +java +javax +org -java.awt.dnd.peer -java.awt.peer -org.apache -org.w3c.dom.css -org.w3c.dom.events -org.w3c.dom.html -org.w3c.dom.stylesheets -org.w3c.dom.traversal -org.w3c.dom.views -java.text.resources >> /tmp/japi.log 2>&1 + if [ $? -ne 0 ]; then + echo "Error running japize" + exit 1 + fi + cp -f "${JAPIZE_DIR}/bin/classpath.japi.gz" /tmp +} + +japicompat_classpath () +{ + today=`date` + echo "${today}" > /tmp/classpath-jdk11-compare.txt + cd "${JAPIZE_DIR}/bin" && ./japicompat -q jdk11.japi.gz classpath.japi.gz >> /tmp/classpath-jdk11-compare.txt + if [ $? -ne 0 ]; then + echo "Error running japicompat" + exit 1 + fi + echo "${today}" > /tmp/classpath-jdk13-compare.txt + cd "${JAPIZE_DIR}/bin" && ./japicompat -q jdk13.japi.gz classpath.japi.gz >> /tmp/classpath-jdk13-compare.txt + if [ $? -ne 0 ]; then + echo "Error running japicompat" + exit 1 + fi +} + +#-------------------------------------------------------------------- +# Update Classpath CVS +#-------------------------------------------------------------------- +classpath_checkout +classpath_update + +#-------------------------------------------------------------------- +# Build Classpath with GCJ 3.2 +#-------------------------------------------------------------------- +classpath_clean +classpath_configure +classpath_build + +#-------------------------------------------------------------------- +# Run japize on glibj.zip +#-------------------------------------------------------------------- +japize_classpath + +#-------------------------------------------------------------------- +# Run japicompat against jdk13 +#-------------------------------------------------------------------- +japicompat_classpath + diff --git a/libjava/classpath/scripts/kissme-mauve b/libjava/classpath/scripts/kissme-mauve new file mode 100755 index 0000000..8a6ee22 --- /dev/null +++ b/libjava/classpath/scripts/kissme-mauve @@ -0,0 +1,346 @@ +#!/bin/sh + +CLASSPATH_CVS=~/mauve/classpath +CLASSPATH_PREFIX=~/mauve/root/classpath +MAUVE_CVS=~/mauve/mauve +KISSME_CVS=~/mauve/kissme +KISSME_PREFIX=~/mauve/root/kissme +KISSME_BIN=~/mauve/kissme/useful_scripts/kissme +LOG=/tmp/mauve.log +RESULTS=/tmp/kissme-mauve.txt +REPORT=/tmp/kissme-mauve-report.txt +TIMEOUT=30 + +rm -f ${LOG} > /dev/null 2>&1 +rm -f ${RESULTS} > /dev/null 2>&1 +today=`date` +echo "${today}" > ${LOG} +touch ${RESULTS} + + +_aclocal () +{ + aclocal "$@" >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running aclocal" + exit 1 + fi +} + +_autoheader () +{ + autoheader "$@" >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running autoheader" + exit 1 + fi +} + +_automake () +{ + automake "$@" >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running automake" + exit 1 + fi +} + +_autoconf () +{ + autoconf "$@" >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error running autoconf" + exit 1 + fi +} + +classpath_checkout () +{ + if [ ! -d "${CLASSPATH_CVS}" ]; then + mkdir --parents ${CLASSPATH_CVS} + local dir=`dirname "${CLASSPATH_CVS}"` + cd "${dir}" + cvs -z3 -d :pserver:anoncvs@subversions.gnu.org:/cvsroot/classpath co classpath >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out classpath" + exit 1 + fi + fi +} + +classpath_update () +{ + cd "${CLASSPATH_CVS}" && cvs update -d -P . >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out classpath" + exit 1 + fi +} + +classpath_clean () +{ + if [ -d "${CLASSPATH_CVS}/build" ]; then + rm -rf "${CLASSPATH_CVS}/build" + fi + if [ -d "${CLASSPATH_PREFIX}" ]; then + rm -rf "${CLASSPATH_PREFIX}" + fi + mkdir --parents "${CLASSPATH_CVS}/build" + mkdir --parents "${CLASSPATH_PREFIX}" +} + +classpath_configure () +{ + cd "${CLASSPATH_CVS}" + + _aclocal + _autoheader + _automake + _autoconf + + cd "${CLASSPATH_CVS}/build" && ../configure --prefix=${CLASSPATH_PREFIX} --with-gcj --enable-jni >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error configuring" + exit 1 + fi +} + +classpath_build () +{ + cd "${CLASSPATH_CVS}/build" && make >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error during make" + exit 1 + fi +} + +classpath_install () +{ + cd "${CLASSPATH_CVS}/build" && make install >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error during make" + exit 1 + fi +} + +kissme_checkout () +{ + if [ ! -d "${KISSME_CVS}" ]; then + mkdir --parents ${KISSME_CVS} + local dir=`dirname "${KISSME_CVS}"` + cd "${KISSME_CVS}" + cvs -z3 -d :pserver:anonymous@cvs.kissme.sourceforge.net:/cvsroot/kissme co . >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out kissme" + exit 1 + fi + fi +} + +kissme_update () +{ + cd "${KISSME_CVS}" && cvs update -d -P . >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out kissme" + exit 1 + fi +} + +kissme_clean () +{ + if [ -d "${KISSME_CVS}/build" ]; then + rm -rf "${KISSME_CVS}/build" + fi + if [ -d "${KISSME_PREFIX}" ]; then + rm -rf "${KISSME_PREFIX}" + fi + mkdir --parents "${KISSME_CVS}/build" + mkdir --parents "${KISSME_PREFIX}" +} + +kissme_configure () +{ + cd "${KISSME_CVS}" + + _aclocal + _autoheader + _automake -a + _autoconf + + cd "${KISSME_CVS}" && ./configure --prefix=${KISSME_PREFIX} \ + --enable-use-zips --with-gnu-classpath=${CLASSPATH_CVS} \ + --with-gnu-classpath-build=${CLASSPATH_CVS}/build \ + --with-classpath-install-dir=${CLASSPATH_PREFIX} >> ${LOG} 2>&1 + + if [ $? -ne 0 ]; then + echo "Error configuring" + exit 1 + fi +} + +kissme_build () +{ + cd "${KISSME_CVS}" && make >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error during make" + exit 1 + fi +} + +kissme_install () +{ + cd "${KISSME_CVS}" && make install >> ${LOG} 2>&1 + if [ $? -ne 0 ]; then + echo "Error during make" + exit 1 + fi +} + +mauve_checkout () +{ + if [ ! -d "${MAUVE_CVS}" ]; then + mkdir --parents ${MAUVE_CVS} + local dir=`dirname "${MAUVE_CVS}"` + cd "${dir}" + cvs -z3 -d :pserver:anoncvs@sources.redhat.com:/cvs/mauve co mauve >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out mauve" + exit 1 + fi + fi +} + +mauve_update () +{ + cd "${MAUVE_CVS}" && cvs update -d -P . >> ${LOG} 2>/dev/null + if [ $? -ne 0 ]; then + echo "Error checking out mauve" + exit 1 + fi +} + +kissme_mauve () +{ + export JAVAC="jikes -bootclasspath ${CLASSPATH_PREFIX}/share/classpath/glibj.zip" + export JAVA="${KISSME_BIN}" + +# if [ -f "${KISSME_CVS}/useful_scripts/mauve-kissme" ]; then +# cp -f "${KISSME_CVS}/useful_scripts/mauve-kissme" "${MAUVE_CVS}" +# fi + + if [ -f "${CLASSPATH_CVS}/mauve-classpath" ]; then + cp -f "${CLASSPATH_CVS}/mauve-classpath" "${MAUVE_CVS}" + fi + + cd "${MAUVE_CVS}" + if [ $? -ne 0 ]; then + echo "Error configuring mauve" + exit 1 + fi + + _aclocal + _automake + _autoconf + + ./configure >> "${LOG}" 2>&1 + if [ $? -ne 0 ]; then + echo "Error configuring mauve" + exit 1 + fi + + # create class choices from key file + if [ -f classes ]; then + rm -f classes 2>/dev/null + fi + if [ -f choices ]; then + rm -f choices 2>/dev/null + fi + /bin/sh choose "${MAUVE_CVS}" classpath + if [ $? -ne 0 ]; then + echo "Error during choose for mauve" + exit 1 + fi + + # compile classes + compile=`cat "${MAUVE_CVS}/classes" | tr '.' '/' | awk '{print $1".java"}' | xargs` + ${JAVAC} -classpath "${MAUVE_CVS}" -d "${MAUVE_CVS}" ${compile} >> "${LOG}" 2>&1 + if [ $? -ne 0 ]; then + echo "Error during compile for mauve" + exit 1 + fi + + set -m + for i in `cat "${MAUVE_CVS}/classes"`; do + echo "$i" | ${JAVA} gnu.testlet.SimpleTestHarness -verbose >> "${RESULTS}" 2>&1 & + + vm_pid=$! + sleep ${TIMEOUT} && kill -9 $vm_pid > /dev/null 2>&1 && echo "FAIL: $i execution aborted" >> "${RESULTS}" & + kill_pid=$! + fg %- 2>/dev/null + kill -9 $kill_pid >/dev/null 2>&1 # && echo Test did not time out + done +} + +mauve_summary () +{ + if [ ! -f "${RESULTS}" ]; then + echo "Error creating summary" + exit 1 + fi + + pass_cnt=`grep PASS "${RESULTS}" | wc -l` + fail_cnt=`grep FAIL "${RESULTS}" | wc -l` + total_cnt=`expr $pass_cnt + $fail_cnt` + + today=`date` + echo "Mauve test results for Kissme" > "${REPORT}" + echo "Report generated on ${today}" >> "${REPORT}" + echo "" >> "${REPORT}" + echo "${fail_cnt} of ${total_cnt} tests failed." >> "${REPORT}" + echo "" >> "${REPORT}" + cat "${RESULTS}" >> "${REPORT}" +} + +#-------------------------------------------------------------------- +# Update Classpath CVS +#-------------------------------------------------------------------- +classpath_checkout +classpath_update + +#-------------------------------------------------------------------- +# Build Classpath with GCJ 3.2 +#-------------------------------------------------------------------- +classpath_clean +classpath_configure +classpath_build +classpath_install + +#-------------------------------------------------------------------- +# Update Kissme CVS +#-------------------------------------------------------------------- +kissme_checkout +kissme_update + +#-------------------------------------------------------------------- +# Build Kissme +#-------------------------------------------------------------------- +kissme_clean +kissme_configure +kissme_build +#kissme_install + +#-------------------------------------------------------------------- +# Update Mauve CVS +#-------------------------------------------------------------------- +mauve_checkout +mauve_update + +#-------------------------------------------------------------------- +# Execute Mauve +#-------------------------------------------------------------------- +kissme_mauve + +#-------------------------------------------------------------------- +# Create report +#-------------------------------------------------------------------- +mauve_summary diff --git a/libjava/classpath/scripts/loc b/libjava/classpath/scripts/loc new file mode 100755 index 0000000..dc2f327 --- /dev/null +++ b/libjava/classpath/scripts/loc @@ -0,0 +1,44 @@ +#!/bin/sh +# +# loc Find a class or package +# +# Usage: loc [-l] class-pattern [dirname] + +# -l Use system locate command instead of find. In that case, loc +# will ignore any directory to be searched. + +# Example: +# +# $ loc -l org.objectweb.jonas.common.JProp +# /var/lib/jonas/demoserver/ejbjars/autoload/mejb.jar +# /var/lib/jonas/lib/common/ow_jonas_bootstrap.jar +# /var/lib/jonas/eclipseserver/ejbjars/autoload/mejb.jar +# /var/lib/jonas/ejbjars/autoload/mejb.jar +# /var/cache/jonas/work/ejbjars/jonas/mejb_2005.09.15-17.01.52.jar +# /usr/src/redhat/BUILD/jonas-4.3.3/jonas/classes/common/org/objectweb/jonas/common/JProp.class + + +MODE=$1 +if test "$MODE" == "-l"; then + COMMAND='(locate \*.jar ; locate \*.war)' + shift +else + COMMAND='(find "$FOO" -name \*.jar -follow ; find "$FOO" -name \*.war -follow)' +fi + +FOO=$2 +if test "x$FOO" == "x"; then + FOO=/usr/share/java +fi + +eval "$COMMAND" 2>/dev/null | while read i; do + if (fastjar tf $i 2>/dev/null | grep $1) > /dev/null 2>&1 ; then + echo $i + fi +done + +if test "$MODE" != "-l"; then + find "$FOO" -name '*.class' 2>/dev/null | grep $1 +else + locate \*.class | grep $1 +fi diff --git a/libjava/classpath/scripts/math_symbols b/libjava/classpath/scripts/math_symbols new file mode 100644 index 0000000..e676a51 --- /dev/null +++ b/libjava/classpath/scripts/math_symbols @@ -0,0 +1,69 @@ +acos +asin +atan +atan2 +cos +sin +tan +cosh +sinh +tanh +exp +frexp +ldexp +expm1 +log +log10 +log1p +modf +pow +sqrt +ceil +fabs +floor +fmod +erf +erfc +gamma +hypot +finite +j0 +j1 +jn +lgamma +y0 +y1 +yn +acosh +asinh +cbrt +logb +nextafter +remainder +logb +scalb +significand +logbf +scalbf +significandf +copysign +ilogb +rint +rintf +scalbn +__ieee754_sqrt +__ieee754_asin +__ieee754_asin +__ieee754_atan2 +__ieee754_exp +__ieee754_fmod +__ieee754_log +__ieee754_pow +__ieee754_rem_pio2 +__ieee754_remainder +__ieee754_scalb +__ieee754_acos +__kernel_cos +__kernel_sin +__kernel_tan +__kernel_rem_pio2 diff --git a/libjava/classpath/scripts/patches.pl b/libjava/classpath/scripts/patches.pl new file mode 100755 index 0000000..57f134d --- /dev/null +++ b/libjava/classpath/scripts/patches.pl @@ -0,0 +1,164 @@ +#!/usr/bin/perl -w +# Purpose is to move patches from upload directory to +# public patches directory. Any file not matching the correct +# pattern is deleted. Any patch file without a README and the +# file was last modified more than 120 minutes ago is deleted. +# Any README file without a patch file which was last modified +# more than 120 minutes ago is deleted. +# +# notes to self: as long as this runs as root do not worry +# about quota problems or disk space + +use strict; + +my ($upload_dir) = "/home/ftp/classpath/incoming"; +my ($public_dir) = "/home/ftp/classpath/pub/patches"; +my ($user) = "classpath"; +my ($group) = "classpath"; +my ($mode_dir) = "775"; +my ($mode_file) = "664"; +my (@patches) = (); + +use vars qw($upload_dir $public_dir @patches $user $group + $mode_dir $mode_file); + +# main +{ + @patches = &getPatches(); + &movePatches(@patches); +} + +#--------------------------------------------------------------- +# Purpose: To remove files not matching the correct pattern. +# To remove README files without patches (last modified greater +# than 2 hours). To remove patches without README files (last +# modified greater than 2 hours). +#--------------------------------------------------------------- +sub getPatches +{ + my (@patches) = (); + my (@entries) = (); + my (%maybe) = (); + my ($entry, $debug, $prefix, $junk, $file, $patch, $readme) = ""; + my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, + $mtime, $ctime, $blksize, $blocks) = ""; + + $debug = 1; + + opendir(INCOMING, "$upload_dir") || die "could not open $upload_dir\n"; + @entries = grep( !/^\.\S+/, readdir(INCOMING)); # no .* + closedir(INCOMING); + foreach $entry (sort @entries) + { + if (($entry eq ".") || ($entry eq "..")) { next; } + if (-d "$upload_dir/$entry") + { + print "Directory: $upload_dir/$entry/\n"; + } + elsif (-e "$upload_dir/$entry") + { + if ($entry eq ".message") { next; } + if ($entry eq "README") { next; } + if ($entry !~ /^\w+-\d\d\d\d\d\d-\d+\.patch\.(gz|README)$/) + { + print "REGEX FAILED: $entry\n"; + unlink("$upload_dir/$entry"); + } + else + { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime, + $ctime,$blksize,$blocks) = stat("$upload_dir/$entry"); + if ($size > 512000) + { + print "LARGE PATCH: $entry\n"; + unlink("$upload_dir/$entry"); + } + else + { + ($prefix,$junk) = split(/(\.gz|\.README)/, $entry, 2); + $maybe{$prefix} += 1; + } + } + } + } + + foreach $entry (keys(%maybe)) + { + if ($maybe{$entry} == 2) + { + $patch = "$entry.gz"; + $readme = "$entry.README"; + + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime, + $ctime,$blksize,$blocks) = stat($patch); + if (time-$mtime > 900) + { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime, + $ctime,$blksize,$blocks) = stat($readme); + if (time-$mtime > 900) + { + $patches[$#patches+1] = $entry; + } + } + } + else + { + if (-e "$upload_dir/$entry.gz") + { + unlink("$upload_dir/$entry.gz"); + print "STALE PATCH: $entry.gz\n"; + } + elsif (-e "$upload_dir/$entry.README") + { + unlink("$upload_dir/$entry.README"); + print "STALE README: $entry.README\n"; + } + } + } + return (@patches); +} + +#--------------------------------------------------------------- +# Purpose: To move the patches to the proper directory and set +# the permissions correctly. +#--------------------------------------------------------------- +sub movePatches +{ + my (@patches) = @_; + my ($patch) = ""; + my ($fail) = 0; + + if (!(-d "$public_dir")) + { + system("mkdir -p $public_dir"); + system("chown $user.$group $public_dir"); + system("chmod $mode_dir $public_dir"); + } + foreach $patch (@patches) + { + if (-e "$public_dir/$patch.gz") + { + print "Patch exists: $public_dir/$patch.gz\n"; + $fail = 1; + } + if (-e "$public_dir/$patch.README") + { + print "README exists: $public_dir/$patch.README\n"; + $fail = 1; + } + if ($fail == 0) + { + system("mv $upload_dir/$patch.gz $public_dir/$patch.gz"); + system("mv $upload_dir/$patch.README $public_dir/$patch.README"); + system("chown $user.$group $public_dir/*"); + system("chmod $mode_file $public_dir/*"); + open(MAIL, "|mail -s \"Classpath: $patch uploaded\" core\@classpath.org") || die "could not open mail\n"; + print MAIL "GNU Classpath FTP Maintenance\n"; + print MAIL "\n"; + print MAIL "Added Files:\n"; + print MAIL "ftp://ftp.classpath.org/pub/patches/$patch.gz\n"; + print MAIL "ftp://ftp.classpath.org/pub/patches/$patch.README\n\n"; + close(MAIL); + } + } +} diff --git a/libjava/classpath/scripts/sanitize-jsr166 b/libjava/classpath/scripts/sanitize-jsr166 new file mode 100755 index 0000000..d4ca858 --- /dev/null +++ b/libjava/classpath/scripts/sanitize-jsr166 @@ -0,0 +1,6 @@ +#! /bin/sh + +# Sanitize a jsr166 download. + +# Remove code copyright Sun. +find . -name '*.java' -print | xargs grep -l 'Copyright.*Sun' | xargs rm diff --git a/libjava/classpath/scripts/timezones.pl b/libjava/classpath/scripts/timezones.pl new file mode 100755 index 0000000..142ea4b --- /dev/null +++ b/libjava/classpath/scripts/timezones.pl @@ -0,0 +1,366 @@ +#!/usr/bin/perl -w +# Create the timezone tables for java/util/TimeZone from the +# standard timezone sources by Arthur David Olson (as used by glibc) +# +# This needs the files from the package tzdata2000h which may be found +# at ftp://ftp.cs.mu.oz.au/pub/. + +$TIMEZONEDIR = "tzdata"; +@TIMEZONEFILES = ("africa", "antarctica", "asia", "australasia", + "europe", "northamerica", "pacificnew", "southamerica", + "../tzabbrevs"); + +# rules hash table: +# key is a rule name +# value is either "-" (no daylight savings) or a list of three elements: +# $value[0] = end savings rule (list containing MONTH, DAY and TIME) +# $value[1] = start savings rule (ditto) +# $value[2] = daylight offset in milliseconds +my %rules = ("-" => "-"); + +# timezones list, list of pairs: +# $timezones[$i][0] is a timezone name +# $timezones[$i][1] = raw offset in milliseconds +# $timezones[$i][2] = rule in the same format as the value of +# the rules table, but TIME in milliseconds +# $timezones[$i][3] = list of timezone names with this rule (aliases) +my @timezones = ( [ "GMT", 0, "-", [ "GMT", "UTC" ] ]); + + +# parse the offset of form +/-hh:mm:ss (:ss is optional) and return it +# in milliseconds against UTC +sub parseOffset($) { + my $offset = $_[0]; + $offset =~ /^([+-]?)(\d+)(:(\d+)(:(\d+))?)?$/ + or die "Can't parse offset $offset"; + my $seconds = $2 * 3600; + $seconds += $4 * 60 if ($3); + $seconds += $6 if ($3 && $5); + if ($1 eq "-") { + $seconds = - $seconds; + } + return $seconds * 1000; +} + +# parse the time of form +/-hh:mm:ss[swguz] (:ss is optional) and return it +# in milliseconds since midnight in local wall time + my $timezonename; +sub parseTime($$$) { + my ($rawoffset, $stdoffset, $time) = @_; + $time =~ /^([+-]?)(\d+):(\d+)(:(\d+))?([swguz]?)$/ + or die "Can't parse time $time"; + my ($hour, $min) = ($2, $3); + my $sec = ($4) ? $5 : 0; + my $millis = ((($hour * 60) + $min) * 60 + $sec) * 1000; + if ($1 eq "-") { + $millis = -$millis; + } + # Normally millis is in wall time, adjust for utc and standard time. + if ($6 =~ /[guz]/) { + $millis += $rawoffset + $stdoffset; + } elsif ($6 =~ /s/) { + $millis += $stdoffset; + } + return $millis; +} + +my %monthnames = + ( "Jan" => "1", + "Feb" => "2", + "Mar" => "3", + "Apr" => "4", + "May" => "5", + "Jun" => "6", + "Jul" => "7", + "Aug" => "8", + "Sep" => "9", + "Oct" => "10", + "Nov" => "11", + "Dec" => "12" ); +sub parseMonth($) { + my $month = $monthnames{"$_[0]"} or die "Unknown month $_[0]"; + return $month; +} + +my %weekdaynames = + ( "Sun" => "7", + "Mon" => "1", + "Tue" => "2", + "Wed" => "3", + "Thu" => "4", + "Fri" => "5", + "Sat" => "6" ); +sub parseWeekday($) { + my $weekday = $weekdaynames{"$_[0]"} or die "Unknown weekday $_[0]"; + return $weekday; +} + +my @weekdayjavanames = + ( "Calendar.SUNDAY", + "Calendar.MONDAY", + "Calendar.TUESDAY", + "Calendar.WEDNESDAY", + "Calendar.THURSDAY", + "Calendar.FRIDAY", + "Calendar.SATURDAY" ); +my @daysInMonths = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); +sub parseDay($$$) { + my ($dayoffset, $month, $day) = @_; + if ($day =~ /^\d+$/) { + return "$day, 0"; + } elsif ($day =~ /^last([A-Z][a-z][a-z])$/) { + my $weekday = ( parseWeekday($1) + $dayoffset + 7 ) % 7; + if ($dayoffset) { + my $day = $daysInMonths[$month - 1] + $dayoffset; + warn "Can only approximate $day with dayoffset in $file" + if ($month == 2); + return "$day, -$weekdayjavanames[$weekday]"; + } else { + return "-1, $weekdayjavanames[$weekday]"; + } + } elsif ($day =~ /^([A-Z][a-z][a-z])>=(\d+)$/) { + my $start = $2 + $dayoffset; + my $weekday = ( parseWeekday($1) + $dayoffset + 7 ) % 7; + if (($start % 7) == 1) { + $start = ($start + 6) / 7; + return "$start, $weekdayjavanames[$weekday]"; + } else { + return "$start, -$weekdayjavanames[$weekday]"; + } + } else { + die "Unknown day $day"; + } +} + +my @monthjavanames = + ( "Calendar.JANUARY", + "Calendar.FEBRUARY", + "Calendar.MARCH", + "Calendar.APRIL", + "Calendar.MAY", + "Calendar.JUNE", + "Calendar.JULY", + "Calendar.AUGUST", + "Calendar.SEPTEMBER", + "Calendar.OCTOBER", + "Calendar.NOVEMBER", + "Calendar.DECEMBER" ); + +sub parseRule($$$) { + my ($rawoffset, $stdoffset, $rule) = @_; + my $monthnr = parseMonth($rule->[0]); + my $time = parseTime($rawoffset, $stdoffset, $rule->[2]); + my $dayoffset = 0; + while ($time < 0) { + $time += 24*3600*1000; + $dayoffset--; + } + while ($time > 24*3600*1000) { + $time -= 24*3600*1000; + $dayoffset++; + } + $day = parseDay($dayoffset, $monthnr, $rule->[1]); + return [ $monthjavanames[$monthnr-1], $day, $time ]; +} + + +sub ruleEquals($$) { + my ($rule1, $rule2) = @_; + # check month names + return (($rule1->[0] eq $rule2->[0]) + && ($rule1->[1] eq $rule2->[1]) + && ($rule1->[2] == $rule2->[2])); +} + +sub findAlias($$) { + my ($rawoffset, $rule) = @_; + foreach $tz (@timezones) { + my ($key, $tzoffset, $tzrule, $aliaslist) = @{$tz}; + next if ($tzoffset != $rawoffset); + if ($rule eq "-") { + return $tz if ($tzrule eq "-"); + } elsif ($tzrule ne "-") { + next if $rule->[2] != $tzrule->[2]; + if (ruleEquals($rule->[0], $tzrule->[0]) + && ruleEquals($rule->[1], $tzrule->[1])) { + return $tz; + } + } + } + return ""; +} + +sub makePretty($) { + my ($offset) = @_; + if (($offset % 3600) == 0) { + $offset /= 3600; + return "$offset * 3600"; + } else { + return "$offset"; + } +} + +sub tzcompare($$) { + my ($a, $b) = @_; + if (($a =~ /\//) != ($b =~ /\//)) { + return ($a =~ /\//) ? 1 : -1; + } else { + return $a cmp $b; + } +} + +foreach $file (@TIMEZONEFILES) { +# print STDERR "$file\n"; + open INPUT, "$TIMEZONEDIR/$file" or die "Can't open $TIMEZONEDIR/$file"; + my $in_time_zone = 0; + while () { + $_ = $1 if /^([^\#]*)\#/; + next if /^\s*$/; + my @entries = split; +# $, = ","; print "'$_' -> [",@entries,"]\n"; + if (!$in_time_zone) { + if ($entries[0] eq "Rule") { + # check if rule still applies + # column 3 is TO entry. + if ($entries[3] eq "max") { + my $rulename = $entries[1]; + my $month = $entries[5]; + my $day = $entries[6]; + my $time = $entries[7]; + if ($entries[8] eq "0") { + # This is the end time rule + $rules{"$rulename"}[0] = [ $month, $day, $time ]; + } else { + # This is the start time rule + $rules{"$rulename"}[1] = [ $month, $day, $time ]; + $rules{"$rulename"}[2] = parseOffset($entries[8]); + } + } + } elsif ($entries[0] eq "Zone") { + $in_time_zone = 1; + shift @entries; + $timezonename = shift @entries; + } elsif ($entries[0] eq "Remove") { + my $found = 0; + foreach $tz (@timezones) { + my @newaliases; + foreach $tzname (@{$tz->[3]}) { + if ($tzname eq $entries[1]) { + $found = 1; + } else { + push @newaliases, $tzname; + } + } + if ($found) { + if ($tz->[0] eq $entries[1]) { + $tz->[0] = $newaliases[0]; + } + $tz->[3] = \@newaliases; + last; + } + } + + die "Unknown link $_" if ! $found; + } elsif ($entries[0] eq "Link") { + my $alias = 0; + foreach $tz (@timezones) { + foreach $tzname (@{$tz->[3]}) { + if ($tzname eq $entries[1]) { + $alias = $tz; + last; + } + } + } + + die "Unknown link $_" if ! $alias; + die "@entries" if $entries[1] =~ /^\d+$/; + push @{$alias->[3]}, $entries[2]; + } else { + die "Unknown command: $_"; + } + } + if ($in_time_zone) { + die "early end of Zone: $_" if ($entries[0] =~ /^[A-Za-z]+/); + if (@entries <= 3) { +# print "found ZONE $timezonename $entries[0] $entries[1] $entries[2]\n"; + # This is the last line and the only we look at. + # other lines are for historic time zones. + my $rawoffset = parseOffset($entries[0]); + my $rule = $rules{"$entries[1]"} || "-"; + if ($rule ne "-") { + if (!defined($rule->[2])) { + $rule = "-"; + } else { + # now we can parse the time since we know raw offset. + my $savings = $rule->[2]; + my $endrule = parseRule($rawoffset, $savings, + $rule->[0]); + my $startrule = parseRule($rawoffset, $savings, + $rule->[1]); + $rule = [ $endrule, $startrule, $savings ]; +# print "start",@{$rule->[1]}, "end", @{$rule->[0]}, +# "offset", $rule->[2],"\n"; + } + } + my $alias = findAlias($rawoffset, $rule); + if ($alias) { + if (($alias->[0] =~ /\//) + && ($timezonename !~ /\//)) { + # alias is of Country/City form, timezonename not + # make timezonename the real zone name + $alias->[0] = $timezonename; + } + push @{$alias->[3]}, $timezonename; + } else { + push @timezones, [ $timezonename, $rawoffset, $rule, + [ $timezonename ] ]; + } + $in_time_zone = 0; + } + } + } + close INPUT; +} + +@timezones = sort { if ($a->[1] != $b->[1]) { $a->[1] <=> $b->[1] } + else { $a->[0] cmp $b->[0] } } @timezones; +for (@timezones) { + my ($name, $rawoffset, $rule, $aliaslist) = @{$_}; + my @aliases = sort { tzcompare($a, $b); } @{$aliaslist}; + $name = $aliases[0]; + $rawoffset = makePretty($rawoffset); + if ($rule eq "-") { + print <[0]}; + my ($startmonth, $startday, $starttime) = @{$rule->[1]}; + $endtime = makePretty($endtime); + $starttime = makePretty($starttime); + my $savings = $rule->[2]; + if ($savings == 3600 * 1000) { + print < +# +# usage: unicode-blocks.pl +# where is obtained from www.unicode.org (named Blocks-3.txt +# for Unicode version 3.0.0). + + +die "Usage: $0 " unless @ARGV == 1; +open (BLOCKS, $ARGV[0]) || die "Can't open Unicode block file: $!\n"; + +# A hash of added fields and the JDK they were added in, to automatically +# print @since tags. Maintaining this is optional (and tedious), but nice. +my %additions = ("SYRIAC" => "1.4", + "THAANA" => "1.4", + "SINHALA" => "1.4", + "MYANMAR" => "1.4", + "ETHIOPIC" => "1.4", + "CHEROKEE" => "1.4", + "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS" => "1.4", + "OGHAM" => "1.4", + "RUNIC" => "1.4", + "KHMER" => "1.4", + "MONGOLIAN" => "1.4", + "BRAILLE_PATTERNS" => "1.4", + "CJK_RADICALS_SUPPLEMENT" => "1.4", + "KANGXI_RADICALS" => "1.4", + "IDEOGRAPHIC_DESCRIPTION_CHARACTERS" => "1.4", + "BOPOMOFO_EXTENDED" => "1.4", + "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A" => "1.4", + "YI_SYLLABLES" => "1.4", + "YI_RADICALS" => "1.4", + "CYRILLIC_SUPPLEMENTARY" => "1.5", + "TAGALOG" => "1.5", + "HANUNOO" => "1.5", + "BUHID" => "1.5", + "TAGBANWA" => "1.5", + "LIMBU" => "1.5", + "TAI_LE" => "1.5", + "KHMER_SYMBOLS" => "1.5", + "PHONETIC_EXTENSIONS" => "1.5", + "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A" => "1.5", + "SUPPLEMENTAL_ARROWS_A" => "1.5", + "SUPPLEMENTAL_ARROWS_B" => "1.5", + "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B" => "1.5", + "SUPPLEMENTAL_MATHEMATICAL_OPERATORS" => "1.5", + "MISCELLANEOUS_SYMBOLS_AND_ARROWS" => "1.5", + "KATAKANA_PHONETIC_EXTENSIONS" => "1.5", + "YIJING_HEXAGRAM_SYMBOLS" => "1.5", + "VARIATION_SELECTORS" => "1.5", + "LINEAR_B_SYLLABARY" => "1.5", + "LINEAR_B_IDEOGRAMS" => "1.5", + "AEGEAN_NUMBERS" => "1.5", + "OLD_ITALIC" => "1.5", + "GOTHIC" => "1.5", + "UGARITIC" => "1.5", + "DESERET" => "1.5", + "SHAVIAN" => "1.5", + "OSMANYA" => "1.5", + "CYPRIOT_SYLLABARY" => "1.5", + "BYZANTINE_MUSICAL_SYMBOLS" => "1.5", + "MUSICAL_SYMBOLS" => "1.5", + "TAI_XUAN_JING_SYMBOLS" => "1.5", + "MATHEMATICAL_ALPHANUMERIC_SYMBOLS" => "1.5", + "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B" => "1.5", + "CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT" => "1.5", + "TAGS" => "1.5", + "VARIATION_SELECTORS_SUPPLEMENT" => "1.5", + "SUPPLEMENTARY_PRIVATE_USE_AREA_A" => "1.5", + "SUPPLEMENTARY_PRIVATE_USE_AREA_B" => "1.5", + "HIGH_SURROGATES" => "1.5", + "HIGH_PRIVATE_USE_SURROGATES" => "1.5", + "LOW_SURROGATES" => "1.5" + ); + +print <<'EOF'; + /** + * A family of character subsets in the Unicode specification. A character + * is in at most one of these blocks. + * + * This inner class was generated automatically from + * $ARGV[0], by some perl scripts. + * This Unicode definition file can be found on the + * http://www.unicode.org website. + * JDK 1.5 uses Unicode version 4.0.0. + * + * @author scripts/unicode-blocks.pl (written by Eric Blake) + * @since 1.2 + */ + public static final class UnicodeBlock extends Subset + { + /** The start of the subset. */ + private final int start; + + /** The end of the subset. */ + private final int end; + + /** The canonical name of the block according to the Unicode standard. */ + private final String canonicalName; + + /** Enumeration for the forName() method */ + private enum NameType { CANONICAL, NO_SPACES, CONSTANT; }; + + /** + * Constructor for strictly defined blocks. + * + * @param start the start character of the range + * @param end the end character of the range + * @param name the block name + * @param canonicalName the name of the block as defined in the Unicode + * standard. + */ + private UnicodeBlock(int start, int end, String name, + String canonicalName) + { + super(name); + this.start = start; + this.end = end; + this.canonicalName = canonicalName; + } + + /** + * Returns the Unicode character block which a character belongs to. + * Note: This method does not support the use of + * supplementary characters. For such support, of(int) + * should be used instead. + * + * @param ch the character to look up + * @return the set it belongs to, or null if it is not in one + */ + public static UnicodeBlock of(char ch) + { + return of((int) ch); + } + + /** + * Returns the Unicode character block which a code point belongs to. + * + * @param codePoint the character to look up + * @return the set it belongs to, or null if it is not in one. + * @throws IllegalArgumentException if the specified code point is + * invalid. + * @since 1.5 + */ + public static UnicodeBlock of(int codePoint) + { + if (codePoint > MAX_CODE_POINT) + throw new IllegalArgumentException("The supplied integer value is " + + "too large to be a codepoint."); + // Simple binary search for the correct block. + int low = 0; + int hi = sets.length - 1; + while (low <= hi) + { + int mid = (low + hi) >> 1; + UnicodeBlock b = sets[mid]; + if (codePoint < b.start) + hi = mid - 1; + else if (codePoint > b.end) + low = mid + 1; + else + return b; + } + return null; + } + + /** + *

+ * Returns the UnicodeBlock with the given name, as defined + * by the Unicode standard. The version of Unicode in use is defined by + * the Character class, and the names are given in the + * Blocks-.txt file corresponding to that version. + * The name may be specified in one of three ways: + *

+ *
    + *
  1. The canonical, human-readable name used by the Unicode standard. + * This is the name with all spaces and hyphens retained. For example, + * `Basic Latin' retrieves the block, UnicodeBlock.BASIC_LATIN.
  2. + *
  3. The canonical name with all spaces removed e.g. `BasicLatin'.
  4. + *
  5. The name used for the constants specified by this class, which + * is the canonical name with all spaces and hyphens replaced with + * underscores e.g. `BASIC_LATIN'
  6. + *
+ *

+ * The names are compared case-insensitively using the case comparison + * associated with the U.S. English locale. The method recognises the + * previous names used for blocks as well as the current ones. At + * present, this simply means that the deprecated `SURROGATES_AREA' + * will be recognised by this method (the of() methods + * only return one of the three new surrogate blocks). + *

+ * + * @param blockName the name of the block to look up. + * @return the specified block. + * @throws NullPointerException if the blockName is + * null. + * @throws IllegalArgumentException if the name does not match any Unicode + * block. + * @since 1.5 + */ + public static final UnicodeBlock forName(String blockName) + { + NameType type; + if (blockName.indexOf(' ') != -1) + type = NameType.CANONICAL; + else if (blockName.indexOf('_') != -1) + type = NameType.CONSTANT; + else + type = NameType.NO_SPACES; + Collator usCollator = Collator.getInstance(Locale.US); + usCollator.setStrength(Collator.PRIMARY); + /* Special case for deprecated blocks not in sets */ + switch (type) + { + case CANONICAL: + if (usCollator.compare(blockName, "Surrogates Area") == 0) + return SURROGATES_AREA; + break; + case NO_SPACES: + if (usCollator.compare(blockName, "SurrogatesArea") == 0) + return SURROGATES_AREA; + break; + case CONSTANT: + if (usCollator.compare(blockName, "SURROGATES_AREA") == 0) + return SURROGATES_AREA; + break; + } + /* Other cases */ + switch (type) + { + case CANONICAL: + for (UnicodeBlock block : sets) + if (usCollator.compare(blockName, block.canonicalName) == 0) + return block; + break; + case NO_SPACES: + for (UnicodeBlock block : sets) + { + String nsName = block.canonicalName.replaceAll(" ",""); + if (usCollator.compare(blockName, nsName) == 0) + return block; + } + break; + case CONSTANT: + for (UnicodeBlock block : sets) + if (usCollator.compare(blockName, block.toString()) == 0) + return block; + break; + } + throw new IllegalArgumentException("No Unicode block found for " + + blockName + "."); + } +EOF + +my @names = (); +while () { + next if /^\#/; + my ($range, $block) = split(/; /); + my ($start, $end) = split /\.\./, $range; + next unless defined $block; + chomp $block; + $block =~ s/ *$//; + + # Translate new Unicode names which have the old name in Java + $block = "Greek" if $block =~ /Greek and Coptic/; + $block = "Combining Marks for Symbols" + if $block =~ /Combining Diacritical Marks for Symbols/; + + (my $name = $block) =~ tr/a-z -/A-Z__/; + push @names, $name; + my $since = (defined $additions{$name} + ? "\n * \@since $additions{$name}" : ""); + print <HIGH_SURROGATES, + * HIGH_PRIVATE_USE_SURROGATES + * and LOW_SURROGATES, as defined + * by the Unicode standard, should be used in preference to + * this. These are also returned from calls to of(int) + * and of(char). + */ + \@Deprecated + public static final UnicodeBlock SURROGATES_AREA + = new UnicodeBlock(0xD800, 0xDFFF, + "SURROGATES_AREA", + "Surrogates Area"); + + /** + * The defined subsets. + */ + private static final UnicodeBlock sets[] = { +EOF + +foreach (@names) { + print " $_,\n"; +} + +print < +# updated to Unicode 4.0.0 by Anthony Balkissoon +# +# Usage: ./unicode-muncher +# where and are .txt files obtained from +# www.unicode.org (named UnicodeData-4.0.0.txt and SpecialCasing-4.0.0.txt for +# Unicode version 4.0.0), and is the final location for the +# Java interface gnu.java.lang.CharData. +# As of JDK 1.5, use Unicode version 4.0.0 for best results. + +## +## Convert a 16-bit integer to a Java source code String literal character +## +sub javaChar($) { + my ($char) = @_; + die "Out of range: $char\n" if $char < -0x8000 or $char > 0x10ffff; + $char += 0x10000 if $char < 0; + # Special case characters that must be escaped, or are shorter as ASCII + return sprintf("\\%03o", $char) if $char < 0x20; + return "\\\"" if $char == 0x22; + return "\\\\" if $char == 0x5c; + return pack("C", $char) if $char < 0x7f; + return sprintf("\\u%04x", $char); +} + +## +## Convert the text UnicodeData file from www.unicode.org into a Java +## interface with string constants holding the compressed information. +## +my @TYPECODES = qw(Cn Lu Ll Lt Lm Lo Mn Me Mc Nd Nl No Zs Zl Zp Cc Cf + SKIPPED Co Cs Pd Ps Pe Pc Po Sm Sc Sk So Pi Pf); +my @DIRCODES = qw(L R AL EN ES ET AN CS NSM BN B S WS ON LRE LRO RLE RLO PDF); + +my $NOBREAK_FLAG = 32; +my $MIRRORED_FLAG = 64; + +my %special = (); + +# infoArray is an array where each element is a list of character information +# for characters in a plane. The index of each list is equal to the plane +# that it corresponds to even though most of these lists will currently be +# empty. This is done so that that this script can be easily modified to +# accomodate future versions of Unicode. +my @infoArray = \((), (), (), (), (), (), (), (), + (), (), (), (), (), (), (), (), ()); + +# info is a reference to one of the lists in infoArray, depending on which +# plane we're currently parsing. +my $info; + +# titlecase is a string of ordered pairs of characters to store the titlecase +# conversions of characters that have them +my $titlecase = ""; + +# count is simply used to print "." to the screen every so often +my $count = 0; + +# range is used when the UnicodeData file blocks out ranges of code points +my $range = 0; + +# largeNums is an array of numerical values that are too large to fit +# into the 16 bit char where most numerical values are stored. +# What is stored in the char then is a number N such that (-N - 3) is +# the index into largeNums where the numerical value can be found. +my @largeNums = (); + +die "Usage: $0 " + unless @ARGV == 3; +$| = 1; +print "GNU Classpath Unicode Attribute Database Generator 2.1\n"; +print "Copyright (C) 1998, 2002 Free Software Foundation, Inc.\n"; + +################################################################################ +################################################################################ +## Stage 0: Parse the special casing file +print "Parsing special casing file\n"; +open (SPECIAL, "< $ARGV[1]") || die "Can't open special casing file: $!\n"; +while () { + next if /^\#/; + my ($ch, undef, undef, $upper) = split / *; */; + + # This grabs only the special casing for multi-char uppercase. Note that + # there are no multi-char lowercase, and that Sun ignores multi-char + # titlecase rules. This script omits 3 special cases in Unicode 3.0.0, + # which must be hardcoded in java.lang.String: + # \u03a3 (Sun ignores this special case) + # \u0049 - lowercases to \u0131, but only in Turkish locale + # \u0069 - uppercases to \u0130, but only in Turkish locale + next unless defined $upper and $upper =~ / /; + $special{hex $ch} = [map {hex} split ' ', $upper]; +} +close SPECIAL; + +################################################################################ +################################################################################ +## Stage 1: Parse the attribute file +print "Parsing attributes file"; +open (UNICODE, "< $ARGV[0]") || die "Can't open Unicode attribute file: $!\n"; +while () { + print "." unless $count++ % 1000; + chomp; + s/\r//g; + my ($ch, $name, $category, undef, $bidir, $decomp, undef, undef, $numeric, + $mirrored, undef, undef, $upcase, $lowcase, $title) = split ';'; + $ch = hex($ch); + + # plane tells us which Unicode code plane we're currently in and is an + # index into infoArray. + my $plane = int($ch / 0x10000); + my $planeBase = $plane * 0x10000; + $info = \@{$infoArray[$plane]}; + + my ($type, $numValue, $upperchar, $lowerchar, $direction); + + # Set the value of the $type variable, checking to make sure that it's valid + # and setting the mirrored and nobreak bits if necessary. + $type = 0; + while ($category !~ /^$TYPECODES[$type]$/) { + if (++$type == @TYPECODES) { + die "$ch: Unknown type: $category"; + } + } + $type |= $NOBREAK_FLAG if ($decomp =~ /noBreak/); + $type |= $MIRRORED_FLAG if ($mirrored =~ /Y/); + + # Set the value of the $numeric variable checking the special cases of + # large numbers or 'a' - 'z' values. + if ($numeric =~ /^[0-9]+$/) { + $numValue = $numeric; + # If numeric takes more than 16 bits to store we want to store that + # number in a separate array and store a number N in numValue such + # that (-N - 3) is the offset into the separate array containing the + # large numerical value. + if ($numValue >= 0x7fff) { + $numValue = -3 - @largeNums; + push @largeNums, $numeric; + } + } elsif ($numeric eq "") { + # Special case sequences of 'a'-'z' + if ($ch >= 0x0041 && $ch <= 0x005a) { + $numValue = $ch - 0x0037; + } elsif ($ch >= 0x0061 && $ch <= 0x007a) { + $numValue = $ch - 0x0057; + } elsif ($ch >= 0xff21 && $ch <= 0xff3a) { + $numValue = $ch - 0xff17; + } elsif ($ch >= 0xff41 && $ch <= 0xff5a) { + $numValue = $ch - 0xff37; + } else { + $numValue = -1; + } + } else { + $numValue = -2; + } + + # Set the uppercase and lowercase expansions for the character. + $upperchar = $upcase ? hex($upcase) - $ch : 0; + $lowerchar = $lowcase ? hex($lowcase) - $ch : 0; + + # If this character has a special titlecase expansion then append it to + # the titlecase String. + if ($title ne $upcase) { + my $titlechar = $title ? hex($title) : $ch; + $titlecase .= pack("n2", $ch, $titlechar); + } + + # Set the direction variable, use the lower 2 bits as a count of how many + # characters will be added to the String if this character undergoes an + # uppercase expansion. + $direction = 0; + while ($bidir !~ /^$DIRCODES[$direction]$/) { + if (++$direction == @DIRCODES) { + $direction = -1; + last; + } + } + $direction <<= 2; + $direction += $#{$special{$ch}} if defined $special{$ch}; + + # If the UnicodeData file blocks off ranges of code points give them all + # the same character information. + if ($range) { + die "Expecting end of range at $ch\n" unless $name =~ /Last>$/; + for ($range + 1 .. $ch - 1) { + $info->[$_ - $planeBase] = pack("n5", $type, $numValue, $upperchar, + $lowerchar, $direction); + } + $range = 0; + } elsif ($name =~ /First>$/) { + $range = $ch; + } + + # Store all this parsed information into the element in infoArray that info + # points to. + $info->[$ch - $planeBase] = pack("n5", $type, $numValue, $upperchar, $lowerchar, + $direction); +} +close UNICODE; + +################################################################################ +################################################################################ +## Stage 2: Compress the data structures +printf "\nCompressing data structures"; +$count = 0; + +# data is a String that will be used to create the DATA String containing +# character information and offsets into the attribute tables. +my @data = (); + +# charhashArray is an array of hashtables used so that we can reuse character +# attributes when characters share the same attributes ... this makes our +# attribute tables smaller. charhash is a pointer into this array. +my @charhashArray = ({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}); +my $charhash = (); + +# charinfoArray is an array of arrays, one per plane, for storing character +# information. charinfo is a pointer into this array. +my @charinfoArray = \((), (), (), (), (), (), (), (), + (), (), (), (), (), (), (), (), ()); +my $charinfo; + +# charlen is an array, one element per plane, that tells us how many unique +# character attributes there are for that plane. +my @charlen = (); + +for my $plane (0 .. 0x10) { + $info = \@{$infoArray[$plane]}; + my $planeBase = $plane * 0x10000; + $charhash = \%{$charhashArray[$plane]}; + $charinfo = \@{$charinfoArray[$plane]}; + + for my $ch ($planeBase .. $planeBase + 0xffff) { + my $index = $ch - $planeBase; + print "." unless $count++ % 0x1000; + $info->[$index] = pack("n5", 0, -1, 0, 0, -4) unless defined $info->[$index]; + + my ($type, $numVal, $upper, $lower, $direction) = unpack("n5", $info->[$index]); + if (! exists $charhash->{$info->[$index]}) { + # If we entered this loop that means the character we're looking at + # now has attributes that are unique from those that we've looked + # at so far for this plane. So we push its attributes into charinfo + # and store in charhash the offset into charinfo where these + # attributes can later be found. + push @{$charinfo}, [ $numVal, $upper, $lower, $direction ]; + $charhash->{$info->[$index]} = @{$charinfo} - 1; + # When the file is generaged, the number we just stored in charhas + # will be the upper 9 bits in the DATA String that are an offset + # into the attribute tables. + } + $data[$plane] .= pack("n", ($charhash->{$info->[$index]} << 7) | $type); + } + $charlen[$plane] = scalar(@{$charinfoArray[$plane]}); +} + +# the shift that results in the best compression of the table. This is an array +# because different shifts are better for the different tables for each plane. +my @bestshift; + +# an initial guess. +my $bestest = 1000000; +my @bestblkstr; +my @blksize = (); + +for my $plane (0 .. 0x10) { + print "\n\nplane: $plane\n"; + print "Unique character entries: $charlen[$plane]\n"; + $bestest = 1000000; + for my $i (3 .. 8) { + my $blksize = 1 << $i; + my %blocks = (); + my @blkarray = (); + my ($j, $k); + print "shift: $i"; + + for ($j = 0; $j < 0x10000; $j += $blksize) { + my $blkkey = substr $data[$plane], 2 * $j, 2 * $blksize; + if (! exists $blocks{$blkkey}) { + push @blkarray, $blkkey; + $blocks{$blkkey} = $#blkarray; + } + } + + my $blknum = @blkarray; + my $blocklen = $blknum * $blksize; + printf " before %5d", $blocklen; + + # Now we try to pack the blkarray as tight as possible by finding matching + # heads and tails. + for ($j = $blksize - 1; $j > 0; $j--) { + my %tails = (); + for $k (0 .. $#blkarray) { + next unless defined $blkarray[$k]; + my $len = length $blkarray[$k]; + my $tail = substr $blkarray[$k], $len - $j * 2; + if (exists $tails{$tail}) { + push @{$tails{$tail}}, $k; + } else { + $tails{$tail} = [ $k ]; + } + } + + # tails are calculated, now calculate the heads and merge. + BLOCK: + for $k (0 .. $#blkarray) { + next unless defined $blkarray[$k]; + my $tomerge = $k; + while (1) { + my $head = substr($blkarray[$tomerge], 0, $j * 2); + my $entry = $tails{$head}; + next BLOCK unless defined $entry; + + my $other = shift @{$entry}; + if ($other == $tomerge) { + if (@{$entry}) { + push @{$entry}, $other; + $other = shift @{$entry}; + } else { + push @{$entry}, $other; + next BLOCK; + } + } + if (@{$entry} == 0) { + delete $tails{$head}; + } + + # a match was found + my $merge = $blkarray[$other] + . substr($blkarray[$tomerge], $j * 2); + $blocklen -= $j; + $blknum--; + + if ($other < $tomerge) { + $blkarray[$tomerge] = undef; + $blkarray[$other] = $merge; + my $len = length $merge; + my $tail = substr $merge, $len - $j * 2; + $tails{$tail} = [ map { $_ == $tomerge ? $other : $_ } + @{$tails{$tail}} ]; + next BLOCK; + } + $blkarray[$tomerge] = $merge; + $blkarray[$other] = undef; + } + } + } + my $blockstr; + for $k (0 .. $#blkarray) { + $blockstr .= $blkarray[$k] if defined $blkarray[$k]; + } + + die "Unexpected $blocklen" if length($blockstr) != 2 * $blocklen; + my $estimate = 2 * $blocklen + (0x20000 >> $i); + + printf " after merge %5d: %6d bytes\n", $blocklen, $estimate; + if ($estimate < $bestest) { + $bestest = $estimate; + $bestshift[$plane] = $i; + $bestblkstr[$plane] = $blockstr; + } + } + $blksize[$plane] = 1 << $bestshift[$plane]; + print "best shift: ", $bestshift[$plane]; + print " blksize: ", $blksize[$plane]; +} +my @blocksArray = \((), (), (), (), (), (), (), (), + (), (), (), (), (), (), (), (), ()); + +for my $plane (0 .. 0x10) { + for (my $j = 0; $j < 0x10000; $j += $blksize[$plane]) { + my $blkkey = substr $data[$plane], 2 * $j, 2 * $blksize[$plane]; + my $index = index $bestblkstr[$plane], $blkkey; + while ($index & 1) { + die "not found: $j" if $index == -1; + $index = index $bestblkstr[$plane], $blkkey, $index + 1; + } + push @{$blocksArray[$plane]}, ($index / 2 - $j) & 0xffff; + } +} + +################################################################################ +################################################################################ +## Stage 3: Generate the file +for my $plane (0 .. 0x10) { + die "UTF-8 limit of blocks may be exceeded for plane $plane: " . scalar(@{$blocksArray[$plane]}) . "\n" + if @{$blocksArray[$plane]} > 0xffff / 3; + die "UTF-8 limit of data may be exceeded for plane $plane: " . length($bestblkstr[$plane]) . "\n" + if length($bestblkstr[$plane]) > 0xffff / 3; +} + +{ + print "\nGenerating $ARGV[2]."; + my ($i, $j); + + open OUTPUT, "> $ARGV[2]" or die "Failed creating output file: $!\n"; + print OUTPUT <$ARGV[0] and + * $ARGV[1], by some + * perl scripts. These Unicode definition files can be found on the + * http://www.unicode.org website. + * JDK 1.5 uses Unicode version 4.0.0. + * + * The data is stored as string constants, but Character will convert these + * Strings to their respective char[] components. The fields + * are stored in arrays of 17 elements each, one element per Unicode plane. + * BLOCKS stores the offset of a block of 2SHIFT + * characters within DATA. The DATA field, in turn, stores + * information about each character in the low order bits, and an offset + * into the attribute tables UPPER, LOWER, + * NUM_VALUE, and DIRECTION. Notice that the + * attribute tables are much smaller than 0xffff entries; as many characters + * in Unicode share common attributes. Numbers that are too large to fit + * into NUM_VALUE as 16 bit chars are stored in LARGENUMS and a number N is + * stored in NUM_VALUE such that (-N - 3) is the offset into LARGENUMS for + * the particular character. The DIRECTION table also contains a field for + * detecting characters with multi-character uppercase expansions. + * Next, there is a listing for TITLE exceptions (most characters + * just have the same title case as upper case). Finally, there are two + * tables for multi-character capitalization, UPPER_SPECIAL + * which lists the characters which are special cased, and + * UPPER_EXPAND, which lists their expansion. + * + * \@author scripts/unicode-muncher.pl (written by Jochen Hoenicke, + * Eric Blake) + * \@see Character + * \@see String + */ +public interface CharData +{ + /** + * The Unicode definition file that was parsed to build this database. + */ + String SOURCE = \"$ARGV[0]\"; + + /** + * The character shift amount to look up the block offset. In other words, + * (char) (BLOCKS.value[ch >> SHIFT[p]] + ch) is the index + * where ch is described in DATA if ch + * is in Unicode plane p. Note that p is simply + * the integer division of ch and 0x10000. + */ + int[] SHIFT +EOF + for ($i = 0; $i < @bestshift - 1; $i++) { + if ($i == 0){ + print OUTPUT " = new int[] {"; + } + print OUTPUT $bestshift[$i], ", "; + } + if (scalar(@bestshift) > 0){ + print OUTPUT $bestshift[-1], "}"; + } + else { + print OUTPUT " = null"; + } + print OUTPUT <DATA. + * Each entry has been adjusted so that the 16-bit sum with the desired + * character gives the actual index into DATA. + */ + String[] BLOCKS = new String[]{ +EOF + for ($plane = 0; $plane <= 0x10; $plane++) { + # The following if statement handles the cases of unassigned planes + # specially so we don't waste space with unused Strings. As of + # Unicode version 4.0.0 only planes 0, 1, 2, and 14 are used. If + # you are updating this script to work with a later version of + # Unicode you may have to alter this if statement. + if ($plane > 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + for ($i = 0; $i < @{$blocksArray[$plane]} / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if @{$blocksArray[$plane]} <= $i * 11 + $j; + my $val = $blocksArray[$plane]->[$i * 11 + $j]; + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT < 0){ + print OUTPUT $largeNums[-1], "}"; + } + else { + print OUTPUT " = null"; + } + print OUTPUT < 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + my $len = length($bestblkstr[$plane]) / 2; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = unpack "n", substr($bestblkstr[$plane], 2 * ($i * 11 + $j), 2); + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT < 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + $len = @{$charinfoArray[$plane]}; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = $charinfoArray[$plane]->[$i * 11 + $j][0]; + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT < 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + $len = @{$charinfoArray[$plane]}; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = $charinfoArray[$plane]->[$i * 11 + $j][1]; + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT < 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + $len = @{$charinfoArray[$plane]}; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = $charinfoArray[$plane]->[$i * 11 + $j][2]; + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT < 2 && $plane != 14) { + print OUTPUT ($plane == 0x10) ? " \"\"}" : " \"\",\n\n"; + } + else { + $len = @{$charinfoArray[$plane]}; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + " : " "; + print OUTPUT "\""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = $charinfoArray[$plane]->[$i * 11 + $j][3]; + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + print OUTPUT ",\n\n"; + } + } + print OUTPUT <UPPER to determine their titlecase). The listing + * is a sorted sequence of character pairs; converting the first character + * of the pair to titlecase produces the second character. + */ + String TITLE +EOF + + $len = length($titlecase) / 2; + for ($i = 0; $i < $len / 11; $i++) { + print OUTPUT $i ? "\n + \"" : " = \""; + for $j (0 .. 10) { + last if $len <= $i * 11 + $j; + my $val = unpack "n", substr($titlecase, 2 * ($i * 11 + $j), 2); + print OUTPUT javaChar($val); + } + print OUTPUT "\""; + } + + print OUTPUT < $b} keys %special; + my $expansion = ""; + my $offset = 0; + $len = @list; + for ($i = 0; $i < $len / 5; $i++) { + print OUTPUT $i ? "\n + \"" : " = \""; + for $j (0 .. 4) { + last if $len <= $i * 5 + $j; + my $ch = $list[$i * 5 + $j]; + print OUTPUT javaChar($ch); + print OUTPUT javaChar($offset); + $offset += @{$special{$ch}}; + $expansion .= pack "n*", @{$special{$ch}}; + } + print OUTPUT "\""; + } + + print OUTPUT <