From f7206e2e001240ed950314cb3fb412f3b32d9138 Mon Sep 17 00:00:00 2001 From: peach280 Date: Fri, 10 Jan 2025 11:39:13 +0000 Subject: [PATCH] Valid xml tokens Signed-off-by: peach280 --- src/lib_ccx/ccx_encoders_spupng.c | 56 +++++++++++++++++-------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/lib_ccx/ccx_encoders_spupng.c b/src/lib_ccx/ccx_encoders_spupng.c index cc511b271..38253bfb6 100644 --- a/src/lib_ccx/ccx_encoders_spupng.c +++ b/src/lib_ccx/ccx_encoders_spupng.c @@ -140,38 +140,44 @@ void spunpg_free(struct spupng_t *sp) } void sanitize_and_write_comment(FILE *fpxml, const char *input_file) { - char sanitized_file[300]; - int j = 0; - for (int i = 0; input_file[i] != '\0' && j < sizeof(sanitized_file) - 1; i++) - { - if (input_file[i] == '-') - { - if (input_file[i + 1] == '-') - { - sanitized_file[j++] = ' '; - i++; - } - else - { - sanitized_file[j++] = input_file[i]; - } - } - else - { - sanitized_file[j++] = input_file[i]; - } - } - sanitized_file[j] = '\0'; + char sanitized_file[300]; + int j = 0; + + for (int i = 0; input_file[i] != '\0' && j < sizeof(sanitized_file) - 1; i++) + { + if (input_file[i] == '-') + { + if (input_file[i + 1] == '-') + { + sanitized_file[j++] = ' '; + i++; + } + else + { + sanitized_file[j++] = input_file[i]; + } + } + else + { + sanitized_file[j++] = input_file[i]; + } + } + sanitized_file[j] = '\0'; fprintf(fpxml, "\n", sanitized_file); } + void spupng_write_header(struct spupng_t *sp, int multiple_files, char *first_input_file) { - fprintf(sp->fpxml, "\n\n"); - if (multiple_files) - sanitize_and_write_comment(sp->fpxml, first_input_file); + fprintf(sp->fpxml, "\n\n"); + + if (multiple_files) + { + sanitize_and_write_comment(sp->fpxml, first_input_file); + } } + void spupng_write_footer(struct spupng_t *sp) { fprintf(sp->fpxml, "\n\n");