diff options
author | Michael Snyder <msnyder@vmware.com> | 2001-11-05 23:27:31 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2001-11-05 23:27:31 +0000 |
commit | 53e8ad3d81c2d599493f764b5b85f3495a131f37 (patch) | |
tree | 903724f780b11bf087044a33cc9c2bfaf95d9acf /gdb/symtab.c | |
parent | 1c5dfdad97705b53aa4f92a58bf527da2448911b (diff) | |
download | gdb-53e8ad3d81c2d599493f764b5b85f3495a131f37.zip gdb-53e8ad3d81c2d599493f764b5b85f3495a131f37.tar.gz gdb-53e8ad3d81c2d599493f764b5b85f3495a131f37.tar.bz2 |
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.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 141 |
1 files changed, 95 insertions, 46 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index c0fa1e7..cd1798d 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; } |