2002-05-14 02:13:07 +08:00
|
|
|
|
/* C preprocessor macro expansion for GDB.
|
2019-01-01 14:01:51 +08:00
|
|
|
|
Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
2002-05-14 02:13:07 +08:00
|
|
|
|
Contributed by Red Hat, Inc.
|
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-05-14 02:13:07 +08:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2002-07-29 Andrew Cagney <ac131313@redhat.com>
* gdb_obstack.h: New file.
* symtab.h: Include "gdb_obstack.h" instead of "obstack.h".
(obstack_chunk_alloc, obstack_chunk_free): Delete macros.
* objfiles.h: Include "gdb_obstack.h".
* Makefile.in (gdb_obstack_h): Define.
(symtab_h): Add $(gdb_obstack_h).
(objfiles_h): Add $(gdb_obstack_h).
* objfiles.c: Include "gdb_obstack.h" instead of "obstack.h".
* macrotab.c, cp-valprint.c, dbxread.c: Ditto.
* ch-typeprint.c, ch-valprint.c, dstread.c: Ditto.
* macroexp.c, p-typeprint.c, stabsread.c: Ditto.
* symtab.c, f-typeprint.c, mdebugread.c: Ditto.
* p-valprint.c, symmisc.c, typeprint.c: Ditto.
* symfile.c, coffread.c, c-typeprint.c: Ditto.
* buildsym.c, bcache.c, ada-typeprint.c: Ditto.
* Makefile.in (bcache.o): Update dependencies.
(buildsym.o, c-typeprint.o, ch-typeprint.o): Ditto.
(ch-valprint.o, coffread.o, cp-valprint.o): Ditto.
(dbxread.o, dstread.o, f-typeprint.o): Ditto.
(objfiles.o, p-typeprint.o, p-valprint.o): Ditto.
(stabsread.o, symfile.o, symmisc.o): Ditto.
(symtab.o, typeprint.o, macroexp.o): Ditto.
(macrotab.o, mdebugread.o): Ditto.
(f_lang_h, coff_sym_h, coff_symconst_h): Define.
(coff_ecoff_h, aout_aout64_h): Define.
(aout_stabs_gnu_h, libaout_h): Define.
2002-07-30 06:55:26 +08:00
|
|
|
|
#include "gdb_obstack.h"
|
2002-05-14 02:13:07 +08:00
|
|
|
|
#include "macrotab.h"
|
|
|
|
|
#include "macroexp.h"
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
#include "c-lang.h"
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A resizeable, substringable string type. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A string type that we can resize, quickly append to, and use to
|
|
|
|
|
refer to substrings of other strings. */
|
|
|
|
|
struct macro_buffer
|
|
|
|
|
{
|
|
|
|
|
/* An array of characters. The first LEN bytes are the real text,
|
|
|
|
|
but there are SIZE bytes allocated to the array. If SIZE is
|
|
|
|
|
zero, then this doesn't point to a malloc'ed block. If SHARED is
|
|
|
|
|
non-zero, then this buffer is actually a pointer into some larger
|
|
|
|
|
string, and we shouldn't append characters to it, etc. Because
|
|
|
|
|
of sharing, we can't assume in general that the text is
|
|
|
|
|
null-terminated. */
|
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
|
|
/* The number of characters in the string. */
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
/* The number of characters allocated to the string. If SHARED is
|
|
|
|
|
non-zero, this is meaningless; in this case, we set it to zero so
|
|
|
|
|
that any "do we have room to append something?" tests will fail,
|
|
|
|
|
so we don't always have to check SHARED before using this field. */
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
|
|
/* Zero if TEXT can be safely realloc'ed (i.e., it's its own malloc
|
|
|
|
|
block). Non-zero if TEXT is actually pointing into the middle of
|
2017-04-06 02:21:33 +08:00
|
|
|
|
some other block, or to a string literal, and we shouldn't
|
|
|
|
|
reallocate it. */
|
|
|
|
|
bool shared;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* For detecting token splicing.
|
|
|
|
|
|
|
|
|
|
This is the index in TEXT of the first character of the token
|
|
|
|
|
that abuts the end of TEXT. If TEXT contains no tokens, then we
|
|
|
|
|
set this equal to LEN. If TEXT ends in whitespace, then there is
|
|
|
|
|
no token abutting the end of TEXT (it's just whitespace), and
|
|
|
|
|
again, we set this equal to LEN. We set this to -1 if we don't
|
|
|
|
|
know the nature of TEXT. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
int last_token = -1;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* If this buffer is holding the result from get_token, then this
|
|
|
|
|
is non-zero if it is an identifier token, zero otherwise. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
int is_identifier = 0;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
macro_buffer ()
|
|
|
|
|
: text (NULL),
|
|
|
|
|
len (0),
|
|
|
|
|
size (0),
|
|
|
|
|
shared (false)
|
|
|
|
|
{
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Set the macro buffer to the empty string, guessing that its
|
|
|
|
|
final contents will fit in N bytes. (It'll get resized if it
|
|
|
|
|
doesn't, so the guess doesn't have to be right.) Allocate the
|
|
|
|
|
initial storage with xmalloc. */
|
|
|
|
|
explicit macro_buffer (int n)
|
|
|
|
|
: len (0),
|
|
|
|
|
size (n),
|
|
|
|
|
shared (false)
|
|
|
|
|
{
|
|
|
|
|
if (n > 0)
|
|
|
|
|
text = (char *) xmalloc (n);
|
|
|
|
|
else
|
|
|
|
|
text = NULL;
|
|
|
|
|
}
|
2012-05-17 04:31:10 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Set the macro buffer to refer to the LEN bytes at ADDR, as a
|
|
|
|
|
shared substring. */
|
|
|
|
|
macro_buffer (const char *addr, int len)
|
|
|
|
|
{
|
|
|
|
|
set_shared (addr, len);
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Set the macro buffer to refer to the LEN bytes at ADDR, as a
|
|
|
|
|
shared substring. */
|
|
|
|
|
void set_shared (const char *addr, int len_)
|
|
|
|
|
{
|
|
|
|
|
text = (char *) addr;
|
|
|
|
|
len = len_;
|
|
|
|
|
size = 0;
|
|
|
|
|
shared = true;
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2018-06-17 00:39:30 +08:00
|
|
|
|
macro_buffer& operator= (const macro_buffer &src)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (src.shared);
|
|
|
|
|
gdb_assert (shared);
|
|
|
|
|
set_shared (src.text, src.len);
|
|
|
|
|
last_token = src.last_token;
|
|
|
|
|
is_identifier = src.is_identifier;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
~macro_buffer ()
|
|
|
|
|
{
|
|
|
|
|
if (! shared && size)
|
|
|
|
|
xfree (text);
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Release the text of the buffer to the caller, which is now
|
|
|
|
|
responsible for freeing it. */
|
2019-02-27 05:52:05 +08:00
|
|
|
|
ATTRIBUTE_UNUSED_RESULT char *release ()
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
{
|
|
|
|
|
gdb_assert (! shared);
|
|
|
|
|
gdb_assert (size);
|
|
|
|
|
char *result = text;
|
|
|
|
|
text = NULL;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Resize the buffer to be at least N bytes long. Raise an error if
|
|
|
|
|
the buffer shouldn't be resized. */
|
|
|
|
|
void resize_buffer (int n)
|
|
|
|
|
{
|
|
|
|
|
/* We shouldn't be trying to resize shared strings. */
|
|
|
|
|
gdb_assert (! shared);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (size == 0)
|
|
|
|
|
size = n;
|
|
|
|
|
else
|
|
|
|
|
while (size <= n)
|
|
|
|
|
size *= 2;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
text = (char *) xrealloc (text, size);
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Append the character C to the buffer. */
|
|
|
|
|
void appendc (int c)
|
|
|
|
|
{
|
|
|
|
|
int new_len = len + 1;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (new_len > size)
|
|
|
|
|
resize_buffer (new_len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
text[len] = c;
|
|
|
|
|
len = new_len;
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* Append the COUNT bytes at ADDR to the buffer. */
|
|
|
|
|
void appendmem (const char *addr, int count)
|
|
|
|
|
{
|
|
|
|
|
int new_len = len + count;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (new_len > size)
|
|
|
|
|
resize_buffer (new_len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
memcpy (text + len, addr, count);
|
|
|
|
|
len = new_len;
|
|
|
|
|
}
|
|
|
|
|
};
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Recognizing preprocessor tokens. */
|
|
|
|
|
|
|
|
|
|
|
2008-07-19 04:55:33 +08:00
|
|
|
|
int
|
|
|
|
|
macro_is_whitespace (int c)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
return (c == ' '
|
|
|
|
|
|| c == '\t'
|
|
|
|
|
|| c == '\n'
|
|
|
|
|
|| c == '\v'
|
|
|
|
|
|| c == '\f');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-07-19 04:55:33 +08:00
|
|
|
|
int
|
|
|
|
|
macro_is_digit (int c)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
return ('0' <= c && c <= '9');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-07-19 04:55:33 +08:00
|
|
|
|
int
|
|
|
|
|
macro_is_identifier_nondigit (int c)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
return (c == '_'
|
|
|
|
|
|| ('a' <= c && c <= 'z')
|
|
|
|
|
|| ('A' <= c && c <= 'Z'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_token (struct macro_buffer *tok, char *start, char *end)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
tok->set_shared (start, end - start);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
tok->last_token = 0;
|
|
|
|
|
|
2011-01-09 11:20:33 +08:00
|
|
|
|
/* Presumed; get_identifier may overwrite this. */
|
2002-05-14 02:13:07 +08:00
|
|
|
|
tok->is_identifier = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_comment (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
if (p + 2 > end)
|
|
|
|
|
return 0;
|
|
|
|
|
else if (p[0] == '/'
|
|
|
|
|
&& p[1] == '*')
|
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
|
|
|
|
|
|
|
|
|
p += 2;
|
|
|
|
|
|
|
|
|
|
for (; p < end; p++)
|
|
|
|
|
if (p + 2 <= end
|
|
|
|
|
&& p[0] == '*'
|
|
|
|
|
&& p[1] == '/')
|
|
|
|
|
{
|
|
|
|
|
p += 2;
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Unterminated comment in macro expansion."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
else if (p[0] == '/'
|
|
|
|
|
&& p[1] == '/')
|
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
|
|
|
|
|
|
|
|
|
p += 2;
|
|
|
|
|
for (; p < end; p++)
|
|
|
|
|
if (*p == '\n')
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_identifier (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
if (p < end
|
2008-07-19 04:55:33 +08:00
|
|
|
|
&& macro_is_identifier_nondigit (*p))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
|
|
|
|
|
|
|
|
|
while (p < end
|
2008-07-19 04:55:33 +08:00
|
|
|
|
&& (macro_is_identifier_nondigit (*p)
|
|
|
|
|
|| macro_is_digit (*p)))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
tok->is_identifier = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_pp_number (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
if (p < end
|
2008-07-19 04:55:33 +08:00
|
|
|
|
&& (macro_is_digit (*p)
|
2008-12-13 01:03:37 +08:00
|
|
|
|
|| (*p == '.'
|
|
|
|
|
&& p + 2 <= end
|
|
|
|
|
&& macro_is_digit (p[1]))))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
|
|
|
|
|
|
|
|
|
while (p < end)
|
|
|
|
|
{
|
2008-12-13 01:03:37 +08:00
|
|
|
|
if (p + 2 <= end
|
|
|
|
|
&& strchr ("eEpP", *p)
|
|
|
|
|
&& (p[1] == '+' || p[1] == '-'))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p += 2;
|
2008-12-13 01:03:37 +08:00
|
|
|
|
else if (macro_is_digit (*p)
|
|
|
|
|
|| macro_is_identifier_nondigit (*p)
|
|
|
|
|
|| *p == '.')
|
|
|
|
|
p++;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If the text starting at P going up to (but not including) END
|
|
|
|
|
starts with a character constant, set *TOK to point to that
|
|
|
|
|
character constant, and return 1. Otherwise, return zero.
|
|
|
|
|
Signal an error if it contains a malformed or incomplete character
|
|
|
|
|
constant. */
|
|
|
|
|
static int
|
|
|
|
|
get_character_constant (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
/* ISO/IEC 9899:1999 (E) Section 6.4.4.4 paragraph 1
|
|
|
|
|
But of course, what really matters is that we handle it the same
|
|
|
|
|
way GDB's C/C++ lexer does. So we call parse_escape in utils.c
|
|
|
|
|
to handle escape sequences. */
|
|
|
|
|
if ((p + 1 <= end && *p == '\'')
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
|| (p + 2 <= end
|
|
|
|
|
&& (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
|
|
|
|
|
&& p[1] == '\''))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
int char_count = 0;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
if (*p == '\'')
|
|
|
|
|
p++;
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
else if (*p == 'L' || *p == 'u' || *p == 'U')
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p += 2;
|
|
|
|
|
else
|
2010-08-19 03:13:33 +08:00
|
|
|
|
gdb_assert_not_reached ("unexpected character constant");
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (p >= end)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Unmatched single quote."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
else if (*p == '\'')
|
|
|
|
|
{
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
if (!char_count)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("A character constant must contain at least one "
|
|
|
|
|
"character."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (*p == '\\')
|
|
|
|
|
{
|
2013-10-02 08:46:07 +08:00
|
|
|
|
const char *s, *o;
|
|
|
|
|
|
|
|
|
|
s = o = ++p;
|
|
|
|
|
char_count += c_parse_escape (&s, NULL);
|
|
|
|
|
p += s - o;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
{
|
|
|
|
|
p++;
|
|
|
|
|
char_count++;
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If the text starting at P going up to (but not including) END
|
|
|
|
|
starts with a string literal, set *TOK to point to that string
|
|
|
|
|
literal, and return 1. Otherwise, return zero. Signal an error if
|
|
|
|
|
it contains a malformed or incomplete string literal. */
|
|
|
|
|
static int
|
|
|
|
|
get_string_literal (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
if ((p + 1 <= end
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
&& *p == '"')
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|| (p + 2 <= end
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
&& (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
|
|
|
|
|
&& p[1] == '"'))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
char *tok_start = p;
|
|
|
|
|
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
if (*p == '"')
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p++;
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
else if (*p == 'L' || *p == 'u' || *p == 'U')
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p += 2;
|
|
|
|
|
else
|
2010-08-19 03:13:33 +08:00
|
|
|
|
gdb_assert_not_reached ("unexpected string literal");
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (p >= end)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Unterminated string in expression."));
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 07:04:40 +08:00
|
|
|
|
else if (*p == '"')
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
p++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (*p == '\n')
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Newline characters may not appear in string "
|
|
|
|
|
"constants."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
else if (*p == '\\')
|
|
|
|
|
{
|
2013-10-02 08:46:07 +08:00
|
|
|
|
const char *s, *o;
|
|
|
|
|
|
|
|
|
|
s = o = ++p;
|
|
|
|
|
c_parse_escape (&s, NULL);
|
|
|
|
|
p += s - o;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_token (tok, tok_start, p);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_punctuator (struct macro_buffer *tok, char *p, char *end)
|
|
|
|
|
{
|
|
|
|
|
/* Here, speed is much less important than correctness and clarity. */
|
|
|
|
|
|
2008-07-27 09:58:01 +08:00
|
|
|
|
/* ISO/IEC 9899:1999 (E) Section 6.4.6 Paragraph 1.
|
|
|
|
|
Note that this table is ordered in a special way. A punctuator
|
|
|
|
|
which is a prefix of another punctuator must appear after its
|
|
|
|
|
"extension". Otherwise, the wrong token will be returned. */
|
2002-05-14 02:13:07 +08:00
|
|
|
|
static const char * const punctuators[] = {
|
2008-07-27 09:58:01 +08:00
|
|
|
|
"[", "]", "(", ")", "{", "}", "?", ";", ",", "~",
|
|
|
|
|
"...", ".",
|
|
|
|
|
"->", "--", "-=", "-",
|
|
|
|
|
"++", "+=", "+",
|
|
|
|
|
"*=", "*",
|
|
|
|
|
"!=", "!",
|
|
|
|
|
"&&", "&=", "&",
|
|
|
|
|
"/=", "/",
|
|
|
|
|
"%>", "%:%:", "%:", "%=", "%",
|
|
|
|
|
"^=", "^",
|
|
|
|
|
"##", "#",
|
|
|
|
|
":>", ":",
|
|
|
|
|
"||", "|=", "|",
|
|
|
|
|
"<<=", "<<", "<=", "<:", "<%", "<",
|
|
|
|
|
">>=", ">>", ">=", ">",
|
|
|
|
|
"==", "=",
|
2002-05-14 02:13:07 +08:00
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (p + 1 <= end)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; punctuators[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
const char *punctuator = punctuators[i];
|
|
|
|
|
|
|
|
|
|
if (p[0] == punctuator[0])
|
|
|
|
|
{
|
|
|
|
|
int len = strlen (punctuator);
|
|
|
|
|
|
|
|
|
|
if (p + len <= end
|
|
|
|
|
&& ! memcmp (p, punctuator, len))
|
|
|
|
|
{
|
|
|
|
|
set_token (tok, p, p + len);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Peel the next preprocessor token off of SRC, and put it in TOK.
|
|
|
|
|
Mutate TOK to refer to the first token in SRC, and mutate SRC to
|
|
|
|
|
refer to the text after that token. SRC must be a shared buffer;
|
|
|
|
|
the resulting TOK will be shared, pointing into the same string SRC
|
|
|
|
|
does. Initialize TOK's last_token field. Return non-zero if we
|
|
|
|
|
succeed, or 0 if we didn't find any more tokens in SRC. */
|
|
|
|
|
static int
|
|
|
|
|
get_token (struct macro_buffer *tok,
|
|
|
|
|
struct macro_buffer *src)
|
|
|
|
|
{
|
|
|
|
|
char *p = src->text;
|
|
|
|
|
char *end = p + src->len;
|
|
|
|
|
|
|
|
|
|
gdb_assert (src->shared);
|
|
|
|
|
|
|
|
|
|
/* From the ISO C standard, ISO/IEC 9899:1999 (E), section 6.4:
|
|
|
|
|
|
|
|
|
|
preprocessing-token:
|
|
|
|
|
header-name
|
|
|
|
|
identifier
|
|
|
|
|
pp-number
|
|
|
|
|
character-constant
|
|
|
|
|
string-literal
|
|
|
|
|
punctuator
|
|
|
|
|
each non-white-space character that cannot be one of the above
|
|
|
|
|
|
|
|
|
|
We don't have to deal with header-name tokens, since those can
|
|
|
|
|
only occur after a #include, which we will never see. */
|
|
|
|
|
|
|
|
|
|
while (p < end)
|
2008-07-19 04:55:33 +08:00
|
|
|
|
if (macro_is_whitespace (*p))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
p++;
|
|
|
|
|
else if (get_comment (tok, p, end))
|
|
|
|
|
p += tok->len;
|
|
|
|
|
else if (get_pp_number (tok, p, end)
|
|
|
|
|
|| get_character_constant (tok, p, end)
|
|
|
|
|
|| get_string_literal (tok, p, end)
|
|
|
|
|
/* Note: the grammar in the standard seems to be
|
|
|
|
|
ambiguous: L'x' can be either a wide character
|
|
|
|
|
constant, or an identifier followed by a normal
|
|
|
|
|
character constant. By trying `get_identifier' after
|
|
|
|
|
we try get_character_constant and get_string_literal,
|
|
|
|
|
we give the wide character syntax precedence. Now,
|
|
|
|
|
since GDB doesn't handle wide character constants
|
|
|
|
|
anyway, is this the right thing to do? */
|
|
|
|
|
|| get_identifier (tok, p, end)
|
|
|
|
|
|| get_punctuator (tok, p, end))
|
|
|
|
|
{
|
|
|
|
|
/* How many characters did we consume, including whitespace? */
|
|
|
|
|
int consumed = p - src->text + tok->len;
|
2010-05-16 08:18:02 +08:00
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
src->text += consumed;
|
|
|
|
|
src->len -= consumed;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We have found a "non-whitespace character that cannot be
|
|
|
|
|
one of the above." Make a token out of it. */
|
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
|
|
set_token (tok, p, p + 1);
|
|
|
|
|
consumed = p - src->text + tok->len;
|
|
|
|
|
src->text += consumed;
|
|
|
|
|
src->len -= consumed;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Appending token strings, with and without splicing */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Append the macro buffer SRC to the end of DEST, and ensure that
|
|
|
|
|
doing so doesn't splice the token at the end of SRC with the token
|
|
|
|
|
at the beginning of DEST. SRC and DEST must have their last_token
|
|
|
|
|
fields set. Upon return, DEST's last_token field is set correctly.
|
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
If DEST is "(" and SRC is "y", then we can return with
|
|
|
|
|
DEST set to "(y" --- we've simply appended the two buffers.
|
|
|
|
|
|
|
|
|
|
However, if DEST is "x" and SRC is "y", then we must not return
|
|
|
|
|
with DEST set to "xy" --- that would splice the two tokens "x" and
|
|
|
|
|
"y" together to make a single token "xy". However, it would be
|
|
|
|
|
fine to return with DEST set to "x y". Similarly, "<" and "<" must
|
|
|
|
|
yield "< <", not "<<", etc. */
|
|
|
|
|
static void
|
|
|
|
|
append_tokens_without_splicing (struct macro_buffer *dest,
|
|
|
|
|
struct macro_buffer *src)
|
|
|
|
|
{
|
|
|
|
|
int original_dest_len = dest->len;
|
|
|
|
|
struct macro_buffer dest_tail, new_token;
|
|
|
|
|
|
|
|
|
|
gdb_assert (src->last_token != -1);
|
|
|
|
|
gdb_assert (dest->last_token != -1);
|
|
|
|
|
|
|
|
|
|
/* First, just try appending the two, and call get_token to see if
|
|
|
|
|
we got a splice. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (src->text, src->len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* If DEST originally had no token abutting its end, then we can't
|
|
|
|
|
have spliced anything, so we're done. */
|
|
|
|
|
if (dest->last_token == original_dest_len)
|
|
|
|
|
{
|
|
|
|
|
dest->last_token = original_dest_len + src->last_token;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set DEST_TAIL to point to the last token in DEST, followed by
|
|
|
|
|
all the stuff we just appended. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest_tail.set_shared (dest->text + dest->last_token,
|
|
|
|
|
dest->len - dest->last_token);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Re-parse DEST's last token. We know that DEST used to contain
|
|
|
|
|
at least one token, so if it doesn't contain any after the
|
|
|
|
|
append, then we must have spliced "/" and "*" or "/" and "/" to
|
|
|
|
|
make a comment start. (Just for the record, I got this right
|
|
|
|
|
the first time. This is not a bug fix.) */
|
|
|
|
|
if (get_token (&new_token, &dest_tail)
|
|
|
|
|
&& (new_token.text + new_token.len
|
|
|
|
|
== dest->text + original_dest_len))
|
|
|
|
|
{
|
|
|
|
|
/* No splice, so we're done. */
|
|
|
|
|
dest->last_token = original_dest_len + src->last_token;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Okay, a simple append caused a splice. Let's chop dest back to
|
|
|
|
|
its original length and try again, but separate the texts with a
|
|
|
|
|
space. */
|
|
|
|
|
dest->len = original_dest_len;
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc (' ');
|
|
|
|
|
dest->appendmem (src->text, src->len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest_tail.set_shared (dest->text + dest->last_token,
|
|
|
|
|
dest->len - dest->last_token);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Try to re-parse DEST's last token, as above. */
|
|
|
|
|
if (get_token (&new_token, &dest_tail)
|
|
|
|
|
&& (new_token.text + new_token.len
|
|
|
|
|
== dest->text + original_dest_len))
|
|
|
|
|
{
|
|
|
|
|
/* No splice, so we're done. */
|
|
|
|
|
dest->last_token = original_dest_len + 1 + src->last_token;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* As far as I know, there's no case where inserting a space isn't
|
|
|
|
|
enough to prevent a splice. */
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("unable to avoid splicing tokens during macro expansion"));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
/* Stringify an argument, and insert it into DEST. ARG is the text to
|
|
|
|
|
stringify; it is LEN bytes long. */
|
|
|
|
|
|
|
|
|
|
static void
|
2012-05-17 04:31:10 +08:00
|
|
|
|
stringify (struct macro_buffer *dest, const char *arg, int len)
|
2008-09-28 05:40:49 +08:00
|
|
|
|
{
|
|
|
|
|
/* Trim initial whitespace from ARG. */
|
|
|
|
|
while (len > 0 && macro_is_whitespace (*arg))
|
|
|
|
|
{
|
|
|
|
|
++arg;
|
|
|
|
|
--len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Trim trailing whitespace from ARG. */
|
|
|
|
|
while (len > 0 && macro_is_whitespace (arg[len - 1]))
|
|
|
|
|
--len;
|
|
|
|
|
|
|
|
|
|
/* Insert the string. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc ('"');
|
2008-09-28 05:40:49 +08:00
|
|
|
|
while (len > 0)
|
|
|
|
|
{
|
|
|
|
|
/* We could try to handle strange cases here, like control
|
|
|
|
|
characters, but there doesn't seem to be much point. */
|
|
|
|
|
if (macro_is_whitespace (*arg))
|
|
|
|
|
{
|
|
|
|
|
/* Replace a sequence of whitespace with a single space. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc (' ');
|
2008-09-28 05:40:49 +08:00
|
|
|
|
while (len > 1 && macro_is_whitespace (arg[1]))
|
|
|
|
|
{
|
|
|
|
|
++arg;
|
|
|
|
|
--len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (*arg == '\\' || *arg == '"')
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc ('\\');
|
|
|
|
|
dest->appendc (*arg);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc (*arg);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
++arg;
|
|
|
|
|
--len;
|
|
|
|
|
}
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendc ('"');
|
2008-09-28 05:40:49 +08:00
|
|
|
|
dest->last_token = dest->len;
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2012-05-17 04:31:10 +08:00
|
|
|
|
/* See macroexp.h. */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
macro_stringify (const char *str)
|
|
|
|
|
{
|
|
|
|
|
int len = strlen (str);
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer buffer (len);
|
2012-05-17 04:31:10 +08:00
|
|
|
|
|
|
|
|
|
stringify (&buffer, str, len);
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
buffer.appendc ('\0');
|
2012-05-17 04:31:10 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
return buffer.release ();
|
2012-05-17 04:31:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Expanding macros! */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A singly-linked list of the names of the macros we are currently
|
|
|
|
|
expanding --- for detecting expansion loops. */
|
|
|
|
|
struct macro_name_list {
|
|
|
|
|
const char *name;
|
|
|
|
|
struct macro_name_list *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return non-zero if we are currently expanding the macro named NAME,
|
|
|
|
|
according to LIST; otherwise, return zero.
|
|
|
|
|
|
|
|
|
|
You know, it would be possible to get rid of all the NO_LOOP
|
|
|
|
|
arguments to these functions by simply generating a new lookup
|
|
|
|
|
function and baton which refuses to find the definition for a
|
|
|
|
|
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
|
2011-01-09 11:20:33 +08:00
|
|
|
|
harder to debug. :( */
|
2002-05-14 02:13:07 +08:00
|
|
|
|
static int
|
|
|
|
|
currently_rescanning (struct macro_name_list *list, const char *name)
|
|
|
|
|
{
|
|
|
|
|
for (; list; list = list->next)
|
* macroexp.c (init_buffer, gather_arguments, expand): Use NULL, not 0.
* macrotab.c (macro_lookup_inclusion, find_definition,
new_macro_table): Same.
* macroexp.c (currently_rescanning, expand): Use `strcmp () == 0',
not `! strcmp ()'. This is a dubious improvement.
* macrotab.c (macro_lookup_inclusion, find_definition): Same.
* macrotab.c (macro_lookup_inclusion): Initialize `best_depth',
although it's not necessary, to avoid a warning.
2002-05-15 05:31:05 +08:00
|
|
|
|
if (strcmp (name, list->name) == 0)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Gather the arguments to a macro expansion.
|
|
|
|
|
|
|
|
|
|
NAME is the name of the macro being invoked. (It's only used for
|
|
|
|
|
printing error messages.)
|
|
|
|
|
|
|
|
|
|
Assume that SRC is the text of the macro invocation immediately
|
|
|
|
|
following the macro name. For example, if we're processing the
|
|
|
|
|
text foo(bar, baz), then NAME would be foo and SRC will be (bar,
|
|
|
|
|
baz).
|
|
|
|
|
|
|
|
|
|
If SRC doesn't start with an open paren ( token at all, return
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
false, leave SRC unchanged, and don't set *ARGS_PTR to anything.
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
If SRC doesn't contain a properly terminated argument list, then
|
|
|
|
|
raise an error.
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
For a variadic macro, NARGS holds the number of formal arguments to
|
|
|
|
|
the macro. For a GNU-style variadic macro, this should be the
|
|
|
|
|
number of named arguments. For a non-variadic macro, NARGS should
|
|
|
|
|
be -1.
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
Otherwise, return true and set *ARGS_PTR to a vector of macro
|
|
|
|
|
buffers referring to the argument texts. The macro buffers share
|
|
|
|
|
their text with SRC, and their last_token fields are initialized.
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
NOTE WELL: if SRC starts with a open paren ( token followed
|
|
|
|
|
immediately by a close paren ) token (e.g., the invocation looks
|
|
|
|
|
like "foo()"), we treat that as one argument, which happens to be
|
|
|
|
|
the empty list of tokens. The caller should keep in mind that such
|
|
|
|
|
a sequence of tokens is a valid way to invoke one-parameter
|
|
|
|
|
function-like macros, but also a valid way to invoke zero-parameter
|
|
|
|
|
function-like macros. Eeew.
|
|
|
|
|
|
|
|
|
|
Consume the tokens from SRC; after this call, SRC contains the text
|
|
|
|
|
following the invocation. */
|
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
static bool
|
|
|
|
|
gather_arguments (const char *name, struct macro_buffer *src, int nargs,
|
|
|
|
|
std::vector<struct macro_buffer> *args_ptr)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
struct macro_buffer tok;
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
std::vector<struct macro_buffer> args;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Does SRC start with an opening paren token? Read from a copy of
|
|
|
|
|
SRC, so SRC itself is unaffected if we don't find an opening
|
|
|
|
|
paren. */
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer temp (src->text, src->len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
if (! get_token (&tok, &temp)
|
|
|
|
|
|| tok.len != 1
|
|
|
|
|
|| tok.text[0] != '(')
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
return false;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Consume SRC's opening paren. */
|
|
|
|
|
get_token (&tok, src);
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
struct macro_buffer *arg;
|
|
|
|
|
int depth;
|
|
|
|
|
|
|
|
|
|
/* Initialize the next argument. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
args.emplace_back ();
|
|
|
|
|
arg = &args.back ();
|
2002-05-14 02:13:07 +08:00
|
|
|
|
set_token (arg, src->text, src->text);
|
|
|
|
|
|
|
|
|
|
/* Gather the argument's tokens. */
|
|
|
|
|
depth = 0;
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (! get_token (&tok, src))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Malformed argument list for macro `%s'."), name);
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* Is tok an opening paren? */
|
|
|
|
|
if (tok.len == 1 && tok.text[0] == '(')
|
|
|
|
|
depth++;
|
|
|
|
|
|
|
|
|
|
/* Is tok is a closing paren? */
|
|
|
|
|
else if (tok.len == 1 && tok.text[0] == ')')
|
|
|
|
|
{
|
|
|
|
|
/* If it's a closing paren at the top level, then that's
|
|
|
|
|
the end of the argument list. */
|
|
|
|
|
if (depth == 0)
|
|
|
|
|
{
|
2008-09-28 05:40:49 +08:00
|
|
|
|
/* In the varargs case, the last argument may be
|
|
|
|
|
missing. Add an empty argument in this case. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (nargs != -1 && args.size () == nargs - 1)
|
2008-09-28 05:40:49 +08:00
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
args.emplace_back ();
|
|
|
|
|
arg = &args.back ();
|
2008-09-28 05:40:49 +08:00
|
|
|
|
set_token (arg, src->text, src->text);
|
|
|
|
|
}
|
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
*args_ptr = std::move (args);
|
|
|
|
|
return true;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
depth--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If tok is a comma at top level, then that's the end of
|
2008-09-28 05:40:49 +08:00
|
|
|
|
the current argument. However, if we are handling a
|
|
|
|
|
variadic macro and we are computing the last argument, we
|
|
|
|
|
want to include the comma and remaining tokens. */
|
|
|
|
|
else if (tok.len == 1 && tok.text[0] == ',' && depth == 0
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
&& (nargs == -1 || args.size () < nargs))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Extend the current argument to enclose this token. If
|
|
|
|
|
this is the current argument's first token, leave out any
|
|
|
|
|
leading whitespace, just for aesthetics. */
|
|
|
|
|
if (arg->len == 0)
|
|
|
|
|
{
|
|
|
|
|
arg->text = tok.text;
|
|
|
|
|
arg->len = tok.len;
|
|
|
|
|
arg->last_token = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
arg->len = (tok.text + tok.len) - arg->text;
|
|
|
|
|
arg->last_token = tok.text - arg->text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The `expand' and `substitute_args' functions both invoke `scan'
|
|
|
|
|
recursively, so we need a forward declaration somewhere. */
|
|
|
|
|
static void scan (struct macro_buffer *dest,
|
|
|
|
|
struct macro_buffer *src,
|
|
|
|
|
struct macro_name_list *no_loop,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton);
|
|
|
|
|
|
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
/* A helper function for substitute_args.
|
|
|
|
|
|
|
|
|
|
ARGV is a vector of all the arguments; ARGC is the number of
|
|
|
|
|
arguments. IS_VARARGS is true if the macro being substituted is a
|
|
|
|
|
varargs macro; in this case VA_ARG_NAME is the name of the
|
|
|
|
|
"variable" argument. VA_ARG_NAME is ignored if IS_VARARGS is
|
|
|
|
|
false.
|
|
|
|
|
|
|
|
|
|
If the token TOK is the name of a parameter, return the parameter's
|
|
|
|
|
index. If TOK is not an argument, return -1. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
find_parameter (const struct macro_buffer *tok,
|
|
|
|
|
int is_varargs, const struct macro_buffer *va_arg_name,
|
|
|
|
|
int argc, const char * const *argv)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (! tok->is_identifier)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < argc; ++i)
|
2011-01-06 06:22:53 +08:00
|
|
|
|
if (tok->len == strlen (argv[i])
|
|
|
|
|
&& !memcmp (tok->text, argv[i], tok->len))
|
2008-09-28 05:40:49 +08:00
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
if (is_varargs && tok->len == va_arg_name->len
|
|
|
|
|
&& ! memcmp (tok->text, va_arg_name->text, tok->len))
|
|
|
|
|
return argc - 1;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 10:36:41 +08:00
|
|
|
|
/* Helper function for substitute_args that gets the next token and
|
|
|
|
|
updates the passed-in state variables. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_next_token_for_substitution (struct macro_buffer *replacement_list,
|
|
|
|
|
struct macro_buffer *token,
|
|
|
|
|
char **start,
|
|
|
|
|
struct macro_buffer *lookahead,
|
|
|
|
|
char **lookahead_start,
|
|
|
|
|
int *lookahead_valid,
|
|
|
|
|
bool *keep_going)
|
|
|
|
|
{
|
|
|
|
|
if (!*lookahead_valid)
|
|
|
|
|
*keep_going = false;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*keep_going = true;
|
|
|
|
|
*token = *lookahead;
|
|
|
|
|
*start = *lookahead_start;
|
|
|
|
|
*lookahead_start = replacement_list->text;
|
|
|
|
|
*lookahead_valid = get_token (lookahead, replacement_list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* Given the macro definition DEF, being invoked with the actual
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
arguments given by ARGV, substitute the arguments into the
|
2002-05-14 02:13:07 +08:00
|
|
|
|
replacement list, and store the result in DEST.
|
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
IS_VARARGS should be true if DEF is a varargs macro. In this case,
|
|
|
|
|
VA_ARG_NAME should be the name of the "variable" argument -- either
|
|
|
|
|
__VA_ARGS__ for c99-style varargs, or the final argument name, for
|
|
|
|
|
GNU-style varargs. If IS_VARARGS is false, this parameter is
|
|
|
|
|
ignored.
|
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
If it is necessary to expand macro invocations in one of the
|
|
|
|
|
arguments, use LOOKUP_FUNC and LOOKUP_BATON to find the macro
|
|
|
|
|
definitions, and don't expand invocations of the macros listed in
|
|
|
|
|
NO_LOOP. */
|
2008-09-28 05:40:49 +08:00
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
static void
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
substitute_args (struct macro_buffer *dest,
|
2002-05-14 02:13:07 +08:00
|
|
|
|
struct macro_definition *def,
|
2008-09-28 05:40:49 +08:00
|
|
|
|
int is_varargs, const struct macro_buffer *va_arg_name,
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
const std::vector<struct macro_buffer> &argv,
|
2002-05-14 02:13:07 +08:00
|
|
|
|
struct macro_name_list *no_loop,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton)
|
|
|
|
|
{
|
2008-09-28 05:40:49 +08:00
|
|
|
|
/* The token we are currently considering. */
|
|
|
|
|
struct macro_buffer tok;
|
|
|
|
|
/* The replacement list's pointer from just before TOK was lexed. */
|
|
|
|
|
char *original_rl_start;
|
|
|
|
|
/* We have a single lookahead token to handle token splicing. */
|
|
|
|
|
struct macro_buffer lookahead;
|
|
|
|
|
/* The lookahead token might not be valid. */
|
|
|
|
|
int lookahead_valid;
|
|
|
|
|
/* The replacement list's pointer from just before LOOKAHEAD was
|
|
|
|
|
lexed. */
|
|
|
|
|
char *lookahead_rl_start;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
/* A macro buffer for the macro's replacement list. */
|
|
|
|
|
struct macro_buffer replacement_list (def->replacement,
|
|
|
|
|
strlen (def->replacement));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
gdb_assert (dest->len == 0);
|
|
|
|
|
dest->last_token = 0;
|
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
original_rl_start = replacement_list.text;
|
|
|
|
|
if (! get_token (&tok, &replacement_list))
|
|
|
|
|
return;
|
|
|
|
|
lookahead_rl_start = replacement_list.text;
|
|
|
|
|
lookahead_valid = get_token (&lookahead, &replacement_list);
|
|
|
|
|
|
2017-09-18 10:36:41 +08:00
|
|
|
|
/* __VA_OPT__ state variable. The states are:
|
|
|
|
|
0 - nothing happening
|
|
|
|
|
1 - saw __VA_OPT__
|
|
|
|
|
>= 2 in __VA_OPT__, the value encodes the parenthesis depth. */
|
|
|
|
|
unsigned vaopt_state = 0;
|
|
|
|
|
|
|
|
|
|
for (bool keep_going = true;
|
|
|
|
|
keep_going;
|
|
|
|
|
get_next_token_for_substitution (&replacement_list,
|
|
|
|
|
&tok,
|
|
|
|
|
&original_rl_start,
|
|
|
|
|
&lookahead,
|
|
|
|
|
&lookahead_rl_start,
|
|
|
|
|
&lookahead_valid,
|
|
|
|
|
&keep_going))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
2017-09-18 10:36:41 +08:00
|
|
|
|
bool token_is_vaopt = (tok.len == 10
|
|
|
|
|
&& strncmp (tok.text, "__VA_OPT__", 10) == 0);
|
|
|
|
|
|
|
|
|
|
if (vaopt_state > 0)
|
|
|
|
|
{
|
|
|
|
|
if (token_is_vaopt)
|
|
|
|
|
error (_("__VA_OPT__ cannot appear inside __VA_OPT__"));
|
|
|
|
|
else if (tok.len == 1 && tok.text[0] == '(')
|
|
|
|
|
{
|
|
|
|
|
++vaopt_state;
|
|
|
|
|
/* We just entered __VA_OPT__, so don't emit this
|
|
|
|
|
token. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (vaopt_state == 1)
|
|
|
|
|
error (_("__VA_OPT__ must be followed by an open parenthesis"));
|
|
|
|
|
else if (tok.len == 1 && tok.text[0] == ')')
|
|
|
|
|
{
|
|
|
|
|
--vaopt_state;
|
|
|
|
|
if (vaopt_state == 1)
|
|
|
|
|
{
|
|
|
|
|
/* Done with __VA_OPT__. */
|
|
|
|
|
vaopt_state = 0;
|
|
|
|
|
/* Don't emit. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If __VA_ARGS__ is empty, then drop the contents of
|
|
|
|
|
__VA_OPT__. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (argv.back ().len == 0)
|
2017-09-18 10:36:41 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (token_is_vaopt)
|
|
|
|
|
{
|
|
|
|
|
if (!is_varargs)
|
|
|
|
|
error (_("__VA_OPT__ is only valid in a variadic macro"));
|
|
|
|
|
vaopt_state = 1;
|
|
|
|
|
/* Don't emit this token. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* Just for aesthetics. If we skipped some whitespace, copy
|
|
|
|
|
that to DEST. */
|
|
|
|
|
if (tok.text > original_rl_start)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (original_rl_start, tok.text - original_rl_start);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
dest->last_token = dest->len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Is this token the stringification operator? */
|
|
|
|
|
if (tok.len == 1
|
|
|
|
|
&& tok.text[0] == '#')
|
2008-09-28 05:40:49 +08:00
|
|
|
|
{
|
|
|
|
|
int arg;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
if (!lookahead_valid)
|
|
|
|
|
error (_("Stringification operator requires an argument."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
arg = find_parameter (&lookahead, is_varargs, va_arg_name,
|
|
|
|
|
def->argc, def->argv);
|
|
|
|
|
if (arg == -1)
|
|
|
|
|
error (_("Argument to stringification operator must name "
|
|
|
|
|
"a macro parameter."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
stringify (dest, argv[arg].text, argv[arg].len);
|
|
|
|
|
|
|
|
|
|
/* Read one token and let the loop iteration code handle the
|
|
|
|
|
rest. */
|
|
|
|
|
lookahead_rl_start = replacement_list.text;
|
|
|
|
|
lookahead_valid = get_token (&lookahead, &replacement_list);
|
|
|
|
|
}
|
|
|
|
|
/* Is this token the splicing operator? */
|
|
|
|
|
else if (tok.len == 2
|
|
|
|
|
&& tok.text[0] == '#'
|
|
|
|
|
&& tok.text[1] == '#')
|
|
|
|
|
error (_("Stray splicing operator"));
|
|
|
|
|
/* Is the next token the splicing operator? */
|
|
|
|
|
else if (lookahead_valid
|
|
|
|
|
&& lookahead.len == 2
|
|
|
|
|
&& lookahead.text[0] == '#'
|
|
|
|
|
&& lookahead.text[1] == '#')
|
|
|
|
|
{
|
2010-05-07 03:41:12 +08:00
|
|
|
|
int finished = 0;
|
2008-09-28 05:40:49 +08:00
|
|
|
|
int prev_was_comma = 0;
|
|
|
|
|
|
|
|
|
|
/* Note that GCC warns if the result of splicing is not a
|
|
|
|
|
token. In the debugger there doesn't seem to be much
|
|
|
|
|
benefit from doing this. */
|
|
|
|
|
|
|
|
|
|
/* Insert the first token. */
|
|
|
|
|
if (tok.len == 1 && tok.text[0] == ',')
|
|
|
|
|
prev_was_comma = 1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int arg = find_parameter (&tok, is_varargs, va_arg_name,
|
|
|
|
|
def->argc, def->argv);
|
2010-05-16 08:18:02 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
if (arg != -1)
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (argv[arg].text, argv[arg].len);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
else
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (tok.text, tok.len);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Apply a possible sequence of ## operators. */
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (! get_token (&tok, &replacement_list))
|
|
|
|
|
error (_("Splicing operator at end of macro"));
|
|
|
|
|
|
|
|
|
|
/* Handle a comma before a ##. If we are handling
|
|
|
|
|
varargs, and the token on the right hand side is the
|
|
|
|
|
varargs marker, and the final argument is empty or
|
|
|
|
|
missing, then drop the comma. This is a GNU
|
|
|
|
|
extension. There is one ambiguous case here,
|
|
|
|
|
involving pedantic behavior with an empty argument,
|
|
|
|
|
but we settle that in favor of GNU-style (GCC uses an
|
|
|
|
|
option). If we aren't dealing with varargs, we
|
|
|
|
|
simply insert the comma. */
|
|
|
|
|
if (prev_was_comma)
|
|
|
|
|
{
|
|
|
|
|
if (! (is_varargs
|
|
|
|
|
&& tok.len == va_arg_name->len
|
|
|
|
|
&& !memcmp (tok.text, va_arg_name->text, tok.len)
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
&& argv.back ().len == 0))
|
|
|
|
|
dest->appendmem (",", 1);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
prev_was_comma = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Insert the token. If it is a parameter, insert the
|
|
|
|
|
argument. If it is a comma, treat it specially. */
|
|
|
|
|
if (tok.len == 1 && tok.text[0] == ',')
|
|
|
|
|
prev_was_comma = 1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int arg = find_parameter (&tok, is_varargs, va_arg_name,
|
|
|
|
|
def->argc, def->argv);
|
2010-05-16 08:18:02 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
if (arg != -1)
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (argv[arg].text, argv[arg].len);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
else
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (tok.text, tok.len);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now read another token. If it is another splice, we
|
|
|
|
|
loop. */
|
|
|
|
|
original_rl_start = replacement_list.text;
|
|
|
|
|
if (! get_token (&tok, &replacement_list))
|
|
|
|
|
{
|
|
|
|
|
finished = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! (tok.len == 2
|
|
|
|
|
&& tok.text[0] == '#'
|
|
|
|
|
&& tok.text[1] == '#'))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prev_was_comma)
|
|
|
|
|
{
|
|
|
|
|
/* We saw a comma. Insert it now. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (",", 1);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dest->last_token = dest->len;
|
|
|
|
|
if (finished)
|
|
|
|
|
lookahead_valid = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Set up for the loop iterator. */
|
|
|
|
|
lookahead = tok;
|
|
|
|
|
lookahead_rl_start = original_rl_start;
|
|
|
|
|
lookahead_valid = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Is this token an identifier? */
|
|
|
|
|
int substituted = 0;
|
|
|
|
|
int arg = find_parameter (&tok, is_varargs, va_arg_name,
|
|
|
|
|
def->argc, def->argv);
|
|
|
|
|
|
|
|
|
|
if (arg != -1)
|
|
|
|
|
{
|
|
|
|
|
/* Expand any macro invocations in the argument text,
|
|
|
|
|
and append the result to dest. Remember that scan
|
|
|
|
|
mutates its source, so we need to scan a new buffer
|
|
|
|
|
referring to the argument's text, not the argument
|
|
|
|
|
itself. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer arg_src (argv[arg].text, argv[arg].len);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
scan (dest, &arg_src, no_loop, lookup_func, lookup_baton);
|
|
|
|
|
substituted = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If it wasn't a parameter, then just copy it across. */
|
|
|
|
|
if (! substituted)
|
|
|
|
|
append_tokens_without_splicing (dest, &tok);
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
2017-09-18 10:36:41 +08:00
|
|
|
|
|
|
|
|
|
if (vaopt_state > 0)
|
|
|
|
|
error (_("Unterminated __VA_OPT__"));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Expand a call to a macro named ID, whose definition is DEF. Append
|
|
|
|
|
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
|
2011-01-09 11:20:33 +08:00
|
|
|
|
LOOKUP_BATON to find definitions for any nested macro references.
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
we don't expand it.) If we return zero, leave SRC unchanged. */
|
|
|
|
|
static int
|
|
|
|
|
expand (const char *id,
|
|
|
|
|
struct macro_definition *def,
|
|
|
|
|
struct macro_buffer *dest,
|
|
|
|
|
struct macro_buffer *src,
|
|
|
|
|
struct macro_name_list *no_loop,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton)
|
|
|
|
|
{
|
|
|
|
|
struct macro_name_list new_no_loop;
|
|
|
|
|
|
|
|
|
|
/* Create a new node to be added to the front of the no-expand list.
|
|
|
|
|
This list is appropriate for re-scanning replacement lists, but
|
|
|
|
|
it is *not* appropriate for scanning macro arguments; invocations
|
|
|
|
|
of the macro whose arguments we are gathering *do* get expanded
|
|
|
|
|
there. */
|
|
|
|
|
new_no_loop.name = id;
|
|
|
|
|
new_no_loop.next = no_loop;
|
|
|
|
|
|
|
|
|
|
/* What kind of macro are we expanding? */
|
|
|
|
|
if (def->kind == macro_object_like)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer replacement_list (def->replacement,
|
|
|
|
|
strlen (def->replacement));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
scan (dest, &replacement_list, &new_no_loop, lookup_func, lookup_baton);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if (def->kind == macro_function_like)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer va_arg_name;
|
2008-09-28 05:40:49 +08:00
|
|
|
|
int is_varargs = 0;
|
|
|
|
|
|
|
|
|
|
if (def->argc >= 1)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (def->argv[def->argc - 1], "...") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* In C99-style varargs, substitution is done using
|
|
|
|
|
__VA_ARGS__. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
va_arg_name.set_shared ("__VA_ARGS__", strlen ("__VA_ARGS__"));
|
2008-09-28 05:40:49 +08:00
|
|
|
|
is_varargs = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int len = strlen (def->argv[def->argc - 1]);
|
2010-05-16 08:18:02 +08:00
|
|
|
|
|
2008-09-28 05:40:49 +08:00
|
|
|
|
if (len > 3
|
|
|
|
|
&& strcmp (def->argv[def->argc - 1] + len - 3, "...") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* In GNU-style varargs, the name of the
|
|
|
|
|
substitution parameter is the name of the formal
|
|
|
|
|
argument without the "...". */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
va_arg_name.set_shared (def->argv[def->argc - 1], len - 3);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
is_varargs = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
std::vector<struct macro_buffer> argv;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* If we couldn't find any argument list, then we don't expand
|
|
|
|
|
this macro. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (!gather_arguments (id, src, is_varargs ? def->argc : -1,
|
|
|
|
|
&argv))
|
|
|
|
|
return 0;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Check that we're passing an acceptable number of arguments for
|
|
|
|
|
this macro. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (argv.size () != def->argc)
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
if (is_varargs && argv.size () >= def->argc - 1)
|
2008-09-28 05:40:49 +08:00
|
|
|
|
{
|
|
|
|
|
/* Ok. */
|
|
|
|
|
}
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* Remember that a sequence of tokens like "foo()" is a
|
|
|
|
|
valid invocation of a macro expecting either zero or one
|
|
|
|
|
arguments. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
else if (! (argv.size () == 1
|
2008-09-28 05:40:49 +08:00
|
|
|
|
&& argv[0].len == 0
|
|
|
|
|
&& def->argc == 0))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Wrong number of arguments to macro `%s' "
|
|
|
|
|
"(expected %d, got %d)."),
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
id, def->argc, int (argv.size ()));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Note that we don't expand macro invocations in the arguments
|
|
|
|
|
yet --- we let subst_args take care of that. Parameters that
|
|
|
|
|
appear as operands of the stringifying operator "#" or the
|
|
|
|
|
splicing operator "##" don't get macro references expanded,
|
|
|
|
|
so we can't really tell whether it's appropriate to macro-
|
|
|
|
|
expand an argument until we see how it's being used. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer substituted (0);
|
2008-09-28 05:40:49 +08:00
|
|
|
|
substitute_args (&substituted, def, is_varargs, &va_arg_name,
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
argv, no_loop, lookup_func, lookup_baton);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Now `substituted' is the macro's replacement list, with all
|
|
|
|
|
argument values substituted into it properly. Re-scan it for
|
|
|
|
|
macro references, but don't expand invocations of this macro.
|
|
|
|
|
|
|
|
|
|
We create a new buffer, `substituted_src', which points into
|
|
|
|
|
`substituted', and scan that. We can't scan `substituted'
|
|
|
|
|
itself, since the tokenization process moves the buffer's
|
|
|
|
|
text pointer around, and we still need to be able to find
|
|
|
|
|
`substituted's original text buffer after scanning it so we
|
|
|
|
|
can free it. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer substituted_src (substituted.text, substituted.len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
scan (dest, &substituted_src, &new_no_loop, lookup_func, lookup_baton);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__, _("bad macro definition kind"));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If the single token in SRC_FIRST followed by the tokens in SRC_REST
|
|
|
|
|
constitute a macro invokation not forbidden in NO_LOOP, append its
|
|
|
|
|
expansion to DEST and return non-zero. Otherwise, return zero, and
|
|
|
|
|
leave DEST unchanged.
|
|
|
|
|
|
|
|
|
|
SRC_FIRST and SRC_REST must be shared buffers; DEST must not be one.
|
|
|
|
|
SRC_FIRST must be a string built by get_token. */
|
|
|
|
|
static int
|
|
|
|
|
maybe_expand (struct macro_buffer *dest,
|
|
|
|
|
struct macro_buffer *src_first,
|
|
|
|
|
struct macro_buffer *src_rest,
|
|
|
|
|
struct macro_name_list *no_loop,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (src_first->shared);
|
|
|
|
|
gdb_assert (src_rest->shared);
|
|
|
|
|
gdb_assert (! dest->shared);
|
|
|
|
|
|
|
|
|
|
/* Is this token an identifier? */
|
|
|
|
|
if (src_first->is_identifier)
|
|
|
|
|
{
|
|
|
|
|
/* Make a null-terminated copy of it, since that's what our
|
|
|
|
|
lookup function expects. */
|
2018-02-07 03:11:21 +08:00
|
|
|
|
std::string id (src_first->text, src_first->len);
|
2010-05-16 08:18:02 +08:00
|
|
|
|
|
2002-05-14 02:13:07 +08:00
|
|
|
|
/* If we're currently re-scanning the result of expanding
|
|
|
|
|
this macro, don't expand it again. */
|
2018-02-07 03:11:21 +08:00
|
|
|
|
if (! currently_rescanning (no_loop, id.c_str ()))
|
2002-05-14 02:13:07 +08:00
|
|
|
|
{
|
|
|
|
|
/* Does this identifier have a macro definition in scope? */
|
2018-02-07 03:11:21 +08:00
|
|
|
|
struct macro_definition *def = lookup_func (id.c_str (),
|
|
|
|
|
lookup_baton);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
2018-02-07 03:11:21 +08:00
|
|
|
|
if (def && expand (id.c_str (), def, dest, src_rest, no_loop,
|
2002-05-14 02:13:07 +08:00
|
|
|
|
lookup_func, lookup_baton))
|
2018-02-07 03:11:21 +08:00
|
|
|
|
return 1;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Expand macro references in SRC, appending the results to DEST.
|
|
|
|
|
Assume we are re-scanning the result of expanding the macros named
|
|
|
|
|
in NO_LOOP, and don't try to re-expand references to them.
|
|
|
|
|
|
|
|
|
|
SRC must be a shared buffer; DEST must not be one. */
|
|
|
|
|
static void
|
|
|
|
|
scan (struct macro_buffer *dest,
|
|
|
|
|
struct macro_buffer *src,
|
|
|
|
|
struct macro_name_list *no_loop,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (src->shared);
|
|
|
|
|
gdb_assert (! dest->shared);
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
struct macro_buffer tok;
|
|
|
|
|
char *original_src_start = src->text;
|
|
|
|
|
|
|
|
|
|
/* Find the next token in SRC. */
|
|
|
|
|
if (! get_token (&tok, src))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Just for aesthetics. If we skipped some whitespace, copy
|
|
|
|
|
that to DEST. */
|
|
|
|
|
if (tok.text > original_src_start)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (original_src_start, tok.text - original_src_start);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
dest->last_token = dest->len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! maybe_expand (dest, &tok, src, no_loop, lookup_func, lookup_baton))
|
|
|
|
|
/* We didn't end up expanding tok as a macro reference, so
|
|
|
|
|
simply append it to dest. */
|
|
|
|
|
append_tokens_without_splicing (dest, &tok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Just for aesthetics. If there was any trailing whitespace in
|
|
|
|
|
src, copy it to dest. */
|
|
|
|
|
if (src->len)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest->appendmem (src->text, src->len);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
dest->last_token = dest->len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-02-06 08:02:00 +08:00
|
|
|
|
gdb::unique_xmalloc_ptr<char>
|
2002-05-14 02:13:07 +08:00
|
|
|
|
macro_expand (const char *source,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_func_baton)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer src (source, strlen (source));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer dest (0);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
dest.last_token = 0;
|
|
|
|
|
|
|
|
|
|
scan (&dest, &src, 0, lookup_func, lookup_func_baton);
|
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest.appendc ('\0');
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
return gdb::unique_xmalloc_ptr<char> (dest.release ());
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-02-06 08:02:00 +08:00
|
|
|
|
gdb::unique_xmalloc_ptr<char>
|
2002-05-14 02:13:07 +08:00
|
|
|
|
macro_expand_once (const char *source,
|
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_func_baton)
|
|
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Expand-once not implemented yet."));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
2013-10-02 08:46:07 +08:00
|
|
|
|
macro_expand_next (const char **lexptr,
|
2002-05-14 02:13:07 +08:00
|
|
|
|
macro_lookup_ftype *lookup_func,
|
|
|
|
|
void *lookup_baton)
|
|
|
|
|
{
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer tok;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Set up SRC to refer to the input text, pointed to by *lexptr. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer src (*lexptr, strlen (*lexptr));
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* Set up DEST to receive the expansion, if there is one. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
struct macro_buffer dest (0);
|
2002-05-14 02:13:07 +08:00
|
|
|
|
dest.last_token = 0;
|
|
|
|
|
|
|
|
|
|
/* Get the text's first preprocessing token. */
|
|
|
|
|
if (! get_token (&tok, &src))
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
return 0;
|
2002-05-14 02:13:07 +08:00
|
|
|
|
|
|
|
|
|
/* If it's a macro invocation, expand it. */
|
|
|
|
|
if (maybe_expand (&dest, &tok, &src, 0, lookup_func, lookup_baton))
|
|
|
|
|
{
|
|
|
|
|
/* It was a macro invocation! Package up the expansion as a
|
|
|
|
|
null-terminated string and return it. Set *lexptr to the
|
|
|
|
|
start of the next token in the input. */
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
dest.appendc ('\0');
|
2002-05-14 02:13:07 +08:00
|
|
|
|
*lexptr = src.text;
|
Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members. Then this is
used to remove various cleanups in macroexp.c.
2018-02-08 Tom Tromey <tom@tromey.com>
* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type. Remove argc_p argument,
add args_ptr argument. Use std::vector.
(substitute_args): Remove argc argument. Accept std::vector.
(expand): Update. Use std::vector.
(scan, macro_expand, macro_expand_next): Update.
2018-02-07 03:10:20 +08:00
|
|
|
|
return dest.release ();
|
2002-05-14 02:13:07 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* It wasn't a macro invocation. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|