[MPlayer-dev-eng] [PATCH] fix SAMI parsing
Howard Chu
hyc at highlandsun.com
Mon Jun 7 05:31:12 CEST 2010
Reimar Döffinger wrote:
> On Sun, Jun 06, 2010 at 02:51:29PM -0700, Howard Chu wrote:
>> Index: subreader.c
>> ===================================================================
>> --- subreader.c (revision 31341)
>> +++ subreader.c (working copy)
>> @@ -116,10 +116,12 @@
>> static char *s = NULL, *slacktime_s;
>> char text[LINE_LEN+1], *p=NULL, *q;
>> int state;
>> + extern int sub_utf8;
>
> There's already one further down, you should just merge them.
> I also think libvo/sub.h is the right way to get this..
OK.
>
>> current->lines = current->start = current->end = 0;
>> current->alignment = SUB_ALIGNMENT_BOTTOMCENTER;
>> state = 0;
>> + sub_utf8 = 1;
>
> I suspect this will cause a memleak with -subcp
> Somewhere around the
> "Detected subtitle file format"
> message might be better.
OK.
> Of course a really nice long-term solution would later
> make this more generic, and only make it the default
> while the user can still override with -utf8 and -noutf8 -
> but that's a bit much for this simple feature.
>
>> @@ -161,17 +165,25 @@
>>
>> case 3: /* get all text until '<' appears */
>> if (*s == '\0') break;
>> - else if (!strncasecmp (s, "<br>", 4)) {
>> + else if (!strncasecmp (s, "<br", 3) ||
>> + !strncasecmp (s, "</p>", 4)) {
>> *p = '\0'; p = text; trail_space (text);
>> if (text[0] != '\0')
>> current->text[current->lines++] = strdup (text);
>> - s += 4;
>> + s = strchr (s, '>');
>> + if (!s) break;
>> + s++;
>
> Not sure it's really better than the original solution, but I don't
> have any particularly better suggestion.
> Maybe add a comment though why the "<br", otherwise someone will think
> the> was just forgotten.
Comment added.
>
>> + else if (!strncasecmp (s, "&#", 2)) {
>
> I've never seen uppercase (nor lowercase) versions of&#
Heh, ok.
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sub.txt
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100606/4e30df94/attachment.txt>
More information about the MPlayer-dev-eng
mailing list