Make copy_name return std::string
authorTom Tromey <tom@tromey.com>
Sun, 7 Apr 2019 21:29:58 +0000 (15:29 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 19 Apr 2019 20:10:23 +0000 (14:10 -0600)
This changes copy_name to return a std::string, updating all the
callers.  In some cases, an extra copy was removed.  This also
required a little bit of constification.

Tested by the buildbot.

gdb/ChangeLog
2019-04-19  Tom Tromey  <tom@tromey.com>

* type-stack.h (struct type_stack) <insert>: Constify string.
* type-stack.c (type_stack::insert): Constify string.
* gdbtypes.h (lookup_template_type): Update.
(address_space_name_to_int): Update.
* gdbtypes.c (address_space_name_to_int): Make space_identifier
const.
(lookup_template_type): Make name const.
* c-exp.y: Update rules.
(lex_one_token, classify_name, classify_inner_name)
(c_print_token): Update.
* p-exp.y: Update rules.
(yylex): Update.
* f-exp.y: Update rules.
(yylex): Update.
* d-exp.y: Update rules.
(lex_one_token, classify_name, classify_inner_name): Update.
* parse.c (write_dollar_variable, copy_name): Return std::string.
* parser-defs.h (copy_name): Change return type.
* m2-exp.y: Update rules.
(yylex): Update.
* go-exp.y (lex_one_token): Update.
Update rules.
(classify_unsafe_function, classify_packaged_name)
(classify_name, yylex): Update.

13 files changed:
gdb/ChangeLog
gdb/c-exp.y
gdb/d-exp.y
gdb/f-exp.y
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/go-exp.y
gdb/m2-exp.y
gdb/p-exp.y
gdb/parse.c
gdb/parser-defs.h
gdb/type-stack.c
gdb/type-stack.h

index 88ae5ddd6d735b479f5fb61cbbd0701f6bbe579f..45f8fa50b209b7b512241e22c165509a1452922c 100644 (file)
@@ -1,3 +1,30 @@
+2019-04-19  Tom Tromey  <tom@tromey.com>
+
+       * type-stack.h (struct type_stack) <insert>: Constify string.
+       * type-stack.c (type_stack::insert): Constify string.
+       * gdbtypes.h (lookup_template_type): Update.
+       (address_space_name_to_int): Update.
+       * gdbtypes.c (address_space_name_to_int): Make space_identifier
+       const.
+       (lookup_template_type): Make name const.
+       * c-exp.y: Update rules.
+       (lex_one_token, classify_name, classify_inner_name)
+       (c_print_token): Update.
+       * p-exp.y: Update rules.
+       (yylex): Update.
+       * f-exp.y: Update rules.
+       (yylex): Update.
+       * d-exp.y: Update rules.
+       (lex_one_token, classify_name, classify_inner_name): Update.
+       * parse.c (write_dollar_variable, copy_name): Return std::string.
+       * parser-defs.h (copy_name): Change return type.
+       * m2-exp.y: Update rules.
+       (yylex): Update.
+       * go-exp.y (lex_one_token): Update.
+       Update rules.
+       (classify_unsafe_function, classify_packaged_name)
+       (classify_name, yylex): Update.
+
 2019-04-19  Sergei Trofimovich <siarheit@google.com>
 
        * configure.ac: add --enable-source-highlight switch.
index e1a17b5628a99102fdadbfc3162b9eecba71243b..47e82b698b418e467f114b03dc1400c0a3e297a7 100644 (file)
@@ -474,14 +474,15 @@ exp       :       OBJC_LBRAC TYPENAME
                        {
                          CORE_ADDR theclass;
 
+                         std::string copy = copy_name ($2.stoken);
                          theclass = lookup_objc_class (pstate->gdbarch (),
-                                                    copy_name ($2.stoken));
+                                                       copy.c_str ());
                          if (theclass == 0)
                            error (_("%s is not an ObjC Class"),
-                                  copy_name ($2.stoken));
+                                  copy.c_str ());
                          write_exp_elt_opcode (pstate, OP_LONG);
                          write_exp_elt_type (pstate,
-                                           parse_type (pstate)->builtin_int);
+                                             parse_type (pstate)->builtin_int);
                          write_exp_elt_longcst (pstate, (LONGEST) theclass);
                          write_exp_elt_opcode (pstate, OP_LONG);
                          start_msglist();
@@ -959,7 +960,7 @@ block       :       BLOCKNAME
                            $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
                          else
                            error (_("No file or function \"%s\"."),
-                                  copy_name ($1.stoken));
+                                  copy_name ($1.stoken).c_str ());
                        }
        |       FILENAME
                        {
@@ -968,13 +969,15 @@ block     :       BLOCKNAME
        ;
 
 block  :       block COLONCOLON name
-                       { struct symbol *tem
-                           = lookup_symbol (copy_name ($3), $1,
+                       {
+                         std::string copy = copy_name ($3);
+                         struct symbol *tem
+                           = lookup_symbol (copy.c_str (), $1,
                                             VAR_DOMAIN, NULL).symbol;
 
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
                            error (_("No function \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
                          $$ = SYMBOL_BLOCK_VALUE (tem); }
        ;
 
@@ -985,7 +988,7 @@ variable:   name_not_typename ENTRY
                              || !symbol_read_needs_frame (sym))
                            error (_("@entry can be used only for function "
                                     "parameters, not for \"%s\""),
-                                  copy_name ($1.stoken));
+                                  copy_name ($1.stoken).c_str ());
 
                          write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
                          write_exp_elt_sym (pstate, sym);
@@ -994,13 +997,15 @@ variable: name_not_typename ENTRY
        ;
 
 variable:      block COLONCOLON name
-                       { struct block_symbol sym
-                           = lookup_symbol (copy_name ($3), $1,
+                       {
+                         std::string copy = copy_name ($3);
+                         struct block_symbol sym
+                           = lookup_symbol (copy.c_str (), $1,
                                             VAR_DOMAIN, NULL);
 
                          if (sym.symbol == 0)
                            error (_("No symbol \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
                          if (symbol_read_needs_frame (sym.symbol))
                            pstate->block_tracker->update (sym);
 
@@ -1049,22 +1054,23 @@ qualified_name: TYPENAME COLONCOLON name
                        }
        |       TYPENAME COLONCOLON name COLONCOLON name
                        {
-                         char *copy = copy_name ($3);
+                         std::string copy = copy_name ($3);
                          error (_("No type \"%s\" within class "
                                   "or namespace \"%s\"."),
-                                copy, TYPE_SAFE_NAME ($1.type));
+                                copy.c_str (), TYPE_SAFE_NAME ($1.type));
                        }
        ;
 
 variable:      qualified_name
        |       COLONCOLON name_not_typename
                        {
-                         char *name = copy_name ($2.stoken);
+                         std::string name = copy_name ($2.stoken);
                          struct symbol *sym;
                          struct bound_minimal_symbol msymbol;
 
                          sym
-                           = lookup_symbol (name, (const struct block *) NULL,
+                           = lookup_symbol (name.c_str (),
+                                            (const struct block *) NULL,
                                             VAR_DOMAIN, NULL).symbol;
                          if (sym)
                            {
@@ -1075,13 +1081,14 @@ variable:       qualified_name
                              break;
                            }
 
-                         msymbol = lookup_bound_minimal_symbol (name);
+                         msymbol = lookup_bound_minimal_symbol (name.c_str ());
                          if (msymbol.minsym != NULL)
                            write_exp_msymbol (pstate, msymbol);
                          else if (!have_full_symbols () && !have_partial_symbols ())
                            error (_("No symbol table is loaded.  Use the \"file\" command."));
                          else
-                           error (_("No symbol \"%s\" in current context."), name);
+                           error (_("No symbol \"%s\" in current context."),
+                                  name.c_str ());
                        }
        ;
 
@@ -1124,17 +1131,17 @@ variable:       name_not_typename
                            }
                          else
                            {
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              bound_minimal_symbol msymbol
-                               = lookup_bound_minimal_symbol (arg);
+                               = lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym == NULL)
                                {
                                  if (!have_full_symbols () && !have_partial_symbols ())
                                    error (_("No symbol table is loaded.  Use the \"file\" command."));
                                  else
                                    error (_("No symbol \"%s\" in current context."),
-                                          copy_name ($1.stoken));
+                                          arg.c_str ());
                                }
 
                              /* This minsym might be an alias for
@@ -1165,7 +1172,8 @@ variable: name_not_typename
 
 space_identifier : '@' NAME
                {
-                 cpstate->type_stack.insert (pstate, copy_name ($2.stoken));
+                 cpstate->type_stack.insert (pstate,
+                                             copy_name ($2.stoken).c_str ());
                }
        ;
 
@@ -1409,7 +1417,7 @@ typebase
                                                0); }
        |       STRUCT name
                        { $$
-                           = lookup_struct (copy_name ($2),
+                           = lookup_struct (copy_name ($2).c_str (),
                                             pstate->expression_context_block);
                        }
        |       STRUCT COMPLETE
@@ -1426,7 +1434,8 @@ typebase
                        }
        |       CLASS name
                        { $$ = lookup_struct
-                           (copy_name ($2), pstate->expression_context_block);
+                           (copy_name ($2).c_str (),
+                            pstate->expression_context_block);
                        }
        |       CLASS COMPLETE
                        {
@@ -1442,7 +1451,7 @@ typebase
                        }
        |       UNION name
                        { $$
-                           = lookup_union (copy_name ($2),
+                           = lookup_union (copy_name ($2).c_str (),
                                            pstate->expression_context_block);
                        }
        |       UNION COMPLETE
@@ -1458,7 +1467,7 @@ typebase
                          $$ = NULL;
                        }
        |       ENUM name
-                       { $$ = lookup_enum (copy_name ($2),
+                       { $$ = lookup_enum (copy_name ($2).c_str (),
                                            pstate->expression_context_block);
                        }
        |       ENUM COMPLETE
@@ -1493,7 +1502,7 @@ typebase
                    in the token processing code in yylex. */
        |       TEMPLATE name '<' type '>'
                        { $$ = lookup_template_type
-                           (copy_name($2), $4,
+                           (copy_name($2).c_str (), $4,
                             pstate->expression_context_block);
                        }
        | const_or_volatile_or_space_identifier_noopt typebase
@@ -2551,7 +2560,6 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
   unsigned int i;
   const char *tokstart;
   bool saw_structop = last_was_structop;
-  char *copy;
 
   last_was_structop = false;
   *is_quoted_name = false;
@@ -2879,9 +2887,9 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
   yylval.sval.length = namelen;
 
   /* Catch specific keywords.  */
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
   for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
-    if (strcmp (copy, ident_tokens[i].oper) == 0)
+    if (copy == ident_tokens[i].oper)
       {
        if ((ident_tokens[i].flags & FLAG_CXX) != 0
            && par_state->language ()->la_language != language_cplus)
@@ -2891,7 +2899,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
          {
            struct field_of_this_result is_a_field_of_this;
 
-           if (lookup_symbol (copy,
+           if (lookup_symbol (copy.c_str (),
                               pstate->expression_context_block,
                               VAR_DOMAIN,
                               (par_state->language ()->la_language
@@ -2953,16 +2961,15 @@ classify_name (struct parser_state *par_state, const struct block *block,
               bool is_quoted_name, bool is_after_structop)
 {
   struct block_symbol bsym;
-  char *copy;
   struct field_of_this_result is_a_field_of_this;
 
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
 
   /* Initialize this in case we *don't* use it in this call; that way
      we can refer to it unconditionally below.  */
   memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
-  bsym = lookup_symbol (copy, block, VAR_DOMAIN,
+  bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN,
                        par_state->language ()->la_name_of_this
                        ? &is_a_field_of_this : NULL);
 
@@ -2985,7 +2992,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
        {
          struct field_of_this_result inner_is_a_field_of_this;
 
-         bsym = lookup_symbol (copy, block, STRUCT_DOMAIN,
+         bsym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN,
                                &inner_is_a_field_of_this);
          if (bsym.symbol != NULL)
            {
@@ -3005,7 +3012,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
          /* See if it's a file name. */
          struct symtab *symtab;
 
-         symtab = lookup_symtab (copy);
+         symtab = lookup_symtab (copy.c_str ());
          if (symtab)
            {
              yylval.bval = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
@@ -3024,13 +3031,14 @@ classify_name (struct parser_state *par_state, const struct block *block,
   /* See if it's an ObjC classname.  */
   if (par_state->language ()->la_language == language_objc && !bsym.symbol)
     {
-      CORE_ADDR Class = lookup_objc_class (par_state->gdbarch (), copy);
+      CORE_ADDR Class = lookup_objc_class (par_state->gdbarch (),
+                                          copy.c_str ());
       if (Class)
        {
          struct symbol *sym;
 
          yylval.theclass.theclass = Class;
-         sym = lookup_struct_typedef (copy,
+         sym = lookup_struct_typedef (copy.c_str (),
                                       par_state->expression_context_block, 1);
          if (sym)
            yylval.theclass.type = SYMBOL_TYPE (sym);
@@ -3046,7 +3054,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
          || (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10)))
     {
       YYSTYPE newlval; /* Its value is ignored.  */
-      int hextype = parse_number (par_state, copy, yylval.sval.length,
+      int hextype = parse_number (par_state, copy.c_str (), yylval.sval.length,
                                  0, &newlval);
 
       if (hextype == INT)
@@ -3064,7 +3072,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
   if (bsym.symbol == NULL
       && par_state->language ()->la_language == language_cplus
       && is_a_field_of_this.type == NULL
-      && lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL)
+      && lookup_minimal_symbol (copy.c_str (), NULL, NULL).minsym == NULL)
     return UNKNOWN_CPP_NAME;
 
   return NAME;
@@ -3079,7 +3087,6 @@ classify_inner_name (struct parser_state *par_state,
                     const struct block *block, struct type *context)
 {
   struct type *type;
-  char *copy;
 
   if (context == NULL)
     return classify_name (par_state, block, false, false);
@@ -3088,16 +3095,18 @@ classify_inner_name (struct parser_state *par_state,
   if (!type_aggregate_p (type))
     return ERROR;
 
-  copy = copy_name (yylval.ssym.stoken);
+  std::string copy = copy_name (yylval.ssym.stoken);
   /* N.B. We assume the symbol can only be in VAR_DOMAIN.  */
-  yylval.ssym.sym = cp_lookup_nested_symbol (type, copy, block, VAR_DOMAIN);
+  yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block,
+                                            VAR_DOMAIN);
 
   /* If no symbol was found, search for a matching base class named
      COPY.  This will allow users to enter qualified names of class members
      relative to the `this' pointer.  */
   if (yylval.ssym.sym.symbol == NULL)
     {
-      struct type *base_type = cp_find_type_baseclass_by_name (type, copy);
+      struct type *base_type = cp_find_type_baseclass_by_name (type,
+                                                              copy.c_str ());
 
       if (base_type != NULL)
        {
@@ -3116,7 +3125,8 @@ classify_inner_name (struct parser_state *par_state,
         named COPY when we really wanted a base class of the same name.
         Double-check this case by looking for a base class.  */
       {
-       struct type *base_type = cp_find_type_baseclass_by_name (type, copy);
+       struct type *base_type
+         = cp_find_type_baseclass_by_name (type, copy.c_str ());
 
        if (base_type != NULL)
          {
@@ -3368,13 +3378,13 @@ c_print_token (FILE *file, int type, YYSTYPE value)
 
     case NSSTRING:
     case DOLLAR_VARIABLE:
-      parser_fprintf (file, "sval<%s>", copy_name (value.sval));
+      parser_fprintf (file, "sval<%s>", copy_name (value.sval).c_str ());
       break;
 
     case TYPENAME:
       parser_fprintf (file, "tsym<type=%s, name=%s>",
                      TYPE_SAFE_NAME (value.tsym.type),
-                     copy_name (value.tsym.stoken));
+                     copy_name (value.tsym.stoken).c_str ());
       break;
 
     case NAME:
@@ -3382,7 +3392,7 @@ c_print_token (FILE *file, int type, YYSTYPE value)
     case NAME_OR_INT:
     case BLOCKNAME:
       parser_fprintf (file, "ssym<name=%s, sym=%s, field_of_this=%d>",
-                      copy_name (value.ssym.stoken),
+                      copy_name (value.ssym.stoken).c_str (),
                       (value.ssym.sym.symbol == NULL
                        ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym.symbol)),
                       value.ssym.is_a_field_of_this);
index 8f04e93bb8f288f044ef20860ccb8c9125ba66f2..6b25ee298d4eaf2e56a7bfdbeb56af26c11e7995 100644 (file)
@@ -415,12 +415,13 @@ PrimaryExpression:
                { /* Do nothing.  */ }
 |      IdentifierExp
                { struct bound_minimal_symbol msymbol;
-                 char *copy = copy_name ($1);
+                 std::string copy = copy_name ($1);
                  struct field_of_this_result is_a_field_of_this;
                  struct block_symbol sym;
 
                  /* Handle VAR, which could be local or global.  */
-                 sym = lookup_symbol (copy, pstate->expression_context_block,
+                 sym = lookup_symbol (copy.c_str (),
+                                      pstate->expression_context_block,
                                       VAR_DOMAIN, &is_a_field_of_this);
                  if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
                    {
@@ -445,13 +446,14 @@ PrimaryExpression:
                  else
                    {
                      /* Lookup foreign name in global static symbols.  */
-                     msymbol = lookup_bound_minimal_symbol (copy);
+                     msymbol = lookup_bound_minimal_symbol (copy.c_str ());
                      if (msymbol.minsym != NULL)
                        write_exp_msymbol (pstate, msymbol);
                      else if (!have_full_symbols () && !have_partial_symbols ())
                        error (_("No symbol table is loaded.  Use the \"file\" command"));
                      else
-                       error (_("No symbol \"%s\" in current context."), copy);
+                       error (_("No symbol \"%s\" in current context."),
+                              copy.c_str ());
                    }
                  }
 |      TypeExp '.' IdentifierExp
@@ -1037,7 +1039,6 @@ lex_one_token (struct parser_state *par_state)
   unsigned int i;
   const char *tokstart;
   int saw_structop = last_was_structop;
-  char *copy;
 
   last_was_structop = 0;
 
@@ -1281,9 +1282,9 @@ lex_one_token (struct parser_state *par_state)
   yylval.sval.length = namelen;
 
   /* Catch specific keywords.  */
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
   for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
-    if (strcmp (copy, ident_tokens[i].oper) == 0)
+    if (copy == ident_tokens[i].oper)
       {
        /* It is ok to always set this, even though we don't always
           strictly need to.  */
@@ -1296,7 +1297,7 @@ lex_one_token (struct parser_state *par_state)
 
   yylval.tsym.type
     = language_lookup_primitive_type (par_state->language (),
-                                     par_state->gdbarch (), copy);
+                                     par_state->gdbarch (), copy.c_str ());
   if (yylval.tsym.type != NULL)
     return TYPENAME;
 
@@ -1345,12 +1346,11 @@ static int
 classify_name (struct parser_state *par_state, const struct block *block)
 {
   struct block_symbol sym;
-  char *copy;
   struct field_of_this_result is_a_field_of_this;
 
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
 
-  sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
   if (sym.symbol && SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF)
     {
       yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
@@ -1359,9 +1359,9 @@ classify_name (struct parser_state *par_state, const struct block *block)
   else if (sym.symbol == NULL)
     {
       /* Look-up first for a module name, then a type.  */
-      sym = lookup_symbol (copy, block, MODULE_DOMAIN, NULL);
+      sym = lookup_symbol (copy.c_str (), block, MODULE_DOMAIN, NULL);
       if (sym.symbol == NULL)
-       sym = lookup_symbol (copy, block, STRUCT_DOMAIN, NULL);
+       sym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, NULL);
 
       if (sym.symbol != NULL)
        {
@@ -1384,7 +1384,6 @@ classify_inner_name (struct parser_state *par_state,
                     const struct block *block, struct type *context)
 {
   struct type *type;
-  char *copy;
 
   if (context == NULL)
     return classify_name (par_state, block);
@@ -1393,8 +1392,8 @@ classify_inner_name (struct parser_state *par_state,
   if (!type_aggregate_p (type))
     return ERROR;
 
-  copy = copy_name (yylval.ssym.stoken);
-  yylval.ssym.sym = d_lookup_nested_symbol (type, copy, block);
+  std::string copy = copy_name (yylval.ssym.stoken);
+  yylval.ssym.sym = d_lookup_nested_symbol (type, copy.c_str (), block);
 
   if (yylval.ssym.sym.symbol == NULL)
     return ERROR;
index 9ee5316470f74632835f2b4ced9173fb9c23dab3..b326d09c44e0ecf4c557cca2cceb64aafe362bd8 100644 (file)
@@ -490,17 +490,17 @@ variable: name_not_typename
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1.stoken));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -1264,7 +1264,7 @@ yylex (void)
      currently as names of types; NAME for other symbols.
      The caller is not constrained to care about the distinction.  */
   {
-    char *tmp = copy_name (yylval.sval);
+    std::string tmp = copy_name (yylval.sval);
     struct block_symbol result;
     struct field_of_this_result is_a_field_of_this;
     enum domain_enum_tag lookup_domains[] =
@@ -1281,7 +1281,7 @@ yylex (void)
           way we can refer to it unconditionally below.  */
        memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
-       result = lookup_symbol (tmp, pstate->expression_context_block,
+       result = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                                lookup_domains[i],
                                pstate->language ()->la_language
                                == language_cplus
@@ -1298,7 +1298,7 @@ yylex (void)
 
     yylval.tsym.type
       = language_lookup_primitive_type (pstate->language (),
-                                       pstate->gdbarch (), tmp);
+                                       pstate->gdbarch (), tmp.c_str ());
     if (yylval.tsym.type != NULL)
       return TYPENAME;
     
index 683238d03d27a457dd097e0317018d9c3154a259..b3424d81be45fe53a208fe11e18a40abffb4237d 100644 (file)
@@ -574,7 +574,8 @@ lookup_function_type_with_arguments (struct type *type,
    return the integer flag defined in gdbtypes.h.  */
 
 int
-address_space_name_to_int (struct gdbarch *gdbarch, char *space_identifier)
+address_space_name_to_int (struct gdbarch *gdbarch,
+                          const char *space_identifier)
 {
   int type_flags;
 
@@ -1618,7 +1619,7 @@ lookup_enum (const char *name, const struct block *block)
    visible in lexical block BLOCK.  */
 
 struct type *
-lookup_template_type (char *name, struct type *type, 
+lookup_template_type (const char *name, struct type *type, 
                      const struct block *block)
 {
   struct symbol *sym;
index a5f6afc6faddb72a3aa8151c07dcd3a30897f163..147a2de355edc72eed5f91a84d4f95050325bb40 100644 (file)
@@ -1859,7 +1859,7 @@ extern struct type *make_atomic_type (struct type *);
 
 extern void replace_type (struct type *, struct type *);
 
-extern int address_space_name_to_int (struct gdbarch *, char *);
+extern int address_space_name_to_int (struct gdbarch *, const char *);
 
 extern const char *address_space_int_to_name (struct gdbarch *, int);
 
@@ -2005,7 +2005,7 @@ extern struct type *lookup_typename (const struct language_defn *,
                                     struct gdbarch *, const char *,
                                     const struct block *, int);
 
-extern struct type *lookup_template_type (char *, struct type *,
+extern struct type *lookup_template_type (const char *, struct type *,
                                          const struct block *);
 
 extern int get_vptr_fieldno (struct type *, struct type **);
index 0084b2f7eb6fe6f56cc780be552e7cdcd690b7f1..ad174119abb57cc4da35241c9fbf830d48a2b4d9 100644 (file)
@@ -538,7 +538,7 @@ variable:   name_not_typename ENTRY
                              || !symbol_read_needs_frame (sym))
                            error (_("@entry can be used only for function "
                                     "parameters, not for \"%s\""),
-                                  copy_name ($1.stoken));
+                                  copy_name ($1.stoken).c_str ());
 
                          write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
                          write_exp_elt_sym (pstate, sym);
@@ -568,10 +568,10 @@ variable: name_not_typename
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols ()
@@ -580,7 +580,7 @@ variable:   name_not_typename
                                       "Use the \"file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1.stoken));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -1014,7 +1014,6 @@ lex_one_token (struct parser_state *par_state)
   unsigned int i;
   const char *tokstart;
   int saw_structop = last_was_structop;
-  char *copy;
 
   last_was_structop = 0;
 
@@ -1263,9 +1262,9 @@ lex_one_token (struct parser_state *par_state)
   yylval.sval.length = namelen;
 
   /* Catch specific keywords.  */
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
   for (i = 0; i < sizeof (ident_tokens) / sizeof (ident_tokens[0]); i++)
-    if (strcmp (copy, ident_tokens[i].oper) == 0)
+    if (copy == ident_tokens[i].oper)
       {
        /* It is ok to always set this, even though we don't always
           strictly need to.  */
@@ -1347,15 +1346,15 @@ package_name_p (const char *name, const struct block *block)
 static int
 classify_unsafe_function (struct stoken function_name)
 {
-  char *copy = copy_name (function_name);
+  std::string copy = copy_name (function_name);
 
-  if (strcmp (copy, "Sizeof") == 0)
+  if (copy == "Sizeof")
     {
       yylval.sval = function_name;
       return SIZEOF_KEYWORD;
     }
 
-  error (_("Unknown function in `unsafe' package: %s"), copy);
+  error (_("Unknown function in `unsafe' package: %s"), copy.c_str ());
 }
 
 /* Classify token(s) "name1.name2" where name1 is known to be a package.
@@ -1367,13 +1366,12 @@ classify_unsafe_function (struct stoken function_name)
 static int
 classify_packaged_name (const struct block *block)
 {
-  char *copy;
   struct block_symbol sym;
   struct field_of_this_result is_a_field_of_this;
 
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
 
-  sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
 
   if (sym.symbol)
     {
@@ -1397,15 +1395,14 @@ classify_name (struct parser_state *par_state, const struct block *block)
 {
   struct type *type;
   struct block_symbol sym;
-  char *copy;
   struct field_of_this_result is_a_field_of_this;
 
-  copy = copy_name (yylval.sval);
+  std::string copy = copy_name (yylval.sval);
 
   /* Try primitive types first so they win over bad/weird debug info.  */
   type = language_lookup_primitive_type (par_state->language (),
                                         par_state->gdbarch (),
-                                        copy);
+                                        copy.c_str ());
   if (type != NULL)
     {
       /* NOTE: We take advantage of the fact that yylval coming in was a
@@ -1417,7 +1414,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
 
   /* TODO: What about other types?  */
 
-  sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
 
   if (sym.symbol)
     {
@@ -1439,7 +1436,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
        struct stoken sval =
          build_packaged_name (current_package_name,
                               strlen (current_package_name),
-                              copy, strlen (copy));
+                              copy.c_str (), copy.size ());
 
        xfree (current_package_name);
        sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN,
@@ -1461,8 +1458,8 @@ classify_name (struct parser_state *par_state, const struct block *block)
       || (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10))
     {
       YYSTYPE newlval; /* Its value is ignored.  */
-      int hextype = parse_number (par_state, copy, yylval.sval.length,
-                                 0, &newlval);
+      int hextype = parse_number (par_state, copy.c_str (),
+                                 yylval.sval.length, 0, &newlval);
       if (hextype == INT)
        {
          yylval.ssym.sym.symbol = NULL;
@@ -1521,17 +1518,15 @@ yylex (void)
       if (name2.token == NAME)
        {
          /* Ok, we have "name1 . name2".  */
-         char *copy;
+         std::string copy = copy_name (current.value.sval);
 
-         copy = copy_name (current.value.sval);
-
-         if (strcmp (copy, "unsafe") == 0)
+         if (copy == "unsafe")
            {
              popping = 1;
              return classify_unsafe_function (name2.value.sval);
            }
 
-         if (package_name_p (copy, pstate->expression_context_block))
+         if (package_name_p (copy.c_str (), pstate->expression_context_block))
            {
              popping = 1;
              yylval.sval = build_packaged_name (current.value.sval.ptr,
index 1ea462ec71919fe4a93d2a19787fef462cf1e677..6a0173b251de7c7e8b9baef0444fa3240bc4f25a 100644 (file)
@@ -507,7 +507,7 @@ block       :       fblock
 
 fblock :       BLOCKNAME
                        { struct symbol *sym
-                           = lookup_symbol (copy_name ($1),
+                           = lookup_symbol (copy_name ($1).c_str (),
                                             pstate->expression_context_block,
                                             VAR_DOMAIN, 0).symbol;
                          $$ = sym;}
@@ -517,11 +517,11 @@ fblock    :       BLOCKNAME
 /* GDB scope operator */
 fblock :       block COLONCOLON BLOCKNAME
                        { struct symbol *tem
-                           = lookup_symbol (copy_name ($3), $1,
+                           = lookup_symbol (copy_name ($3).c_str (), $1,
                                             VAR_DOMAIN, 0).symbol;
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
                            error (_("No function \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy_name ($3).c_str ());
                          $$ = tem;
                        }
        ;
@@ -541,12 +541,12 @@ variable: DOLLAR_VARIABLE
 /* GDB scope operator */
 variable:      block COLONCOLON NAME
                        { struct block_symbol sym
-                           = lookup_symbol (copy_name ($3), $1,
+                           = lookup_symbol (copy_name ($3).c_str (), $1,
                                             VAR_DOMAIN, 0);
 
                          if (sym.symbol == 0)
                            error (_("No symbol \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy_name ($3).c_str ());
                          if (symbol_read_needs_frame (sym.symbol))
                            pstate->block_tracker->update (sym);
 
@@ -562,7 +562,7 @@ variable:   NAME
                          struct field_of_this_result is_a_field_of_this;
 
                          sym
-                           = lookup_symbol (copy_name ($1),
+                           = lookup_symbol (copy_name ($1).c_str (),
                                             pstate->expression_context_block,
                                             VAR_DOMAIN,
                                             &is_a_field_of_this);
@@ -580,17 +580,17 @@ variable: NAME
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1);
+                             std::string arg = copy_name ($1);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"symbol-file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -600,7 +600,7 @@ type
                        { $$
                            = lookup_typename (pstate->language (),
                                               pstate->gdbarch (),
-                                              copy_name ($1),
+                                              copy_name ($1).c_str (),
                                               pstate->expression_context_block,
                                               0);
                        }
@@ -965,20 +965,17 @@ yylex (void)
      currently as names of types; NAME for other symbols.
      The caller is not constrained to care about the distinction.  */
  {
-
-
-    char *tmp = copy_name (yylval.sval);
+    std::string tmp = copy_name (yylval.sval);
     struct symbol *sym;
 
-    if (lookup_symtab (tmp))
+    if (lookup_symtab (tmp.c_str ()))
       return BLOCKNAME;
-    sym = lookup_symbol (tmp, pstate->expression_context_block,
+    sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                         VAR_DOMAIN, 0).symbol;
     if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
       return BLOCKNAME;
     if (lookup_typename (pstate->language (), pstate->gdbarch (),
-                        copy_name (yylval.sval),
-                        pstate->expression_context_block, 1))
+                        tmp.c_str (), pstate->expression_context_block, 1))
       return TYPENAME;
 
     if(sym)
index da25ae42af6784ed4045570df251905f3dd023a1..2d11ff077ac02419fd8e26e199ecf00b62e18594 100644 (file)
@@ -620,37 +620,41 @@ block     :       BLOCKNAME
                              $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
                          else
                            {
+                             std::string copy = copy_name ($1.stoken);
                              struct symtab *tem =
-                                 lookup_symtab (copy_name ($1.stoken));
+                                 lookup_symtab (copy.c_str ());
                              if (tem)
                                $$ = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (tem),
                                                        STATIC_BLOCK);
                              else
                                error (_("No file or function \"%s\"."),
-                                      copy_name ($1.stoken));
+                                      copy.c_str ());
                            }
                        }
        ;
 
 block  :       block COLONCOLON name
-                       { struct symbol *tem
-                           = lookup_symbol (copy_name ($3), $1,
+                       {
+                         std::string copy = copy_name ($3);
+                         struct symbol *tem
+                           = lookup_symbol (copy.c_str (), $1,
                                             VAR_DOMAIN, NULL).symbol;
 
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
                            error (_("No function \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
                          $$ = SYMBOL_BLOCK_VALUE (tem); }
        ;
 
 variable:      block COLONCOLON name
                        { struct block_symbol sym;
 
-                         sym = lookup_symbol (copy_name ($3), $1,
+                         std::string copy = copy_name ($3);
+                         sym = lookup_symbol (copy.c_str (), $1,
                                               VAR_DOMAIN, NULL);
                          if (sym.symbol == 0)
                            error (_("No symbol \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
 
                          write_exp_elt_opcode (pstate, OP_VAR_VALUE);
                          write_exp_elt_block (pstate, sym.block);
@@ -677,12 +681,13 @@ qualified_name:   typebase COLONCOLON name
 variable:      qualified_name
        |       COLONCOLON name
                        {
-                         char *name = copy_name ($2);
+                         std::string name = copy_name ($2);
                          struct symbol *sym;
                          struct bound_minimal_symbol msymbol;
 
                          sym =
-                           lookup_symbol (name, (const struct block *) NULL,
+                           lookup_symbol (name.c_str (),
+                                          (const struct block *) NULL,
                                           VAR_DOMAIN, NULL).symbol;
                          if (sym)
                            {
@@ -693,7 +698,8 @@ variable:   qualified_name
                              break;
                            }
 
-                         msymbol = lookup_bound_minimal_symbol (name);
+                         msymbol
+                           = lookup_bound_minimal_symbol (name.c_str ());
                          if (msymbol.minsym != NULL)
                            write_exp_msymbol (pstate, msymbol);
                          else if (!have_full_symbols ()
@@ -702,7 +708,7 @@ variable:   qualified_name
                                   "Use the \"file\" command."));
                          else
                            error (_("No symbol \"%s\" in current context."),
-                                  name);
+                                  name.c_str ());
                        }
        ;
 
@@ -742,17 +748,17 @@ variable: name_not_typename
                              if (this_type)
                                current_type = lookup_struct_elt_type (
                                  this_type,
-                                 copy_name ($1.stoken), 0);
+                                 copy_name ($1.stoken).c_str (), 0);
                              else
                                current_type = NULL;
                            }
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols ()
@@ -761,7 +767,7 @@ variable:   name_not_typename
                                       "Use the \"file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1.stoken));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -788,12 +794,12 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                        { $$ = $1.type; }
        |       STRUCT name
                        { $$
-                           = lookup_struct (copy_name ($2),
+                           = lookup_struct (copy_name ($2).c_str (),
                                             pstate->expression_context_block);
                        }
        |       CLASS name
                        { $$
-                           = lookup_struct (copy_name ($2),
+                           = lookup_struct (copy_name ($2).c_str (),
                                             pstate->expression_context_block);
                        }
        /* "const" and "volatile" are curently ignored.  A type qualifier
@@ -1508,7 +1514,7 @@ yylex (void)
      currently as names of types; NAME for other symbols.
      The caller is not constrained to care about the distinction.  */
   {
-    char *tmp = copy_name (yylval.sval);
+    std::string tmp = copy_name (yylval.sval);
     struct symbol *sym;
     struct field_of_this_result is_a_field_of_this;
     int is_a_field = 0;
@@ -1516,11 +1522,12 @@ yylex (void)
 
     is_a_field_of_this.type = NULL;
     if (search_field && current_type)
-      is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+      is_a_field = (lookup_struct_elt_type (current_type,
+                                           tmp.c_str (), 1) != NULL);
     if (is_a_field)
       sym = NULL;
     else
-      sym = lookup_symbol (tmp, pstate->expression_context_block,
+      sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                           VAR_DOMAIN, &is_a_field_of_this).symbol;
     /* second chance uppercased (as Free Pascal does).  */
     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
@@ -1531,11 +1538,12 @@ yylex (void)
              tmp[i] -= ('a'-'A');
          }
        if (search_field && current_type)
-        is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+        is_a_field = (lookup_struct_elt_type (current_type,
+                                              tmp.c_str (), 1) != NULL);
        if (is_a_field)
         sym = NULL;
        else
-        sym = lookup_symbol (tmp, pstate->expression_context_block,
+        sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                              VAR_DOMAIN, &is_a_field_of_this).symbol;
       }
     /* Third chance Capitalized (as GPC does).  */
@@ -1553,18 +1561,19 @@ yylex (void)
              tmp[i] -= ('A'-'a');
           }
        if (search_field && current_type)
-        is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+        is_a_field = (lookup_struct_elt_type (current_type,
+                                              tmp.c_str (), 1) != NULL);
        if (is_a_field)
         sym = NULL;
        else
-        sym = lookup_symbol (tmp, pstate->expression_context_block,
+        sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                              VAR_DOMAIN, &is_a_field_of_this).symbol;
       }
 
     if (is_a_field || (is_a_field_of_this.type != NULL))
       {
        tempbuf = (char *) realloc (tempbuf, namelen + 1);
-       strncpy (tempbuf, tmp, namelen);
+       strncpy (tempbuf, tmp.c_str (), namelen);
        tempbuf [namelen] = 0;
        yylval.sval.ptr = tempbuf;
        yylval.sval.length = namelen;
@@ -1581,7 +1590,7 @@ yylex (void)
        no psymtabs (coff, xcoff, or some future change to blow away the
        psymtabs once once symbols are read).  */
     if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
-        || lookup_symtab (tmp))
+        || lookup_symtab (tmp.c_str ()))
       {
        yylval.ssym.sym.symbol = sym;
        yylval.ssym.sym.block = NULL;
@@ -1641,13 +1650,13 @@ yylex (void)
                      /* As big as the whole rest of the expression, which is
                         at least big enough.  */
                      char *ncopy
-                       = (char *) alloca (strlen (tmp) + strlen (namestart)
+                       = (char *) alloca (tmp.size () + strlen (namestart)
                                           + 3);
                      char *tmp1;
 
                      tmp1 = ncopy;
-                     memcpy (tmp1, tmp, strlen (tmp));
-                     tmp1 += strlen (tmp);
+                     memcpy (tmp1, tmp.c_str (), tmp.size ());
+                     tmp1 += tmp.size ();
                      memcpy (tmp1, "::", 2);
                      tmp1 += 2;
                      memcpy (tmp1, namestart, p - namestart);
@@ -1685,7 +1694,7 @@ yylex (void)
         }
     yylval.tsym.type
       = language_lookup_primitive_type (pstate->language (),
-                                       pstate->gdbarch (), tmp);
+                                       pstate->gdbarch (), tmp.c_str ());
     if (yylval.tsym.type != NULL)
       {
        free (uptokstart);
index 3e02057bf7b0dd044916d6a05b74b10dff709d53..52f29757231c92e416821b3d550da46329a9aabb 100644 (file)
@@ -548,6 +548,7 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
   struct block_symbol sym;
   struct bound_minimal_symbol msym;
   struct internalvar *isym = NULL;
+  std::string copy;
 
   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
      and $$digits (equivalent to $<-digits> if you could type that).  */
@@ -588,7 +589,8 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
 
   /* Any names starting with $ are probably debugger internal variables.  */
 
-  isym = lookup_only_internalvar (copy_name (str) + 1);
+  copy = copy_name (str);
+  isym = lookup_only_internalvar (copy.c_str () + 1);
   if (isym)
     {
       write_exp_elt_opcode (ps, OP_INTERNALVAR);
@@ -600,7 +602,7 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
   /* On some systems, such as HP-UX and hppa-linux, certain system routines 
      have names beginning with $ or $$.  Check for those, first.  */
 
-  sym = lookup_symbol (copy_name (str), NULL, VAR_DOMAIN, NULL);
+  sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL);
   if (sym.symbol)
     {
       write_exp_elt_opcode (ps, OP_VAR_VALUE);
@@ -609,7 +611,7 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
       write_exp_elt_opcode (ps, OP_VAR_VALUE);
       return;
     }
-  msym = lookup_bound_minimal_symbol (copy_name (str));
+  msym = lookup_bound_minimal_symbol (copy.c_str ());
   if (msym.minsym)
     {
       write_exp_msymbol (ps, msym);
@@ -619,7 +621,7 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
   /* Any other names are assumed to be debugger internal variables.  */
 
   write_exp_elt_opcode (ps, OP_INTERNALVAR);
-  write_exp_elt_intern (ps, create_internalvar (copy_name (str) + 1));
+  write_exp_elt_intern (ps, create_internalvar (copy.c_str () + 1));
   write_exp_elt_opcode (ps, OP_INTERNALVAR);
   return;
 handle_last:
@@ -706,33 +708,12 @@ find_template_name_end (const char *p)
    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.
+   into a separate block of storage.  */
 
-   N.B. A single buffer is reused on each call.  */
-
-char *
+std::string
 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)
-    {
-      namecopy_size = token.length + 1;
-      namecopy = (char *) xrealloc (namecopy, token.length + 1);
-    }
-      
-  memcpy (namecopy, token.ptr, token.length);
-  namecopy[token.length] = 0;
-
-  return namecopy;
+  return std::string (token.ptr, token.length);
 }
 \f
 
index 5244842e58d8d3e527c2226b60622b05b13e991d..4254ef60e621b010797ded1d162823868c038e94 100644 (file)
@@ -331,7 +331,7 @@ extern void write_dollar_variable (struct parser_state *, struct stoken str);
 
 extern const char *find_template_name_end (const char *);
 
-extern char *copy_name (struct stoken);
+extern std::string copy_name (struct stoken);
 
 extern int dump_subexp (struct expression *, struct ui_file *, int);
 
index cb0c147d307afb8472355ab20664bc4de54b07f5..7c2a7046ca24c70c5aa7b2ee5012b39a318447e5 100644 (file)
@@ -50,7 +50,7 @@ type_stack::insert (enum type_pieces tp)
 /* See type-stack.h.  */
 
 void
-type_stack::insert (struct expr_builder *pstate, char *string)
+type_stack::insert (struct expr_builder *pstate, const char *string)
 {
   union type_stack_elt element;
   int slot;
index 672ad05483774e25c1fa04d2a23e6a6f0109e1da..762afde0bf7b882e91bd7339abe7b2475fde26a1 100644 (file)
@@ -160,7 +160,7 @@ public:
      tp_pointer, and the new values are inserted above the first
      item.  */
 
-  void insert (struct expr_builder *pstate, char *string);
+  void insert (struct expr_builder *pstate, const char *string);
 
   /* Append the elements of the type stack FROM to the type stack
      THIS.  Always returns THIS.  */
This page took 0.048732 seconds and 4 git commands to generate.