aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jcf-io.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-02-03 19:09:54 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-02-03 19:09:54 +0000
commitd8b6d4cf4005460d0da2f5e115fb11489cdb1919 (patch)
tree4fe32e02624ca48f176d330fca2479e978a28c61 /gcc/java/jcf-io.c
parent2c2f0e546b8b1b1f2f2f6ef4668adf44fa5e9164 (diff)
downloadgcc-d8b6d4cf4005460d0da2f5e115fb11489cdb1919.zip
gcc-d8b6d4cf4005460d0da2f5e115fb11489cdb1919.tar.gz
gcc-d8b6d4cf4005460d0da2f5e115fb11489cdb1919.tar.bz2
* jcf-io.c (jcf_print_utf8_replace): Handle UTF-8 input.
From-SVN: r31779
Diffstat (limited to 'gcc/java/jcf-io.c')
-rw-r--r--gcc/java/jcf-io.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c
index 0f65023..869bc00 100644
--- a/gcc/java/jcf-io.c
+++ b/gcc/java/jcf-io.c
@@ -1,5 +1,5 @@
/* Utility routines for finding and reading Java(TM) .class files.
- Copyright (C) 1996, 97-98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1996, 97-98, 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -505,11 +505,15 @@ DEFUN(jcf_print_utf8_replace, (stream, str, length, in_char, out_char),
FILE *stream AND const unsigned char *str AND int length
AND int in_char AND int out_char)
{
-
- int i;/* FIXME - actually handle Unicode! */
- for (i = 0; i < length; i++)
+ const unsigned char *limit = str + length;
+ while (str < limit)
{
- int ch = str[i];
+ int ch = UTF8_GET (str, limit);
+ if (ch < 0)
+ {
+ fprintf (stream, "\\<invalid>");
+ return;
+ }
jcf_print_char (stream, ch == in_char ? out_char : ch);
}
}