Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/scripts/genCharsetProvider.sh
32280 views
#! /bin/sh12#3# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation. Oracle designates this9# particular file as subject to the "Classpath" exception as provided10# by Oracle in the LICENSE file that accompanied this code.11#12# This code is distributed in the hope that it will be useful, but WITHOUT13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or14# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License15# version 2 for more details (a copy is included in the LICENSE file that16# accompanied this code).17#18# You should have received a copy of the GNU General Public License version19# 2 along with this work; if not, write to the Free Software Foundation,20# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.21#22# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA23# or visit www.oracle.com if you need additional information or have any24# questions.25#2627# Generate a charset provider class2829# Required environment variables30# NAWK awk tool31# TEMPDIR temporary directory32# HASHER Hasher program3334SPEC=$1; shift35DST=$1; shift3637eval `$NAWK <$SPEC '38/^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; }39/^[ \t]*package / { printf "PKG=%s\n", $2; }40/^[ \t]*class / { printf "CLASS=%s\n", $2; }41'`4243OUT=$DST/$CLASS.java44echo '-->' $OUT454647# Header48#4950$SH ${SCRIPTS}/addNotices.sh "$COPYRIGHT_YEARS" > $OUT5152cat <<__END__ >>$OUT5354// -- This file was mechanically generated: Do not edit! -- //5556package $PKG;5758import java.nio.charset.*;596061public class $CLASS62extends FastCharsetProvider63{6465__END__666768# Alias tables69#70$NAWK <$SPEC >>$OUT '71BEGIN { n = 1; m = 1; }7273/^[ \t]*charset / {74csn = $2; cln = $3;75lcsn = tolower(csn);76lcsns[n++] = lcsn;77csns[lcsn] = csn;78classMap[lcsn] = cln;79if (n > 2)80printf " };\n\n";81printf " static final String[] aliases_%s = new String[] {\n", cln;82}8384/^[ \t]*alias / {85acsns[m++] = tolower($2);86aliasMap[tolower($2)] = lcsn;87printf " \"%s\",\n", $2;88}8990END {91printf " };\n\n";92}93'949596# Prehashed alias and class maps97#98$NAWK <$SPEC >$TEMPDIR/aliases '99/^[ \t]*charset / {100csn = $2;101lcsn = tolower(csn);102}103/^[ \t]*alias / {104an = tolower($2);105printf "%-20s \"%s\"\n", an, lcsn;106}107'108109$NAWK <$SPEC >$TEMPDIR/classes '110/^[ \t]*charset / {111csn = $2; cln = $3;112lcsn = tolower(csn);113printf "%-20s \"%s\"\n", lcsn, cln;114}115'116117${HASHER} -i Aliases <$TEMPDIR/aliases >>$OUT118${HASHER} -i Classes <$TEMPDIR/classes >>$OUT119${HASHER} -i -e Cache -t Charset <$TEMPDIR/classes >>$OUT120121122# Constructor123#124cat <<__END__ >>$OUT125public $CLASS() {126super("$PKG", new Aliases(), new Classes(), new Cache());127}128129}130__END__131132133