aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-01-09 17:27:20 +0000
committerDoug Evans <dje@google.com>2012-01-09 17:27:20 +0000
commit1a4eeb98116176cb9a3e33a057bc2700a9e0d736 (patch)
tree182a9c4a25e9bd3925a17e904ddff505f9ff6781 /gdb
parent06db92f05489431368ef8d1ece01ea588235741d (diff)
downloadgdb-1a4eeb98116176cb9a3e33a057bc2700a9e0d736.zip
gdb-1a4eeb98116176cb9a3e33a057bc2700a9e0d736.tar.gz
gdb-1a4eeb98116176cb9a3e33a057bc2700a9e0d736.tar.bz2
* parser-defs.h (namecopy): Delete.
* parse.c (namecopy, namecopy_size): Move into copy_name.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/parse.c29
-rw-r--r--gdb/parser-defs.h11
3 files changed, 22 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 43827ed..64ebd3b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-09 Doug Evans <dje@google.com>
+
+ * parser-defs.h (namecopy): Delete.
+ * parse.c (namecopy, namecopy_size): Move into copy_name.
+
2012-01-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Partially fix duplicate .o files after omitting libbfd.a.
diff --git a/gdb/parse.c b/gdb/parse.c
index b0fa237..f405dc5 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -90,16 +90,6 @@ int in_parse_field;
'->'. This is set when parsing and is only used when completing a
field name. It is -1 if no dereference operation was found. */
static int expout_last_struct = -1;
-
-/* A temporary buffer for identifiers, so we can null-terminate them.
-
- We allocate this with xrealloc. parse_exp_1 used to allocate with
- alloca, using the size of the whole expression as a conservative
- estimate of the space needed. However, macro expansion can
- introduce names longer than the original expression; there's no
- practical way to know beforehand how large that might be. */
-char *namecopy;
-size_t namecopy_size;
static int expressiondebug = 0;
static void
@@ -744,13 +734,28 @@ find_template_name_end (char *p)
}
+/* Return a null-terminated temporary copy of the name of a string token.
-/* Return a null-terminated temporary copy of the name
- of a string token. */
+ Tokens that refer to names do so with explicit pointer and length,
+ so they can share the storage that lexptr is parsing.
+ When it is necessary to pass a name to a function that expects
+ a null-terminated string, the substring is copied out
+ into a separate block of storage.
+
+ N.B. A single buffer is reused on each call. */
char *
copy_name (struct stoken token)
{
+ /* A temporary buffer for identifiers, so we can null-terminate them.
+ We allocate this with xrealloc. parse_exp_1 used to allocate with
+ alloca, using the size of the whole expression as a conservative
+ estimate of the space needed. However, macro expansion can
+ introduce names longer than the original expression; there's no
+ practical way to know beforehand how large that might be. */
+ static char *namecopy;
+ static size_t namecopy_size;
+
/* Make sure there's enough space for the token. */
if (namecopy_size < token.length + 1)
{
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index d14aea6..16b40ac 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -216,17 +216,6 @@ extern char *lexptr;
Currently used only for error reporting. */
extern char *prev_lexptr;
-/* Tokens that refer to names do so with explicit pointer and length,
- so they can share the storage that lexptr is parsing.
-
- When it is necessary to pass a name to a function that expects
- a null-terminated string, the substring is copied out
- into a block of storage that namecopy points to.
-
- namecopy is allocated once, guaranteed big enough, for each parsing. */
-
-extern char *namecopy;
-
/* Current depth in parentheses within the expression. */
extern int paren_depth;