summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-01-13 13:11:19 +0000
committerBruno Haible <bruno@clisp.org>2006-01-13 13:11:19 +0000
commitb6e1deb8fc7ec96c59fadc02bcd3f1ba453891ed (patch)
tree228aab2fff59816e77366a2acf6bfb20282462ef
parent2fcad22bd62237536b35c8bfa5b6e81f24937757 (diff)
downloadgperf-b6e1deb8fc7ec96c59fadc02bcd3f1ba453891ed.tar.gz
Fix #line directives for filenames containing backslashes.
-rw-r--r--ChangeLog10
-rw-r--r--src/output.cc35
2 files changed, 32 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index aafc1eb..145a033 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* src/keyword.cc: Tweak comment to avoid nesting.
diff --git a/src/output.cc b/src/output.cc
index 19af43e..d409ab4 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -1,5 +1,5 @@
/* 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>
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 "").
The output is terminated with a space. */
@@ -1084,9 +1100,8 @@ Output::output_string_pool () const
static void
output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent)
{
- if (option[TYPE] && option.get_input_file_name ())
- printf ("#line %u \"%s\"\n",
- temp->_lineno, option.get_input_file_name ());
+ if (option[TYPE])
+ output_line_directive (temp->_lineno);
printf ("%s ", indent);
if (option[TYPE])
printf ("{");
@@ -2003,18 +2018,14 @@ Output::output ()
if (_verbatim_declarations < _verbatim_declarations_end)
{
- if (option.get_input_file_name ())
- printf ("#line %u \"%s\"\n",
- _verbatim_declarations_lineno, option.get_input_file_name ());
+ output_line_directive (_verbatim_declarations_lineno);
fwrite (_verbatim_declarations, 1,
_verbatim_declarations_end - _verbatim_declarations, stdout);
}
if (option[TYPE] && !option[NOTYPE]) /* Output type declaration now, reference it later on.... */
{
- if (option.get_input_file_name ())
- printf ("#line %u \"%s\"\n",
- _struct_decl_lineno, option.get_input_file_name ());
+ output_line_directive (_struct_decl_lineno);
printf ("%s\n", _struct_decl);
}
@@ -2075,9 +2086,7 @@ Output::output ()
if (_verbatim_code < _verbatim_code_end)
{
- if (option.get_input_file_name ())
- printf ("#line %u \"%s\"\n",
- _verbatim_code_lineno, option.get_input_file_name ());
+ output_line_directive (_verbatim_code_lineno);
fwrite (_verbatim_code, 1, _verbatim_code_end - _verbatim_code, stdout);
}