summaryrefslogtreecommitdiffstats
path: root/meta/packages/xorg-lib/libxfont
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@openedhand.com>2007-07-23 11:59:23 +0000
committerDodji Seketeli <dodji@openedhand.com>2007-07-23 11:59:23 +0000
commit450b758e1746a2a6ef9424c1db7d548e972ee895 (patch)
treee65b370a9583609d9c401c170673b9a4f3eaa1a7 /meta/packages/xorg-lib/libxfont
parent42b4848d6c02a1757ee828ec609a9d388e1a582d (diff)
downloadpoky-450b758e1746a2a6ef9424c1db7d548e972ee895.tar.gz
added builtinreaddirectory-no-side-effect.patch to fix #394
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2208 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/xorg-lib/libxfont')
-rw-r--r--meta/packages/xorg-lib/libxfont/builtinreaddirectory-no-side-effect.patch188
1 files changed, 188 insertions, 0 deletions
diff --git a/meta/packages/xorg-lib/libxfont/builtinreaddirectory-no-side-effect.patch b/meta/packages/xorg-lib/libxfont/builtinreaddirectory-no-side-effect.patch
new file mode 100644
index 0000000000..dd307434b9
--- /dev/null
+++ b/meta/packages/xorg-lib/libxfont/builtinreaddirectory-no-side-effect.patch
@@ -0,0 +1,188 @@
1commit 7670d4a2720c61fbc7b989fed14c676f04ac3ad1
2Author: Dodji Seketeli <dodji@openedhand.com>
3Date: Mon Jul 16 12:24:34 2007 +0200
4
5 Remove side effects from BuiltinReadDirectory()
6
7 The first time BuiltinReadDirectory() is called,
8 save the content of builtin_dir and builtin_alias,
9 before calling FontFileAddFontFile(), because that fonction
10 will modify those.
11
12 Then, in subsequent calls to BuiltinReadDirectory(), restore
13 builtin_dir and builtin_alias so that the side effect incurred
14 by the first call disappears.
15
16diff --git a/src/builtins/dir.c b/src/builtins/dir.c
17index c272449..97f1e1e 100644
18--- a/src/builtins/dir.c
19+++ b/src/builtins/dir.c
20@@ -29,6 +29,133 @@
21 #endif
22 #include "builtin.h"
23
24+BuiltinDirPtr
25+BuiltinDirsDup (const BuiltinDirPtr a_dirs,
26+ int a_dirs_len)
27+{
28+ BuiltinDirPtr dirs=NULL ;
29+ int i=0 ;
30+
31+ if (!a_dirs)
32+ return NULL ;
33+
34+ dirs = xcalloc (a_dirs_len, sizeof (BuiltinDirRec)) ;
35+ if (!dirs)
36+ return NULL ;
37+
38+ for (i=0; i < a_dirs_len; i++) {
39+ int len = strlen (a_dirs[i].file_name) ;
40+ dirs[i].file_name = xcalloc (1, len) ;
41+ memmove (dirs[i].file_name, a_dirs[i].file_name, len);
42+ len = strlen (a_dirs[i].font_name) ;
43+ dirs[i].font_name = xcalloc (1, len) ;
44+ memmove (dirs[i].font_name, a_dirs[i].font_name, len);
45+ }
46+ return dirs ;
47+}
48+
49+/**
50+ * Copy a_save back into a_cur
51+ * @param a_cur the instance of BuiltinDir to restore
52+ * @param a_saved the saved instance of BuiltinDir to copy into a_cur
53+ * @return 0 if went okay, 1 otherwise.
54+ */
55+int
56+BuiltinDirRestore (BuiltinDirPtr a_cur,
57+ const BuiltinDirPtr a_saved)
58+{
59+ if (!a_cur)
60+ return 1 ;
61+ if (!a_saved)
62+ return 0 ;
63+
64+ if (a_saved->font_name)
65+ memmove (a_cur->font_name, a_saved->font_name, strlen (a_saved->font_name)) ;
66+ return 0 ;
67+}
68+
69+
70+int
71+BuiltinDirsRestore (BuiltinDirPtr a_cur_tab,
72+ const BuiltinDirPtr a_saved_tab,
73+ int a_tab_len)
74+{
75+ int i=0 ;
76+
77+ if (!a_cur_tab)
78+ return 1 ;
79+ if (!a_saved_tab)
80+ return 0 ;
81+
82+ for (i=0 ; i < a_tab_len; i++) {
83+ if (BuiltinDirRestore (&a_cur_tab[i], &a_saved_tab[i]))
84+ return 1 ;
85+ }
86+ return 0 ;
87+}
88+
89+BuiltinAliasPtr
90+BuiltinAliasesDup (const BuiltinAliasPtr a_aliases,
91+ int a_aliases_len)
92+{
93+ BuiltinAliasPtr aliases=NULL ;
94+ int i=0 ;
95+
96+ if (!a_aliases)
97+ return NULL ;
98+
99+ aliases = xcalloc (a_aliases_len, sizeof (BuiltinAliasRec)) ;
100+ if (!aliases)
101+ return NULL ;
102+
103+ for (i=0; i < a_aliases_len; i++) {
104+ int len = strlen (a_aliases[i].font_name) ;
105+ aliases[i].font_name = xcalloc (1, len) ;
106+ memmove (aliases[i].font_name, a_aliases[i].font_name, len);
107+ }
108+ return aliases ;
109+}
110+
111+/**
112+ * Copy a_save back into a_cur
113+ * @param a_cur the instance of BuiltinAlias to restore
114+ * @param a_saved the saved instance of BuiltinAlias to copy into a_cur
115+ * @return 0 if went okay, 1 otherwise.
116+ */
117+int
118+BuiltinAliasRestore (BuiltinAliasPtr a_cur,
119+ const BuiltinAliasPtr a_save)
120+{
121+ if (!a_cur)
122+ return 1 ;
123+ if (!a_save)
124+ return 0 ;
125+ if (a_save->alias_name)
126+ memmove (a_cur->alias_name, a_save->alias_name, strlen (a_save->alias_name)) ;
127+ if (a_save->font_name)
128+ memmove (a_cur->font_name, a_save->font_name, strlen (a_save->font_name)) ;
129+ return 0 ;
130+}
131+
132+int
133+BuiltinAliasesRestore (BuiltinAliasPtr a_cur_tab,
134+ const BuiltinAliasPtr a_saved_tab,
135+ int a_tab_len)
136+{
137+ int i=0 ;
138+
139+ if (!a_cur_tab)
140+ return 1 ;
141+ if (!a_saved_tab)
142+ return 0 ;
143+
144+ for (i=0 ; i < a_tab_len; i++) {
145+ if (BuiltinAliasRestore (&a_cur_tab[i], &a_saved_tab[i]))
146+ return 1 ;
147+ }
148+ return 0 ;
149+}
150+
151 int
152 BuiltinReadDirectory (char *directory, FontDirectoryPtr *pdir)
153 {
154@@ -36,6 +163,34 @@ BuiltinReadDirectory (char *directory, FontDirectoryPtr *pdir)
155 int i;
156
157 dir = FontFileMakeDir ("", builtin_dir_count);
158+ static BuiltinDirPtr saved_builtin_dir ;
159+ static BuiltinAliasPtr saved_builtin_alias ;
160+
161+
162+ if (saved_builtin_dir)
163+ {
164+ BuiltinDirsRestore ((BuiltinDirPtr) builtin_dir,
165+ saved_builtin_dir,
166+ builtin_dir_count) ;
167+ }
168+ else
169+ {
170+ saved_builtin_dir = BuiltinDirsDup ((const BuiltinDirPtr) builtin_dir,
171+ builtin_dir_count) ;
172+ }
173+
174+ if (saved_builtin_alias)
175+ {
176+ BuiltinAliasesRestore ((BuiltinAliasPtr) builtin_alias,
177+ saved_builtin_alias,
178+ builtin_alias_count) ;
179+ }
180+ else
181+ {
182+ saved_builtin_alias = BuiltinAliasesDup ((const BuiltinAliasPtr) builtin_alias,
183+ builtin_alias_count) ;
184+ }
185+
186 for (i = 0; i < builtin_dir_count; i++)
187 {
188 if (!FontFileAddFontFile (dir,