Index: subreader.c =================================================================== RCS file: /cvsroot/mplayer/main/subreader.c,v retrieving revision 1.128 diff -u -r1.128 subreader.c --- subreader.c 29 Jan 2004 10:53:19 -0000 1.128 +++ subreader.c 29 Jan 2004 23:51:46 -0000 @@ -468,12 +468,45 @@ int hour1, min1, sec1, hunsec1, hour2, min2, sec2, hunsec2, nothing; int num; + static int event, nbcomma = 0; char line[LINE_LEN+1], line3[LINE_LEN+1], *line2; char *tmp; + /*if we don't read [Events]*/ + while (!event) + { + if (!fgets (line, LINE_LEN, fd)) return NULL; + if (!strncmp (line, "[Events]",8)) + { + event=1; + break; + } + } + + /*if we don't read the line after [Events]*/ + while (!nbcomma) + { + if (!fgets (line, LINE_LEN, fd)) return NULL; + + /*this line indicate the parameter, and so the number of comma*/ + if (!strncmp (line, "Format:",7)) + { + tmp=strchr(line, ','); + for (comma = 0; comma < max_comma; comma ++) + { + tmp=strchr(++tmp, ','); + if(!tmp) break; + } + max_comma=comma; + nbcomma=1; + } + else + return ERR; + } + do { if (!fgets (line, LINE_LEN, fd)) return NULL; } while (sscanf (line, "Dialogue: Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d," @@ -488,20 +521,16 @@ &hour2, &min2, &sec2, &hunsec2, line3) < 9 ); - line2=strchr(line3, ','); + tmp=strchr(line3, ','); for (comma = 4; comma < max_comma; comma ++) { - tmp = line2; - if(!(tmp=strchr(++tmp, ','))) break; - if(*(++tmp) == ' ') break; - /* a space after a comma means we're already in a sentence */ - line2 = tmp; + tmp=strchr(++tmp, ','); + if(!tmp) break;/*In this case the line is invalid*/ } - if(comma < max_comma)max_comma = comma; - /* eliminate the trailing comma */ - if(*line2 == ',') line2++; + line2 = ++tmp; + while (*line2 == ' ') line2++;/*remove the space at the beginning*/ current->lines=0;num=0; current->start = 360000*hour1 + 6000*min1 + 100*sec1 + hunsec1;