[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Encoding of #line argument in XS parser.
From: |
Gavin D. Smith |
Subject: |
branch master updated: Encoding of #line argument in XS parser. |
Date: |
Tue, 01 Mar 2022 15:54:58 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 03dc9e8efd Encoding of #line argument in XS parser.
03dc9e8efd is described below
commit 03dc9e8efd8b931255f5dd220635151d9940b830
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Mar 1 20:54:42 2022 +0000
Encoding of #line argument in XS parser.
* tp/Texinfo/XS/parsetexi/input.c (encode_file_name): Save
return value with save_string.
* tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line):
Update call to end_line_misc_line.
* tp/Texinfo/XS/parsetexi/input.c (save_line_directive):
Call encode_file_name on argument. Do not save reference to
argument.
* tp/Texinfo/XS/parsetexi/parser.c (check_line_directive):
Update code calling save_line_directive so not to allocate
unneeded string.
Patrice reported that encode_file_name should be used here.
---
ChangeLog | 17 +++++++++++++++
tp/Texinfo/XS/parsetexi/end_line.c | 2 --
tp/Texinfo/XS/parsetexi/input.c | 42 +++++++++++++++++++++++---------------
tp/t/results/include/cpp_lines.pl | 4 ++--
4 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 124e73045d..efa3f2bbe1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2022-03-01 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Encoding of #line argument in XS parser.
+
+ * tp/Texinfo/XS/parsetexi/input.c (encode_file_name): Save
+ return value with save_string.
+ * tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line):
+ Update call to end_line_misc_line.
+ * tp/Texinfo/XS/parsetexi/input.c (save_line_directive):
+ Call encode_file_name on argument. Do not save reference to
+ argument.
+ * tp/Texinfo/XS/parsetexi/parser.c (check_line_directive):
+ Update code calling save_line_directive so not to allocate
+ unneeded string.
+
+ Patrice reported that encode_file_name should be used here.
+
2022-03-01 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (parse_texi_file, _save_line_directive)
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index d2615762b1..42452ac127 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1427,7 +1427,6 @@ end_line_misc_line (ELEMENT *current)
char *sys_filename = encode_file_name (text);
fullpath = locate_include_file (sys_filename);
- free (sys_filename);
if (!fullpath)
{
@@ -1446,7 +1445,6 @@ end_line_misc_line (ELEMENT *current)
}
else
included_file = 1;
- free (fullpath);
}
}
else if (current->cmd == CM_verbatiminclude)
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index fdf0662e99..725f0881b0 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -86,19 +86,6 @@ int input_space = 0;
/* Current filename and line number. Used for reporting. */
SOURCE_INFO current_source_info;
-/* Change the line number of filename of the top input source. Used to
- record a #line directive. If FILENAME is non-null, it should hbae
- been returned from save_string. */
-void
-save_line_directive (int line_nr, char *filename)
-{
- INPUT *top = &input_stack[input_number - 1];
- if (line_nr)
- top->source_info.line_nr = line_nr;
- if (filename)
- top->source_info.file_name = filename;
-}
-
/* Collect text from the input sources until a newline is found. This is used
instead of next_text when we need to be sure we get an entire line of
Texinfo input (for example as a line argument to a command), which might
not
@@ -289,7 +276,7 @@ static iconv_t reverse_iconv;
/* Reverse the decoding of the filename to the input encoding, to retrieve
the bytes that were present in the original Texinfo file. Return
- value to be freed by caller. */
+ value is freed by free_small_strings. */
char *
encode_file_name (char *filename)
{
@@ -302,14 +289,37 @@ encode_file_name (char *filename)
}
if (reverse_iconv && reverse_iconv != (iconv_t) -1)
{
- return encode_with_iconv (reverse_iconv, filename);
+ char *s, *conv;
+ conv = encode_with_iconv (reverse_iconv, filename);
+ s = save_string (conv);
+ free (conv);
+ return s;
}
else
{
- return strdup (filename);
+ return save_string (filename);
}
}
+/* Change the line number of filename of the top input source. Used to
+ record a #line directive. */
+void
+save_line_directive (int line_nr, char *filename)
+{
+ char *f = 0;
+ INPUT *top;
+
+ if (filename)
+ f = encode_file_name (filename);
+
+ top = &input_stack[input_number - 1];
+ if (line_nr)
+ top->source_info.line_nr = line_nr;
+ if (filename)
+ top->source_info.file_name = f;
+}
+
+
int
expanding_macro (char *macro)
diff --git a/tp/t/results/include/cpp_lines.pl
b/tp/t/results/include/cpp_lines.pl
index aebc699440..53c66df26e 100644
--- a/tp/t/results/include/cpp_lines.pl
+++ b/tp/t/results/include/cpp_lines.pl
@@ -708,7 +708,7 @@ $result_trees{'cpp_lines'} = {
},
'parent' => {},
'source_info' => {
- 'file_name' => 'accentêd',
+ 'file_name' => 'accentêd',
'line_nr' => 7,
'macro' => ''
}
@@ -988,7 +988,7 @@ $result_errors{'cpp_lines'} = [
{
'error_line' => "warning: l\x{e0}ng is not a valid language code
",
- 'file_name' => 'accentêd',
+ 'file_name' => 'accentêd',
'line_nr' => 7,
'macro' => '',
'text' => "l\x{e0}ng is not a valid language code",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Encoding of #line argument in XS parser.,
Gavin D. Smith <=