0N/A#! /bin/sh
0N/A
0N/A#
2362N/A# Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
2362N/A# by Oracle in the LICENSE file that accompanied this code.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A# Generate a charset provider class
0N/A
0N/A# Required environment variables
0N/A# NAWK awk tool
0N/A# TEMPDIR temporary directory
0N/A# HASHER Hasher program
0N/A
0N/ASPEC=$1; shift
0N/ADST=$1; shift
0N/A
0N/Aeval `$NAWK <$SPEC '
2366N/A /^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; }
0N/A /^[ \t]*package / { printf "PKG=%s\n", $2; }
0N/A /^[ \t]*class / { printf "CLASS=%s\n", $2; }
0N/A'`
0N/A
0N/AOUT=$DST/$CLASS.java
0N/Aecho '-->' $OUT
0N/A
0N/A
0N/A# Header
0N/A#
0N/A
6N/A$SH ./addNotices.sh "$COPYRIGHT_YEARS" > $OUT
0N/A
0N/Acat <<__END__ >>$OUT
0N/A
0N/A// -- This file was mechanically generated: Do not edit! -- //
0N/A
0N/Apackage $PKG;
0N/A
0N/Aimport java.nio.charset.*;
0N/A
0N/A
0N/Apublic class $CLASS
0N/A extends FastCharsetProvider
0N/A{
0N/A
0N/A__END__
0N/A
0N/A
0N/A# Alias tables
0N/A#
0N/A$NAWK <$SPEC >>$OUT '
0N/A BEGIN { n = 1; m = 1; }
0N/A
0N/A /^[ \t]*charset / {
0N/A csn = $2; cln = $3;
0N/A lcsn = tolower(csn);
0N/A lcsns[n++] = lcsn;
0N/A csns[lcsn] = csn;
0N/A classMap[lcsn] = cln;
0N/A if (n > 2)
0N/A printf " };\n\n";
0N/A printf " static final String[] aliases_%s = new String[] {\n", cln;
0N/A }
0N/A
0N/A /^[ \t]*alias / {
0N/A acsns[m++] = tolower($2);
0N/A aliasMap[tolower($2)] = lcsn;
0N/A printf " \"%s\",\n", $2;
0N/A }
0N/A
0N/A END {
0N/A printf " };\n\n";
0N/A }
0N/A'
0N/A
0N/A
0N/A# Prehashed alias and class maps
0N/A#
0N/A$NAWK <$SPEC >$TEMPDIR/aliases '
0N/A /^[ \t]*charset / {
0N/A csn = $2;
0N/A lcsn = tolower(csn);
0N/A }
0N/A /^[ \t]*alias / {
0N/A an = tolower($2);
0N/A printf "%-20s \"%s\"\n", an, lcsn;
0N/A }
0N/A'
0N/A
0N/A$NAWK <$SPEC >$TEMPDIR/classes '
0N/A /^[ \t]*charset / {
0N/A csn = $2; cln = $3;
0N/A lcsn = tolower(csn);
0N/A printf "%-20s \"%s\"\n", lcsn, cln;
0N/A }
0N/A'
0N/A
0N/A${HASHER} -i Aliases <$TEMPDIR/aliases >>$OUT
0N/A${HASHER} -i Classes <$TEMPDIR/classes >>$OUT
0N/A${HASHER} -i -e Cache -t Charset <$TEMPDIR/classes >>$OUT
0N/A
0N/A
0N/A# Constructor
0N/A#
0N/Acat <<__END__ >>$OUT
0N/A public $CLASS() {
0N/A super("$PKG", new Aliases(), new Classes(), new Cache());
0N/A }
0N/A
0N/A}
0N/A__END__