2001-11-01 Michael Snyder <msnyder@redhat.com>

* symtab.c (operator_chars): Allow '*' and '[' to be quoted in
	operator names, to avoid regexp expansion.
	(search_symbols): Alloca buffer is too small, may get clobbered.
This commit is contained in:
Michael Snyder 2001-11-05 23:27:31 +00:00
parent 1c5dfdad97
commit 53e8ad3d81
2 changed files with 101 additions and 46 deletions

View File

@ -67,6 +67,12 @@
* MAINTAINERS: Update my entry.
2001-11-01 Michael Snyder <msnyder@redhat.com>
* symtab.c (operator_chars): Allow '*' and '[' to be quoted in
operator names, to avoid regexp expansion.
(search_symbols): Alloca buffer is too small, may get clobbered.
2001-11-01 Fred Fish <fnf@redhat.com>
* coff-solib.c (coff_solib_add): Add new readsyms arg.

View File

@ -2067,53 +2067,102 @@ operator_chars (char *p, char **end)
return p;
}
switch (*p)
{
case '!':
case '=':
case '*':
case '/':
case '%':
case '^':
if (p[1] == '=')
*end = p + 2;
else
while (*p)
switch (*p)
{
case '\\': /* regexp quoting */
if (p[1] == '*')
{
if (p[2] == '=') /* 'operator\*=' */
*end = p + 3;
else /* 'operator\*' */
*end = p + 2;
return p;
}
else if (p[1] == '[')
{
if (p[2] == ']')
error ("mismatched quoting on brackets, try 'operator\\[\\]'");
else if (p[2] == '\\' && p[3] == ']')
{
*end = p + 4; /* 'operator\[\]' */
return p;
}
else
error ("nothing is allowed between '[' and ']'");
}
else
{
/* Gratuitous qoute: skip it and move on. */
p++;
continue;
}
break;
case '!':
case '=':
case '*':
case '/':
case '%':
case '^':
if (p[1] == '=')
*end = p + 2;
else
*end = p + 1;
return p;
case '<':
case '>':
case '+':
case '-':
case '&':
case '|':
if (p[0] == '-' && p[1] == '>')
{
/* Struct pointer member operator 'operator->'. */
if (p[2] == '*')
{
*end = p + 3; /* 'operator->*' */
return p;
}
else if (p[2] == '\\')
{
*end = p + 4; /* Hopefully 'operator->\*' */
return p;
}
else
{
*end = p + 2; /* 'operator->' */
return p;
}
}
if (p[1] == '=' || p[1] == p[0])
*end = p + 2;
else
*end = p + 1;
return p;
case '~':
case ',':
*end = p + 1;
return p;
case '<':
case '>':
case '+':
case '-':
case '&':
case '|':
if (p[1] == '=' || p[1] == p[0])
return p;
case '(':
if (p[1] != ')')
error ("`operator ()' must be specified without whitespace in `()'");
*end = p + 2;
else
*end = p + 1;
return p;
case '~':
case ',':
*end = p + 1;
return p;
case '(':
if (p[1] != ')')
error ("`operator ()' must be specified without whitespace in `()'");
*end = p + 2;
return p;
case '?':
if (p[1] != ':')
error ("`operator ?:' must be specified without whitespace in `?:'");
*end = p + 2;
return p;
case '[':
if (p[1] != ']')
error ("`operator []' must be specified without whitespace in `[]'");
*end = p + 2;
return p;
default:
error ("`operator %s' not supported", p);
break;
}
return p;
case '?':
if (p[1] != ':')
error ("`operator ?:' must be specified without whitespace in `?:'");
*end = p + 2;
return p;
case '[':
if (p[1] != ']')
error ("`operator []' must be specified without whitespace in `[]'");
*end = p + 2;
return p;
default:
error ("`operator %s' not supported", p);
break;
}
*end = "";
return *end;
}
@ -2365,7 +2414,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
/* If wrong number of spaces, fix it. */
if (fix >= 0)
{
char *tmp = (char *) alloca (opend - opname + 10);
char *tmp = (char *) alloca (strlen (regexp) + fix);
sprintf (tmp, "operator%.*s%s", fix, " ", opname);
regexp = tmp;
}