[MPlayer-cvslog] r26302 - trunk/libass/ass.c
eugeni
subversion at mplayerhq.hu
Sun Mar 30 19:42:17 CEST 2008
Author: eugeni
Date: Sun Mar 30 19:42:17 2008
New Revision: 26302
Log:
Skip BOM at the beginning of text in ASS parser.
Modified:
trunk/libass/ass.c
Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c (original)
+++ trunk/libass/ass.c Sun Mar 30 19:42:17 2008
@@ -647,7 +647,7 @@ static int process_fonts_line(ass_track_
*/
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 (!strncmp(str, "[Script Info]", 13)) {
track->parser_priv->state = PST_INFO;
} else if (!strncmp(str, "[V4 Styles]", 11)) {
track->parser_priv->state = PST_STYLES;
@@ -690,7 +690,11 @@ static int process_text(ass_track_t* tra
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;
More information about the MPlayer-cvslog
mailing list