diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d07aab8c92f..723ce0c02d1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -67,6 +67,12 @@ * MAINTAINERS: Update my entry. +2001-11-01 Michael Snyder + + * 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 * coff-solib.c (coff_solib_add): Add new readsyms arg. diff --git a/gdb/symtab.c b/gdb/symtab.c index c0fa1e71ea4..cd1798d95f5 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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; }