aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/gjavah.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-11-04 04:56:25 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-11-04 04:56:25 +0000
commit0160fbe1508e18e4ff7b50822b3620f69cffe400 (patch)
treeb9112af0216cc95c9d4df1196c09dc07277d8cf7 /gcc/java/gjavah.c
parentf132f529e0f604f68eef0aa780b86dabeb00d964 (diff)
downloadgcc-0160fbe1508e18e4ff7b50822b3620f69cffe400.zip
gcc-0160fbe1508e18e4ff7b50822b3620f69cffe400.tar.gz
gcc-0160fbe1508e18e4ff7b50822b3620f69cffe400.tar.bz2
class.c (cxx_keyword_p): Accept keywords with trailing `$'s.
* class.c (cxx_keyword_p): Accept keywords with trailing `$'s. * gjavah.c (cxx_keyword_subst): Handle any number of trailing `$'. From-SVN: r37243
Diffstat (limited to 'gcc/java/gjavah.c')
-rw-r--r--gcc/java/gjavah.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c
index 6aabf1c..f49b717 100644
--- a/gcc/java/gjavah.c
+++ b/gcc/java/gjavah.c
@@ -440,16 +440,32 @@ cxx_keyword_subst (str, length)
mid != old;
old = mid, mid = (last + first) / 2)
{
- int r = utf8_cmp (str, length, cxx_keywords[mid]);
+ int kwl = strlen (cxx_keywords[mid]);
+ int min_length = kwl > length ? length : kwl;
+ int r = utf8_cmp (str, min_length, cxx_keywords[mid]);
if (r == 0)
{
- char *str = xmalloc (2 + strlen (cxx_keywords[mid]));
- strcpy (str, cxx_keywords[mid]);
- strcat (str, "$");
- return str;
+ int i;
+
+ /* Skip all trailing `$'. */
+ for (i = min_length; i < length && str[i] == '$'; ++i)
+ ;
+ /* We've only found a match if all the remaining characters
+ are `$'. */
+ if (i == length)
+ {
+ char *dup = xmalloc (2 + length - min_length + kwl);
+ strcpy (dup, cxx_keywords[mid]);
+ for (i = kwl; i < length + 1; ++i)
+ dup[i] = '$';
+ dup[i] = '\0';
+ return dup;
+ }
+ r = 1;
}
- else if (r < 0)
+
+ if (r < 0)
last = mid;
else
first = mid;