Commit 64e68197 by Bryce McKinlay Committed by Bryce McKinlay

gjavah.c (throwable_p): Accept argument as either a classname or signature fragment.

	* gjavah.c (throwable_p): Accept argument as either a classname or
	signature fragment. Create null-terminated classname string for super
	when calling itself recursively.
	(decode_signature_piece): Skip first character from class name
	signature when calling throwable_p.

From-SVN: r54427
parent 42722871
2002-06-10 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* gjavah.c (throwable_p): Accept argument as either a classname or
signature fragment. Create null-terminated classname string for super
when calling itself recursively.
(decode_signature_piece): Skip first character from class name
signature when calling throwable_p.
2002-06-08 H.J. Lu (hjl@gnu.org) 2002-06-08 H.J. Lu (hjl@gnu.org)
* jcf-path.c (jcf_path_init): Allocate 1 more byte for string. * jcf-path.c (jcf_path_init): Allocate 1 more byte for string.
......
...@@ -1104,11 +1104,12 @@ gcjh_streq (p1, p2) ...@@ -1104,11 +1104,12 @@ gcjh_streq (p1, p2)
return ! strcmp ((char *) p1, (char *) p2); return ! strcmp ((char *) p1, (char *) p2);
} }
/* Return 1 if the initial (L<classname>;) part of SIGNATURE names a /* Return 1 if the initial part of CLNAME names a subclass of throwable,
subclass of throwable, or 0 if not. */ or 0 if not. CLNAME may be extracted from a signature, and can be
terminated with either `;' or NULL. */
static int static int
throwable_p (signature) throwable_p (clname)
const unsigned char *signature; const unsigned char *clname;
{ {
int length; int length;
unsigned char *current; unsigned char *current;
...@@ -1148,12 +1149,12 @@ throwable_p (signature) ...@@ -1148,12 +1149,12 @@ throwable_p (signature)
init_done = 1; init_done = 1;
} }
for (length = 0; signature[length] != ';'; ++length) for (length = 0; clname[length] != ';' && clname[length] != '\0'; ++length)
; ;
current = (unsigned char *) ALLOC (length); current = (unsigned char *) ALLOC (length);
for (i = 1; signature[i] != ';'; ++i) for (i = 0; i < length; ++i)
current[i - 1] = signature[i] == '/' ? '.' : signature[i]; current[i] = clname[i] == '/' ? '.' : clname[i];
current[i - 1] = '\0'; current[length] = '\0';
/* We don't compute the hash slot here because the table might be /* We don't compute the hash slot here because the table might be
modified by the recursion. In that case the slot could be modified by the recursion. In that case the slot could be
...@@ -1166,6 +1167,8 @@ throwable_p (signature) ...@@ -1166,6 +1167,8 @@ throwable_p (signature)
{ {
JCF jcf; JCF jcf;
PTR *slot; PTR *slot;
unsigned char *super, *tmp;
int super_length = -1;
const char *classfile_name = find_class (current, strlen (current), const char *classfile_name = find_class (current, strlen (current),
&jcf, 0); &jcf, 0);
...@@ -1185,7 +1188,12 @@ throwable_p (signature) ...@@ -1185,7 +1188,12 @@ throwable_p (signature)
} }
jcf_parse_class (&jcf); jcf_parse_class (&jcf);
result = throwable_p (super_class_name (&jcf, NULL)); tmp = (unsigned char *) super_class_name (&jcf, &super_length);
super = (unsigned char *) ALLOC (super_length + 1);
memcpy (super, tmp, super_length);
super[super_length] = '\0';
result = throwable_p (super);
slot = htab_find_slot (result ? throw_hash : non_throw_hash, slot = htab_find_slot (result ? throw_hash : non_throw_hash,
current, INSERT); current, INSERT);
*slot = current; *slot = current;
...@@ -1317,7 +1325,8 @@ decode_signature_piece (stream, signature, limit, need_space) ...@@ -1317,7 +1325,8 @@ decode_signature_piece (stream, signature, limit, need_space)
else if (! strncmp (signature, "Ljava/lang/Class;", else if (! strncmp (signature, "Ljava/lang/Class;",
sizeof ("Ljava/lang/Class;") - 1)) sizeof ("Ljava/lang/Class;") - 1))
ctype = "jclass"; ctype = "jclass";
else if (throwable_p (signature)) /* Skip leading 'L' for throwable_p call. */
else if (throwable_p (signature + 1))
ctype = "jthrowable"; ctype = "jthrowable";
else else
ctype = "jobject"; ctype = "jobject";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment