1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Fix #line directives for filenames containing backslashes.

This commit is contained in:
Bruno Haible
2006-01-13 13:11:19 +00:00
parent 2fcad22bd6
commit b6e1deb8fc
2 changed files with 32 additions and 13 deletions

View File

@@ -1,3 +1,13 @@
2006-01-13 Bruno Haible <bruno@clisp.org>
Fix #line directives for filenames containing backslashes.
* src/output.cc (output_line_directive): New function.
(output_keyword_entry, Output::output): Use it.
Reported by Alexander <alexander.me@gmail.com>.
* src/options.cc (Options::parse_options): Update years in --version
output.
2005-08-29 Brendan Kehoe <brendan@zen.org> 2005-08-29 Brendan Kehoe <brendan@zen.org>
* src/keyword.cc: Tweak comment to avoid nesting. * src/keyword.cc: Tweak comment to avoid nesting.

View File

@@ -1,5 +1,5 @@
/* Output routines. /* Output routines.
Copyright (C) 1989-1998, 2000, 2002-2004 Free Software Foundation, Inc. Copyright (C) 1989-1998, 2000, 2002-2004, 2006 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu> Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>. and Bruno Haible <bruno@clisp.org>.
@@ -472,6 +472,22 @@ output_string (const char *key, int len)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* Outputs a #line directive, referring to the given line number. */
static void
output_line_directive (unsigned int lineno)
{
const char *file_name = option.get_input_file_name ();
if (file_name != NULL)
{
printf ("#line %u ", lineno);
output_string (file_name, strlen (file_name));
printf ("\n");
}
}
/* ------------------------------------------------------------------------- */
/* Outputs a type and a const specifier (i.e. "const " or ""). /* Outputs a type and a const specifier (i.e. "const " or "").
The output is terminated with a space. */ The output is terminated with a space. */
@@ -1084,9 +1100,8 @@ Output::output_string_pool () const
static void static void
output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent) output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent)
{ {
if (option[TYPE] && option.get_input_file_name ()) if (option[TYPE])
printf ("#line %u \"%s\"\n", output_line_directive (temp->_lineno);
temp->_lineno, option.get_input_file_name ());
printf ("%s ", indent); printf ("%s ", indent);
if (option[TYPE]) if (option[TYPE])
printf ("{"); printf ("{");
@@ -2003,18 +2018,14 @@ Output::output ()
if (_verbatim_declarations < _verbatim_declarations_end) if (_verbatim_declarations < _verbatim_declarations_end)
{ {
if (option.get_input_file_name ()) output_line_directive (_verbatim_declarations_lineno);
printf ("#line %u \"%s\"\n",
_verbatim_declarations_lineno, option.get_input_file_name ());
fwrite (_verbatim_declarations, 1, fwrite (_verbatim_declarations, 1,
_verbatim_declarations_end - _verbatim_declarations, stdout); _verbatim_declarations_end - _verbatim_declarations, stdout);
} }
if (option[TYPE] && !option[NOTYPE]) /* Output type declaration now, reference it later on.... */ if (option[TYPE] && !option[NOTYPE]) /* Output type declaration now, reference it later on.... */
{ {
if (option.get_input_file_name ()) output_line_directive (_struct_decl_lineno);
printf ("#line %u \"%s\"\n",
_struct_decl_lineno, option.get_input_file_name ());
printf ("%s\n", _struct_decl); printf ("%s\n", _struct_decl);
} }
@@ -2075,9 +2086,7 @@ Output::output ()
if (_verbatim_code < _verbatim_code_end) if (_verbatim_code < _verbatim_code_end)
{ {
if (option.get_input_file_name ()) output_line_directive (_verbatim_code_lineno);
printf ("#line %u \"%s\"\n",
_verbatim_code_lineno, option.get_input_file_name ());
fwrite (_verbatim_code, 1, _verbatim_code_end - _verbatim_code, stdout); fwrite (_verbatim_code, 1, _verbatim_code_end - _verbatim_code, stdout);
} }