aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/java/ChangeLog4
-rw-r--r--gcc/java/gjavah.c11
2 files changed, 11 insertions, 4 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 87e6f4c..dc1d3e0 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,7 @@
+2000-04-19 Tom Tromey <tromey@cygnus.com>
+
+ * gjavah.c (cxx_keyword_subst): Avoid potential infinite loop.
+
2000-04-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (maybe_make_nested_class_name): Use `obstack_grow0'.
diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c
index 0ee85a5..4c6d81d 100644
--- a/gcc/java/gjavah.c
+++ b/gcc/java/gjavah.c
@@ -407,12 +407,15 @@ cxx_keyword_subst (str, length)
{
int last = sizeof (cxx_keywords) / sizeof (const char *);
int first = 0;
- int mid, r;
+ int mid = (last + first) / 2;
+ int old = -1;
- while (last != first)
+ for (mid = (last + first) / 2;
+ mid != old;
+ old = mid, mid = (last + first) / 2)
{
- mid = (last + first) / 2;
- r = utf8_cmp (str, length, cxx_keywords[mid]);
+ int r = utf8_cmp (str, length, cxx_keywords[mid]);
+
if (r == 0)
{
char *str = xmalloc (9 + strlen (cxx_keywords[mid]));