comparison subreader.c @ 29251:cada7608488b

Get rid of some more trailing whitespace
author reynaldo
date Tue, 12 May 2009 02:41:04 +0000
parents b226cc9b492c
children 0f1b5b68af32
comparison
equal deleted inserted replaced
29250:bc5115226204 29251:cada7608488b
51 int sub_match_fuzziness=0; // level of sub name matching fuzziness 51 int sub_match_fuzziness=0; // level of sub name matching fuzziness
52 52
53 /* Use the SUB_* constant defined in the header file */ 53 /* Use the SUB_* constant defined in the header file */
54 int sub_format=SUB_INVALID; 54 int sub_format=SUB_INVALID;
55 #ifdef CONFIG_SORTSUB 55 #ifdef CONFIG_SORTSUB
56 /* 56 /*
57 Some subtitling formats, namely AQT and Subrip09, define the end of a 57 Some subtitling formats, namely AQT and Subrip09, define the end of a
58 subtitle as the beginning of the following. Since currently we read one 58 subtitle as the beginning of the following. Since currently we read one
59 subtitle at time, for these format we keep two global *subtitle, 59 subtitle at time, for these format we keep two global *subtitle,
60 previous_aqt_sub and previous_subrip09_sub, pointing to previous subtitle, 60 previous_aqt_sub and previous_subrip09_sub, pointing to previous subtitle,
61 so we can change its end when we read current subtitle starting time. 61 so we can change its end when we read current subtitle starting time.
112 do { 112 do {
113 switch (state) { 113 switch (state) {
114 114
115 case 0: /* find "START=" or "Slacktime:" */ 115 case 0: /* find "START=" or "Slacktime:" */
116 slacktime_s = stristr (s, "Slacktime:"); 116 slacktime_s = stristr (s, "Slacktime:");
117 if (slacktime_s) 117 if (slacktime_s)
118 sub_slacktime = strtol (slacktime_s+10, NULL, 0) / 10; 118 sub_slacktime = strtol (slacktime_s+10, NULL, 0) / 10;
119 119
120 s = stristr (s, "Start="); 120 s = stristr (s, "Start=");
121 if (s) { 121 if (s) {
122 current->start = strtol (s + 6, &s, 0) / 10; 122 current->start = strtol (s + 6, &s, 0) / 10;
124 for (; *s != '>' && *s != '\0'; s++); 124 for (; *s != '>' && *s != '\0'; s++);
125 s++; 125 s++;
126 state = 1; continue; 126 state = 1; continue;
127 } 127 }
128 break; 128 break;
129 129
130 case 1: /* find (optionnal) "<P", skip other TAGs */ 130 case 1: /* find (optionnal) "<P", skip other TAGs */
131 for (; *s == ' ' || *s == '\t'; s++); /* strip blanks, if any */ 131 for (; *s == ' ' || *s == '\t'; s++); /* strip blanks, if any */
132 if (*s == '\0') break; 132 if (*s == '\0') break;
133 if (*s != '<') { state = 3; p = text; continue; } /* not a TAG */ 133 if (*s != '<') { state = 3; p = text; continue; } /* not a TAG */
134 s++; 134 s++;
136 for (; *s != '>' && *s != '\0'; s++); /* skip remains of non-<P> TAG */ 136 for (; *s != '>' && *s != '\0'; s++); /* skip remains of non-<P> TAG */
137 if (s == '\0') 137 if (s == '\0')
138 break; 138 break;
139 s++; 139 s++;
140 continue; 140 continue;
141 141
142 case 2: /* find ">" */ 142 case 2: /* find ">" */
143 if ((s = strchr (s, '>'))) { s++; state = 3; p = text; continue; } 143 if ((s = strchr (s, '>'))) { s++; state = 3; p = text; continue; }
144 break; 144 break;
145 145
146 case 3: /* get all text until '<' appears */ 146 case 3: /* get all text until '<' appears */
147 if (*s == '\0') break; 147 if (*s == '\0') break;
148 else if (!strncasecmp (s, "<br>", 4)) { 148 else if (!strncasecmp (s, "<br>", 4)) {
149 *p = '\0'; p = text; trail_space (text); 149 *p = '\0'; p = text; trail_space (text);
150 if (text[0] != '\0') 150 if (text[0] != '\0')
158 else if (*s == '\r' || *s == '\n') { s++; } 158 else if (*s == '\r' || *s == '\n') { s++; }
159 else *p++ = *s++; 159 else *p++ = *s++;
160 160
161 /* skip duplicated space */ 161 /* skip duplicated space */
162 if (p > text + 2) if (*(p-1) == ' ' && *(p-2) == ' ') p--; 162 if (p > text + 2) if (*(p-1) == ' ' && *(p-2) == ' ') p--;
163 163
164 continue; 164 continue;
165 165
166 case 4: /* get current->end or skip <TAG> */ 166 case 4: /* get current->end or skip <TAG> */
167 q = stristr (s, "Start="); 167 q = stristr (s, "Start=");
168 if (q) { 168 if (q) {
219 break; // if it is the last subtitle 219 break; // if it is the last subtitle
220 } else { 220 } else {
221 return 0; 221 return 0;
222 } 222 }
223 } 223 }
224 224
225 } while (state != 99); 225 } while (state != 99);
226 226
227 // For the last subtitle 227 // For the last subtitle
228 if (current->end <= 0) { 228 if (current->end <= 0) {
229 current->end = current->start + sub_slacktime; 229 current->end = current->start + sub_slacktime;
230 *p = '\0'; trail_space (text); 230 *p = '\0'; trail_space (text);
231 if (text[0] != '\0') 231 if (text[0] != '\0')
232 current->text[current->lines++] = strdup (text); 232 current->text[current->lines++] = strdup (text);
233 } 233 }
234 234
235 return current; 235 return current;
236 } 236 }
237 237
238 238
239 static char *sub_readtext(char *source, char **dest) { 239 static char *sub_readtext(char *source, char **dest) {
240 int len=0; 240 int len=0;
241 char *p=source; 241 char *p=source;
242 242
243 // printf("src=%p dest=%p \n",source,dest); 243 // printf("src=%p dest=%p \n",source,dest);
244 244
245 while ( !eol(*p) && *p!= '|' ) { 245 while ( !eol(*p) && *p!= '|' ) {
246 p++,len++; 246 p++,len++;
247 } 247 }
248 248
249 *dest= malloc (len+1); 249 *dest= malloc (len+1);
250 if (!dest) {return ERR;} 250 if (!dest) {return ERR;}
251 251
252 strncpy(*dest, source, len); 252 strncpy(*dest, source, len);
253 (*dest)[len]=0; 253 (*dest)[len]=0;
254 254
255 while (*p=='\r' || *p=='\n' || *p=='|') p++; 255 while (*p=='\r' || *p=='\n' || *p=='|') p++;
256 256
257 if (*p) return p; // not-last text field 257 if (*p) return p; // not-last text field
258 else return NULL; // last text field 258 else return NULL; // last text field
259 } 259 }
260 260
261 static subtitle *sub_read_line_microdvd(stream_t *st,subtitle *current) { 261 static subtitle *sub_read_line_microdvd(stream_t *st,subtitle *current) {
315 static subtitle *sub_read_line_subrip(stream_t* st, subtitle *current) { 315 static subtitle *sub_read_line_subrip(stream_t* st, subtitle *current) {
316 char line[LINE_LEN+1]; 316 char line[LINE_LEN+1];
317 int a1,a2,a3,a4,b1,b2,b3,b4; 317 int a1,a2,a3,a4,b1,b2,b3,b4;
318 char *p=NULL, *q=NULL; 318 char *p=NULL, *q=NULL;
319 int len; 319 int len;
320 320
321 while (1) { 321 while (1) {
322 if (!stream_read_line (st, line, LINE_LEN)) return NULL; 322 if (!stream_read_line (st, line, LINE_LEN)) return NULL;
323 if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4) < 8) continue; 323 if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4) < 8) continue;
324 current->start = a1*360000+a2*6000+a3*100+a4; 324 current->start = a1*360000+a2*6000+a3*100+a4;
325 current->end = b1*360000+b2*6000+b3*100+b4; 325 current->end = b1*360000+b2*6000+b3*100+b4;
345 static subtitle *sub_read_line_subviewer(stream_t *st,subtitle *current) { 345 static subtitle *sub_read_line_subviewer(stream_t *st,subtitle *current) {
346 char line[LINE_LEN+1]; 346 char line[LINE_LEN+1];
347 int a1,a2,a3,a4,b1,b2,b3,b4; 347 int a1,a2,a3,a4,b1,b2,b3,b4;
348 char *p=NULL; 348 char *p=NULL;
349 int i,len; 349 int i,len;
350 350
351 while (!current->text[0]) { 351 while (!current->text[0]) {
352 if (!stream_read_line (st, line, LINE_LEN)) return NULL; 352 if (!stream_read_line (st, line, LINE_LEN)) return NULL;
353 if ((len=sscanf (line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d",&a1,&a2,&a3,(char *)&i,&a4,&b1,&b2,&b3,(char *)&i,&b4)) < 10) 353 if ((len=sscanf (line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d",&a1,&a2,&a3,(char *)&i,&a4,&b1,&b2,&b3,(char *)&i,&b4)) < 10)
354 continue; 354 continue;
355 current->start = a1*360000+a2*6000+a3*100+a4/10; 355 current->start = a1*360000+a2*6000+a3*100+a4/10;
397 static subtitle *sub_read_line_subviewer2(stream_t *st,subtitle *current) { 397 static subtitle *sub_read_line_subviewer2(stream_t *st,subtitle *current) {
398 char line[LINE_LEN+1]; 398 char line[LINE_LEN+1];
399 int a1,a2,a3,a4; 399 int a1,a2,a3,a4;
400 char *p=NULL; 400 char *p=NULL;
401 int i,len; 401 int i,len;
402 402
403 while (!current->text[0]) { 403 while (!current->text[0]) {
404 if (!stream_read_line (st, line, LINE_LEN)) return NULL; 404 if (!stream_read_line (st, line, LINE_LEN)) return NULL;
405 if (line[0]!='{') 405 if (line[0]!='{')
406 continue; 406 continue;
407 if ((len=sscanf (line, "{T %d:%d:%d:%d",&a1,&a2,&a3,&a4)) < 4) 407 if ((len=sscanf (line, "{T %d:%d:%d:%d",&a1,&a2,&a3,&a4)) < 4)
441 if (!(current->start = a1*360000+a2*6000+a3*100)) 441 if (!(current->start = a1*360000+a2*6000+a3*100))
442 continue; 442 continue;
443 /* removed by wodzu 443 /* removed by wodzu
444 p=line; 444 p=line;
445 // finds the body of the subtitle 445 // finds the body of the subtitle
446 for (i=0; i<3; i++){ 446 for (i=0; i<3; i++){
447 p=strchr(p,':'); 447 p=strchr(p,':');
448 if (p==NULL) break; 448 if (p==NULL) break;
449 ++p; 449 ++p;
450 } 450 }
451 if (p==NULL) { 451 if (p==NULL) {
452 printf("SUB: Skipping incorrect subtitle line!\n"); 452 printf("SUB: Skipping incorrect subtitle line!\n");
453 continue; 453 continue;
454 } 454 }
455 */ 455 */
472 } 472 }
473 return current; 473 return current;
474 } 474 }
475 475
476 static subtitle *sub_read_line_rt(stream_t *st,subtitle *current) { 476 static subtitle *sub_read_line_rt(stream_t *st,subtitle *current) {
477 //TODO: This format uses quite rich (sub/super)set of xhtml 477 //TODO: This format uses quite rich (sub/super)set of xhtml
478 // I couldn't check it since DTD is not included. 478 // I couldn't check it since DTD is not included.
479 // WARNING: full XML parses can be required for proper parsing 479 // WARNING: full XML parses can be required for proper parsing
480 char line[LINE_LEN+1]; 480 char line[LINE_LEN+1];
481 int a1,a2,a3,a4,b1,b2,b3,b4; 481 int a1,a2,a3,a4,b1,b2,b3,b4;
482 char *p=NULL,*next=NULL; 482 char *p=NULL,*next=NULL;
483 int i,len,plen; 483 int i,len,plen;
484 484
485 while (!current->text[0]) { 485 while (!current->text[0]) {
486 if (!stream_read_line (st, line, LINE_LEN)) return NULL; 486 if (!stream_read_line (st, line, LINE_LEN)) return NULL;
487 //TODO: it seems that format of time is not easily determined, it may be 1:12, 1:12.0 or 0:1:12.0 487 //TODO: it seems that format of time is not easily determined, it may be 1:12, 1:12.0 or 0:1:12.0
488 //to describe the same moment in time. Maybe there are even more formats in use. 488 //to describe the same moment in time. Maybe there are even more formats in use.
489 //if ((len=sscanf (line, "<Time Begin=\"%d:%d:%d.%d\" End=\"%d:%d:%d.%d\"",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8) 489 //if ((len=sscanf (line, "<Time Begin=\"%d:%d:%d.%d\" End=\"%d:%d:%d.%d\"",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8)
498 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\" %*[Ee]nd=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4,&plen)) < 8) && 498 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\" %*[Ee]nd=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4,&plen)) < 8) &&
499 //now try it without end time 499 //now try it without end time
500 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d.%d\"%*[^<]<clear/>%n",&a3,&a4,&plen)) < 2) && 500 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d.%d\"%*[^<]<clear/>%n",&a3,&a4,&plen)) < 2) &&
501 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&plen)) < 2) && 501 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&plen)) < 2) &&
502 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&plen)) < 3) && 502 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&plen)) < 3) &&
503 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&plen)) < 4) 503 ((len=sscanf (line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&plen)) < 4)
504 ) 504 )
505 continue; 505 continue;
506 current->start = a1*360000+a2*6000+a3*100+a4/10; 506 current->start = a1*360000+a2*6000+a3*100+a4/10;
507 current->end = b1*360000+b2*6000+b3*100+b4/10; 507 current->end = b1*360000+b2*6000+b3*100+b4/10;
508 if (b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0) 508 if (b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0)
548 548
549 do { 549 do {
550 if (!stream_read_line (st, line, LINE_LEN)) return NULL; 550 if (!stream_read_line (st, line, LINE_LEN)) return NULL;
551 } while (sscanf (line, "Dialogue: Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d," 551 } while (sscanf (line, "Dialogue: Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d,"
552 "%[^\n\r]", &nothing, 552 "%[^\n\r]", &nothing,
553 &hour1, &min1, &sec1, &hunsec1, 553 &hour1, &min1, &sec1, &hunsec1,
554 &hour2, &min2, &sec2, &hunsec2, 554 &hour2, &min2, &sec2, &hunsec2,
555 line3) < 9 555 line3) < 9
556 && 556 &&
557 sscanf (line, "Dialogue: %d,%d:%d:%d.%d,%d:%d:%d.%d," 557 sscanf (line, "Dialogue: %d,%d:%d:%d.%d,%d:%d:%d.%d,"
558 "%[^\n\r]", &nothing, 558 "%[^\n\r]", &nothing,
559 &hour1, &min1, &sec1, &hunsec1, 559 &hour1, &min1, &sec1, &hunsec1,
560 &hour2, &min2, &sec2, &hunsec2, 560 &hour2, &min2, &sec2, &hunsec2,
561 line3) < 9 ); 561 line3) < 9 );
562 562
563 line2=strchr(line3, ','); 563 line2=strchr(line3, ',');
564 564
565 for (comma = 4; comma < max_comma; comma ++) 565 for (comma = 4; comma < max_comma; comma ++)
566 { 566 {
567 tmp = line2; 567 tmp = line2;
568 if(!(tmp=strchr(++tmp, ','))) break; 568 if(!(tmp=strchr(++tmp, ','))) break;
569 if(*(++tmp) == ' ') break; 569 if(*(++tmp) == ' ') break;
570 /* a space after a comma means we're already in a sentence */ 570 /* a space after a comma means we're already in a sentence */
571 line2 = tmp; 571 line2 = tmp;
572 } 572 }
573 573
574 if(comma < max_comma)max_comma = comma; 574 if(comma < max_comma)max_comma = comma;
671 do 671 do
672 { 672 {
673 if (!stream_read_line(st, line, LINE_LEN)) return NULL; 673 if (!stream_read_line(st, line, LINE_LEN)) return NULL;
674 } while (sscanf (line, "%f %f", &a, &b) !=2); 674 } while (sscanf (line, "%f %f", &a, &b) !=2);
675 675
676 mpsub_position += a*mpsub_multiplier; 676 mpsub_position += a*mpsub_multiplier;
677 current->start=(int) mpsub_position; 677 current->start=(int) mpsub_position;
678 mpsub_position += b*mpsub_multiplier; 678 mpsub_position += b*mpsub_multiplier;
679 current->end=(int) mpsub_position; 679 current->end=(int) mpsub_position;
680 680
681 while (num < SUB_MAX_TEXT) { 681 while (num < SUB_MAX_TEXT) {
682 if (!stream_read_line (st, line, LINE_LEN)) { 682 if (!stream_read_line (st, line, LINE_LEN)) {
683 if (num == 0) return NULL; 683 if (num == 0) return NULL;
717 if (!stream_read_line (st, line, LINE_LEN)) 717 if (!stream_read_line (st, line, LINE_LEN))
718 return NULL; 718 return NULL;
719 if (!(sscanf (line, "-->> %ld", &(current->start)) <1)) 719 if (!(sscanf (line, "-->> %ld", &(current->start)) <1))
720 break; 720 break;
721 } 721 }
722 722
723 #ifdef CONFIG_SORTSUB 723 #ifdef CONFIG_SORTSUB
724 previous_sub_end = (current->start) ? current->start - 1 : 0; 724 previous_sub_end = (current->start) ? current->start - 1 : 0;
725 #else 725 #else
726 if (previous_aqt_sub != NULL) 726 if (previous_aqt_sub != NULL)
727 previous_aqt_sub->end = current->start-1; 727 previous_aqt_sub->end = current->start-1;
728 728
729 previous_aqt_sub = current; 729 previous_aqt_sub = current;
730 #endif 730 #endif
731 731
732 if (!stream_read_line (st, line, LINE_LEN)) 732 if (!stream_read_line (st, line, LINE_LEN))
733 return NULL; 733 return NULL;
767 static subtitle *sub_read_line_subrip09(stream_t *st,subtitle *current) { 767 static subtitle *sub_read_line_subrip09(stream_t *st,subtitle *current) {
768 char line[LINE_LEN+1]; 768 char line[LINE_LEN+1];
769 int a1,a2,a3; 769 int a1,a2,a3;
770 char * next=NULL; 770 char * next=NULL;
771 int i,len; 771 int i,len;
772 772
773 while (1) { 773 while (1) {
774 // try to locate next subtitle 774 // try to locate next subtitle
775 if (!stream_read_line (st, line, LINE_LEN)) 775 if (!stream_read_line (st, line, LINE_LEN))
776 return NULL; 776 return NULL;
777 if (!((len=sscanf (line, "[%d:%d:%d]",&a1,&a2,&a3)) < 3)) 777 if (!((len=sscanf (line, "[%d:%d:%d]",&a1,&a2,&a3)) < 3))
778 break; 778 break;
779 } 779 }
780 780
781 current->start = a1*360000+a2*6000+a3*100; 781 current->start = a1*360000+a2*6000+a3*100;
782 782
783 #ifdef CONFIG_SORTSUB 783 #ifdef CONFIG_SORTSUB
784 previous_sub_end = (current->start) ? current->start - 1 : 0; 784 previous_sub_end = (current->start) ? current->start - 1 : 0;
785 #else 785 #else
786 if (previous_subrip09_sub != NULL) 786 if (previous_subrip09_sub != NULL)
787 previous_subrip09_sub->end = current->start-1; 787 previous_subrip09_sub->end = current->start-1;
788 788
789 previous_subrip09_sub = current; 789 previous_subrip09_sub = current;
790 #endif 790 #endif
791 791
792 if (!stream_read_line (st, line, LINE_LEN)) 792 if (!stream_read_line (st, line, LINE_LEN))
793 return NULL; 793 return NULL;
794 794
795 next = line,i=0; 795 next = line,i=0;
796 796
797 current->text[0]=""; // just to be sure that string is clear 797 current->text[0]=""; // just to be sure that string is clear
798 798
799 while ((next =sub_readtext (next, &(current->text[i])))) { 799 while ((next =sub_readtext (next, &(current->text[i])))) {
800 if (current->text[i]==ERR) {return ERR;} 800 if (current->text[i]==ERR) {return ERR;}
801 i++; 801 i++;
802 if (i>=SUB_MAX_TEXT) { mp_msg(MSGT_SUBREADER,MSGL_WARN,"Too many lines in a subtitle\n");current->lines=i;return current;} 802 if (i>=SUB_MAX_TEXT) { mp_msg(MSGT_SUBREADER,MSGL_WARN,"Too many lines in a subtitle\n");current->lines=i;return current;}
803 } 803 }
1009 1009
1010 static int sub_autodetect (stream_t* st, int *uses_time) { 1010 static int sub_autodetect (stream_t* st, int *uses_time) {
1011 char line[LINE_LEN+1]; 1011 char line[LINE_LEN+1];
1012 int i,j=0; 1012 int i,j=0;
1013 char p; 1013 char p;
1014 1014
1015 while (j < 100) { 1015 while (j < 100) {
1016 j++; 1016 j++;
1017 if (!stream_read_line (st, line, LINE_LEN)) 1017 if (!stream_read_line (st, line, LINE_LEN))
1018 return SUB_INVALID; 1018 return SUB_INVALID;
1019 1019
1087 if (st && st->flags & STREAM_SEEK ) { 1087 if (st && st->flags & STREAM_SEEK ) {
1088 cp_tmp = guess_cp(st, enca_lang, enca_fallback); 1088 cp_tmp = guess_cp(st, enca_lang, enca_fallback);
1089 } else { 1089 } else {
1090 cp_tmp = enca_fallback; 1090 cp_tmp = enca_fallback;
1091 if (st) 1091 if (st)
1092 mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: enca failed, stream must be seekable.\n"); 1092 mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: enca failed, stream must be seekable.\n");
1093 } 1093 }
1094 } 1094 }
1095 #endif 1095 #endif
1096 if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){ 1096 if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){
1097 mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n"); 1097 mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n");
1160 int char_set_num; 1160 int char_set_num;
1161 fribidi_boolean log2vis; 1161 fribidi_boolean log2vis;
1162 if(flip_hebrew) { // Please fix the indentation someday 1162 if(flip_hebrew) { // Please fix the indentation someday
1163 fribidi_set_mirroring(1); 1163 fribidi_set_mirroring(1);
1164 fribidi_set_reorder_nsm(0); 1164 fribidi_set_reorder_nsm(0);
1165 1165
1166 if( sub_utf8 == 0 ) { 1166 if( sub_utf8 == 0 ) {
1167 char_set_num = fribidi_parse_charset (fribidi_charset?fribidi_charset:"ISO8859-8"); 1167 char_set_num = fribidi_parse_charset (fribidi_charset?fribidi_charset:"ISO8859-8");
1168 }else { 1168 }else {
1169 char_set_num = fribidi_parse_charset ("UTF-8"); 1169 char_set_num = fribidi_parse_charset ("UTF-8");
1170 } 1170 }
1284 mp_msg(MSGT_SUBREADER, MSGL_V, "ENCA supported languages: "); 1284 mp_msg(MSGT_SUBREADER, MSGL_V, "ENCA supported languages: ");
1285 for (i = 0; i < langcnt; i++) { 1285 for (i = 0; i < langcnt; i++) {
1286 mp_msg(MSGT_SUBREADER, MSGL_V, "%s ", languages[i]); 1286 mp_msg(MSGT_SUBREADER, MSGL_V, "%s ", languages[i]);
1287 } 1287 }
1288 mp_msg(MSGT_SUBREADER, MSGL_V, "\n"); 1288 mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
1289 1289
1290 for (i = 0; i < langcnt; i++) { 1290 for (i = 0; i < langcnt; i++) {
1291 if (strcasecmp(languages[i], preferred_language) != 0) continue; 1291 if (strcasecmp(languages[i], preferred_language) != 0) continue;
1292 analyser = enca_analyser_alloc(languages[i]); 1292 analyser = enca_analyser_alloc(languages[i]);
1293 encoding = enca_analyse_const(analyser, buffer, buflen); 1293 encoding = enca_analyse_const(analyser, buffer, buflen);
1294 enca_analyser_free(analyser); 1294 enca_analyser_free(analyser);
1295 if (encoding.charset != ENCA_CS_UNKNOWN) { 1295 if (encoding.charset != ENCA_CS_UNKNOWN) {
1296 detected_sub_cp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV); 1296 detected_sub_cp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
1297 break; 1297 break;
1298 } 1298 }
1299 } 1299 }
1300 1300
1301 free(languages); 1301 free(languages);
1302 1302
1303 if (!detected_sub_cp) { 1303 if (!detected_sub_cp) {
1304 detected_sub_cp = fallback; 1304 detected_sub_cp = fallback;
1305 mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback); 1305 mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback);
1319 1319
1320 buffer = malloc(MAX_GUESS_BUFFER_SIZE); 1320 buffer = malloc(MAX_GUESS_BUFFER_SIZE);
1321 buflen = stream_read(st,buffer, MAX_GUESS_BUFFER_SIZE); 1321 buflen = stream_read(st,buffer, MAX_GUESS_BUFFER_SIZE);
1322 1322
1323 detected_sub_cp = guess_buffer_cp(buffer, buflen, preferred_language, fallback); 1323 detected_sub_cp = guess_buffer_cp(buffer, buflen, preferred_language, fallback);
1324 1324
1325 free(buffer); 1325 free(buffer);
1326 stream_reset(st); 1326 stream_reset(st);
1327 stream_seek(st,0); 1327 stream_seek(st,0);
1328 1328
1329 return detected_sub_cp; 1329 return detected_sub_cp;
1353 { sub_read_line_subrip09, NULL, "subrip 0.9" }, 1353 { sub_read_line_subrip09, NULL, "subrip 0.9" },
1354 { sub_read_line_jacosub, NULL, "jacosub" }, 1354 { sub_read_line_jacosub, NULL, "jacosub" },
1355 { sub_read_line_mpl2, NULL, "mpl2" } 1355 { sub_read_line_mpl2, NULL, "mpl2" }
1356 }; 1356 };
1357 struct subreader *srp; 1357 struct subreader *srp;
1358 1358
1359 if(filename==NULL) return NULL; //qnx segfault 1359 if(filename==NULL) return NULL; //qnx segfault
1360 i = 0; 1360 i = 0;
1361 fd=open_stream (filename, NULL, &i); if (!fd) return NULL; 1361 fd=open_stream (filename, NULL, &i); if (!fd) return NULL;
1362 1362
1363 sub_format=sub_autodetect (fd, &uses_time); 1363 sub_format=sub_autodetect (fd, &uses_time);
1364 mpsub_multiplier = (uses_time ? 100.0 : 1.0); 1364 mpsub_multiplier = (uses_time ? 100.0 : 1.0);
1365 if (sub_format==SUB_INVALID) {mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: Could not determine file format\n");return NULL;} 1365 if (sub_format==SUB_INVALID) {mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: Could not determine file format\n");return NULL;}
1366 srp=sr+sub_format; 1366 srp=sr+sub_format;
1367 mp_msg(MSGT_SUBREADER, MSGL_V, "SUB: Detected subtitle file format: %s\n", srp->name); 1367 mp_msg(MSGT_SUBREADER, MSGL_V, "SUB: Detected subtitle file format: %s\n", srp->name);
1368 1368
1369 stream_reset(fd); 1369 stream_reset(fd);
1370 stream_seek(fd,0); 1370 stream_seek(fd,0);
1371 1371
1372 #ifdef CONFIG_ICONV 1372 #ifdef CONFIG_ICONV
1373 sub_utf8_prev=sub_utf8; 1373 sub_utf8_prev=sub_utf8;
1393 subcp_close(); 1393 subcp_close();
1394 sub_utf8=sub_utf8_prev; 1394 sub_utf8=sub_utf8_prev;
1395 #endif 1395 #endif
1396 return NULL; 1396 return NULL;
1397 } 1397 }
1398 1398
1399 #ifdef CONFIG_SORTSUB 1399 #ifdef CONFIG_SORTSUB
1400 sub = malloc(sizeof(subtitle)); 1400 sub = malloc(sizeof(subtitle));
1401 //This is to deal with those formats (AQT & Subrip) which define the end of a subtitle 1401 //This is to deal with those formats (AQT & Subrip) which define the end of a subtitle
1402 //as the beginning of the following 1402 //as the beginning of the following
1403 previous_sub_end = 0; 1403 previous_sub_end = 0;
1404 #endif 1404 #endif
1405 while(1){ 1405 while(1){
1406 if(sub_num>=n_max){ 1406 if(sub_num>=n_max){
1407 n_max+=16; 1407 n_max+=16;
1408 first=realloc(first,n_max*sizeof(subtitle)); 1408 first=realloc(first,n_max*sizeof(subtitle));
1409 } 1409 }
1423 { 1423 {
1424 #ifdef CONFIG_ICONV 1424 #ifdef CONFIG_ICONV
1425 subcp_close(); 1425 subcp_close();
1426 #endif 1426 #endif
1427 if ( first ) free(first); 1427 if ( first ) free(first);
1428 return NULL; 1428 return NULL;
1429 } 1429 }
1430 // Apply any post processing that needs recoding first 1430 // Apply any post processing that needs recoding first
1431 if ((sub!=ERR) && !sub_no_text_pp && srp->post) srp->post(sub); 1431 if ((sub!=ERR) && !sub_no_text_pp && srp->post) srp->post(sub);
1432 #ifdef CONFIG_SORTSUB 1432 #ifdef CONFIG_SORTSUB
1433 if(!sub_num || (first[sub_num - 1].start <= sub->start)){ 1433 if(!sub_num || (first[sub_num - 1].start <= sub->start)){
1469 } 1469 }
1470 } 1470 }
1471 #endif 1471 #endif
1472 if(sub==ERR) ++sub_errs; else ++sub_num; // Error vs. Valid 1472 if(sub==ERR) ++sub_errs; else ++sub_num; // Error vs. Valid
1473 } 1473 }
1474 1474
1475 free_stream(fd); 1475 free_stream(fd);
1476 1476
1477 #ifdef CONFIG_ICONV 1477 #ifdef CONFIG_ICONV
1478 subcp_close(); 1478 subcp_close();
1479 #endif 1479 #endif
1711 #if 0 1711 #if 0
1712 char * strreplace( char * in,char * what,char * whereof ) 1712 char * strreplace( char * in,char * what,char * whereof )
1713 { 1713 {
1714 int i; 1714 int i;
1715 char * tmp; 1715 char * tmp;
1716 1716
1717 if ( ( in == NULL )||( what == NULL )||( whereof == NULL )||( ( tmp=strstr( in,what ) ) == NULL ) ) return NULL; 1717 if ( ( in == NULL )||( what == NULL )||( whereof == NULL )||( ( tmp=strstr( in,what ) ) == NULL ) ) return NULL;
1718 for( i=0;i<strlen( whereof );i++ ) tmp[i]=whereof[i]; 1718 for( i=0;i<strlen( whereof );i++ ) tmp[i]=whereof[i];
1719 if ( strlen( what ) > strlen( whereof ) ) tmp[i]=0; 1719 if ( strlen( what ) > strlen( whereof ) ) tmp[i]=0;
1720 return in; 1720 return in;
1721 } 1721 }
1742 if (*s == 0) break; 1742 if (*s == 0) break;
1743 *d++ = ' '; 1743 *d++ = ' ';
1744 } 1744 }
1745 *d = 0; 1745 *d = 0;
1746 } 1746 }
1747 1747
1748 static void strcpy_strip_ext(char *d, char *s) 1748 static void strcpy_strip_ext(char *d, char *s)
1749 { 1749 {
1750 char *tmp = strrchr(s,'.'); 1750 char *tmp = strrchr(s,'.');
1751 if (!tmp) { 1751 if (!tmp) {
1752 strcpy(d, s); 1752 strcpy(d, s);
1758 while (*d) { 1758 while (*d) {
1759 *d = tolower(*d); 1759 *d = tolower(*d);
1760 d++; 1760 d++;
1761 } 1761 }
1762 } 1762 }
1763 1763
1764 static void strcpy_get_ext(char *d, char *s) 1764 static void strcpy_get_ext(char *d, char *s)
1765 { 1765 {
1766 char *tmp = strrchr(s,'.'); 1766 char *tmp = strrchr(s,'.');
1767 if (!tmp) { 1767 if (!tmp) {
1768 strcpy(d, ""); 1768 strcpy(d, "");
1800 1800
1801 char** sub_filenames(const char* path, char *fname) 1801 char** sub_filenames(const char* path, char *fname)
1802 { 1802 {
1803 char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp, *tmp_sub_id; 1803 char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp, *tmp_sub_id;
1804 char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult; 1804 char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult;
1805 1805
1806 int len, pos, found, i, j; 1806 int len, pos, found, i, j;
1807 char * sub_exts[] = { "utf", "utf8", "utf-8", "sub", "srt", "smi", "rt", "txt", "ssa", "aqt", "jss", "js", "ass", NULL}; 1807 char * sub_exts[] = { "utf", "utf8", "utf-8", "sub", "srt", "smi", "rt", "txt", "ssa", "aqt", "jss", "js", "ass", NULL};
1808 subfn *result; 1808 subfn *result;
1809 char **result2; 1809 char **result2;
1810 1810
1811 int subcnt; 1811 int subcnt;
1812 1812
1813 FILE *f; 1813 FILE *f;
1814 1814
1815 DIR *d; 1815 DIR *d;
1816 struct dirent *de; 1816 struct dirent *de;
1817 1817
1829 1829
1830 tmpresult = malloc(len); 1830 tmpresult = malloc(len);
1831 1831
1832 result = malloc(sizeof(subfn)*MAX_SUBTITLE_FILES); 1832 result = malloc(sizeof(subfn)*MAX_SUBTITLE_FILES);
1833 memset(result, 0, sizeof(subfn)*MAX_SUBTITLE_FILES); 1833 memset(result, 0, sizeof(subfn)*MAX_SUBTITLE_FILES);
1834 1834
1835 subcnt = 0; 1835 subcnt = 0;
1836 1836
1837 tmp = strrchr(fname,'/'); 1837 tmp = strrchr(fname,'/');
1838 #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) 1838 #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__)
1839 if(!tmp)tmp = strrchr(fname,'\\'); 1839 if(!tmp)tmp = strrchr(fname,'\\');
1840 if(!tmp)tmp = strrchr(fname,':'); 1840 if(!tmp)tmp = strrchr(fname,':');
1841 #endif 1841 #endif
1842 1842
1843 // extract filename & dirname from fname 1843 // extract filename & dirname from fname
1844 if (tmp) { 1844 if (tmp) {
1845 strcpy(f_fname, tmp+1); 1845 strcpy(f_fname, tmp+1);
1846 pos = tmp - fname; 1846 pos = tmp - fname;
1847 strncpy(f_dir, fname, pos+1); 1847 strncpy(f_dir, fname, pos+1);
1848 f_dir[pos+1] = 0; 1848 f_dir[pos+1] = 0;
1849 } else { 1849 } else {
1850 strcpy(f_fname, fname); 1850 strcpy(f_fname, fname);
1851 strcpy(f_dir, "./"); 1851 strcpy(f_dir, "./");
1852 } 1852 }
1853 1853
1854 strcpy_strip_ext(f_fname_noext, f_fname); 1854 strcpy_strip_ext(f_fname_noext, f_fname);
1855 strcpy_trim(f_fname_trim, f_fname_noext); 1855 strcpy_trim(f_fname_trim, f_fname_noext);
1856 1856
1857 tmp_sub_id = NULL; 1857 tmp_sub_id = NULL;
1858 if (dvdsub_lang && !whiteonly(dvdsub_lang)) { 1858 if (dvdsub_lang && !whiteonly(dvdsub_lang)) {
1887 if (strcasecmp(sub_exts[i], tmp_fname_ext) == 0) { 1887 if (strcasecmp(sub_exts[i], tmp_fname_ext) == 0) {
1888 found = 1; 1888 found = 1;
1889 break; 1889 break;
1890 } 1890 }
1891 } 1891 }
1892 1892
1893 // we have a (likely) subtitle file 1893 // we have a (likely) subtitle file
1894 if (found) { 1894 if (found) {
1895 int prio = 0; 1895 int prio = 0;
1896 if (!prio && tmp_sub_id) 1896 if (!prio && tmp_sub_id)
1897 { 1897 {
1898 sprintf(tmpresult, "%s %s", f_fname_trim, tmp_sub_id); 1898 sprintf(tmpresult, "%s %s", f_fname_trim, tmp_sub_id);
1899 mp_msg(MSGT_SUBREADER,MSGL_INFO,"dvdsublang...%s\n", tmpresult); 1899 mp_msg(MSGT_SUBREADER,MSGL_INFO,"dvdsublang...%s\n", tmpresult);
1900 if (strcmp(tmp_fname_trim, tmpresult) == 0 && sub_match_fuzziness >= 1) { 1900 if (strcmp(tmp_fname_trim, tmpresult) == 0 && sub_match_fuzziness >= 1) {
1901 // matches the movie name + lang extension 1901 // matches the movie name + lang extension
1902 prio = 5; 1902 prio = 5;
1903 } 1903 }
1904 } 1904 }
1905 if (!prio && strcmp(tmp_fname_trim, f_fname_trim) == 0) { 1905 if (!prio && strcmp(tmp_fname_trim, f_fname_trim) == 0) {
1906 // matches the movie name 1906 // matches the movie name
1907 prio = 4; 1907 prio = 4;
1908 } 1908 }
1948 } 1948 }
1949 if (subcnt >= MAX_SUBTITLE_FILES) break; 1949 if (subcnt >= MAX_SUBTITLE_FILES) break;
1950 } 1950 }
1951 closedir(d); 1951 closedir(d);
1952 } 1952 }
1953 1953
1954 } 1954 }
1955 1955
1956 if (tmp_sub_id) free(tmp_sub_id); 1956 if (tmp_sub_id) free(tmp_sub_id);
1957 1957
1958 free(f_dir); 1958 free(f_dir);
1959 free(f_fname); 1959 free(f_fname);
1960 free(f_fname_noext); 1960 free(f_fname_noext);
1961 free(f_fname_trim); 1961 free(f_fname_trim);
1962 1962
1973 1973
1974 for (i = 0; i < subcnt; i++) { 1974 for (i = 0; i < subcnt; i++) {
1975 result2[i] = result[i].fname; 1975 result2[i] = result[i].fname;
1976 } 1976 }
1977 result2[subcnt] = NULL; 1977 result2[subcnt] = NULL;
1978 1978
1979 free(result); 1979 free(result);
1980 1980
1981 return result2; 1981 return result2;
1982 } 1982 }
1983 1983
1996 mp_msg(MSGT_SUBREADER,MSGL_INFO,"\t\t%d: %s%s", i,egysub->text[i], i==egysub->lines-1?"":" \n "); 1996 mp_msg(MSGT_SUBREADER,MSGL_INFO,"\t\t%d: %s%s", i,egysub->text[i], i==egysub->lines-1?"":" \n ");
1997 } 1997 }
1998 mp_msg(MSGT_SUBREADER,MSGL_INFO,"\n"); 1998 mp_msg(MSGT_SUBREADER,MSGL_INFO,"\n");
1999 } 1999 }
2000 2000
2001 mp_msg(MSGT_SUBREADER,MSGL_INFO,"Subtitle format %s time.\n", 2001 mp_msg(MSGT_SUBREADER,MSGL_INFO,"Subtitle format %s time.\n",
2002 subd->sub_uses_time ? "uses":"doesn't use"); 2002 subd->sub_uses_time ? "uses":"doesn't use");
2003 mp_msg(MSGT_SUBREADER,MSGL_INFO,"Read %i subtitles, %i errors.\n", subd->sub_num, subd->sub_errs); 2003 mp_msg(MSGT_SUBREADER,MSGL_INFO,"Read %i subtitles, %i errors.\n", subd->sub_num, subd->sub_errs);
2004 } 2004 }
2005 2005
2006 void dump_srt(sub_data* subd, float fps){ 2006 void dump_srt(sub_data* subd, float fps){
2013 2013
2014 if (!subd->sub_uses_time && sub_fps == 0) 2014 if (!subd->sub_uses_time && sub_fps == 0)
2015 sub_fps = fps; 2015 sub_fps = fps;
2016 fd=fopen("dumpsub.srt","w"); 2016 fd=fopen("dumpsub.srt","w");
2017 if(!fd) 2017 if(!fd)
2018 { 2018 {
2019 perror("dump_srt: fopen"); 2019 perror("dump_srt: fopen");
2020 return; 2020 return;
2021 } 2021 }
2022 for(i=0; i < subd->sub_num; i++) 2022 for(i=0; i < subd->sub_num; i++)
2023 { 2023 {
2079 b=((egysub->end-egysub->start)/100.0); 2079 b=((egysub->end-egysub->start)/100.0);
2080 if ( (float)((int)a) == a) 2080 if ( (float)((int)a) == a)
2081 fprintf (fd, "%.0f",a); 2081 fprintf (fd, "%.0f",a);
2082 else 2082 else
2083 fprintf (fd, "%.2f",a); 2083 fprintf (fd, "%.2f",a);
2084 2084
2085 if ( (float)((int)b) == b) 2085 if ( (float)((int)b) == b)
2086 fprintf (fd, " %.0f\n",b); 2086 fprintf (fd, " %.0f\n",b);
2087 else 2087 else
2088 fprintf (fd, " %.2f\n",b); 2088 fprintf (fd, " %.2f\n",b);
2089 } else { 2089 } else {
2126 end = end * sub_fps / fps; 2126 end = end * sub_fps / fps;
2127 } 2127 }
2128 start -= delay; 2128 start -= delay;
2129 end -= delay; 2129 end -= delay;
2130 fprintf(fd, "{%d}{%d}", start, end); 2130 fprintf(fd, "{%d}{%d}", start, end);
2131 for (j = 0; j < subs[i].lines; ++j) 2131 for (j = 0; j < subs[i].lines; ++j)
2132 fprintf(fd, "%s%s", j ? "|" : "", subs[i].text[j]); 2132 fprintf(fd, "%s%s", j ? "|" : "", subs[i].text[j]);
2133 fprintf(fd, "\n"); 2133 fprintf(fd, "\n");
2134 } 2134 }
2135 fclose(fd); 2135 fclose(fd);
2136 mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.sub\'.\n"); 2136 mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.sub\'.\n");
2146 2146
2147 if (!subd->sub_uses_time && sub_fps == 0) 2147 if (!subd->sub_uses_time && sub_fps == 0)
2148 sub_fps = fps; 2148 sub_fps = fps;
2149 fd=fopen("dumpsub.jss","w"); 2149 fd=fopen("dumpsub.jss","w");
2150 if(!fd) 2150 if(!fd)
2151 { 2151 {
2152 perror("dump_jacosub: fopen"); 2152 perror("dump_jacosub: fopen");
2153 return; 2153 return;
2154 } 2154 }
2155 fprintf(fd, "#TIMERES %d\n", (subd->sub_uses_time) ? 100 : (int)sub_fps); 2155 fprintf(fd, "#TIMERES %d\n", (subd->sub_uses_time) ? 100 : (int)sub_fps);
2156 for(i=0; i < subd->sub_num; i++) 2156 for(i=0; i < subd->sub_num; i++)
2157 { 2157 {
2158 onesub=subs+i; //=&subs[i]; 2158 onesub=subs+i; //=&subs[i];
2159 2159
2160 temp=onesub->start; 2160 temp=onesub->start;
2195 2195
2196 if (!subd->sub_uses_time && sub_fps == 0) 2196 if (!subd->sub_uses_time && sub_fps == 0)
2197 sub_fps = fps; 2197 sub_fps = fps;
2198 fd=fopen("dumpsub.smi","w"); 2198 fd=fopen("dumpsub.smi","w");
2199 if(!fd) 2199 if(!fd)
2200 { 2200 {
2201 perror("dump_jacosub: fopen"); 2201 perror("dump_jacosub: fopen");
2202 return; 2202 return;
2203 } 2203 }
2204 fprintf(fd, "<SAMI>\n" 2204 fprintf(fd, "<SAMI>\n"
2205 "<HEAD>\n" 2205 "<HEAD>\n"
2241 } 2241 }
2242 2242
2243 void sub_free( sub_data * subd ) 2243 void sub_free( sub_data * subd )
2244 { 2244 {
2245 int i; 2245 int i;
2246 2246
2247 if ( !subd ) return; 2247 if ( !subd ) return;
2248 2248
2249 if (subd->subtitles) { 2249 if (subd->subtitles) {
2250 for (i=0; i < subd->subtitles->lines; i++) free( subd->subtitles->text[i] ); 2250 for (i=0; i < subd->subtitles->lines; i++) free( subd->subtitles->text[i] );
2251 free( subd->subtitles ); 2251 free( subd->subtitles );
2252 } 2252 }
2253 if (subd->filename) free( subd->filename ); 2253 if (subd->filename) free( subd->filename );
2304 } 2304 }
2305 double_newline = 1; 2305 double_newline = 1;
2306 buf[pos] = 0; 2306 buf[pos] = 0;
2307 sub->lines++; 2307 sub->lines++;
2308 pos = 0; 2308 pos = 0;
2309 buf = malloc(MAX_SUBLINE + 1); 2309 buf = malloc(MAX_SUBLINE + 1);
2310 sub->text[sub->lines] = buf; 2310 sub->text[sub->lines] = buf;
2311 sub->endpts[sub->lines] = endpts; 2311 sub->endpts[sub->lines] = endpts;
2312 } 2312 }
2313 } 2313 }
2314 buf[pos] = 0; 2314 buf[pos] = 0;