]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/libass_mplayer_updates.patch
953752086fbaa962cfc0bb3101cd358dcc59f44a
[vlc] / extras / contrib / src / Patches / libass_mplayer_updates.patch
1 diff -ruN libass/libass/ass.c libass.update/libass/ass.c
2 --- libass/libass/ass.c 2008-05-22 20:01:18.000000000 +0200
3 +++ libass.update/libass/ass.c  2008-08-04 04:10:14.000000000 +0200
4 @@ -846,16 +846,22 @@
5                 char* ip;
6                 char* op;
7                 size_t rc;
8 +                int clear = 0;
9                 
10 -               outbuf = malloc(size);
11 +               outbuf = malloc(osize);
12                 ip = data;
13                 op = outbuf;
14                 
15 -               while (ileft) {
16 +               while (1) {
17 +                        if(ileft)
18                         rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
19 +                        else {// clear the conversion state and leave
20 +                            clear = 1;
21 +                            rc = iconv(icdsc, NULL, NULL, &op, &oleft);
22 +                        }
23                         if (rc == (size_t)(-1)) {
24                                 if (errno == E2BIG) {
25 -                                       int offset = op - outbuf;
26 +                                       size_t offset = op - outbuf;
27                                         outbuf = (char*)realloc(outbuf, osize + size);
28                                         op = outbuf + offset;
29                                         osize += size;
30 @@ -864,7 +870,9 @@
31                                         mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile);
32                                         return NULL;
33                                 }
34 -                       }
35 +                       } else
36 +                            if( clear )
37 +                                break;
38                 }
39                 outbuf[osize - oleft - 1] = 0;
40         }
41 diff -ruN libass/libass/ass_fontconfig.c libass.update/libass/ass_fontconfig.c
42 --- libass/libass/ass_fontconfig.c      2008-05-22 20:01:18.000000000 +0200
43 +++ libass.update/libass/ass_fontconfig.c       2008-08-04 04:14:45.000000000 +0200
44 @@ -129,6 +129,8 @@
45                 goto error;
46  
47         fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
48 +        if(!fset)
49 +            goto error;
50  
51         for (curf = 0; curf < fset->nfont; ++curf) {
52                 FcPattern* curp = fset->fonts[curf];
53 @@ -351,12 +353,15 @@
54         FcPattern* pattern;
55         FcFontSet* fset;
56         FcBool res;
57 +        int face_index, num_faces = 1;
58  
59 -       rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, 0, &face);
60 +       for (face_index = 0; face_index < num_faces; ++face_index) {
61 +        rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, 0, &face);
62         if (rc) {
63                 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, name);
64                 return;
65         }
66 +        num_faces = face->num_faces;
67  
68         pattern = FcFreeTypeQueryFace(face, (unsigned char*)name, 0, FcConfigGetBlanks(priv->config));
69         if (!pattern) {
70 @@ -380,6 +385,7 @@
71         }
72  
73         FT_Done_Face(face);
74 +        }
75  #endif
76  }
77  
78 @@ -419,7 +425,8 @@
79         for (i = 0; i < library->num_fontdata; ++i)
80                 process_fontdata(priv, library, ftlibrary, i);
81  
82 -       if (FcDirCacheValid((const FcChar8 *)dir) == FcFalse)
83 +       if(dir) {
84 +        if (FcDirCacheValid((const FcChar8 *)dir) == FcFalse)
85         {
86                 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_UpdatingFontCache);
87                 if (FcGetVersion() >= 20390 && FcGetVersion() < 20400)
88 @@ -457,6 +464,7 @@
89         if (!rc) {
90                 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcConfigAppFontAddDirFailed);
91         }
92 +        }
93  
94         priv->family_default = family ? strdup(family) : 0;
95         priv->path_default = path ? strdup(path) : 0;
96 diff -ruN libass/libass/ass_render.c libass.update/libass/ass_render.c
97 --- libass/libass/ass_render.c  2008-05-22 20:01:18.000000000 +0200
98 +++ libass.update/libass/ass_render.c   2008-08-04 04:16:01.000000000 +0200
99 @@ -679,11 +679,11 @@
100   * \param pwr multiplier for some tag effects (comes from \t tags)
101   */
102  static char* parse_tag(char* p, double pwr) {
103 -#define skip_all(x) if (*p == (x)) ++p; else { \
104 -       while ((*p != (x)) && (*p != '}') && (*p != 0)) {++p;} }
105 +#define skip_to(x) while ((*p != (x)) && (*p != '}') && (*p != 0)) { ++p;}
106  #define skip(x) if (*p == (x)) ++p; else { return p; }
107         
108 -       skip_all('\\');
109 +       skip_to('\\');
110 +       skip('\\');
111         if ((*p == '}') || (*p == 0))
112                 return p;
113  
114 @@ -787,7 +787,7 @@
115         } else if (mystrcmp(&p, "fn")) {
116                 char* start = p;
117                 char* family;
118 -               skip_all('\\');
119 +               skip_to('\\');
120                 if (p > start) {
121                         family = malloc(p - start + 1);
122                         strncpy(family, start, p - start);
123 @@ -928,7 +928,8 @@
124                 }
125                 while (*p == '\\')
126                         p = parse_tag(p, k); // maybe k*pwr ? no, specs forbid nested \t's 
127 -               skip_all(')'); // FIXME: better skip(')'), but much more tags support required
128 +               skip_to(')'); // in case there is some unknown tag or a comment
129 +               skip(')');
130         } else if (mystrcmp(&p, "clip")) {
131                 int x0, y0, x1, y1;
132                 int res = 1;
133 @@ -1031,7 +1032,7 @@
134         return p;
135  
136  #undef skip
137 -#undef skip_all
138 +#undef skip_to
139  }
140  
141  /**