aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2001-11-05 23:27:31 +0000
committerMichael Snyder <msnyder@vmware.com>2001-11-05 23:27:31 +0000
commit53e8ad3d81c2d599493f764b5b85f3495a131f37 (patch)
tree903724f780b11bf087044a33cc9c2bfaf95d9acf
parent1c5dfdad97705b53aa4f92a58bf527da2448911b (diff)
downloadgdb-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.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/symtab.c141
2 files changed, 101 insertions, 46 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d07aab8..723ce0c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
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;
}