projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2012-03-01 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git]
/
gdb
/
macroexp.c
diff --git
a/gdb/macroexp.c
b/gdb/macroexp.c
index 7fb23ce65b3e90fd7bbfbf5a10f80cba59b64302..d5e4e40326301b36fb1d4cfd2cc602c08d0933f5 100644
(file)
--- a/
gdb/macroexp.c
+++ b/
gdb/macroexp.c
@@
-1,5
+1,5
@@
/* C preprocessor macro expansion for GDB.
/* C preprocessor macro expansion for GDB.
- Copyright (C) 2002, 2007
, 2008
Free Software Foundation, Inc.
+ Copyright (C) 2002, 2007
-2012
Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of GDB.
Contributed by Red Hat, Inc.
This file is part of GDB.
@@
-23,6
+23,7
@@
#include "macrotab.h"
#include "macroexp.h"
#include "gdb_assert.h"
#include "macrotab.h"
#include "macroexp.h"
#include "gdb_assert.h"
+#include "c-lang.h"
\f
\f
@@
-204,7
+205,7
@@
set_token (struct macro_buffer *tok, char *start, char *end)
init_shared_buffer (tok, start, end - start);
tok->last_token = 0;
init_shared_buffer (tok, start, end - start);
tok->last_token = 0;
- /* Presumed; get_identifier may overwrite this. */
+ /* Presumed; get_identifier may overwrite this.
*/
tok->is_identifier = 0;
}
tok->is_identifier = 0;
}
@@
-278,20
+279,22
@@
get_pp_number (struct macro_buffer *tok, char *p, char *end)
{
if (p < end
&& (macro_is_digit (*p)
{
if (p < end
&& (macro_is_digit (*p)
- || *p == '.'))
+ || (*p == '.'
+ && p + 2 <= end
+ && macro_is_digit (p[1]))))
{
char *tok_start = p;
while (p < end)
{
{
char *tok_start = p;
while (p < end)
{
- if (macro_is_digit (*p)
- || macro_is_identifier_nondigit (*p)
- || *p == '.')
- p++;
- else if (p + 2 <= end
- && strchr ("eEpP.", *p)
- && (p[1] == '+' || p[1] == '-'))
+ if (p + 2 <= end
+ && strchr ("eEpP", *p)
+ && (p[1] == '+' || p[1] == '-'))
p += 2;
p += 2;
+ else if (macro_is_digit (*p)
+ || macro_is_identifier_nondigit (*p)
+ || *p == '.')
+ p++;
else
break;
}
else
break;
}
@@
-318,17
+321,20
@@
get_character_constant (struct macro_buffer *tok, char *p, char *end)
way GDB's C/C++ lexer does. So we call parse_escape in utils.c
to handle escape sequences. */
if ((p + 1 <= end && *p == '\'')
way GDB's C/C++ lexer does. So we call parse_escape in utils.c
to handle escape sequences. */
if ((p + 1 <= end && *p == '\'')
- || (p + 2 <= end && p[0] == 'L' && p[1] == '\''))
+ || (p + 2 <= end
+ && (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
+ && p[1] == '\''))
{
char *tok_start = p;
char *body_start;
{
char *tok_start = p;
char *body_start;
+ int char_count = 0;
if (*p == '\'')
p++;
if (*p == '\'')
p++;
- else if (*p == 'L')
+ else if (*p == 'L'
|| *p == 'u' || *p == 'U'
)
p += 2;
else
p += 2;
else
- gdb_assert
(0
);
+ gdb_assert
_not_reached ("unexpected character constant"
);
body_start = p;
for (;;)
body_start = p;
for (;;)
@@
-337,7
+343,7
@@
get_character_constant (struct macro_buffer *tok, char *p, char *end)
error (_("Unmatched single quote."));
else if (*p == '\'')
{
error (_("Unmatched single quote."));
else if (*p == '\'')
{
- if (
p == body_star
t)
+ if (
!char_coun
t)
error (_("A character constant must contain at least one "
"character."));
p++;
error (_("A character constant must contain at least one "
"character."));
p++;
@@
-346,10
+352,13
@@
get_character_constant (struct macro_buffer *tok, char *p, char *end)
else if (*p == '\\')
{
p++;
else if (*p == '\\')
{
p++;
-
parse_escape (&p
);
+
char_count += c_parse_escape (&p, NULL
);
}
else
}
else
- p++;
+ {
+ p++;
+ char_count++;
+ }
}
set_token (tok, tok_start, p);
}
set_token (tok, tok_start, p);
@@
-368,25
+377,25
@@
static int
get_string_literal (struct macro_buffer *tok, char *p, char *end)
{
if ((p + 1 <= end
get_string_literal (struct macro_buffer *tok, char *p, char *end)
{
if ((p + 1 <= end
- && *p == '
\
"')
+ && *p == '"')
|| (p + 2 <= end
|| (p + 2 <= end
- &&
p[0] == 'L'
- && p[1] == '
\
"'))
+ &&
(p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
+ && p[1] == '"'))
{
char *tok_start = p;
{
char *tok_start = p;
- if (*p == '
\
"')
+ if (*p == '"')
p++;
p++;
- else if (*p == 'L')
+ else if (*p == 'L'
|| *p == 'u' || *p == 'U'
)
p += 2;
else
p += 2;
else
- gdb_assert
(0
);
+ gdb_assert
_not_reached ("unexpected string literal"
);
for (;;)
{
if (p >= end)
error (_("Unterminated string in expression."));
for (;;)
{
if (p >= end)
error (_("Unterminated string in expression."));
- else if (*p == '
\
"')
+ else if (*p == '"')
{
p++;
break;
{
p++;
break;
@@
-397,7
+406,7
@@
get_string_literal (struct macro_buffer *tok, char *p, char *end)
else if (*p == '\\')
{
p++;
else if (*p == '\\')
{
p++;
-
parse_escape (&p
);
+
c_parse_escape (&p, NULL
);
}
else
p++;
}
else
p++;
@@
-516,6
+525,7
@@
get_token (struct macro_buffer *tok,
{
/* How many characters did we consume, including whitespace? */
int consumed = p - src->text + tok->len;
{
/* How many characters did we consume, including whitespace? */
int consumed = p - src->text + tok->len;
+
src->text += consumed;
src->len -= consumed;
return 1;
src->text += consumed;
src->len -= consumed;
return 1;
@@
-693,7
+703,7
@@
struct macro_name_list {
particular macro, and otherwise delegates the decision to another
function/baton pair. But that makes the linked list of excluded
macros chained through untyped baton pointers, which will make it
particular macro, and otherwise delegates the decision to another
function/baton pair. But that makes the linked list of excluded
macros chained through untyped baton pointers, which will make it
- harder to debug. :( */
+ harder to debug. :(
*/
static int
currently_rescanning (struct macro_name_list *list, const char *name)
{
static int
currently_rescanning (struct macro_name_list *list, const char *name)
{
@@
-758,6
+768,7
@@
gather_arguments (const char *name, struct macro_buffer *src,
paren. */
{
struct macro_buffer temp;
paren. */
{
struct macro_buffer temp;
+
init_shared_buffer (&temp, src->text, src->len);
if (! get_token (&tok, &temp)
init_shared_buffer (&temp, src->text, src->len);
if (! get_token (&tok, &temp)
@@
-796,8
+807,6
@@
gather_arguments (const char *name, struct macro_buffer *src,
depth = 0;
for (;;)
{
depth = 0;
for (;;)
{
- char *start = src->text;
-
if (! get_token (&tok, src))
error (_("Malformed argument list for macro `%s'."), name);
if (! get_token (&tok, src))
error (_("Malformed argument list for macro `%s'."), name);
@@
-892,7
+901,8
@@
find_parameter (const struct macro_buffer *tok,
return -1;
for (i = 0; i < argc; ++i)
return -1;
for (i = 0; i < argc; ++i)
- if (tok->len == strlen (argv[i]) && ! memcmp (tok->text, argv[i], tok->len))
+ if (tok->len == strlen (argv[i])
+ && !memcmp (tok->text, argv[i], tok->len))
return i;
if (is_varargs && tok->len == va_arg_name->len
return i;
if (is_varargs && tok->len == va_arg_name->len
@@
-995,7
+1005,7
@@
substitute_args (struct macro_buffer *dest,
&& lookahead.text[0] == '#'
&& lookahead.text[1] == '#')
{
&& lookahead.text[0] == '#'
&& lookahead.text[1] == '#')
{
- int
arg,
finished = 0;
+ int finished = 0;
int prev_was_comma = 0;
/* Note that GCC warns if the result of splicing is not a
int prev_was_comma = 0;
/* Note that GCC warns if the result of splicing is not a
@@
-1009,6
+1019,7
@@
substitute_args (struct macro_buffer *dest,
{
int arg = find_parameter (&tok, is_varargs, va_arg_name,
def->argc, def->argv);
{
int arg = find_parameter (&tok, is_varargs, va_arg_name,
def->argc, def->argv);
+
if (arg != -1)
appendmem (dest, argv[arg].text, argv[arg].len);
else
if (arg != -1)
appendmem (dest, argv[arg].text, argv[arg].len);
else
@@
-1048,6
+1059,7
@@
substitute_args (struct macro_buffer *dest,
{
int arg = find_parameter (&tok, is_varargs, va_arg_name,
def->argc, def->argv);
{
int arg = find_parameter (&tok, is_varargs, va_arg_name,
def->argc, def->argv);
+
if (arg != -1)
appendmem (dest, argv[arg].text, argv[arg].len);
else
if (arg != -1)
appendmem (dest, argv[arg].text, argv[arg].len);
else
@@
-1128,7
+1140,7
@@
substitute_args (struct macro_buffer *dest,
its expansion to DEST. SRC is the input text following the ID
token. We are currently rescanning the expansions of the macros
named in NO_LOOP; don't re-expand them. Use LOOKUP_FUNC and
its expansion to DEST. SRC is the input text following the ID
token. We are currently rescanning the expansions of the macros
named in NO_LOOP; don't re-expand them. Use LOOKUP_FUNC and
- LOOKUP_BATON to find definitions for any nested macro references.
+ LOOKUP_BATON to find definitions for any nested macro references.
Return 1 if we decided to expand it, zero otherwise. (If it's a
function-like macro name that isn't followed by an argument list,
Return 1 if we decided to expand it, zero otherwise. (If it's a
function-like macro name that isn't followed by an argument list,
@@
-1170,7
+1182,7
@@
expand (const char *id,
struct macro_buffer *argv = NULL;
struct macro_buffer substituted;
struct macro_buffer substituted_src;
struct macro_buffer *argv = NULL;
struct macro_buffer substituted;
struct macro_buffer substituted_src;
- struct macro_buffer va_arg_name;
+ struct macro_buffer va_arg_name
= {0}
;
int is_varargs = 0;
if (def->argc >= 1)
int is_varargs = 0;
if (def->argc >= 1)
@@
-1186,6
+1198,7
@@
expand (const char *id,
else
{
int len = strlen (def->argv[def->argc - 1]);
else
{
int len = strlen (def->argv[def->argc - 1]);
+
if (len > 3
&& strcmp (def->argv[def->argc - 1] + len - 3, "...") == 0)
{
if (len > 3
&& strcmp (def->argv[def->argc - 1] + len - 3, "...") == 0)
{
@@
-1290,6
+1303,7
@@
maybe_expand (struct macro_buffer *dest,
lookup function expects. */
char *id = xmalloc (src_first->len + 1);
struct cleanup *back_to = make_cleanup (xfree, id);
lookup function expects. */
char *id = xmalloc (src_first->len + 1);
struct cleanup *back_to = make_cleanup (xfree, id);
+
memcpy (id, src_first->text, src_first->len);
id[src_first->len] = 0;
memcpy (id, src_first->text, src_first->len);
id[src_first->len] = 0;
This page took
0.026817 seconds
and
4
git commands to generate.