From 8fa30c8f1562b3af080ba061687dc266d56b7ba3 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Mon, 21 Apr 2008 05:47:09 +0000 Subject: [PATCH] libass update r26303: Case insensitive parsing of SSA/ASS section headers. Originally committed to SVN as r2184. --- libass/ass.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 6271736e8..14f6c1587 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -647,17 +647,17 @@ static int process_fonts_line(ass_track_t* track, char *str) */ static int process_line(ass_track_t* track, char *str) { - if (strstr(str, "[Script Info]")) { // FIXME: strstr to skip possible BOM at the beginning of the script + if (!strncasecmp(str, "[Script Info]", 13)) { track->parser_priv->state = PST_INFO; - } else if (!strncmp(str, "[V4 Styles]", 11)) { + } else if (!strncasecmp(str, "[V4 Styles]", 11)) { track->parser_priv->state = PST_STYLES; track->track_type = TRACK_TYPE_SSA; - } else if (!strncmp(str, "[V4+ Styles]", 12)) { + } else if (!strncasecmp(str, "[V4+ Styles]", 12)) { track->parser_priv->state = PST_STYLES; track->track_type = TRACK_TYPE_ASS; - } else if (!strncmp(str, "[Events]", 8)) { + } else if (!strncasecmp(str, "[Events]", 8)) { track->parser_priv->state = PST_EVENTS; - } else if (!strncmp(str, "[Fonts]", 7)) { + } else if (!strncasecmp(str, "[Fonts]", 7)) { track->parser_priv->state = PST_FONTS; } else { switch (track->parser_priv->state) { @@ -690,7 +690,11 @@ static int process_text(ass_track_t* track, char* str) char* p = str; while(1) { char* q; - for (;((*p=='\r')||(*p=='\n'));++p) {} + while (1) { + if ((*p=='\r')||(*p=='\n')) ++p; + else if (p[0]=='\xef' && p[1]=='\xbb' && p[2]=='\xbf') p+=3; // U+FFFE (BOM) + else break; + } for (q=p; ((*q!='\0')&&(*q!='\r')&&(*q!='\n')); ++q) {}; if (q==p) break;