encodings.pl: New file.

* scripts/encodings.pl: New file.
	* Makefile.in: Rebuilt.
	* Makefile.am (convert_source_files): Added IOConverter.java.
	* gnu/gcj/convert/UnicodeToBytes.java (UnicodeToBytes): Extend
	IOConverter.
	(getDefaultDecodingClass): Canonicalize default encoding name.
	(getEncoder): Likewise.
	* gnu/gcj/convert/BytesToUnicode.java (BytesToUnicode): Extend
	IOConverter.
	(getDefaultDecodingClass): Canonicalize default encoding name.
	(getDecoder): Likewise.
	* gnu/gcj/convert/IOConverter.java: New file.

From-SVN: r35432
This commit is contained in:
Tom Tromey 2000-08-02 19:56:53 +00:00 committed by Tom Tromey
parent 5f51a7528f
commit f9427d1704
7 changed files with 186 additions and 30 deletions

View File

@ -1,3 +1,18 @@
2000-08-02 Tom Tromey <tromey@cygnus.com>
* scripts/encodings.pl: New file.
* Makefile.in: Rebuilt.
* Makefile.am (convert_source_files): Added IOConverter.java.
* gnu/gcj/convert/UnicodeToBytes.java (UnicodeToBytes): Extend
IOConverter.
(getDefaultDecodingClass): Canonicalize default encoding name.
(getEncoder): Likewise.
* gnu/gcj/convert/BytesToUnicode.java (BytesToUnicode): Extend
IOConverter.
(getDefaultDecodingClass): Canonicalize default encoding name.
(getDecoder): Likewise.
* gnu/gcj/convert/IOConverter.java: New file.
2000-08-02 Bryce McKinlay <bryce@albatross.co.nz>
* interpret.cc (_Jv_InterpMethod::continue1): Type of `fun' changed

View File

@ -473,6 +473,7 @@ gnu/gcj/convert/Input_JavaSrc.java \
gnu/gcj/convert/Input_SJIS.java \
gnu/gcj/convert/Input_UTF8.java \
gnu/gcj/convert/Input_iconv.java \
gnu/gcj/convert/IOConverter.java \
gnu/gcj/convert/Output_8859_1.java \
gnu/gcj/convert/Output_EUCJIS.java \
gnu/gcj/convert/Output_JavaSrc.java \
@ -494,8 +495,8 @@ java/awt/AWTEventMulticaster.java \
java/awt/AWTException.java \
java/awt/ActiveEvent.java \
java/awt/Adjustable.java \
java/awt/Button.java \
java/awt/BorderLayout.java \
java/awt/Button.java \
java/awt/CheckboxGroup.java \
java/awt/Color.java \
java/awt/Component.java \

View File

@ -115,31 +115,48 @@ here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@TESTSUBDIR_TRUE@SUBDIRS = \
@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = \
@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = \
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = \
@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = \
@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
toolexeclib_LTLIBRARIES = libgcj.la
toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.zip
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
@NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
@NEEDS_DATA_START_TRUE@libgcjdata.c
@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
@NATIVE_TRUE@bin_PROGRAMS = \
@NATIVE_TRUE@jv-convert gij
bin_SCRIPTS = addr2name.awk
@CANADIAN_TRUE@@NULL_TARGET_TRUE@GCJ = @CANADIAN_TRUE@@NULL_TARGET_TRUE@gcj
@CANADIAN_TRUE@@NULL_TARGET_FALSE@GCJ = @CANADIAN_TRUE@@NULL_TARGET_FALSE@$(target_alias)-gcj
@CANADIAN_FALSE@GCJ = @CANADIAN_FALSE@$(expanded)/gcj$(EXEEXT) -B$(expanded)/
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_FALSE@expanded = @CANADIAN_FALSE@`cd $(MULTIBUILDTOP)../$(COMPPATH)/gcc && pwd`
@CANADIAN_TRUE@@NULL_TARGET_TRUE@GCJ = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@gcj
@CANADIAN_TRUE@@NULL_TARGET_FALSE@GCJ = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@$(target_alias)-gcj
@CANADIAN_FALSE@GCJ = \
@CANADIAN_FALSE@$(expanded)/gcj$(EXEEXT) -B$(expanded)/
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
@CANADIAN_FALSE@ZIP = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@GCJH = \
@CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_FALSE@expanded = \
@CANADIAN_FALSE@`cd $(MULTIBUILDTOP)../$(COMPPATH)/gcc && pwd`
GCJCOMPILE = CLASSPATH=$(here) $(LIBTOOL) --mode=compile $(GCJ) -fassume-compiled -L$(here) $(JC1FLAGS) -c
GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
@ -153,8 +170,10 @@ WARNINGS = -W -Wall
AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fasynchronous-exceptions \
@LIBGCJ_CXXFLAGS@ @EXCEPTIONSPEC@ $(WARNINGS) -D_GNU_SOURCE
@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
@USING_GCC_TRUE@AM_CFLAGS = \
@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = \
@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
@ -206,7 +225,8 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
@ -250,6 +270,7 @@ gnu/gcj/convert/Input_JavaSrc.java \
gnu/gcj/convert/Input_SJIS.java \
gnu/gcj/convert/Input_UTF8.java \
gnu/gcj/convert/Input_iconv.java \
gnu/gcj/convert/IOConverter.java \
gnu/gcj/convert/Output_8859_1.java \
gnu/gcj/convert/Output_EUCJIS.java \
gnu/gcj/convert/Output_JavaSrc.java \
@ -270,8 +291,8 @@ java/awt/AWTEventMulticaster.java \
java/awt/AWTException.java \
java/awt/ActiveEvent.java \
java/awt/Adjustable.java \
java/awt/Button.java \
java/awt/BorderLayout.java \
java/awt/Button.java \
java/awt/CheckboxGroup.java \
java/awt/Color.java \
java/awt/Component.java \
@ -992,7 +1013,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/defineclass.P .deps/exception.P .deps/gij.P \
.deps/gnu/gcj/RawData.P .deps/gnu/gcj/awt/BitMaskExtent.P \
.deps/gnu/gcj/awt/Buffers.P .deps/gnu/gcj/convert/BytesToUnicode.P \
.deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/Input_8859_1.P \
.deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/IOConverter.P \
.deps/gnu/gcj/convert/Input_8859_1.P \
.deps/gnu/gcj/convert/Input_EUCJIS.P \
.deps/gnu/gcj/convert/Input_JavaSrc.P \
.deps/gnu/gcj/convert/Input_SJIS.P .deps/gnu/gcj/convert/Input_UTF8.P \
@ -1765,7 +1787,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

View File

@ -8,7 +8,7 @@ details. */
package gnu.gcj.convert;
public abstract class BytesToUnicode
public abstract class BytesToUnicode extends IOConverter
{
/** Buffer to read bytes from.
* The characters inbuffer[inpos] ... inbuffer[inlength-1] are available. */
@ -25,7 +25,7 @@ public abstract class BytesToUnicode
// Test (defaultDecodingClass == null) again in case of race condition.
if (defaultDecodingClass == null)
{
String encoding = System.getProperty("file.encoding");
String encoding = canonicalize (System.getProperty("file.encoding"));
String className = "gnu.gcj.convert.Input_"+encoding;
try
{
@ -60,7 +60,7 @@ public abstract class BytesToUnicode
public static BytesToUnicode getDecoder (String encoding)
throws java.io.UnsupportedEncodingException
{
String className = "gnu.gcj.convert.Input_"+encoding;
String className = "gnu.gcj.convert.Input_" + canonicalize (encoding);
Class decodingClass;
try
{
@ -71,6 +71,8 @@ public abstract class BytesToUnicode
{
try
{
// We pass the original name to iconv and let it handle
// its own aliasing.
return new Input_iconv (encoding);
}
catch (Throwable _)

View File

@ -0,0 +1,52 @@
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* This is a base class that handles aliasing issues for
UnicodeToBytes to BytesToUnicode. */
package gnu.gcj.convert;
import java.util.Hashtable;
public abstract class IOConverter
{
// Map encoding aliases to our canonical form.
static private Hashtable hash = new Hashtable ();
static
{
// Manually maintained aliases. Note that the value must be our
// canonical name.
hash.put ("ISO-Latin-1", "8859_1");
// All aliases after this point are automatically generated by the
// `encodings.pl' script. Run it to make any corrections.
hash.put ("ISO_8859-1:1987", "8859_1");
hash.put ("iso-ir-100", "8859_1");
hash.put ("ISO_8859-1", "8859_1");
hash.put ("ISO-8859-1", "8859_1");
hash.put ("latin1", "8859_1");
hash.put ("l1", "8859_1");
hash.put ("IBM819", "8859_1");
hash.put ("CP819", "8859_1");
hash.put ("csISOLatin1", "8859_1");
hash.put ("UTF-8", "UTF8");
hash.put ("Shift_JIS", "SJIS");
hash.put ("MS_Kanji", "SJIS");
hash.put ("csShiftJIS", "SJIS");
hash.put ("Extended_UNIX_Code_Packed_Format_for_Japanese", "EUCJIS");
hash.put ("csEUCPkdFmtJapanese", "EUCJIS");
hash.put ("EUC-JP", "EUCJIS");
}
// Turn an alias into the canonical form.
protected static final String canonicalize (String name)
{
String c = (String) hash.get (name);
return c == null ? name : c;
}
}

View File

@ -8,7 +8,7 @@ details. */
package gnu.gcj.convert;
public abstract class UnicodeToBytes
public abstract class UnicodeToBytes extends IOConverter
{
/** Buffer to emit bytes to.
* The locations buf[count] ... buf[buf.length-1] are available. */
@ -22,7 +22,7 @@ public abstract class UnicodeToBytes
// Test (defaultEncodingClass == null) again in case of race condition.
if (defaultEncodingClass == null)
{
String encoding = System.getProperty("file.encoding");
String encoding = canonicalize (System.getProperty("file.encoding"));
String className = "gnu.gcj.convert.Output_"+encoding;
try
{
@ -58,7 +58,7 @@ public abstract class UnicodeToBytes
public static UnicodeToBytes getEncoder (String encoding)
throws java.io.UnsupportedEncodingException
{
String className = "gnu.gcj.convert.Output_"+encoding;
String className = "gnu.gcj.convert.Output_" + canonicalize (encoding);
Class encodingClass;
try
{
@ -69,6 +69,8 @@ public abstract class UnicodeToBytes
{
try
{
// We pass the original name to iconv and let it handle
// its own aliasing.
return new Output_iconv (encoding);
}
catch (Throwable _)

View File

@ -0,0 +1,62 @@
# encodings.pl - Download IANA text and compute alias list.
# Assumes you are running this program from gnu/gcj/convert/.
# Output suitable for direct inclusion in IOConverter.java.
# Map IANA canonical names onto our canonical names.
%map = (
'ISO_8859-1:1987' => '8859_1',
'UTF-8' => 'UTF8',
'Shift_JIS' => 'SJIS',
'Extended_UNIX_Code_Packed_Format_for_Japanese' => 'EUCJIS'
);
if ($ARGV[0] eq '')
{
$file = 'character-sets';
if (! -f $file)
{
# Too painful to figure out how to get Perl to do it.
system 'wget -o .wget-log http://www.isi.edu/in-notes/iana/assignments/character-sets';
}
}
else
{
$file = $ARGV[0];
}
open (INPUT, "< $file") || die "couldn't open $file: $!";
$body = 0;
$current = '';
while (<INPUT>)
{
chop;
$body = 1 if /^Name:/;
next unless $body;
if (/^$/)
{
$current = '';
next;
}
($type, $name) = split (/\s+/);
if ($type eq 'Name:')
{
$current = $map{$name};
if ($current)
{
print " hash.put (\"$name\", \"$current\");\n";
}
}
elsif ($type eq 'Alias:')
{
# The IANA list has some ugliness.
if ($name ne '' && $name ne 'NONE' && $current)
{
print " hash.put (\"$name\", \"$current\");\n";
}
}
}
close (INPUT);