[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 10 Dec 2023 05:33:10 -0500 (EST) |
branch: master
commit 529e4cc109f6b5df35ebc7af28da046f82c5f338
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 10 10:43:54 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c (html_finalize_output_state),
tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
(JSLICENSE_FILE_INFO, JSLICENSE_FILE_INFO_LIST)
(JSLICENSE_CATEGORY_LIST, CONVERTER): get jslicenses information from
perl.
---
ChangeLog | 9 ++++
tp/Texinfo/XS/convert/convert_html.c | 26 ++++++++++
tp/Texinfo/XS/convert/get_html_perl_info.c | 81 ++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/converter_types.h | 19 +++++++
4 files changed, 135 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index de7c29e151..389425cf2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-12-10 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_finalize_output_state),
+ tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
+ (JSLICENSE_FILE_INFO, JSLICENSE_FILE_INFO_LIST)
+ (JSLICENSE_CATEGORY_LIST, CONVERTER): get jslicenses information from
+ perl.
+
2023-12-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_default_format_end_file): avoid using
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 99788497b9..33206fa493 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -8523,6 +8523,32 @@ html_finalize_output_state (CONVERTER *self)
self->index_entries_by_letter = 0;
}
+ if (self->jslicenses.number)
+ {
+ int i;
+ for (i = 0; i < self->jslicenses.number; i++)
+ {
+ JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+ = &self->jslicenses.list[i];
+ free (jslicences_files_info->category);
+ if (jslicences_files_info->number)
+ {
+ int j;
+ for (j = 0; j < jslicences_files_info->number; j++)
+ {
+ JSLICENSE_FILE_INFO *jslicense_file_info
+ = &jslicences_files_info->list[j];
+ free (jslicense_file_info->filename);
+ free (jslicense_file_info->license);
+ free (jslicense_file_info->url);
+ free (jslicense_file_info->source);
+ }
+ }
+ free (jslicences_files_info->list);
+ }
+ free (self->jslicenses.list);
+ }
+
clear_output_files_information (&self->output_files_information);
clear_output_unit_files (&self->output_unit_files);
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index b9152f7f39..74240f6c9b 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -141,6 +141,7 @@ html_converter_initialize_sv (SV *converter_sv,
HV *default_css_string_types_conversion_hv;
HV *default_output_units_conversion_hv;
SV **htmlxref_sv;
+ SV **jslicenses_sv;
SV **formatting_function_sv;
SV **sorted_special_unit_varieties_sv;
SV **no_arg_commands_formatting_sv;
@@ -226,6 +227,86 @@ html_converter_initialize_sv (SV *converter_sv,
}
}
+ FETCH(jslicenses)
+
+ if (jslicenses_sv)
+ {
+ I32 hv_number;
+ I32 i;
+
+ HV *jslicenses_hv = (HV *)SvRV (*jslicenses_sv);
+
+ hv_number = hv_iterinit (jslicenses_hv);
+
+ converter->jslicenses.number = hv_number;
+ converter->jslicenses.list = (JSLICENSE_FILE_INFO_LIST *)
+ malloc (hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
+ memset (converter->jslicenses.list, 0,
+ hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
+
+ for (i = 0; i < hv_number; i++)
+ {
+ I32 hv_files_number;
+ I32 j;
+ HE *next = hv_iternext (jslicenses_hv);
+ SV *category_sv = hv_iterkeysv (next);
+ char *category = (char *) SvPVutf8_nolen (category_sv);
+ SV *files_info_sv = HeVAL(next);
+ HV *files_info_hv = (HV *)SvRV (files_info_sv);
+
+ JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+ = &converter->jslicenses.list[i];
+
+ jslicences_files_info->category = strdup (category);
+
+ hv_files_number = hv_iterinit (files_info_hv);
+ jslicences_files_info->number = hv_files_number;
+ jslicences_files_info->list = (JSLICENSE_FILE_INFO *)
+ malloc (hv_files_number * sizeof (JSLICENSE_FILE_INFO));
+ memset (jslicences_files_info->list, 0,
+ hv_files_number * sizeof (JSLICENSE_FILE_INFO));
+
+ for (j = 0; j < hv_files_number; j++)
+ {
+ HE *next_file = hv_iternext (files_info_hv);
+ SV *filename_sv = hv_iterkeysv (next);
+ char *filename = (char *) SvPVutf8_nolen (filename_sv);
+ SV *file_info_sv = HeVAL(next_file);
+ AV *file_info_av = (AV *)SvRV (file_info_sv);
+ SSize_t file_info_nr;
+ SV **license_sv;
+ SV **url_sv;
+ SV **source_sv;
+
+ JSLICENSE_FILE_INFO *jslicense_file_info
+ = &jslicences_files_info->list[j];
+ jslicense_file_info->filename = strdup (filename);
+
+ file_info_nr = av_top_index (file_info_av) +1;
+ if (file_info_nr != 3)
+ {
+ fprintf (stderr,
+ "BUG: %s: %s: jslicence file needs 3 item: %zu\n",
+ category, filename, file_info_nr);
+ continue;
+ }
+ license_sv = av_fetch (file_info_av, 0, 0);
+ if (license_sv && SvOK (*license_sv))
+ jslicense_file_info->license
+ = strdup ((char *) SvPVutf8_nolen (*license_sv));
+ url_sv = av_fetch (file_info_av, 0, 0);
+ if (url_sv && SvOK (*url_sv))
+ jslicense_file_info->url
+ = strdup ((char *) SvPVutf8_nolen (*url_sv));
+ source_sv = av_fetch (file_info_av, 0, 0);
+ if (source_sv && SvOK (*source_sv))
+ jslicense_file_info->source
+ = strdup ((char *) SvPVutf8_nolen (*source_sv));
+ }
+
+ }
+ }
+
FETCH(formatting_function);
/* no need to check if it exists */
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 38e356f368..451188fcc3 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -604,6 +604,24 @@ typedef struct ASSOCIATED_INFO_LIST {
ASSOCIATED_INFO *list;
} ASSOCIATED_INFO_LIST;
+typedef struct JSLICENSE_FILE_INFO {
+ char *filename;
+ char *license;
+ char *url;
+ char *source;
+} JSLICENSE_FILE_INFO;
+
+typedef struct JSLICENSE_FILE_INFO_LIST {
+ char *category;
+ size_t number;
+ JSLICENSE_FILE_INFO *list;
+} JSLICENSE_FILE_INFO_LIST;
+
+typedef struct JSLICENSE_CATEGORY_LIST {
+ size_t number;
+ JSLICENSE_FILE_INFO_LIST *list;
+} JSLICENSE_CATEGORY_LIST;
+
typedef struct CONVERTER {
int converter_descriptor;
/* perl converter. This should be HV *hv,
@@ -687,6 +705,7 @@ typedef struct CONVERTER {
size_t *special_unit_file_indices; /* same for special output units */
ELEMENT *simpletitle_tree;
enum command_id simpletitle_cmd;
+ JSLICENSE_CATEGORY_LIST jslicenses;
/* state only in C converter */
unsigned long modified_state; /* specifies which perl state to rebuild */