[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 1 Oct 2024 12:40:09 -0400 (EDT) |
branch: master
commit 7d69b4e9e9b41e0fdda3a6385806d0be2fdfc89d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Jul 25 18:58:45 2024 +0200
* tp/Texinfo/XS/parsetexi/input.c (set_input_encoding)
(encode_file_name): use encode_string to encode the file name. Remove
reverse_iconv.
---
ChangeLog | 6 +++++
tp/Texinfo/XS/parsetexi/input.c | 54 +++++++++++++++--------------------------
2 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e02e590c47..971e4ba29f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-07-25 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/parsetexi/input.c (set_input_encoding)
+ (encode_file_name): use encode_string to encode the file name. Remove
+ reverse_iconv.
+
2024-07-25 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/input.c (set_input_encoding)
diff --git a/tp/Texinfo/XS/parsetexi/input.c b/tp/Texinfo/XS/parsetexi/input.c
index 028f058fab..da637b87bf 100644
--- a/tp/Texinfo/XS/parsetexi/input.c
+++ b/tp/Texinfo/XS/parsetexi/input.c
@@ -55,8 +55,6 @@ typedef struct {
static char *input_pushback_string;
-static iconv_t reverse_iconv; /* used in encode_file_name */
-
static ENCODING_CONVERSION *current_encoding_conversion = 0;
/* ENCODING should always be lower cased */
@@ -68,12 +66,6 @@ set_input_encoding (const char *encoding)
{
int encoding_set = 0;
- if (reverse_iconv)
- {
- iconv_close (reverse_iconv);
- reverse_iconv = (iconv_t) 0;
- }
-
current_encoding_conversion
= get_encoding_conversion (encoding, &input_conversions);
if (current_encoding_conversion)
@@ -178,36 +170,28 @@ convert_to_utf8 (char *s)
char *
encode_file_name (char *filename)
{
- if (!reverse_iconv)
+ int status;
+ const char *encoding = 0;
+
+ if (global_parser_conf.input_file_name_encoding)
+ encoding = global_parser_conf.input_file_name_encoding;
+ else if (global_parser_conf.doc_encoding_for_input_file_name)
{
- if (global_parser_conf.input_file_name_encoding)
- {
- reverse_iconv
- = iconv_open (global_parser_conf.input_file_name_encoding,
"UTF-8");
- }
- else if (global_parser_conf.doc_encoding_for_input_file_name)
- {
- if (current_encoding_conversion
- && strcmp (parsed_document->global_info.input_encoding_name,
- "utf-8"))
- {
- char *conversion_encoding
- = current_encoding_conversion->encoding_name;
- reverse_iconv = iconv_open (conversion_encoding, "UTF-8");
- }
- }
- else if (global_parser_conf.locale_encoding)
- {
- reverse_iconv = iconv_open (global_parser_conf.locale_encoding,
"UTF-8");
- }
+ if (current_encoding_conversion
+ && strcmp (parsed_document->global_info.input_encoding_name,
+ "utf-8"))
+ encoding = current_encoding_conversion->encoding_name;
}
- if (reverse_iconv && reverse_iconv != (iconv_t) -1)
+ else if (global_parser_conf.locale_encoding)
+ encoding = global_parser_conf.locale_encoding;
+
+ if (encoding)
{
- char *s, *conv;
- conv = encode_with_iconv (reverse_iconv, filename, ¤t_source_info);
- s = save_string (conv);
- free (conv);
- return s;
+ char *result = encode_string (filename, encoding, &status,
+ ¤t_source_info);
+ char *saved_string = save_string (result);
+ free (result);
+ return saved_string;
}
else
{