[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 17:11:42 -0400 (EDT) |
branch: master
commit d2a3d6e1266b7e635caddf07cb93f09b04607808
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 8 23:07:40 2024 +0200
* tp/Texinfo/XS/main/utils.c (parse_file_path),
tp/Texinfo/XS/parsetexi/api.c: move parse_file_path to utils.c.
---
ChangeLog | 5 +++++
tp/Texinfo/XS/main/utils.c | 30 ++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/utils.h | 1 +
tp/Texinfo/XS/parsetexi/api.c | 30 ------------------------------
4 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eb19e82342..f4eb9eb51f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/utils.c (parse_file_path),
+ tp/Texinfo/XS/parsetexi/api.c: move parse_file_path to utils.c.
+
2024-07-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/build_perl_info.c (init): set encoding conversion
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 9896d7470a..7e53f6c59b 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -869,6 +869,36 @@ normalize_encoding_name (const char *text, int
*possible_encoding)
return normalized_text;
}
+/* RESULT should be an array of size two. Upon return, it holds
+ the file name in the first position and directory, if any, in
+ the second position. The file name and directory should be
+ freed.
+ */
+void
+parse_file_path (const char *input_file_path, char **result)
+{
+ /* Strip off a leading directory path, by looking for the last
+ '/' in input_file_path. */
+ const char *p = 0;
+ const char *q = strchr (input_file_path, '/');
+ while (q)
+ {
+ p = q;
+ q = strchr (q + 1, '/');
+ }
+
+ if (p)
+ {
+ result[0] = strdup (p + 1);
+ result[1] = strndup (input_file_path, (p - input_file_path) + 1);
+ }
+ else
+ {
+ result[0] = strdup (input_file_path);
+ result[1] = 0;
+ }
+}
+
/* index related functions used in diverse situations, not only in parser */
void
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 84b5192676..6b3f57bfd8 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -182,6 +182,7 @@ int section_level (const ELEMENT *section);
enum command_id section_level_adjusted_command_name (const ELEMENT *element);
char *collapse_spaces (const char *text);
char *parse_line_directive (const char *line, int *retval, int *out_line_no);
+void parse_file_path (const char *input_file_path, char **result);
int is_content_empty (const ELEMENT *tree, int do_not_ignore_index_entries);
STRING_LIST *new_string_list (void);
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 1009c9cd69..42b0c360c0 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -124,36 +124,6 @@ reset_parser (int local_debug_output)
reset_parser_conf ();
}
-/* RESULT should be an array of size two. Upon return, it holds
- the file name in the first position and directory, if any, in
- the second position. The file name and directory should be
- freed.
- */
-static void
-parse_file_path (const char *input_file_path, char **result)
-{
- /* Strip off a leading directory path, by looking for the last
- '/' in input_file_path. */
- const char *p = 0;
- const char *q = strchr (input_file_path, '/');
- while (q)
- {
- p = q;
- q = strchr (q + 1, '/');
- }
-
- if (p)
- {
- result[0] = strdup (p + 1);
- result[1] = strndup (input_file_path, (p - input_file_path) + 1);
- }
- else
- {
- result[0] = strdup (input_file_path);
- result[1] = 0;
- }
-}
-
/* Determine directory path based on file name.
Return a DOCUMENT_DESCRIPTOR that can be used to retrieve the
tree and document obtained by parsing INPUT_FILE_PATH.