Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/lib_ccx/ccx_encoders_spupng.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,32 @@ void write_sputag_close(struct spupng_t *sp)
}
void write_spucomment(struct spupng_t *sp, const char *str)
{
fprintf(sp->fpxml, "<!--\n%s\n-->\n", str);
fprintf(sp->fpxml, "<!--\n");

const char *p = str;
const char *last_safe_pos = str; // Track the last safe position to flush

while (*p) {

if (*p == '-' && *(p + 1) == '-') {

if (p > last_safe_pos) {
fwrite(last_safe_pos, 1, p - last_safe_pos, sp->fpxml);
}

fputc('-', sp->fpxml);
p += 2;
last_safe_pos = p;
} else {
p++;
}
}

if (p > last_safe_pos) {
fwrite(last_safe_pos, 1, p - last_safe_pos, sp->fpxml);
}

fprintf(sp->fpxml, "\n-->\n");
}

char *get_spupng_filename(void *ctx)
Expand Down
Loading