• R/O
  • SSH
  • HTTPS

vmaid: Commit


Commit MetaInfo

Revision313 (tree)
Zeit2009-12-08 09:18:34
Autoriwm

Log Message

add g_mapped_file_unref macro

Ändern Zusammenfassung

Diff

--- vmaid/trunk/gcommon.h (revision 312)
+++ vmaid/trunk/gcommon.h (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 gcommon
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -49,6 +49,10 @@
4949 #endif /* not GLIB_CHECK_VERSION(2,14,0) */
5050 typedef gint64 glonglong;
5151 typedef guint64 gulonglong;
52+#if ! GLIB_CHECK_VERSION(2,18,0)
53+typedef glong gintptr;
54+typedef gulong guintptr;
55+#endif /* not GLIB_CHECK_VERSION(2,18,0) */
5256
5357
5458 #ifndef G_GUINT64_CONSTANT
@@ -58,6 +62,9 @@
5862 # define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION(val##ULL))
5963 # endif /* not _MSC_VER */
6064 #endif /* not G_GUINT64_CONSTANT */
65+#ifndef G_GOFFSET_CONSTANT
66+# define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
67+#endif /* not G_GOFFSET_CONSTANT */
6168
6269
6370 #ifndef G_MININT8
@@ -113,6 +120,17 @@
113120 #endif /* not G_IS_DIR_SEPARATOR */
114121
115122
123+#ifndef G_PASTE
124+# define G_PASTE(identifier1,identifier2) G_PASTE_ARGS(identifier1,identifier2)
125+#endif /* not G_PASTE */
126+#ifndef G_PASTE_ARGS
127+# define G_PASTE_ARGS(identifier1,identifier2) identifier1##identifier2
128+#endif /* not G_PASTE_ARGS */
129+#ifndef G_STATIC_ASSERT
130+# define G_STATIC_ASSERT(expr) typedef struct { char Compile_Time_Assertion[(expr) ? 1 : -1]; } G_PASTE (_GStaticAssert_, __LINE__)
131+#endif /* not G_STATIC_ASSERT */
132+
133+
116134 #ifndef G_GNUC_MALLOC
117135 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
118136 # define G_GNUC_MALLOC __attribute__((__malloc__))
@@ -120,6 +138,20 @@
120138 # define G_GNUC_MALLOC
121139 # endif
122140 #endif /* not G_GNUC_MALLOC */
141+#ifndef G_GNUC_ALLOC_SIZE
142+# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
143+# define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
144+# else
145+# define G_GNUC_ALLOC_SIZE(x)
146+# endif
147+#endif /* not G_GNUC_ALLOC_SIZE */
148+#ifndef G_GNUC_ALLOC_SIZE2
149+# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
150+# define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
151+# else
152+# define G_GNUC_ALLOC_SIZE2(x,y)
153+# endif
154+#endif /* not G_GNUC_ALLOC_SIZE2 */
123155 #ifndef G_GNUC_DEPRECATED
124156 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
125157 # define G_GNUC_DEPRECATED __attribute__((__deprecated__))
@@ -141,19 +173,25 @@
141173 # define G_GNUC_WARN_UNUSED_RESULT
142174 # endif
143175 #endif /* not G_GNUC_WARN_UNUSED_RESULT */
144-
145-
146-#ifndef G_STRFUNC
147-# if defined (__GNUC__)
148-# define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__))
149-# elif defined (G_HAVE_ISO_VARARGS)
150-# define G_STRFUNC ((const char*) (__func__))
176+#ifndef G_GNUC_INTERNAL
177+# if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
178+# define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
179+# elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
180+# define G_GNUC_INTERNAL __hidden
181+# elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
182+# define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
151183 # else
152-# define G_STRFUNC ((const char*) ("???"))
184+# define G_GNUC_INTERNAL
185+# endif
186+#endif /* not G_GNUC_INTERNAL */
187+#ifndef G_GNUC_MAY_ALIAS
188+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
189+# define G_GNUC_MAY_ALIAS __attribute__((may_alias))
190+# else
191+# define G_GNUC_MAY_ALIAS
153192 # endif
154-#endif /* not G_STRFUNC */
193+#endif /* not G_GNUC_MAY_ALIAS */
155194
156-
157195 #if ! defined (G_LIKELY) || ! defined (G_UNLIKELY)
158196 # if defined (__GNUC__) && __GNUC__ > 2 && defined (__OPTIMIZE__)
159197 # define _G_BOOLEAN_EXPR(expr) \
@@ -182,6 +220,17 @@
182220 #endif /* ! defined (G_LIKELY) || ! defined (G_UNLIKELY) */
183221
184222
223+#ifndef G_STRFUNC
224+# if defined (__GNUC__)
225+# define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__))
226+# elif defined (G_HAVE_ISO_VARARGS)
227+# define G_STRFUNC ((const char*) (__func__))
228+# else
229+# define G_STRFUNC ((const char*) ("???"))
230+# endif
231+#endif /* not G_STRFUNC */
232+
233+
185234 #ifndef G_GINT16_MODIFIER
186235 # define G_GINT16_MODIFIER "h"
187236 #endif /* not G_GINT16_MODIFIER */
@@ -194,9 +243,6 @@
194243 #ifndef G_GSIZE_MODIFIER
195244 # define G_GSIZE_MODIFIER ""
196245 #endif /* not G_GSIZE_MODIFIER */
197-#ifndef G_GSSIZE_MODIFIER
198-# define G_GSSIZE_MODIFIER ""
199-#endif /* not G_GSSIZE_MODIFIER */
200246 #ifndef G_GSIZE_FORMAT
201247 # define G_GSIZE_FORMAT "u"
202248 #endif /* not G_GSIZE_FORMAT */
@@ -203,6 +249,21 @@
203249 #ifndef G_GSSIZE_FORMAT
204250 # define G_GSSIZE_FORMAT "i"
205251 #endif /* not G_GSSIZE_FORMAT */
252+#ifndef G_GOFFSET_MODIFIER
253+# define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
254+#endif /* not G_GOFFSET_MODIFIER */
255+#ifndef G_GOFFSET_FORMAT
256+# define G_GOFFSET_FORMAT G_GINT64_FORMAT
257+#endif /* not G_GOFFSET_FORMAT */
258+#ifndef G_GINTPTR_MODIFIER
259+# define G_GINTPTR_MODIFIER "l"
260+#endif /* not G_GINTPTR_MODIFIER */
261+#ifndef G_GINTPTR_FORMAT
262+# define G_GINTPTR_FORMAT "li"
263+#endif /* not G_GINTPTR_FORMAT */
264+#ifndef G_GUINTPTR_FORMAT
265+# define G_GUINTPTR_FORMAT "lu"
266+#endif /* not G_GUINTPTR_FORMAT */
206267
207268
208269 #define g_strcpy(dest,src) g_strlcpy(dest,src,G_MAXSIZE)
@@ -241,12 +302,15 @@
241302 #if ! GLIB_CHECK_VERSION(2,12,0)
242303 # define g_ascii_strtoll strtol
243304 #endif /* not GLIB_CHECK_VERSION(2,12,0) */
305+#if ! GLIB_CHECK_VERSION(2,22,0)
306+# define g_mapped_file_unref g_mapped_file_free
307+#endif /* not GLIB_CHECK_VERSION(2,22,0) */
244308 #ifdef G_OS_WIN32
245-# define g_strfilecmp(s1,s2) g_ascii_strcasecmp(s1,s2)
246-# define g_strfilencmp(s1,s2,n) g_ascii_strncasecmp(s1,s2,n)
309+# define g_strfilecmp g_ascii_strcasecmp
310+# define g_strfilencmp g_ascii_strncasecmp
247311 #else /* not G_OS_WIN32 */
248-# define g_strfilecmp(s1,s2) g_strcmp(s1,s2)
249-# define g_strfilencmp(s1,s2,n) g_strncmp(s1,s2,n)
312+# define g_strfilecmp g_strcmp
313+# define g_strfilencmp g_strncmp
250314 #endif /* not G_OS_WIN32 */
251315
252316
--- vmaid/trunk/src/codec.c (revision 312)
+++ vmaid/trunk/src/codec.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 Video maid
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -152,62 +152,55 @@
152152 4, NULL,
153153 -1);
154154 glist = icm_get_handler_list ();
155- if (glist)
155+ for (glist = g_list_first (glist);
156+ glist; glist = g_list_delete_link (glist, glist))
156157 {
157- gint length;
158+ IcmObject *icm_object;
158159
159- length = g_list_length (glist);
160- for (i = 0; i < length; i++)
160+ icm_object = icm_open (GPOINTER_TO_UINT (glist->data), ICM_MODE_QUERY);
161+ if (icm_object)
161162 {
162- IcmObject *icm_object;
163+ gchar *handler;
164+ const gchar *name, *attribute;
163165
164- icm_object = icm_open (GPOINTER_TO_UINT (g_list_nth_data (glist, i)),
165- ICM_MODE_QUERY);
166- if (icm_object)
166+ name = icm_get_name (icm_object);
167+ handler = icm_handler_to_string (icm_get_handler (icm_object));
168+ switch (icm_get_attribute (icm_object))
167169 {
168- gchar *handler;
169- const gchar *name, *attribute;
170-
171- name = icm_get_name (icm_object);
172- handler = icm_handler_to_string (icm_get_handler (icm_object));
173- switch (icm_get_attribute (icm_object))
174- {
175- case ICM_ATTR_NATIVE:
176- attribute = _("Video maid Native");
177- break;
178- case ICM_ATTR_WIN32:
170+ case ICM_ATTR_NATIVE:
171+ attribute = _("Video maid Native");
172+ break;
173+ case ICM_ATTR_WIN32:
179174 #ifdef G_OS_WIN32
180- attribute = _("Win32 Native");
175+ attribute = _("Win32 Native");
181176 #else /* not G_OS_WIN32 */
182- attribute = _("Win32 Emulation");
177+ attribute = _("Win32 Emulation");
183178 #endif /* not G_OS_WIN32 */
184- break;
185- default:
186- attribute = _("Unknown");
187- }
188- if (name && handler)
189- {
190- GtkTreeIter iter;
179+ break;
180+ default:
181+ attribute = _("Unknown");
182+ }
183+ if (name && handler)
184+ {
185+ GtkTreeIter iter;
191186
192- gtk_tree_store_append (store, &iter, &iter_parent);
193- gtk_tree_store_set (store, &iter, 0, name,
187+ gtk_tree_store_append (store, &iter, &iter_parent);
188+ gtk_tree_store_set (store, &iter, 0, name,
194189 1, handler,
195190 2, attribute,
196191 3, NULL,
197192 4, NULL,
198193 -1);
199- if (icm_is_dialog_preference (icm_object))
200- {
201- gtk_tree_store_set (store, &iter, 3, icm_object, -1);
202- icm_object = NULL;
203- }
194+ if (icm_is_dialog_preference (icm_object))
195+ {
196+ gtk_tree_store_set (store, &iter, 3, icm_object, -1);
197+ icm_object = NULL;
204198 }
205- g_free (handler);
206- if (icm_object)
207- icm_close (icm_object);
208199 }
200+ g_free (handler);
201+ if (icm_object)
202+ icm_close (icm_object);
209203 }
210- g_list_free (glist);
211204 }
212205 gtk_tree_store_append (store, &iter_parent, NULL);
213206 gtk_tree_store_set (store, &iter_parent, 0, _("Audio Compressor"),
@@ -217,62 +210,55 @@
217210 4, NULL,
218211 -1);
219212 glist = acm_get_tag_list ();
220- if (glist)
213+ for (glist = g_list_first (glist);
214+ glist; glist = g_list_delete_link (glist, glist))
221215 {
222- gint length;
216+ AcmObject *acm_object;
223217
224- length = g_list_length (glist);
225- for (i = 0; i < length; i++)
218+ acm_object = acm_open ((guint16)GPOINTER_TO_UINT (glist->data));
219+ if (acm_object)
226220 {
227- AcmObject *acm_object;
221+ gchar *handler;
222+ const gchar *name, *attribute;
228223
229- acm_object = acm_open
230- ((guint16)GPOINTER_TO_UINT (g_list_nth_data (glist, i)));
231- if (acm_object)
224+ name = acm_get_name (acm_object);
225+ handler = g_strdup_printf ("%04X", acm_get_tag (acm_object));
226+ switch (acm_get_attribute (acm_object))
232227 {
233- gchar *handler;
234- const gchar *name, *attribute;
235-
236- name = acm_get_name (acm_object);
237- handler = g_strdup_printf ("%04X", acm_get_tag (acm_object));
238- switch (acm_get_attribute (acm_object))
239- {
240- case ACM_ATTR_NATIVE:
241- attribute = _("Video maid Native");
242- break;
243- case ACM_ATTR_WIN32:
228+ case ACM_ATTR_NATIVE:
229+ attribute = _("Video maid Native");
230+ break;
231+ case ACM_ATTR_WIN32:
244232 #ifdef G_OS_WIN32
245- attribute = _("Win32 Native");
233+ attribute = _("Win32 Native");
246234 #else /* not G_OS_WIN32 */
247- attribute = _("Win32 Emulation");
235+ attribute = _("Win32 Emulation");
248236 #endif /* not G_OS_WIN32 */
249- break;
250- default:
251- attribute = _("Unknown");
252- }
253- if (name && handler)
254- {
255- GtkTreeIter iter;
237+ break;
238+ default:
239+ attribute = _("Unknown");
240+ }
241+ if (name && handler)
242+ {
243+ GtkTreeIter iter;
256244
257- gtk_tree_store_append (store, &iter, &iter_parent);
258- gtk_tree_store_set (store, &iter, 0, name,
245+ gtk_tree_store_append (store, &iter, &iter_parent);
246+ gtk_tree_store_set (store, &iter, 0, name,
259247 1, handler,
260248 2, attribute,
261249 3, NULL,
262250 4, NULL,
263251 -1);
264- if (acm_is_dialog_preference (acm_object))
265- {
266- gtk_tree_store_set (store, &iter, 4, acm_object, -1);
267- acm_object = NULL;
268- }
252+ if (acm_is_dialog_preference (acm_object))
253+ {
254+ gtk_tree_store_set (store, &iter, 4, acm_object, -1);
255+ acm_object = NULL;
269256 }
270- g_free (handler);
271- if (acm_object)
272- acm_close (acm_object);
273257 }
258+ g_free (handler);
259+ if (acm_object)
260+ acm_close (acm_object);
274261 }
275- g_list_free (glist);
276262 }
277263 tview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
278264 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tview), FALSE);
--- vmaid/trunk/src/thread.c (revision 312)
+++ vmaid/trunk/src/thread.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 Video maid
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -132,7 +132,6 @@
132132 #endif /* not USE_THREAD */
133133 thread_idle (gpointer data)
134134 {
135- guint length;
136135 GList *glist;
137136
138137 #ifdef USE_THREAD
@@ -139,8 +138,11 @@
139138 G_LOCK (critical);
140139 critical = TRUE;
141140 gdk_threads_enter ();
142-#endif /* USE_THREAD */
141+#else /* not USE_THREAD */
142+ guint length;
143+
143144 length = g_list_length (glist_thread);
145+#endif /* not USE_THREAD */
144146 /* ja:中断された終了を探す */
145147 for (glist = g_list_first (glist_thread); glist; glist = g_list_next (glist))
146148 {
--- vmaid/trunk/src/version.c (revision 312)
+++ vmaid/trunk/src/version.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 Video maid
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -224,62 +224,55 @@
224224 4, NULL,
225225 -1);
226226 glist = icm_get_handler_list ();
227- if (glist)
227+ for (glist = g_list_first (glist);
228+ glist; glist = g_list_delete_link (glist, glist))
228229 {
229- gint length;
230+ IcmObject *icm_object;
230231
231- length = g_list_length (glist);
232- for (i = 0; i < length; i++)
232+ icm_object = icm_open (GPOINTER_TO_UINT (glist->data), ICM_MODE_QUERY);
233+ if (icm_object)
233234 {
234- IcmObject *icm_object;
235+ gchar *handler;
236+ const gchar *name, *attribute;
235237
236- icm_object = icm_open (GPOINTER_TO_UINT (g_list_nth_data (glist, i)),
237- ICM_MODE_QUERY);
238- if (icm_object)
238+ name = icm_get_name (icm_object);
239+ handler = icm_handler_to_string (icm_get_handler (icm_object));
240+ switch (icm_get_attribute (icm_object))
239241 {
240- gchar *handler;
241- const gchar *name, *attribute;
242-
243- name = icm_get_name (icm_object);
244- handler = icm_handler_to_string (icm_get_handler (icm_object));
245- switch (icm_get_attribute (icm_object))
246- {
247- case ICM_ATTR_NATIVE:
248- attribute = _("Video maid Native");
249- break;
250- case ICM_ATTR_WIN32:
242+ case ICM_ATTR_NATIVE:
243+ attribute = _("Video maid Native");
244+ break;
245+ case ICM_ATTR_WIN32:
251246 #ifdef G_OS_WIN32
252- attribute = _("Win32 Native");
247+ attribute = _("Win32 Native");
253248 #else /* not G_OS_WIN32 */
254- attribute = _("Win32 Emulation");
249+ attribute = _("Win32 Emulation");
255250 #endif /* not G_OS_WIN32 */
256- break;
257- default:
258- attribute = _("Unknown");
259- }
260- if (name && handler)
261- {
262- GtkTreeIter iter;
251+ break;
252+ default:
253+ attribute = _("Unknown");
254+ }
255+ if (name && handler)
256+ {
257+ GtkTreeIter iter;
263258
264- gtk_tree_store_append (store, &iter, &iter_parent);
265- gtk_tree_store_set (store, &iter, 0, name,
259+ gtk_tree_store_append (store, &iter, &iter_parent);
260+ gtk_tree_store_set (store, &iter, 0, name,
266261 1, handler,
267262 2, attribute,
268263 3, NULL,
269264 4, NULL,
270265 -1);
271- if (icm_is_dialog_about (icm_object))
272- {
273- gtk_tree_store_set (store, &iter, 3, icm_object, -1);
274- icm_object = NULL;
275- }
266+ if (icm_is_dialog_about (icm_object))
267+ {
268+ gtk_tree_store_set (store, &iter, 3, icm_object, -1);
269+ icm_object = NULL;
276270 }
277- g_free (handler);
278- if (icm_object)
279- icm_close (icm_object);
280271 }
272+ g_free (handler);
273+ if (icm_object)
274+ icm_close (icm_object);
281275 }
282- g_list_free (glist);
283276 }
284277 gtk_tree_store_append (store, &iter_parent, NULL);
285278 gtk_tree_store_set (store, &iter_parent, 0, _("Audio Compressor"),
@@ -289,62 +282,55 @@
289282 4, NULL,
290283 -1);
291284 glist = acm_get_tag_list ();
292- if (glist)
285+ for (glist = g_list_first (glist);
286+ glist; glist = g_list_delete_link (glist, glist))
293287 {
294- gint length;
288+ AcmObject *acm_object;
295289
296- length = g_list_length (glist);
297- for (i = 0; i < length; i++)
290+ acm_object = acm_open ((guint16)GPOINTER_TO_UINT (glist->data));
291+ if (acm_object)
298292 {
299- AcmObject *acm_object;
293+ gchar *handler;
294+ const gchar *name, *attribute;
300295
301- acm_object = acm_open
302- ((guint16)GPOINTER_TO_UINT (g_list_nth_data (glist, i)));
303- if (acm_object)
296+ name = acm_get_name (acm_object);
297+ handler = g_strdup_printf ("%04X", acm_get_tag (acm_object));
298+ switch (acm_get_attribute (acm_object))
304299 {
305- gchar *handler;
306- const gchar *name, *attribute;
307-
308- name = acm_get_name (acm_object);
309- handler = g_strdup_printf ("%04X", acm_get_tag (acm_object));
310- switch (acm_get_attribute (acm_object))
311- {
312- case ACM_ATTR_NATIVE:
313- attribute = _("Video maid Native");
314- break;
315- case ACM_ATTR_WIN32:
300+ case ACM_ATTR_NATIVE:
301+ attribute = _("Video maid Native");
302+ break;
303+ case ACM_ATTR_WIN32:
316304 #ifdef G_OS_WIN32
317- attribute = _("Win32 Native");
305+ attribute = _("Win32 Native");
318306 #else /* not G_OS_WIN32 */
319- attribute = _("Win32 Emulation");
307+ attribute = _("Win32 Emulation");
320308 #endif /* not G_OS_WIN32 */
321- break;
322- default:
323- attribute = _("Unknown");
324- }
325- if (name && handler)
326- {
327- GtkTreeIter iter;
309+ break;
310+ default:
311+ attribute = _("Unknown");
312+ }
313+ if (name && handler)
314+ {
315+ GtkTreeIter iter;
328316
329- gtk_tree_store_append (store, &iter, &iter_parent);
330- gtk_tree_store_set (store, &iter, 0, name,
317+ gtk_tree_store_append (store, &iter, &iter_parent);
318+ gtk_tree_store_set (store, &iter, 0, name,
331319 1, handler,
332320 2, attribute,
333321 3, NULL,
334322 4, NULL,
335323 -1);
336- if (acm_is_dialog_about (acm_object))
337- {
338- gtk_tree_store_set (store, &iter, 4, acm_object, -1);
339- acm_object = NULL;
340- }
324+ if (acm_is_dialog_about (acm_object))
325+ {
326+ gtk_tree_store_set (store, &iter, 4, acm_object, -1);
327+ acm_object = NULL;
341328 }
342- g_free (handler);
343- if (acm_object)
344- acm_close (acm_object);
345329 }
330+ g_free (handler);
331+ if (acm_object)
332+ acm_close (acm_object);
346333 }
347- g_list_free (glist);
348334 }
349335 tview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
350336 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tview), FALSE);
--- vmaid/trunk/ChangeLog (revision 312)
+++ vmaid/trunk/ChangeLog (revision 313)
@@ -1,3 +1,32 @@
1+2009-12-29 Kazuki IWAMOTO <iwm@maid.org>
2+
3+ * version 2.2.2
4+
5+2009-12-10 Kazuki IWAMOTO <iwm@maid.org>
6+
7+ * gcommon.h: add g_mapped_file_unref macro
8+
9+ * w32loader/image.h
10+ * w32loader/w32ldr.c: add IMAGE_DOS_HEADER
11+
12+ * avicore/aviextra.c
13+ * avicore/avimemory.c
14+ * misc/fileio.c
15+ * orz/orzaccel.c
16+ * orz/orzcomm.c
17+ * orz/orzhistory.c
18+ * orz/orzmdi.c
19+ * orz/orzwinmenu.c
20+ * src/codec.c
21+ * src/thread.c
22+ * src/version.c
23+ * w32loader/advapi32.c
24+ * w32loader/kernel32.c
25+ * w32loader/msvcrt.[ch]
26+ * w32loader/user32.c
27+ * w32loader/w32ldr.[ch]
28+ * w32loader/w32tool.c: modify GList enumeration
29+
130 2009-11-29 Kazuki IWAMOTO <iwm@maid.org>
231
332 * version 2.2.1
--- vmaid/trunk/avicore/avimemory.c (revision 312)
+++ vmaid/trunk/avicore/avimemory.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 avicore
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "avibase.h"
2019
@@ -47,41 +46,39 @@
4746 avi_memory_register (gpointer data,
4847 const gsize length)
4948 {
50- gint i;
5149 AviMemory *avi_memory = NULL;
5250
53- if (!data || length <= 0)
54- return NULL;
51+ if (data && length > 0)
52+ {
53+ GList *glist;
54+
5555 # ifdef USE_THREAD
56- G_LOCK (critical);
57- critical = TRUE;
56+ G_LOCK (critical);
57+ critical = TRUE;
5858 # endif /* USE_THREAD */
59- for (i = g_list_length (glist_memory) - 1; i >= 0; i--)
60- {
61- AviMemory *avi_mem;
62-
63- avi_mem = g_list_nth_data (glist_memory, i);
64- if (avi_mem->length == length
65- && g_memcmp (avi_mem->data, data, length) == 0)
59+ for (glist = g_list_first (glist_memory);
60+ glist; glist = g_list_next (glist))
61+ if (((AviMemory *)glist->data)->length == length
62+ && g_memcmp (((AviMemory *)glist->data)->data, data, length) == 0)
63+ {
64+ g_free (data);
65+ avi_memory = glist->data;
66+ avi_memory->counter++;
67+ break;
68+ }
69+ if (!avi_memory)
6670 {
67- g_free (data);
68- avi_memory = avi_mem;
69- avi_memory->counter++;
70- break;
71+ avi_memory = g_malloc (sizeof (AviMemory));
72+ avi_memory->counter = 1;
73+ avi_memory->length = length;
74+ avi_memory->data = data;
75+ glist_memory = g_list_append (glist_memory, avi_memory);
7176 }
72- }
73- if (!avi_memory)
74- {
75- avi_memory = g_malloc (length);
76- avi_memory->counter = 1;
77- avi_memory->length = length;
78- avi_memory->data = data;
79- glist_memory = g_list_append (glist_memory, avi_memory);
80- }
8177 # ifdef USE_THREAD
82- critical = FALSE;
83- G_UNLOCK (critical);
78+ critical = FALSE;
79+ G_UNLOCK (critical);
8480 # endif /* USE_THREAD */
81+ }
8582 return avi_memory;
8683 }
8784
@@ -94,40 +91,38 @@
9491 avi_memory_alloc (gconstpointer data,
9592 const gsize length)
9693 {
97- gint i;
9894 AviMemory *avi_memory = NULL;
9995
100- if (!data || length <= 0)
101- return NULL;
96+ if (data && length > 0)
97+ {
98+ GList *glist;
99+
102100 # ifdef USE_THREAD
103- G_LOCK (critical);
104- critical = TRUE;
101+ G_LOCK (critical);
102+ critical = TRUE;
105103 # endif /* USE_THREAD */
106- for (i = g_list_length (glist_memory) - 1; i >= 0; i--)
107- {
108- AviMemory *avi_mem;
109-
110- avi_mem = g_list_nth_data (glist_memory, i);
111- if (avi_mem->length == length
112- && g_memcmp (avi_mem->data, data, length) == 0)
104+ for (glist = g_list_first (glist_memory);
105+ glist; glist = g_list_next (glist))
106+ if (((AviMemory *)glist->data)->length == length
107+ && g_memcmp (((AviMemory *)glist->data)->data, data, length) == 0)
108+ {
109+ avi_memory = glist->data;
110+ avi_memory->counter++;
111+ break;
112+ }
113+ if (!avi_memory)
113114 {
114- avi_memory = avi_mem;
115- avi_memory->counter++;
116- break;
115+ avi_memory = g_malloc (sizeof (AviMemory));
116+ avi_memory->counter = 1;
117+ avi_memory->length = length;
118+ avi_memory->data = g_memdup (data, length);
119+ glist_memory = g_list_append (glist_memory, avi_memory);
117120 }
118- }
119- if (!avi_memory)
120- {
121- avi_memory = g_malloc (length);
122- avi_memory->counter = 1;
123- avi_memory->length = length;
124- avi_memory->data = g_memdup (data, length);
125- glist_memory = g_list_append (glist_memory, avi_memory);
126- }
127121 # ifdef USE_THREAD
128- critical = FALSE;
129- G_UNLOCK (critical);
122+ critical = FALSE;
123+ G_UNLOCK (critical);
130124 # endif /* USE_THREAD */
125+ }
131126 return avi_memory;
132127 }
133128
--- vmaid/trunk/avicore/aviextra.c (revision 312)
+++ vmaid/trunk/avicore/aviextra.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 avicore
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -160,14 +160,12 @@
160160 gtk_widget_set_sensitive (GTK_WIDGET (extra->notebook), TRUE);
161161 if (GTK_IS_NOTEBOOK (extra->notebook))
162162 {
163- gint i;
164163 GList *glist;
165164
166165 glist = gtk_container_get_children (GTK_CONTAINER (extra->notebook));
167- for (i = g_list_length (glist) - 1; i >= 0; i--)
168- gtk_widget_set_sensitive (GTK_WIDGET (g_list_nth_data (glist, i)),
169- TRUE);
170- g_list_free (glist);
166+ for (glist = g_list_first (glist);
167+ glist; glist = g_list_delete_link (glist, glist))
168+ gtk_widget_set_sensitive (GTK_WIDGET (glist->data), TRUE);
171169 }
172170 }
173171
@@ -186,15 +184,13 @@
186184 #endif /* GTK_CHECK_VERSION(2,2,0) */
187185 if (extra->video > 1)
188186 {
189- gint i;
190187 GList *glist;
191188
192189 gtk_widget_set_sensitive (GTK_WIDGET (extra->notebook), TRUE);
193190 glist = gtk_container_get_children (GTK_CONTAINER (extra->notebook));
194- for (i = g_list_length (glist) - 1; i >= 0; i--)
195- gtk_widget_set_sensitive (GTK_WIDGET (g_list_nth_data (glist, i)),
196- FALSE);
197- g_list_free (glist);
191+ for (glist = g_list_first (glist);
192+ glist; glist = g_list_delete_link (glist, glist))
193+ gtk_widget_set_sensitive (GTK_WIDGET (glist->data), FALSE);
198194 }
199195 else
200196 {
@@ -219,15 +215,13 @@
219215 gtk_widget_set_sensitive (GTK_WIDGET (extra->hbox_png), TRUE);
220216 if (extra->video > 1)
221217 {
222- gint i;
223218 GList *glist;
224219
225220 gtk_widget_set_sensitive (GTK_WIDGET (extra->notebook), TRUE);
226221 glist = gtk_container_get_children (GTK_CONTAINER (extra->notebook));
227- for (i = g_list_length (glist) - 1; i >= 0; i--)
228- gtk_widget_set_sensitive (GTK_WIDGET (g_list_nth_data (glist, i)),
229- FALSE);
230- g_list_free (glist);
222+ for (glist = g_list_first (glist);
223+ glist; glist = g_list_delete_link (glist, glist))
224+ gtk_widget_set_sensitive (GTK_WIDGET (glist->data), FALSE);
231225 }
232226 else
233227 {
@@ -247,21 +241,20 @@
247241 gtk_widget_set_sensitive (GTK_WIDGET (extra->notebook), TRUE);
248242 if (GTK_IS_NOTEBOOK (extra->notebook))
249243 {
250- gint i;
251244 GList *glist;
252245
253246 glist = gtk_container_get_children (GTK_CONTAINER (extra->notebook));
254- for (i = g_list_length (glist) - 1; i >= 0; i--)
247+ for (glist = g_list_first (glist);
248+ glist; glist = g_list_delete_link (glist, glist))
255249 {
256250 GtkWidget *child;
257251 AviExtraStream *avi_stream;
258252
259- child = g_list_nth_data (glist, i);
253+ child = glist->data;
260254 avi_stream = g_object_get_data (G_OBJECT (child), "user_data");
261255 gtk_widget_set_sensitive (GTK_WIDGET (child),
262256 avi_edit_type (avi_stream->avi_edit) == AVI_TYPE_AUDIO);
263257 }
264- g_list_free (glist);
265258 }
266259 else
267260 {
@@ -320,7 +313,6 @@
320313 GtkTreeIter iter;
321314 #else /* not GTK_CHECK_VERSION(2,4,0) */
322315 const gchar *text;
323- gint i;
324316 GList *glist;
325317 #endif /* not GTK_CHECK_VERSION(2,4,0) */
326318 IcmObject *icm_object = NULL;
@@ -334,19 +326,14 @@
334326 text = gtk_entry_get_text (GTK_ENTRY (widget));
335327 glist = gtk_container_get_children
336328 (GTK_CONTAINER (GTK_COMBO (avi_stream->combo)->list));
337- for (i = g_list_length (glist) - 1; i >= 0; i--)
338- {
339- const gchar *label;
340-
341- label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
342- (GTK_BIN (g_list_nth_data (glist, i)))));
343- if (g_strcmp (label, text) == 0)
344- {
345- icm_object = g_object_get_data
346- (G_OBJECT (g_list_nth_data (glist, i)), "user_data");
347- break;
348- }
349- }
329+ for (glist = g_list_first (glist);
330+ glist; glist = g_list_delete_link (glist, glist))
331+ if (g_strcmp (gtk_label_get_text
332+ (GTK_LABEL (gtk_bin_get_child (GTK_BIN (glist->data)))), text) == 0)
333+ {
334+ icm_object = g_object_get_data (G_OBJECT (glist->data), "user_data");
335+ break;
336+ }
350337 g_list_free (glist);
351338 #endif /* not GTK_CHECK_VERSION(2,4,0) */
352339 g_object_set_data (G_OBJECT (avi_stream->combo), "user_data", icm_object);
@@ -418,7 +405,6 @@
418405 GtkTreeIter iter;
419406 #else /* not GTK_CHECK_VERSION(2,4,0) */
420407 const gchar *text;
421- gint i;
422408 GList *glist;
423409 #endif /* not GTK_CHECK_VERSION(2,4,0) */
424410 WaveFormatEx *wfx = NULL;
@@ -432,19 +418,14 @@
432418 text = gtk_entry_get_text (GTK_ENTRY (widget));
433419 glist = gtk_container_get_children
434420 (GTK_CONTAINER (GTK_COMBO (avi_stream->combo)->list));
435- for (i = g_list_length (glist) - 1; i >= 0; i--)
436- {
437- const gchar *label;
438-
439- label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
440- (GTK_BIN (g_list_nth_data (glist, i)))));
441- if (g_strcmp (label, text) == 0)
442- {
443- wfx = g_object_get_data
444- (G_OBJECT (g_list_nth_data (glist, i)), "user_data");
445- break;
446- }
447- }
421+ for (glist = g_list_first (glist);
422+ glist; glist = g_list_delete_link (glist, glist))
423+ if (g_strcmp (gtk_label_get_text
424+ (GTK_LABEL (gtk_bin_get_child (GTK_BIN (glist->data)))), text) == 0)
425+ {
426+ wfx = g_object_get_data (G_OBJECT (glist->data), "user_data");
427+ break;
428+ }
448429 g_list_free (glist);
449430 #endif /* not GTK_CHECK_VERSION(2,4,0) */
450431 g_object_set_data (G_OBJECT (avi_stream->combo), "user_data", wfx);
@@ -512,14 +493,12 @@
512493 avi_extra_destroy_list_video (GtkWidget *widget,
513494 gpointer user_data)
514495 {
515- gint i;
516496 GList *glist;
517497
518498 glist = gtk_container_get_children (GTK_CONTAINER (widget));
519- for (i = g_list_length (glist) - 1; i >= 0; i--)
520- icm_close (g_object_get_data (G_OBJECT (g_list_nth_data (glist, i)),
521- "user_data"));
522- g_list_free (glist);
499+ for (glist = g_list_first (glist);
500+ glist; glist = g_list_delete_link (glist, glist))
501+ icm_close (g_object_get_data (G_OBJECT (glist->data), "user_data"));
523502 }
524503
525504
@@ -528,14 +507,12 @@
528507 avi_extra_destroy_list_audio (GtkWidget *widget,
529508 gpointer user_data)
530509 {
531- gint i;
532510 GList *glist;
533511
534512 glist = gtk_container_get_children (GTK_CONTAINER (widget));
535- for (i = g_list_length (glist) - 1; i >= 0; i--)
536- g_free (g_object_get_data (G_OBJECT (g_list_nth_data (glist, i)),
537- "user_data"));
538- g_list_free (glist);
513+ for (glist = g_list_first (glist);
514+ glist; glist = g_list_delete_link (glist, glist))
515+ g_free (g_object_get_data (G_OBJECT (glist->data), "user_data"));
539516 }
540517 #endif /* not GTK_CHECK_VERSION(2,4,0) */
541518
@@ -553,7 +530,6 @@
553530 GtkTreeIter iter;
554531 # else /* not GTK_CHECK_VERSION(2,4,0) */
555532 const gchar *text;
556- gint i;
557533 GList *glist;
558534 # endif /* not GTK_CHECK_VERSION(2,4,0) */
559535 GdkPixbufFormat *format = NULL;
@@ -567,19 +543,14 @@
567543 text = gtk_entry_get_text (GTK_ENTRY (widget));
568544 glist = gtk_container_get_children
569545 (GTK_CONTAINER (GTK_COMBO (extra->combo)->list));
570- for (i = g_list_length (glist) - 1; i >= 0; i--)
571- {
572- const gchar *label;
573-
574- label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
575- (GTK_BIN (g_list_nth_data (glist, i)))));
576- if (g_strcmp (label, text) == 0)
577- {
578- format = g_object_get_data
579- (G_OBJECT (g_list_nth_data (glist, i)), "user_data");
580- break;
581- }
582- }
546+ for (glist = g_list_first (glist);
547+ glist; glist = g_list_delete_link (glist, glist))
548+ if (g_strcmp (gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
549+ (GTK_BIN (glist->data)))), text) == 0)
550+ {
551+ format = g_object_get_data (G_OBJECT (glist->data), "user_data");
552+ break;
553+ }
583554 g_list_free (glist);
584555 # endif /* not GTK_CHECK_VERSION(2,4,0) */
585556 vbox = gtk_widget_get_parent (gtk_widget_get_parent (extra->combo));
@@ -699,13 +670,9 @@
699670 if (!extra)
700671 return;
701672 glist = gtk_container_get_children (GTK_CONTAINER (extra));
702- if (glist)
703- {
704- for (i = g_list_length (glist) - 1; i >= 0; i--)
705- gtk_container_remove (GTK_CONTAINER (extra),
706- GTK_WIDGET (g_list_nth_data (glist, i)));
707- g_list_free (glist);
708- }
673+ for (glist = g_list_first (glist);
674+ glist; glist = g_list_delete_link (glist, glist))
675+ gtk_container_remove (GTK_CONTAINER (extra), GTK_WIDGET (glist->data));
709676 #if GTK_CHECK_VERSION(2,2,0)
710677 if (extra->hbox_ico)
711678 gtk_widget_destroy (extra->hbox_ico);
@@ -797,7 +764,6 @@
797764 G_CALLBACK (avi_extra_destroy_vbox), avi_stream);
798765 if (avi_edit_type (avi_edit[i]) == AVI_TYPE_VIDEO)
799766 { /* ja:ビデオストリーム */
800- gint j;
801767 GList *glist_object; /* ja:IcmObjectのリスト */
802768 GList *glist_name; /* ja:名前のリスト */
803769
@@ -810,13 +776,13 @@
810776 glist_object = g_list_append (NULL, NULL);
811777 glist_name = g_list_append (NULL, _("Uncompress"));
812778 /* ja:各4文字コードについて */
813- for (j = 0; j < leng_handler; j++)
779+ for (glist = g_list_first (glist_handler);
780+ glist; glist = g_list_next (glist))
814781 {
815782 IcmObject *icm_object;
816783
817784 icm_object = icm_open
818- (GPOINTER_TO_UINT (g_list_nth_data (glist_handler, j)),
819- ICM_MODE_COMPRESS);
785+ (GPOINTER_TO_UINT (glist->data), ICM_MODE_COMPRESS);
820786 if (!icm_object)
821787 continue;
822788 if (!icm_compress_query (icm_object, avi_edit[i]->bmih))
@@ -850,6 +816,7 @@
850816 }
851817 if (g_list_length (glist_name) > 1)
852818 {
819+ gint j;
853820 #if GTK_CHECK_VERSION(2,4,0)
854821 GtkListStore *store;
855822 GtkCellRenderer *renderer;
@@ -1027,7 +994,6 @@
1027994 }
1028995 else
1029996 { /* ja:オーディオストリーム */
1030- gint j;
1031997 GList *glist_wfx; /* ja:WaveFormatEx構造体のリスト */
1032998 GList *glist_name; /* ja:名前のリスト */
1033999 #if GTK_CHECK_VERSION(2,4,0)
@@ -1045,7 +1011,8 @@
10451011 glist_name = g_list_append (NULL, g_strdup (_("PCM")));
10461012 #endif /* not GTK_CHECK_VERSION(2,4,0) */
10471013 /* ja:各タグについて */
1048- for (j = 0; j < leng_tag; j++)
1014+ for (glist = g_list_first (glist_tag);
1015+ glist; glist = g_list_next (glist))
10491016 {
10501017 gsize leng;
10511018 gchar *name;
@@ -1053,8 +1020,7 @@
10531020 AcmObject *acm_object;
10541021 WaveFormatEx *wfx;
10551022
1056- acm_object = acm_open ((guint16)GPOINTER_TO_UINT
1057- (g_list_nth_data (glist_tag, j)));
1023+ acm_object = acm_open ((guint16)GPOINTER_TO_UINT (glist->data));
10581024 if (!acm_object)
10591025 continue;
10601026 leng = acm_compress_get_format_size (acm_object,
@@ -1085,6 +1051,7 @@
10851051 }
10861052 if (g_list_length (glist_name) > 1)
10871053 {
1054+ gint j;
10881055 #if GTK_CHECK_VERSION(2,4,0)
10891056 GtkListStore *store;
10901057 GtkCellRenderer *renderer;
@@ -1179,11 +1146,10 @@
11791146 g_list_nth_data (glist_name, 0));
11801147 #endif /* not GTK_CHECK_VERSION(2,4,0) */
11811148 }
1182- for (j = g_list_length (glist_name) - 1; j >= 0; j--)
11831149 #if GTK_CHECK_VERSION(2,4,0)
1184- g_strfreev (g_list_nth_data (glist_name, j));
1150+ g_list_foreach (glist_name, (GFunc)g_strfreev, NULL);
11851151 #else /* not GTK_CHECK_VERSION(2,4,0) */
1186- g_free (g_list_nth_data (glist_name, j));
1152+ g_list_foreach (glist_name, (GFunc)g_free, NULL);
11871153 #endif /* not GTK_CHECK_VERSION(2,4,0) */
11881154 g_list_free (glist_wfx);
11891155 g_list_free (glist_name);
@@ -1270,7 +1236,6 @@
12701236 {
12711237 GtkWidget *label1, *hbox1;
12721238 #if GTK_CHECK_VERSION(2,2,0)
1273- gint j;
12741239 GSList *gslist_formats, *gslist_sorted = NULL;
12751240 GtkWidget *vbox;
12761241 #endif /* GTK_CHECK_VERSION(2,2,0) */
@@ -1303,19 +1268,15 @@
13031268 gtk_label_set_mnemonic_widget (GTK_LABEL (label1), extra->spin_end);
13041269 /* ja:コンボボックス */
13051270 #if GTK_CHECK_VERSION(2,2,0)
1306- gslist_formats = gdk_pixbuf_get_formats ();
1307- for (j = 0; j < g_slist_length (gslist_formats); j++)
1308- {
1309- GdkPixbufFormat *format;
1310-
1311- format = g_slist_nth_data (gslist_formats, j);
1312- if (gdk_pixbuf_format_is_writable (format))
1313- gslist_sorted = g_slist_insert_sorted (gslist_sorted, format,
1271+ for (gslist_formats = gdk_pixbuf_get_formats (); gslist_formats;
1272+ gslist_formats = g_slist_delete_link (gslist_formats, gslist_formats))
1273+ if (gdk_pixbuf_format_is_writable (gslist_formats->data))
1274+ gslist_sorted = g_slist_insert_sorted (gslist_sorted,
1275+ gslist_formats->data,
13141276 (GCompareFunc)avi_extra_set_handle_sort);
1315- }
1316- g_slist_free (gslist_formats);
13171277 if (g_slist_length (gslist_sorted) > 0)
13181278 {
1279+ GSList *gsl;
13191280 # if GTK_CHECK_VERSION(2,4,0)
13201281 GtkCellRenderer *renderer;
13211282 GtkListStore *store;
@@ -1325,7 +1286,7 @@
13251286 GList *glist = NULL;
13261287
13271288 # endif /* GTK_CHECK_VERSION(2,2,0) */
1328- for (j = 0; j < g_slist_length (gslist_sorted); j++)
1289+ for (gsl = gslist_sorted; gsl; gsl = g_slist_next (gsl))
13291290 {
13301291 gchar *desc, *name;
13311292 GdkPixbufFormat *format;
@@ -1333,7 +1294,7 @@
13331294 GtkTreeIter iter;
13341295 # endif /* GTK_CHECK_VERSION(2,4,0) */
13351296
1336- format = g_slist_nth_data (gslist_sorted, j);
1297+ format = gsl->data;
13371298 desc = gdk_pixbuf_format_get_description (format);
13381299 name = gdk_pixbuf_format_get_name (format);
13391300 if (g_strcmp (name, "ico") == 0)
@@ -1426,7 +1387,7 @@
14261387 gtk_widget_set_sensitive
14271388 (GTK_WIDGET (extra->spin_ico_y), FALSE);
14281389 gtk_widget_show_all (extra->hbox_ico);
1429- if (j <= 0)
1390+ if (!extra->hbox_current)
14301391 extra->hbox_current = extra->hbox_ico;
14311392 }
14321393 else if (g_strcmp (name, "jpeg") == 0)
@@ -1448,7 +1409,7 @@
14481409 gtk_widget_set_sensitive
14491410 (GTK_WIDGET (extra->spin_jpeg), FALSE);
14501411 gtk_widget_show_all (GTK_WIDGET (extra->hbox_jpeg));
1451- if (j <= 0)
1412+ if (!extra->hbox_current)
14521413 extra->hbox_current = extra->hbox_jpeg;
14531414 }
14541415 else if (g_strcmp (name, "png") == 0)
@@ -1477,7 +1438,7 @@
14771438 gtk_widget_set_sensitive
14781439 (GTK_WIDGET (extra->spin_png), FALSE);
14791440 gtk_widget_show_all (GTK_WIDGET (extra->hbox_png));
1480- if (j <= 0)
1441+ if (!extra->hbox_current)
14811442 extra->hbox_current = extra->hbox_png;
14821443 }
14831444 # if GTK_CHECK_VERSION(2,4,0)
@@ -1503,8 +1464,7 @@
15031464 }
15041465 extra->combo = gtk_combo_new ();
15051466 gtk_combo_set_popdown_strings (GTK_COMBO (extra->combo), glist);
1506- for (j = g_list_length (glist) - 1; j >= 0; j--)
1507- g_free (g_list_nth_data (glist, j));
1467+ g_list_foreach (glist, (GFunc)g_free, NULL);
15081468 g_list_free (glist);
15091469 glist = gtk_container_get_children
15101470 (GTK_CONTAINER (GTK_COMBO (extra->combo)->list));
@@ -1797,7 +1757,6 @@
17971757 GtkTreeIter iter;
17981758 # else /* not GTK_CHECK_VERSION(2,4,0) */
17991759 const gchar *text;
1800- gint i;
18011760 GList *glist_combo;
18021761 # endif /* not GTK_CHECK_VERSION(2,4,0) */
18031762 GdkPixbufFormat *format = NULL;
@@ -1812,19 +1771,15 @@
18121771 (GTK_ENTRY (GTK_COMBO (extra->combo)->entry));
18131772 glist_combo = gtk_container_get_children
18141773 (GTK_CONTAINER (GTK_COMBO (extra->combo)->list));
1815- for (i = g_list_length (glist_combo) - 1; i >= 0; i--)
1816- {
1817- const gchar *label;
1818-
1819- label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
1820- (GTK_BIN (g_list_nth_data (glist_combo, i)))));
1821- if (g_strcmp (label, text) == 0)
1822- {
1823- format = g_object_get_data (G_OBJECT (g_list_nth_data
1824- (glist_combo, i)), "user_data");
1825- break;
1826- }
1827- }
1774+ for (glist_combo = g_list_first (glist_combo); glist_combo;
1775+ glist_combo = g_list_delete_link (glist_combo, glist_combo))
1776+ if (g_strcmp (gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
1777+ (GTK_BIN (glist_combo->data)))), text) == 0)
1778+ {
1779+ format = g_object_get_data (G_OBJECT (glist_combo->data),
1780+ "user_data");
1781+ break;
1782+ }
18281783 g_list_free (glist_combo);
18291784 # endif /* not GTK_CHECK_VERSION(2,4,0) */
18301785 if (format)
--- vmaid/trunk/misc/fileio.c (revision 312)
+++ vmaid/trunk/misc/fileio.c (revision 313)
@@ -510,8 +510,7 @@
510510 # endif /* not GLIB_CHECK_VERSION(2,6,0) */
511511 #else /* not G_OS_WIN32 */
512512 int fd, flags;
513- gint i;
514- guint length;
513+ GList *glist;
515514 #endif /* not G_OS_WIN32 */
516515
517516 if (!file)
@@ -615,19 +614,15 @@
615614 G_LOCK (critical);
616615 critical = TRUE;
617616 # endif /* USE_THREAD */
618- length = g_list_length (glist_fileio);
619- for (i = 0; i < length; i++)
620- {
621- fio = g_list_nth_data (glist_fileio, i);
622- if (g_strfilecmp (fio->file, path) == 0
623- && (fio->share & access) != access)
624- break;
625- }
617+ for (glist = g_list_first (glist_fileio); glist; glist = g_list_next (glist))
618+ if (g_strfilecmp (((FileIO *)glist->data)->file, path) == 0
619+ && (((FileIO *)glist->data)->share & access) != access)
620+ break;
626621 # ifdef USE_THREAD
627622 critical = FALSE;
628623 G_UNLOCK (critical);
629624 # endif /* USE_THREAD */
630- if (i < length)
625+ if (glist)
631626 {
632627 g_free (path);
633628 return NULL;
--- vmaid/trunk/w32loader/w32ldr.c (revision 312)
+++ vmaid/trunk/w32loader/w32ldr.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 w32loader
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "w32ldr.h"
2019 #include "image.h"
@@ -92,7 +91,7 @@
9291
9392 image = (guint8 *)(module + 1);
9493 pifh = (PIMAGE_FILE_HEADER)
95- (image + *(LPDWORD)(image + 0x3c) + sizeof (DWORD));
94+ (image + ((PIMAGE_DOS_HEADER)image)->e_lfanew + sizeof (DWORD));
9695 pioh = (PIMAGE_OPTIONAL_HEADER)(pifh + 1);
9796 for (i = 0; i < pird->NumberOfNamedEntries + pird->NumberOfIdEntries; i++)
9897 {
@@ -153,18 +152,19 @@
153152 static gchar *
154153 w32ldr_module_get_basename (const gchar *file)
155154 {
156- gchar *name;
155+ gchar *name = NULL;
157156
158- if (!file)
159- return NULL;
160- name = g_path_get_basename (file);
161- if (!g_strrchr (name, '.'))
157+ if (file)
162158 {
163- gchar *tmp;
159+ name = g_path_get_basename (file);
160+ if (!g_strrchr (name, '.'))
161+ {
162+ gchar *tmp;
164163
165- tmp = g_strconcat (name, ".dll", NULL);
166- g_free (name);
167- name = tmp;
164+ tmp = g_strconcat (name, ".dll", NULL);
165+ g_free (name);
166+ name = tmp;
167+ }
168168 }
169169 return name;
170170 }
@@ -176,36 +176,34 @@
176176 W32LdrModule *
177177 w32ldr_module_get_library (const gchar *file)
178178 {
179- gchar *base, *name;
180- gint i;
181179 W32LdrModule *module = NULL;
182180
183- if (!file)
184- return NULL;
185- base = g_path_get_basename (file);
186- name = w32ldr_module_get_basename (file);
187-#ifdef USE_THREAD
188- G_LOCK (critical);
189- critical = TRUE;
190-#endif /* USE_THREAD */
191- for (i = g_list_length (glist_module) - 1; i >= 0; i--)
181+ if (file)
192182 {
193- W32LdrModule *mod;
183+ gchar *base, *name;
184+ GList *glist;
194185
195- mod = g_list_nth_data (glist_module, i);
196- if (g_ascii_strcasecmp (mod->name, base) == 0
197- || g_ascii_strcasecmp (mod->name, name) == 0)
198- {
199- module = mod;
200- break;
201- }
202- }
186+ base = g_path_get_basename (file);
187+ name = w32ldr_module_get_basename (file);
203188 #ifdef USE_THREAD
204- critical = FALSE;
205- G_UNLOCK (critical);
189+ G_LOCK (critical);
190+ critical = TRUE;
206191 #endif /* USE_THREAD */
207- g_free (base);
208- g_free (name);
192+ for (glist = g_list_first (glist_module);
193+ glist; glist = g_list_next (glist))
194+ if (g_ascii_strcasecmp (((W32LdrModule *)glist->data)->name, base) == 0
195+ || g_ascii_strcasecmp (((W32LdrModule *)glist->data)->name, name) == 0)
196+ {
197+ module = glist->data;
198+ break;
199+ }
200+#ifdef USE_THREAD
201+ critical = FALSE;
202+ G_UNLOCK (critical);
203+#endif /* USE_THREAD */
204+ g_free (base);
205+ g_free (name);
206+ }
209207 return module;
210208 }
211209
@@ -219,10 +217,11 @@
219217 const gboolean exec)
220218 {
221219 gboolean result = TRUE;
222- gssize leng, length;
220+ gssize leng;
223221 guint8 *image;
224222 gint i;
225223 W32LdrModule *module;
224+ PIMAGE_DOS_HEADER pidh;
226225 PIMAGE_FILE_HEADER pifh;
227226 PIMAGE_OPTIONAL_HEADER pioh;
228227 PIMAGE_SECTION_HEADER pish;
@@ -264,8 +263,132 @@
264263 if (g_ascii_strcasecmp (osdll[i].name, module->name) == 0)
265264 {
266265 /* ja:内蔵DLL */
267- gint j;
266+ guint8 *p;
267+ gchar *q;
268+ gint j, k = 0, implement = 0, num = 0;
269+ gint ordinal_min = G_MAXINT, ordinal_max = G_MININT;
270+ gsize leng_head, leng_code, leng_data;
271+ LPDWORD signature, func, name;
272+ LPWORD ordinal;
273+ PIMAGE_EXPORT_DIRECTORY pied;
268274
275+ leng_head = sizeof (IMAGE_DOS_HEADER)
276+ + sizeof (DWORD)
277+ + sizeof (IMAGE_FILE_HEADER)
278+ + sizeof (IMAGE_OPTIONAL_HEADER)
279+ + sizeof (IMAGE_SECTION_HEADER);
280+ leng_code = 0;
281+ leng_data = sizeof (IMAGE_EXPORT_DIRECTORY)
282+ + g_strlen (osdll[i].name) + 1;
283+ for (j = 0; osdll[i].exports[j].func; j++)
284+ if (osdll[i].exports[j].implement)
285+ {
286+ implement++;
287+ leng_code += 5;
288+ if (osdll[i].exports[j].name)
289+ {
290+ num++;
291+ leng_data += g_strlen (osdll[i].exports[j].name) + 1
292+ + sizeof (DWORD) + sizeof (WORD);
293+ }
294+ if (ordinal_min > osdll[i].exports[j].ordinal)
295+ ordinal_min = osdll[i].exports[j].ordinal;
296+ if (ordinal_max < osdll[i].exports[j].ordinal)
297+ ordinal_max = osdll[i].exports[j].ordinal;
298+ }
299+ if (implement > 0)
300+ leng_data += (ordinal_max - ordinal_min + 1) * sizeof (DWORD);
301+ leng = leng_head + leng_code + leng_data;
302+ module = g_realloc (module, leng + sizeof (W32LdrModule));
303+ g_memset (module + 1, 0, leng);
304+ /* ja:ポインタ */
305+ image = (guint8 *)(module + 1);
306+ pidh = (PIMAGE_DOS_HEADER)image;
307+ signature = (LPDWORD)(pidh + 1);
308+ pifh = (PIMAGE_FILE_HEADER)(signature + 1);
309+ pioh = (PIMAGE_OPTIONAL_HEADER)(pifh + 1);
310+ pish = (PIMAGE_SECTION_HEADER)(pioh + 1);
311+ p = (guint8 *)(pish + 1);
312+ pied = (PIMAGE_EXPORT_DIRECTORY)(p + leng_code);
313+ func = (LPDWORD)(pied + 1);
314+ name = func + ordinal_max - ordinal_min + 1;
315+ ordinal = (LPWORD)(name + num);
316+ q = (gchar *)(ordinal + num);
317+ /* ja:設定 */
318+ pidh->e_magic = IMAGE_DOS_SIGNATURE;
319+ pidh->e_lfanew = sizeof (IMAGE_DOS_HEADER);
320+ *signature = IMAGE_NT_SIGNATURE;
321+ pifh->Machine = IMAGE_FILE_MACHINE_I386;
322+ pifh->NumberOfSections = 1;
323+ pifh->SizeOfOptionalHeader = sizeof (IMAGE_OPTIONAL_HEADER);
324+ pifh->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE
325+ | IMAGE_FILE_LINE_NUMS_STRIPPED
326+ | IMAGE_FILE_LOCAL_SYMS_STRIPPED
327+ | IMAGE_FILE_32BIT_MACHINE
328+ | IMAGE_FILE_DLL;
329+ pioh->Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
330+ pioh->SizeOfCode = leng_code;
331+ pioh->SizeOfInitializedData = leng_data;
332+ pioh->BaseOfCode = leng_head;
333+ pioh->BaseOfData = leng_head + leng_code;
334+ pioh->ImageBase = 0x10000000;
335+ pioh->SectionAlignment = 1;
336+ pioh->FileAlignment = 1;
337+ pioh->MajorOperatingSystemVersion = 4;
338+ pioh->MinorOperatingSystemVersion = 0;
339+ pioh->MajorSubsystemVersion = 4;
340+ pioh->MinorSubsystemVersion = 0;
341+ pioh->SizeOfImage = leng;
342+ pioh->SizeOfHeaders = leng_head;
343+ pioh->Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
344+ pioh->SizeOfStackReserve = 0x100000;
345+ pioh->SizeOfStackCommit = 0x1000;
346+ pioh->SizeOfHeapReserve = 0x100000;
347+ pioh->SizeOfHeapCommit = 0x1000;
348+ pioh->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
349+ pioh->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress
350+ = leng_head + leng_code;
351+ pioh->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = leng_data;
352+ pish->Misc.VirtualSize = leng_code + leng_data;
353+ pish->VirtualAddress = leng_head;
354+ pish->SizeOfRawData = leng_code + leng_data;
355+ pish->PointerToRawData = leng_head;
356+ pish->Characteristics = IMAGE_SCN_CNT_CODE
357+ | IMAGE_SCN_CNT_INITIALIZED_DATA
358+ | IMAGE_SCN_MEM_EXECUTE
359+ | IMAGE_SCN_MEM_READ;
360+ pied->Name = GPOINTER_TO_UINT (q) - GPOINTER_TO_UINT (image);
361+ pied->Base = ordinal_min;
362+ pied->NumberOfFunctions = implement;
363+ pied->NumberOfNames = num;
364+ pied->AddressOfFunctions = GPOINTER_TO_UINT (func)
365+ - GPOINTER_TO_UINT (image);
366+ pied->AddressOfNames = GPOINTER_TO_UINT (name)
367+ - GPOINTER_TO_UINT (image);
368+ pied->AddressOfNameOrdinals = GPOINTER_TO_UINT (ordinal)
369+ - GPOINTER_TO_UINT (image);
370+ g_strcpy (q, osdll[i].name);
371+ q += g_strlen (osdll[i].name) + 1;
372+ for (j = 0; osdll[i].exports[j].func; j++)
373+ if (osdll[i].exports[j].implement)
374+ {
375+ gint index;
376+
377+ index = osdll[i].exports[j].ordinal - ordinal_min;
378+ func[index] = GPOINTER_TO_UINT (p) - GPOINTER_TO_UINT (image);
379+ *p++ = 0xe9;
380+ *(guint32 *)p = GPOINTER_TO_UINT (osdll[i].exports[j].func)
381+ - (GPOINTER_TO_UINT (p) + 4);
382+ p += 4;
383+ if (osdll[i].exports[j].name)
384+ {
385+ name[k] = GPOINTER_TO_UINT (q) - GPOINTER_TO_UINT (image);
386+ g_strcpy (q, osdll[i].exports[j].name);
387+ q += g_strlen (osdll[i].exports[j].name) + 1;
388+ ordinal[k] = index;
389+ k++;
390+ }
391+ }
269392 module->file = g_build_filename
270393 (w32ldr_dir_get_path (W32LDR_DIR_SYSTEM), osdll[i].name, NULL);
271394 module->exports = g_hash_table_new (g_str_hash, g_str_equal);
@@ -273,7 +396,8 @@
273396 for (j = 0; osdll[i].exports[j].func; j++)
274397 if (osdll[i].exports[j].implement)
275398 {
276- g_hash_table_insert (module->exports,
399+ if (osdll[i].exports[j].name)
400+ g_hash_table_insert (module->exports,
277401 osdll[i].exports[j].name, osdll[i].exports[j].func);
278402 g_hash_table_insert (module->ordinals,
279403 GUINT_TO_POINTER ((guint)osdll[i].exports[j].ordinal),
@@ -293,7 +417,7 @@
293417
294418 module->name = g_path_get_basename (file);
295419 module->file = fileio_get_full_path (file);
296- image = fileio_load (module->file, &length);
420+ image = fileio_load (module->file, &leng);
297421 for (i = 0; i < 8; i++)
298422 if (!image)
299423 {
@@ -310,11 +434,14 @@
310434 i < 6 ? "bin" : "lib", module->name, NULL);
311435 module->file = w32ldr_dir_get_case_insensitive (path);
312436 g_free (path);
313- image = fileio_load (module->file, &length);
437+ image = fileio_load (module->file, &leng);
314438 }
315- if (!image || length < 0x40 || *(guint16 *)image != IMAGE_DOS_SIGNATURE
316- || length <= *(guint32 *)(image + 0x3c)
317- || *(guint32 *)(image + *(guint32 *)(image + 0x3c)) != IMAGE_NT_SIGNATURE)
439+ pidh = (PIMAGE_DOS_HEADER)image;
440+ if (!image || leng < sizeof (IMAGE_DOS_HEADER)
441+ || pidh->e_magic != IMAGE_DOS_SIGNATURE
442+ || leng < pidh->e_lfanew + sizeof (DWORD)
443+ + sizeof (IMAGE_FILE_HEADER) + sizeof (IMAGE_OPTIONAL_HEADER)
444+ || *(LPDWORD)(image + pidh->e_lfanew) != IMAGE_NT_SIGNATURE)
318445 {
319446 g_free (image);
320447 g_free (module->name);
@@ -322,13 +449,16 @@
322449 g_free (module);
323450 return NULL;
324451 }
325- pifh = (PIMAGE_FILE_HEADER)
326- (image + *(LPDWORD)(image + 0x3c) + sizeof (DWORD));
452+ pifh = (PIMAGE_FILE_HEADER)(image + pidh->e_lfanew + sizeof (DWORD));
327453 pioh = (PIMAGE_OPTIONAL_HEADER)(pifh + 1);
328454 pish = (PIMAGE_SECTION_HEADER)(pioh + 1);
329455 if (pifh->Machine != IMAGE_FILE_MACHINE_I386
330456 || pifh->SizeOfOptionalHeader != sizeof (IMAGE_OPTIONAL_HEADER)
331- || pioh->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
457+ || pioh->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC
458+ || leng < pioh->SizeOfHeaders
459+ || leng < pidh->e_lfanew + sizeof (DWORD)
460+ + sizeof (IMAGE_FILE_HEADER) + sizeof (IMAGE_OPTIONAL_HEADER)
461+ + sizeof (IMAGE_SECTION_HEADER) * pifh->NumberOfSections)
332462 {
333463 g_free (image);
334464 g_free (module->name);
@@ -339,8 +469,10 @@
339469 /* ja:イメージ作成 */
340470 leng = pioh->SizeOfImage;
341471 for (i = 0; i < pifh->NumberOfSections; i++)
342- if (leng < pish[i].VirtualAddress + pish[i].Misc.VirtualSize)
343- leng = pish[i].VirtualAddress + pish[i].Misc.VirtualSize;
472+ if (leng < pish[i].VirtualAddress
473+ + MAX (pish[i].Misc.VirtualSize, pish[i].SizeOfRawData))
474+ leng = pish[i].VirtualAddress
475+ + MAX (pish[i].Misc.VirtualSize, pish[i].SizeOfRawData);
344476 module = g_realloc (module, leng + sizeof (W32LdrModule));
345477 g_memset (module + 1, 0, leng);
346478 g_memmove (module + 1, image, pioh->SizeOfHeaders);
@@ -350,7 +482,7 @@
350482 g_free (image);
351483 image = (guint8 *)(module + 1);
352484 pifh = (PIMAGE_FILE_HEADER)
353- (image + *(LPDWORD)(image + 0x3c) + sizeof (DWORD));
485+ (image + ((PIMAGE_DOS_HEADER)image)->e_lfanew + sizeof (DWORD));
354486 pioh = (PIMAGE_OPTIONAL_HEADER)(pifh + 1);
355487 pish = (PIMAGE_SECTION_HEADER)(pioh + 1);
356488
@@ -369,14 +501,11 @@
369501 module->exports = g_hash_table_new (g_str_hash, g_str_equal);
370502 module->ordinals = g_hash_table_new (g_direct_hash, g_direct_equal);
371503 for (i = 0; i < pied->NumberOfNames; i++)
372- {
373- gpointer addr;
374-
375- addr = image + func[ordinal[i]];
376- g_hash_table_insert (module->exports, image + name[i], addr);
377- g_hash_table_insert (module->ordinals,
378- GUINT_TO_POINTER (ordinal[i] + pied->Base), addr);
379- }
504+ g_hash_table_insert (module->exports,
505+ image + name[i], image + func[ordinal[i]]);
506+ for (i = 0; i < pied->NumberOfFunctions; i++)
507+ g_hash_table_insert (module->ordinals,
508+ GUINT_TO_POINTER (i + pied->Base), image + func[i]);
380509 }
381510 #ifdef USE_THREAD
382511 G_LOCK (critical);
@@ -475,15 +604,15 @@
475604 pilt[j].u1.Function = GPOINTER_TO_UINT (func);
476605 #endif /* not USE_DEBUG */
477606 }
478- module->module = g_list_append (module->module, mod);
607+ module->glist = g_list_append (module->glist, mod);
479608 }
480-#ifdef USE_DEBUG
481609 else
482610 {
611+#ifdef USE_DEBUG
483612 g_warning ("import-module:%s\n", image + piid[i].Name);
613+#endif /* USE_DEBUG */
484614 result = FALSE;
485615 }
486-#endif /* USE_DEBUG */
487616 }
488617 }
489618 if (!result)
@@ -578,8 +707,6 @@
578707 module->counter--;
579708 if (module->counter <= 0)
580709 {
581- gint i;
582-
583710 if (module->DllMain)
584711 module->DllMain ((W32LdrModule *)(module + 1),
585712 DLL_PROCESS_DETACH, NULL);
@@ -592,8 +719,9 @@
592719 critical = FALSE;
593720 G_UNLOCK (critical);
594721 #endif /* USE_THREAD */
595- for (i = g_list_length (module->module) - 1; i >= 0; i--)
596- if (!w32ldr_module_free (g_list_nth_data (module->module, i)))
722+ for (module->glist = g_list_first (module->glist); module->glist;
723+ module->glist = g_list_delete_link (module->glist, module->glist))
724+ if (!w32ldr_module_free (module->glist->data))
597725 result = FALSE;
598726 if (module->resource)
599727 {
--- vmaid/trunk/w32loader/msvcrt.c (revision 312)
+++ vmaid/trunk/w32loader/msvcrt.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 w32loader
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "msvcrt.h"
2019 #include "kernel32.h"
@@ -1411,13 +1410,9 @@
14111410 /* _atoi64 ordinal = 165, argument = 0 */
14121411 gint64 CDECL _atoi64 (const char *string)
14131412 {
1414-#if GLIB_CHECK_VERSION(2,12,0)
14151413 gchar *endptr;
14161414
14171415 return g_ascii_strtoll (string, &endptr, 0);
1418-#else /* not GLIB_CHECK_VERSION(2,12,0) */
1419- return strtol (string, &endptr, 0);
1420-#endif /* not GLIB_CHECK_VERSION(2,12,0) */
14211416 }
14221417
14231418
@@ -5089,7 +5084,7 @@
50895084
50905085
50915086 /* exit ordinal = 607, argument = 0 */
5092-void CDECL msvcrt_exit (int status)
5087+static void CDECL msvcrt_exit (int status)
50935088 {
50945089 exit (status);
50955090 }
--- vmaid/trunk/w32loader/w32ldr.h (revision 312)
+++ vmaid/trunk/w32loader/w32ldr.h (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 w32loader
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@
4141 gchar *file, *name;
4242 gint counter;
4343 GHashTable *exports, *ordinals, *resource;
44- GList *module;
44+ GList *glist;
4545 DllEntryProc DllMain;
4646 } W32LdrModule;
4747 typedef struct _W32LdrExport
--- vmaid/trunk/w32loader/msvcrt.h (revision 312)
+++ vmaid/trunk/w32loader/msvcrt.h (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 w32loader
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -670,7 +670,6 @@
670670 FILE CDECL *_wfsopen (const gunichar2 *filename, const gunichar2 *mode, int shflag);
671671 int CDECL _wmkdir (const gunichar2 *dirname);
672672 int CDECL _wunlink (const gunichar2 *filename);
673-void CDECL msvcrt_exit (int status);
674673 int CDECL fwscanf (FILE *stream, const gunichar2 *format, ...);
675674 int CDECL isleadbyte (int c);
676675 int CDECL swscanf (const gunichar2 *buffer, const gunichar2 *format, ...);
--- vmaid/trunk/w32loader/kernel32.c (revision 312)
+++ vmaid/trunk/w32loader/kernel32.c (revision 313)
@@ -4988,16 +4988,9 @@
49884988 gint j;
49894989
49904990 for (j = 0; groups[j]; j++)
4991- {
4992- gint k;
4993-
4994- for (k = g_list_length (glist) - 1; k >= 0; k--)
4995- if (g_ascii_strcasecmp
4996- (g_list_nth_data (glist, k), groups[j]) == 0)
4997- break;
4998- if (k < 0)
4999- glist = g_list_append (glist, g_strdup (groups[k]));
5000- }
4991+ if (!g_list_find_custom (glist, groups[j],
4992+ (GCompareFunc)g_ascii_strcasecmp))
4993+ glist = g_list_append (glist, g_strdup (groups[j]));
50014994 g_strfreev (groups);
50024995 }
50034996 g_key_file_free (key_file);
@@ -5039,25 +5032,18 @@
50395032 gint k;
50405033
50415034 for (k = 0; keys[k]; k++)
5042- {
5043- gint l;
5035+ if (!g_list_find_custom (glist, keys[k],
5036+ (GCompareFunc)g_ascii_strcasecmp))
5037+ {
5038+ gchar *str;
50445039
5045- for (l = g_list_length (glist) - 1; l >= 0; l--)
5046- if (g_ascii_strcasecmp
5047- (g_list_nth_data (glist, l), keys[k]) == 0)
5048- break;
5049- if (l < 0)
5050- {
5051- gchar *str;
5052-
5053- glist = g_list_append (glist, g_strdup (keys[k]));
5054- str = g_key_file_get_string (key_file,
5040+ glist = g_list_append (glist, g_strdup (keys[k]));
5041+ str = g_key_file_get_string (key_file,
50555042 groups[j], keys[k], NULL);
5056- glist_pair = g_list_append (glist,
5043+ glist_pair = g_list_append (glist,
50575044 g_strconcat (keys[k], "=", str, NULL));
5058- g_free (str);
5059- }
5060- }
5045+ g_free (str);
5046+ }
50615047 g_strfreev (keys);
50625048 }
50635049 }
@@ -5065,8 +5051,7 @@
50655051 }
50665052 g_key_file_free (key_file);
50675053 }
5068- for (i = g_list_length (glist) - 1; i >= 0; i--)
5069- g_free (g_list_nth_data (glist, i));
5054+ g_list_foreach (glist, (GFunc)g_free, NULL);
50705055 g_list_free (glist);
50715056 return glist_pair;
50725057 }
@@ -5076,7 +5061,6 @@
50765061 DWORD WINAPI GetPrivateProfileSectionA (LPCSTR lpAppName, LPSTR lpReturnedString, DWORD nSize, LPCSTR lpFileName)
50775062 {
50785063 gchar *file, *group, *result = NULL;
5079- gint i;
50805064 GList *glist;
50815065 DWORD dwResult = 0;
50825066
@@ -5085,19 +5069,19 @@
50855069 glist = kernel32_inifile_enum_key (file, group);
50865070 g_free (file);
50875071 g_free (group);
5088- for (i = 0; i < g_list_length (glist); i++)
5072+ for (glist = g_list_first (glist);
5073+ glist; glist = g_list_delete_link (glist, glist))
50895074 {
50905075 gchar *mb;
50915076 gsize leng;
50925077
5093- mb = w32ldr_utf8_to_mb (g_list_nth_data (glist, i));
5094- g_free (g_list_nth_data (glist, i));
5078+ mb = w32ldr_utf8_to_mb (glist->data);
5079+ g_free (glist->data);
50955080 leng = g_strlen (mb) + 1;
50965081 result = g_realloc (result, (dwResult + leng) * sizeof (gchar));
50975082 g_memmove (result + dwResult, mb, leng * sizeof (gchar));
50985083 dwResult += leng;
50995084 }
5100- g_list_free (glist);
51015085 if (nSize < dwResult)
51025086 {
51035087 g_memmove (lpReturnedString, result, dwResult * sizeof (gchar));
@@ -5116,7 +5100,6 @@
51165100 DWORD WINAPI GetPrivateProfileSectionNamesA (LPSTR lpszReturnBuffer, DWORD nSize, LPCSTR lpFileName)
51175101 {
51185102 gchar *file, *result = NULL;
5119- gint i;
51205103 GList *glist;
51215104 DWORD dwResult = 0;
51225105
@@ -5123,19 +5106,19 @@
51235106 file = w32ldr_filename_from_mb (lpFileName);
51245107 glist = kernel32_inifile_enum_section (file);
51255108 g_free (file);
5126- for (i = 0; i < g_list_length (glist); i++)
5109+ for (glist = g_list_first (glist);
5110+ glist; glist = g_list_delete_link (glist, glist))
51275111 {
51285112 gchar *mb;
51295113 gsize leng;
51305114
5131- mb = w32ldr_utf8_to_mb (g_list_nth_data (glist, i));
5132- g_free (g_list_nth_data (glist, i));
5115+ mb = w32ldr_utf8_to_mb (glist->data);
5116+ g_free (glist->data);
51335117 leng = g_strlen (mb) + 1;
51345118 result = g_realloc (result, (dwResult + leng) * sizeof (gchar));
51355119 g_memmove (result + dwResult, mb, leng * sizeof (gchar));
51365120 dwResult += leng;
51375121 }
5138- g_list_free (glist);
51395122 if (nSize < dwResult)
51405123 {
51415124 g_memmove (lpszReturnBuffer, result, dwResult * sizeof (gchar));
@@ -5154,7 +5137,6 @@
51545137 static DWORD WINAPI GetPrivateProfileSectionNamesW (LPWSTR lpszReturnBuffer, DWORD nSize, LPCWSTR lpFileName)
51555138 {
51565139 gchar *file, *result = NULL;
5157- gint i;
51585140 GList *glist;
51595141 DWORD dwResult = 0;
51605142
@@ -5161,19 +5143,19 @@
51615143 file = w32ldr_filename_from_wc (lpFileName);
51625144 glist = kernel32_inifile_enum_section (file);
51635145 g_free (file);
5164- for (i = 0; i < g_list_length (glist); i++)
5146+ for (glist = g_list_first (glist);
5147+ glist; glist = g_list_delete_link (glist, glist))
51655148 {
51665149 gunichar2 *wc;
51675150 gsize leng;
51685151
5169- wc = g_utf8_to_utf16 (g_list_nth_data (glist, i), -1, NULL, NULL, NULL);
5170- g_free (g_list_nth_data (glist, i));
5152+ wc = g_utf8_to_utf16 (glist->data, -1, NULL, NULL, NULL);
5153+ g_free (glist->data);
51715154 leng = lstrlenW (wc) + 1;
51725155 result = g_realloc (result, (dwResult + leng) * sizeof (gunichar2));
51735156 g_memmove (result + dwResult, wc, leng * sizeof (gunichar2));
51745157 dwResult += leng;
51755158 }
5176- g_list_free (glist);
51775159 if (nSize < dwResult)
51785160 {
51795161 g_memmove (lpszReturnBuffer, result, dwResult * sizeof (gunichar2));
@@ -5192,7 +5174,6 @@
51925174 DWORD WINAPI GetPrivateProfileSectionW (LPCWSTR lpAppName, LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName)
51935175 {
51945176 gchar *file, *group, *result = NULL;
5195- gint i;
51965177 GList *glist;
51975178 DWORD dwResult = 0;
51985179
@@ -5201,19 +5182,19 @@
52015182 glist = kernel32_inifile_enum_key (file, group);
52025183 g_free (file);
52035184 g_free (group);
5204- for (i = 0; i < g_list_length (glist); i++)
5185+ for (glist = g_list_first (glist);
5186+ glist; glist = g_list_delete_link (glist, glist))
52055187 {
52065188 gsize leng;
52075189 gunichar2 *wc;
52085190
5209- wc = g_utf8_to_utf16 (g_list_nth_data (glist, i), -1, NULL, NULL, NULL);
5210- g_free (g_list_nth_data (glist, i));
5191+ wc = g_utf8_to_utf16 (glist->data, -1, NULL, NULL, NULL);
5192+ g_free (glist->data);
52115193 leng = lstrlenW (wc) + 1;
52125194 result = g_realloc (result, (dwResult + leng) * sizeof (gunichar2));
52135195 g_memmove (result + dwResult, wc, leng * sizeof (gunichar2));
52145196 dwResult += leng;
52155197 }
5216- g_list_free (glist);
52175198 if (nSize < dwResult)
52185199 {
52195200 g_memmove (lpReturnedString, result, dwResult * sizeof (gunichar2));
@@ -5400,17 +5381,27 @@
54005381 }
54015382
54025383
5403-#define W32LDR_HEAP_SIZE 512
5404-static GList *glist_heap = NULL;
5384+static LPDWORD **lpHeap = NULL;
54055385
54065386
54075387 /* GetProcessHeap ordinal = 346, argument = 0 */
54085388 HANDLE WINAPI GetProcessHeap (VOID)
54095389 {
5410- if (!glist_heap)
5411- glist_heap = g_list_append (glist_heap,
5412- g_malloc0 (sizeof (LPDWORD) * W32LDR_HEAP_SIZE));
5413- return g_list_nth_data (glist_heap, 0);
5390+#ifdef USE_THREAD
5391+ G_LOCK (critical);
5392+ critical = TRUE;
5393+#endif /* USE_THREAD */
5394+ if (!lpHeap)
5395+ {
5396+ lpHeap = g_malloc (sizeof (LPDWORD *) * 2);
5397+ lpHeap[0] = g_malloc0 (sizeof (LPDWORD));
5398+ lpHeap[1] = GINT_TO_POINTER (-1);
5399+ }
5400+#ifdef USE_THREAD
5401+ critical = FALSE;
5402+ G_UNLOCK (critical);
5403+#endif /* USE_THREAD */
5404+ return GINT_TO_POINTER (1);
54145405 }
54155406
54165407
@@ -5418,15 +5409,26 @@
54185409 DWORD WINAPI GetProcessHeaps (DWORD NumberOfHeaps, HANDLE *ProcessHeaps)
54195410 {
54205411 gint i;
5421- guint length;
54225412
5423- if (!glist_heap)
5424- glist_heap = g_list_append (glist_heap,
5425- g_malloc0 (sizeof (LPDWORD) * W32LDR_HEAP_SIZE));
5426- length = MIN (g_list_length (glist_heap), NumberOfHeaps);
5427- for (i = 0; i < length; i++)
5428- ProcessHeaps[i] = g_list_nth_data (glist_heap, i);
5429- return g_list_length (glist_heap);
5413+#ifdef USE_THREAD
5414+ G_LOCK (critical);
5415+ critical = TRUE;
5416+#endif /* USE_THREAD */
5417+ if (!lpHeap)
5418+ {
5419+ lpHeap = g_malloc (sizeof (LPDWORD *) * 2);
5420+ lpHeap[0] = g_malloc0 (sizeof (LPDWORD));
5421+ lpHeap[1] = GINT_TO_POINTER (-1);
5422+ }
5423+ for (i = 0; i < NumberOfHeaps && lpHeap[i] != GINT_TO_POINTER (-1); i++)
5424+ ProcessHeaps[i] = GINT_TO_POINTER (i + 1);
5425+ while (lpHeap[i] != GINT_TO_POINTER (-1))
5426+ i++;
5427+#ifdef USE_THREAD
5428+ critical = FALSE;
5429+ G_UNLOCK (critical);
5430+#endif /* USE_THREAD */
5431+ return i;
54305432 }
54315433
54325434
@@ -6151,7 +6153,13 @@
61516153 /* GlobalAlloc ordinal = 417, argument = 8 */
61526154 HGLOBAL WINAPI GlobalAlloc (UINT uFlags, UINT uBytes)
61536155 {
6154- return LocalAlloc (uFlags, uBytes);
6156+ LPUINT hMem;
6157+
6158+ if (uBytes <= 0 || !(hMem = g_malloc0 (uBytes + sizeof (UINT) * 2)))
6159+ return NULL;
6160+ hMem[0] = uFlags;
6161+ hMem[1] = uBytes;
6162+ return hMem + 2;
61556163 }
61566164
61576165
@@ -6193,7 +6201,7 @@
61936201 /* GlobalFlags ordinal = 423, argument = 4 */
61946202 UINT WINAPI GlobalFlags (HGLOBAL hMem)
61956203 {
6196- return LocalFlags (hMem);
6204+ return hMem ? ((LPUINT)hMem)[-2] : GMEM_INVALID_HANDLE;
61976205 }
61986206
61996207
@@ -6200,7 +6208,9 @@
62006208 /* GlobalFree ordinal = 424, argument = 4 */
62016209 HGLOBAL WINAPI GlobalFree (HGLOBAL hMem)
62026210 {
6203- return LocalFree (hMem);
6211+ if (hMem)
6212+ g_free ((LPUINT)hMem - 2);
6213+ return NULL;
62046214 }
62056215
62066216
@@ -6247,7 +6257,7 @@
62476257 /* GlobalHandle ordinal = 427, argument = 4 */
62486258 HGLOBAL WINAPI GlobalHandle (LPCVOID pMem)
62496259 {
6250- return LocalHandle (pMem);
6260+ return (HGLOBAL)pMem;
62516261 }
62526262
62536263
@@ -6254,7 +6264,7 @@
62546264 /* GlobalLock ordinal = 428, argument = 4 */
62556265 LPVOID WINAPI GlobalLock (HGLOBAL hMem)
62566266 {
6257- return LocalLock (hMem);
6267+ return hMem;
62586268 }
62596269
62606270
@@ -6275,7 +6285,21 @@
62756285 /* GlobalReAlloc ordinal = 431, argument = 12 */
62766286 HGLOBAL WINAPI GlobalReAlloc (HGLOBAL hMem, UINT uBytes, UINT uFlags)
62776287 {
6278- return LocalReAlloc (hMem, uBytes, uFlags);
6288+ if (!hMem)
6289+ return GlobalAlloc (uFlags, uBytes);
6290+ if (uBytes <= 0)
6291+ {
6292+ g_free ((LPUINT)hMem - 2);
6293+ return NULL;
6294+ }
6295+ hMem = g_realloc ((LPUINT)hMem - 2, uBytes + sizeof (UINT) * 2);
6296+ if (!hMem)
6297+ return NULL;
6298+ if (((LPUINT)hMem)[1] < uBytes)
6299+ g_memset ((guint8 *)hMem + sizeof (UINT) * 2 + ((LPUINT)hMem)[1], 0,
6300+ uBytes - ((LPUINT)hMem)[1]);
6301+ ((LPUINT)hMem)[1] = uBytes;
6302+ return (LPUINT)hMem + 2;
62796303 }
62806304
62816305
@@ -6282,7 +6306,7 @@
62826306 /* GlobalSize ordinal = 432, argument = 4 */
62836307 UINT WINAPI GlobalSize (HGLOBAL hMem)
62846308 {
6285- return LocalSize (hMem);
6309+ return hMem ? ((LPUINT)hMem)[-1] : 0;
62866310 }
62876311
62886312
@@ -6303,7 +6327,7 @@
63036327 /* GlobalUnlock ordinal = 435, argument = 4 */
63046328 UINT WINAPI GlobalUnlock (HGLOBAL hMem)
63056329 {
6306- return LocalUnlock (hMem);
6330+ return FALSE;
63076331 }
63086332
63096333
@@ -6345,7 +6369,7 @@
63456369 /* HeapAlloc ordinal = 441, argument = 12 */
63466370 LPVOID WINAPI HeapAlloc (HANDLE hHeap, DWORD dwFlags, DWORD dwBytes)
63476371 {
6348- if (hHeap && dwBytes > 0)
6372+ if (hHeap)
63496373 {
63506374 LPDWORD hMem;
63516375
@@ -6352,17 +6376,27 @@
63526376 hMem = g_malloc0 (dwBytes + sizeof (DWORD) * 2);
63536377 if (hMem)
63546378 {
6355- gint i;
6379+ gint i, index;
6380+ LPDWORD *lpdwHeap;
63566381
63576382 hMem[0] = dwFlags;
63586383 hMem[1] = dwBytes;
6359- for (i = 0; i < W32LDR_HEAP_SIZE; i++)
6360- if (!((LPDWORD *)hHeap)[i])
6361- {
6362- ((LPDWORD *)hHeap)[i] = hMem;
6363- return hMem + 2;
6364- }
6365- g_free (hMem);
6384+ index = GPOINTER_TO_INT (hHeap) - 1;
6385+#ifdef USE_THREAD
6386+ G_LOCK (critical);
6387+ critical = TRUE;
6388+#endif /* USE_THREAD */
6389+ lpdwHeap = lpHeap[index];
6390+ for (i = 0; lpdwHeap[i]; i++);
6391+ lpHeap[index] = lpdwHeap = g_realloc (lpHeap[index],
6392+ (i + 2) * sizeof (LPDWORD));
6393+ lpdwHeap[i] = hMem;
6394+ lpdwHeap[i + 1] = NULL;
6395+#ifdef USE_THREAD
6396+ critical = FALSE;
6397+ G_UNLOCK (critical);
6398+#endif /* USE_THREAD */
6399+ return hMem + 2;
63666400 }
63676401 }
63686402 return NULL;
@@ -6379,14 +6413,36 @@
63796413 /* HeapCreate ordinal = 443, argument = 12 */
63806414 HANDLE WINAPI HeapCreate (DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize)
63816415 {
6382- HANDLE hHeap;
6416+ gint i;
63836417
6384- if (!glist_heap)
6385- glist_heap = g_list_append (glist_heap,
6386- g_malloc0 (sizeof (LPDWORD) * W32LDR_HEAP_SIZE));
6387- hHeap = g_malloc0 (sizeof (LPDWORD) * W32LDR_HEAP_SIZE);
6388- glist_heap = g_list_append (glist_heap, hHeap);
6389- return hHeap;
6418+#ifdef USE_THREAD
6419+ G_LOCK (critical);
6420+ critical = TRUE;
6421+#endif /* USE_THREAD */
6422+ if (lpHeap)
6423+ {
6424+ for (i = 0; lpHeap[i] != GINT_TO_POINTER (-1); i++)
6425+ if (!lpHeap[i])
6426+ break;
6427+ }
6428+ else
6429+ {
6430+ lpHeap = g_malloc (sizeof (LPDWORD *) * 3);
6431+ lpHeap[0] = g_malloc0 (sizeof (LPDWORD));
6432+ lpHeap[2] = GINT_TO_POINTER (-1);
6433+ i = 1;
6434+ }
6435+ if (lpHeap[i] == GINT_TO_POINTER (-1))
6436+ {
6437+ lpHeap = g_realloc (lpHeap, (i + 2) * sizeof (LPDWORD *));
6438+ lpHeap[i + 1] = GINT_TO_POINTER (-1);
6439+ }
6440+ lpHeap[i] = g_malloc0 (sizeof (LPDWORD));
6441+#ifdef USE_THREAD
6442+ critical = FALSE;
6443+ G_UNLOCK (critical);
6444+#endif /* USE_THREAD */
6445+ return GINT_TO_POINTER (i + 1);
63906446 }
63916447
63926448
@@ -6400,14 +6456,24 @@
64006456 /* HeapDestroy ordinal = 445, argument = 4 */
64016457 BOOL WINAPI HeapDestroy (HANDLE hHeap)
64026458 {
6403- gint i;
6459+ gint i, index;
6460+ LPDWORD *lpdwHeap;
64046461
6405- if (!hHeap)
6462+ index = GPOINTER_TO_INT (hHeap) - 1;
6463+ if (index <= 0)
64066464 return FALSE;
6407- glist_heap = g_list_remove (glist_heap, hHeap);
6408- for (i = 0; i < W32LDR_HEAP_SIZE; i++)
6409- g_free (((LPDWORD *)hHeap)[i]);
6410- g_free (hHeap);
6465+ lpdwHeap = lpHeap[index];
6466+ lpHeap[index] = NULL;
6467+ for (i = 0; lpdwHeap[i]; i++)
6468+ g_free (lpdwHeap[i]);
6469+ g_free (lpdwHeap);
6470+ if (lpHeap[index + 1] == GINT_TO_POINTER (-1))
6471+ {
6472+ while (!lpHeap[index])
6473+ index--;
6474+ lpHeap = g_realloc (lpHeap, (index + 2) * sizeof (LPDWORD *));
6475+ lpHeap[index + 1] = GINT_TO_POINTER (-1);
6476+ }
64116477 return TRUE;
64126478 }
64136479
@@ -6422,18 +6488,38 @@
64226488 /* HeapFree ordinal = 447, argument = 12 */
64236489 BOOL WINAPI HeapFree (HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
64246490 {
6425- gint i;
6491+ gboolean result = FALSE;
64266492
6427- if (!hHeap || !lpMem)
6428- return FALSE;
6429- for (i = 0; i < W32LDR_HEAP_SIZE; i++)
6430- if (((LPDWORD *)hHeap)[i] == (LPDWORD)lpMem - 2)
6431- {
6432- g_free (((LPDWORD *)hHeap)[i]);
6433- ((LPDWORD *)hHeap)[i] = NULL;
6434- return TRUE;
6435- }
6436- return FALSE;
6493+ if (hHeap && lpMem)
6494+ {
6495+ gint i, index;
6496+ LPDWORD *lpdwHeap;
6497+
6498+ index = GPOINTER_TO_INT (hHeap) - 1;
6499+#ifdef USE_THREAD
6500+ G_LOCK (critical);
6501+ critical = TRUE;
6502+#endif /* USE_THREAD */
6503+ lpdwHeap = lpHeap[index];
6504+ for (i = 0; lpdwHeap[i]; i++)
6505+ if (lpdwHeap[i] == (LPDWORD)lpMem - 2)
6506+ {
6507+ g_free (lpdwHeap[i]);
6508+ while (lpdwHeap[i])
6509+ {
6510+ lpdwHeap[i] = lpdwHeap[i + 1];
6511+ i++;
6512+ }
6513+ lpHeap[index] = g_realloc (lpHeap[index], i * sizeof (LPDWORD));
6514+ result = TRUE;
6515+ break;
6516+ }
6517+#ifdef USE_THREAD
6518+ critical = FALSE;
6519+ G_UNLOCK (critical);
6520+#endif /* USE_THREAD */
6521+ }
6522+ return result;
64376523 }
64386524
64396525
@@ -6461,27 +6547,40 @@
64616547 /* HeapReAlloc ordinal = 451, argument = 16 */
64626548 LPVOID WINAPI HeapReAlloc (HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, DWORD dwBytes)
64636549 {
6464- gint i;
6550+ gpointer result = NULL;
64656551
6466- if (!hHeap || !lpMem)
6467- return NULL;
6468- if (dwBytes <= 0)
6552+ if (hHeap)
64696553 {
6470- HeapFree (hHeap, dwFlags, lpMem);
6471- return NULL;
6554+ gint i, index;
6555+ LPDWORD *lpdwHeap;
6556+
6557+ if (!lpMem)
6558+ return HeapAlloc (hHeap, dwFlags, dwBytes);
6559+ index = GPOINTER_TO_INT (hHeap) - 1;
6560+#ifdef USE_THREAD
6561+ G_LOCK (critical);
6562+ critical = TRUE;
6563+#endif /* USE_THREAD */
6564+ lpdwHeap = lpHeap[index];
6565+ for (i = 0; lpdwHeap[i]; i++)
6566+ if (lpdwHeap[i] == (LPDWORD)lpMem - 2)
6567+ {
6568+ lpdwHeap[i] = g_realloc (lpdwHeap[i],
6569+ dwBytes + sizeof (DWORD) * 2);
6570+ if ((lpdwHeap[i])[1] < dwBytes)
6571+ g_memset ((guint8 *)(lpdwHeap[i] + 2) + (lpdwHeap[i])[1], 0,
6572+ dwBytes - (lpdwHeap[i])[1]);
6573+ (lpdwHeap[i])[0] = dwFlags;
6574+ (lpdwHeap[i])[1] = dwBytes;
6575+ result = lpdwHeap[i] + 2;
6576+ break;
6577+ }
6578+#ifdef USE_THREAD
6579+ critical = FALSE;
6580+ G_UNLOCK (critical);
6581+#endif /* USE_THREAD */
64726582 }
6473- for (i = 0; i < W32LDR_HEAP_SIZE; i++)
6474- if (((LPDWORD *)hHeap)[i] == (LPDWORD)lpMem - 2)
6475- break;
6476- if (!((LPDWORD *)hHeap)[i]
6477- || !(lpMem = g_realloc ((LPDWORD)lpMem - 2, dwBytes + sizeof (DWORD) * 2)))
6478- return NULL;
6479- if (((LPDWORD)lpMem)[1] < dwBytes)
6480- g_memset ((guint8 *)lpMem + sizeof (DWORD) * 2 + ((LPDWORD)lpMem)[1], 0,
6481- dwBytes - ((LPDWORD)lpMem)[1]);
6482- ((LPDWORD)lpMem)[1] = dwBytes;
6483- ((LPDWORD *)hHeap)[i] = lpMem;
6484- return (LPDWORD)lpMem + 2;
6583+ return result;
64856584 }
64866585
64876586
@@ -6840,13 +6939,7 @@
68406939 /* LocalAlloc ordinal = 492, argument = 8 */
68416940 HLOCAL WINAPI LocalAlloc (UINT uFlags, UINT uBytes)
68426941 {
6843- LPUINT hMem;
6844-
6845- if (uBytes <= 0 || !(hMem = g_malloc0 (uBytes + sizeof (UINT) * 2)))
6846- return NULL;
6847- hMem[0] = uFlags;
6848- hMem[1] = uBytes;
6849- return hMem + 2;
6942+ return GlobalAlloc (uFlags, uBytes);
68506943 }
68516944
68526945
@@ -6868,7 +6961,7 @@
68686961 /* LocalFlags ordinal = 495, argument = 4 */
68696962 UINT WINAPI LocalFlags (HLOCAL hMem)
68706963 {
6871- return hMem ? ((LPUINT)hMem)[-2] : LMEM_INVALID_HANDLE;
6964+ return GlobalFlags (hMem);
68726965 }
68736966
68746967
@@ -6875,9 +6968,7 @@
68756968 /* LocalFree ordinal = 496, argument = 4 */
68766969 HLOCAL WINAPI LocalFree (HLOCAL hMem)
68776970 {
6878- if (hMem)
6879- g_free ((LPUINT)hMem - 2);
6880- return NULL;
6971+ return GlobalFree (hMem);
68816972 }
68826973
68836974
@@ -6884,7 +6975,7 @@
68846975 /* LocalHandle ordinal = 497, argument = 4 */
68856976 HLOCAL WINAPI LocalHandle (LPCVOID pMem)
68866977 {
6887- return (HLOCAL)pMem;
6978+ return GlobalHandle (pMem);
68886979 }
68896980
68906981
@@ -6891,7 +6982,7 @@
68916982 /* LocalLock ordinal = 498, argument = 4 */
68926983 LPVOID WINAPI LocalLock (HLOCAL hMem)
68936984 {
6894- return hMem;
6985+ return GlobalLock (hMem);
68956986 }
68966987
68976988
@@ -6898,21 +6989,7 @@
68986989 /* LocalReAlloc ordinal = 499, argument = 12 */
68996990 HLOCAL WINAPI LocalReAlloc (HLOCAL hMem, UINT uBytes, UINT uFlags)
69006991 {
6901- if (!hMem)
6902- return LocalAlloc (uFlags, uBytes);
6903- if (uBytes <= 0)
6904- {
6905- g_free ((LPUINT)hMem - 2);
6906- return NULL;
6907- }
6908- hMem = g_realloc((LPUINT)hMem - 2, uBytes + sizeof (UINT) * 2);
6909- if (!hMem)
6910- return NULL;
6911- if (((LPUINT)hMem)[1] < uBytes)
6912- g_memset ((guint8 *)hMem + sizeof (UINT) * 2 + ((LPUINT)hMem)[1], 0,
6913- uBytes - ((LPUINT)hMem)[1]);
6914- ((LPUINT)hMem)[1] = uBytes;
6915- return (LPUINT)hMem + 2;
6992+ return GlobalReAlloc (hMem, uBytes, uFlags);
69166993 }
69176994
69186995
@@ -6926,7 +7003,7 @@
69267003 /* LocalSize ordinal = 501, argument = 4 */
69277004 UINT WINAPI LocalSize (HLOCAL hMem)
69287005 {
6929- return hMem ? ((LPUINT)hMem)[-1] : 0;
7006+ return GlobalSize (hMem);
69307007 }
69317008
69327009
@@ -6933,7 +7010,7 @@
69337010 /* LocalUnlock ordinal = 502, argument = 4 */
69347011 UINT WINAPI LocalUnlock (HLOCAL hMem)
69357012 {
6936- return FALSE;
7013+ return GlobalUnlock (hMem);
69377014 }
69387015
69397016
@@ -9291,23 +9368,42 @@
92919368 /* VirtualAlloc ordinal = 757, argument = 16 */
92929369 LPVOID WINAPI VirtualAlloc (LPVOID lpAddress, DWORD dwSize, DWORD flAllocationType, DWORD flProtect)
92939370 {
9371+ gpointer result = NULL;
92949372 GList *glist;
9295- W32LdrVirtual *w32vir;
92969373
9374+#ifdef USE_THREAD
9375+ G_LOCK (critical);
9376+ critical = TRUE;
9377+#endif /* USE_THREAD */
92979378 for (glist = g_list_first (glist_virtual); glist;
92989379 glist = g_list_next (glist))
92999380 {
9381+ W32LdrVirtual *w32vir;
9382+
93009383 w32vir = glist->data;
93019384 if (GPOINTER_TO_UINT (w32vir->p) <= GPOINTER_TO_UINT (lpAddress)
93029385 && GPOINTER_TO_UINT (lpAddress) + dwSize
93039386 <= GPOINTER_TO_UINT (w32vir->p) + w32vir->len)
9304- return lpAddress;
9387+ {
9388+ result = lpAddress;
9389+ break;
9390+ }
93059391 }
9306- w32vir = g_malloc (sizeof (W32LdrVirtual));
9307- w32vir->p = g_malloc0 (dwSize);
9308- w32vir->len = dwSize;
9309- glist_virtual = g_list_append (glist_virtual, w32vir);
9310- return w32vir->p;
9392+ if (!result)
9393+ {
9394+ W32LdrVirtual *w32vir;
9395+
9396+ w32vir = g_malloc (sizeof (W32LdrVirtual));
9397+ w32vir->p = g_malloc0 (dwSize);
9398+ w32vir->len = dwSize;
9399+ glist_virtual = g_list_append (glist_virtual, w32vir);
9400+ result = w32vir->p;
9401+ }
9402+#ifdef USE_THREAD
9403+ critical = FALSE;
9404+ G_UNLOCK (critical);
9405+#endif /* USE_THREAD */
9406+ return result;
93119407 }
93129408
93139409
@@ -9328,12 +9424,19 @@
93289424 /* VirtualFree ordinal = 760, argument = 12 */
93299425 BOOL WINAPI VirtualFree (LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType)
93309426 {
9427+ gboolean result;
9428+
93319429 if (dwFreeType & MEM_RELEASE)
93329430 {
9431+ result = FALSE;
93339432 if (dwSize <= 0)
93349433 {
93359434 GList *glist;
93369435
9436+#ifdef USE_THREAD
9437+ G_LOCK (critical);
9438+ critical = TRUE;
9439+#endif /* USE_THREAD */
93379440 for (glist = g_list_first (glist_virtual); glist;
93389441 glist = g_list_next (glist))
93399442 {
@@ -9345,13 +9448,21 @@
93459448 glist_virtual = g_list_remove (glist_virtual, w32vir);
93469449 g_free (w32vir);
93479450 g_free (lpAddress);
9348- return TRUE;
9451+ result = TRUE;
9452+ break;
93499453 }
93509454 }
9455+#ifdef USE_THREAD
9456+ critical = FALSE;
9457+ G_UNLOCK (critical);
9458+#endif /* USE_THREAD */
93519459 }
9352- return FALSE;
93539460 }
9354- return TRUE;
9461+ else
9462+ {
9463+ result = TRUE;
9464+ }
9465+ return result;
93559466 }
93569467
93579468
--- vmaid/trunk/w32loader/image.h (revision 312)
+++ vmaid/trunk/w32loader/image.h (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 w32loader
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -32,9 +32,38 @@
3232 #define IMAGE_NT_SIGNATURE 0x00004550
3333
3434
35+/* ja:MS-DOSヘッダ */
36+typedef struct _IMAGE_DOS_HEADER
37+{
38+ WORD e_magic;
39+ WORD e_cblp;
40+ WORD e_cp;
41+ WORD e_crlc;
42+ WORD e_cparhdr;
43+ WORD e_minalloc;
44+ WORD e_maxalloc;
45+ WORD e_ss;
46+ WORD e_sp;
47+ WORD e_csum;
48+ WORD e_ip;
49+ WORD e_cs;
50+ WORD e_lfarlc;
51+ WORD e_ovno;
52+ WORD e_res[4];
53+ WORD e_oemid;
54+ WORD e_oeminfo;
55+ WORD e_res2[10];
56+ LONG e_lfanew;
57+} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
58+
59+
3560 /* ja:ファイルヘッダ */
3661 #define IMAGE_FILE_MACHINE_I386 0x014c
37-#define IMAGE_FILE_DLL 0x2000
62+#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
63+#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
64+#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
65+#define IMAGE_FILE_32BIT_MACHINE 0x0100
66+#define IMAGE_FILE_DLL 0x2000
3867 typedef struct _IMAGE_FILE_HEADER
3968 {
4069 WORD Machine;
@@ -58,6 +87,12 @@
5887 DWORD Size;
5988 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
6089 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
90+#define IMAGE_SUBSYSTEM_UNKNOWN 0
91+#define IMAGE_SUBSYSTEM_NATIVE 1
92+#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
93+#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
94+#define IMAGE_SUBSYSTEM_POSIX_CUI 7
95+#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
6196 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
6297 typedef struct _IMAGE_OPTIONAL_HEADER
6398 {
@@ -97,6 +132,17 @@
97132
98133 /* ja:セクションヘッダ */
99134 #define IMAGE_SIZEOF_SHORT_NAME 8
135+#define IMAGE_SCN_CNT_CODE 0x00000020
136+#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
137+#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
138+#define IMAGE_SCN_LNK_OVFL 0x01000000
139+#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
140+#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
141+#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
142+#define IMAGE_SCN_MEM_SHARED 0x10000000
143+#define IMAGE_SCN_MEM_EXECUTE 0x20000000
144+#define IMAGE_SCN_MEM_READ 0x40000000
145+#define IMAGE_SCN_MEM_WRITE 0x80000000
100146 typedef struct _IMAGE_SECTION_HEADER
101147 {
102148 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
--- vmaid/trunk/w32loader/w32tool.c (revision 312)
+++ vmaid/trunk/w32loader/w32tool.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 w32loader
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "w32private.h"
2019 #include "commctrl.h"
@@ -820,17 +819,12 @@
820819 w32tool_destroy (GtkWidget *widget,
821820 gpointer user_data)
822821 {
823- GList *glist;
824822 W32LdrToolData *td;
825823
826824 td = g_object_get_data (G_OBJECT (widget), "user_data");
827- for (glist = g_list_first (td->glist_pixbuf); glist;
828- glist = g_list_next (glist))
829- g_object_unref (G_OBJECT (glist->data));
825+ g_list_foreach (td->glist_pixbuf, (GFunc)g_object_unref, NULL);
830826 g_list_free (td->glist_pixbuf);
831- for (glist = g_list_first (td->glist_string); glist;
832- glist = g_list_next (glist))
833- g_free (glist->data);
827+ g_list_foreach (td->glist_string, (GFunc)g_free, NULL);
834828 g_list_free (td->glist_string);
835829 }
836830
--- vmaid/trunk/w32loader/makew32ldrheader.pl (revision 312)
+++ vmaid/trunk/w32loader/makew32ldrheader.pl (revision 313)
@@ -1,7 +1,7 @@
11 #!/usr/bin/perl
22 #
33 # w32loader
4-# copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
4+# copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
55 #
66 # This program is free software: you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
@@ -18,14 +18,14 @@
1818
1919 foreach (<STDIN>) {
2020 chomp;
21- if (not $macro and /^#include "(\w+)\.h"$/) {
21+ if (not $macro and /^#include\s+"(\w+)\.h"$/) {
2222 $export="$1_exports";
2323 $macro="__$1_H__";
2424 $macro=~tr/a-z/A-Z/;
25- } elsif (/#ifdef\s+W32LDR_HEADER/) {
25+ } elsif (/#ifdef\s+W32LDR_HEADER$/) {
2626 $header=1;
2727 } elsif (/#endif\s*\/\*\s+W32LDR_HEADER\s+\*\/$/) {
28- $header=0;
28+ undef $header;
2929 } elsif ($header) {
3030 $head.="$_\n";
3131 } elsif (/^\s*\/\*\s+(\w+)\s+ordinal\s*=\s*\d+,\s*argument\s*=\s*\d+\s+\*\/\s*$/) {
@@ -32,17 +32,35 @@
3232 $name=$1;
3333 } elsif ($name) {
3434 if (not /^\s*static\s+/) {
35- $func[$n_func]{name}=$name;
36- $func[$n_func]{proc}=$_;
37- $n_func++;
35+ exit -1 if $proto{$name};
36+ push @api,$name;
37+ $proto{$name}=$_;
3838 }
3939 undef $name;
4040 }
4141 }
42+exit -1 if not $macro or $header or $name;
43+for (my $i=$#api;$i>=0;$i--) {
44+ if ($proto{"$api[$i]A"} and $proto{"$api[$i]W"}) {
45+ delete $proto{$api[$i]};
46+ splice @api,$i,1;
47+ }
48+}
49+for (my $i=0;$i<@api;$i++) {
50+ if ($api[$i]=~/^(\w+)(A|W)$/) {
51+ for (my $j=$i+1;$j<@api;$j++) {
52+ if ($api[$j] eq "$1A" or $api[$j] eq "$1W") {
53+ push @define,$1;
54+ last;
55+ }
56+ }
57+ }
58+}
59+$year=(localtime)[5]+1900;
4260 print <<EOF;
4361 /*
4462 w32loader
45- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm\@maid.org
63+ copyright (c) 1998-$year Kazuki IWAMOTO http://www.maid.org/ iwm\@maid.org
4664
4765 This program is free software: you can redistribute it and/or modify
4866 it under the terms of the GNU General Public License as published by
@@ -68,39 +86,30 @@
6886
6987
7088 EOF
89+undef $year;
7190 print "$head\n\n" if $head;
7291 print "extern W32LdrExport $export\[\];\n";
73-print "\n\n" if $n_func;
74-for ($i=0;$i<$n_func;$i++) {
75- for ($j=0;$j<$n_func;$j++) {
76- if ("$func[$i]{name}A" eq $func[$j]{name}) {
77- delete $func[$i]{name};
78- last;
79- }
92+if (@api) {
93+ print "\n\n";
94+ foreach (@api) {
95+ print $proto{$_};
96+ print ';' unless $proto{$_}=~/^\s*\/\*.*?\*\/\s*$/;
97+ print "\n";
8098 }
81- if ($func[$i]{name}) {
82- if ($func[$i]{proc}=~/^\s*\/\*.*?\*\/\s*$/) {
83- print "$func[$i]{proc}\n";
84- } else {
85- print "$func[$i]{proc};\n";
86- }
87- }
88- if ($func[$i]{name}=~/^(\w+)(A|W)$/) {
89- for ($j=$i+1;$j<$n_func;$j++) {
90- $define[$n_define++]=$1 if $2 eq 'A' and $func[$j]{name} eq "$1W" or $2 eq 'W' and $func[$j]{name} eq "$1A";
91- }
92- }
99+ undef @api;
100+ undef %proto;
93101 }
94-if ($n_define) {
102+if (@define) {
95103 print "\n\n#ifdef UNICODE\n";
96- for ($i=0;$i<$n_define;$i++) {
97- print "# define $define[$i] $define[$i]W\n";
104+ foreach (@define) {
105+ print "# define $_ ${_}W\n";
98106 }
99107 print "#else /* not UNICODE*/\n";
100- for ($i=0;$i<$n_define;$i++) {
101- print "# define $define[$i] $define[$i]A\n";
108+ foreach (@define) {
109+ print "# define $_ ${_}A\n";
102110 }
103111 print "#endif /* not UNICODE */\n";
112+ undef @define;
104113 }
105114 print <<EOF;
106115
--- vmaid/trunk/w32loader/user32.c (revision 312)
+++ vmaid/trunk/w32loader/user32.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 w32loader
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "user32.h"
2019 #include "kernel32.h"
@@ -2977,7 +2976,7 @@
29772976 glist = g_list_next (glist))
29782977 if (!lpEnumFunc (glist->data, lParam))
29792978 break;
2980- g_list_foreach (glist_toplevels, (GFunc)g_object_ref, NULL);
2979+ g_list_foreach (glist_toplevels, (GFunc)g_object_unref, NULL);
29812980 g_list_free (glist_toplevels);
29822981 }
29832982 return TRUE;
@@ -4803,16 +4802,16 @@
48034802 utf8str = g_utf16_to_utf8 (lpszNewItem, -1, NULL, NULL, NULL);
48044803 if (utf8str)
48054804 {
4806- gint i;
48074805 GList *glist;
48084806 GtkWidget *label = NULL;
48094807
48104808 glist = gtk_container_get_children
48114809 (GTK_CONTAINER (menu_item));
4812- for (i = 0; i < g_list_length (glist); i++)
4813- if (GTK_IS_LABEL (g_list_nth_data (glist, i)))
4810+ for (glist = g_list_first (glist);
4811+ glist; glist = g_list_delete_link (glist, glist))
4812+ if (GTK_IS_LABEL (glist->data))
48144813 {
4815- label = g_list_nth_data (glist, i);
4814+ label = glist->data;
48164815 break;
48174816 }
48184817 g_list_free (glist);
@@ -4819,7 +4818,7 @@
48194818 if (label)
48204819 {
48214820 gchar *title;
4822- gint j = 0;
4821+ gint i, j = 0;
48234822
48244823 title = g_malloc ((g_strlen (utf8str) * 2 + 1)
48254824 * sizeof (gchar));
@@ -7249,16 +7248,16 @@
72497248 }
72507249 if (utf8str)
72517250 {
7252- gint i;
72537251 GList *glist;
72547252 GtkWidget *label = NULL;
72557253
72567254 glist = gtk_container_get_children
72577255 (GTK_CONTAINER (menu_item));
7258- for (i = 0; i < g_list_length (glist); i++)
7259- if (GTK_IS_LABEL (g_list_nth_data (glist, i)))
7256+ for (glist = g_list_first (glist);
7257+ glist; glist = g_list_delete_link (glist, glist))
7258+ if (GTK_IS_LABEL (glist->data))
72607259 {
7261- label = g_list_nth_data (glist, i);
7260+ label = glist->data;
72627261 break;
72637262 }
72647263 g_list_free (glist);
@@ -7265,7 +7264,7 @@
72657264 if (label)
72667265 {
72677266 gchar *title;
7268- gint j = 0;
7267+ gint i, j = 0;
72697268
72707269 title = g_malloc ((g_strlen (utf8str) * 2 + 1)
72717270 * sizeof (gchar));
@@ -7397,16 +7396,16 @@
73977396 }
73987397 if (utf8str)
73997398 {
7400- gint i;
74017399 GList *glist;
74027400 GtkWidget *label = NULL;
74037401
74047402 glist = gtk_container_get_children
74057403 (GTK_CONTAINER (menu_item));
7406- for (i = 0; i < g_list_length (glist); i++)
7407- if (GTK_IS_LABEL (g_list_nth_data (glist, i)))
7404+ for (glist = g_list_first (glist);
7405+ glist; glist = g_list_delete_link (glist, glist))
7406+ if (GTK_IS_LABEL (glist->data))
74087407 {
7409- label = g_list_nth_data (glist, i);
7408+ label = glist->data;
74107409 break;
74117410 }
74127411 g_list_free (glist);
@@ -7413,7 +7412,7 @@
74137412 if (label)
74147413 {
74157414 gchar *title;
7416- gint j = 0;
7415+ gint i, j = 0;
74177416
74187417 title = g_malloc ((g_strlen (utf8str) * 2 + 1)
74197418 * sizeof (gchar));
--- vmaid/trunk/w32loader/advapi32.c (revision 312)
+++ vmaid/trunk/w32loader/advapi32.c (revision 313)
@@ -1,10 +1,10 @@
11 /*
22 w32loader
3- copyright (c) 1998-2007 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
5- This program is free software; you can redistribute it and/or modify
5+ This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 2 of the License, or
7+ the Free Software Foundation, either version 3 of the License, or
88 (at your option) any later version.
99
1010 This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
1313 GNU General Public License for more details.
1414
1515 You should have received a copy of the GNU General Public License
16- along with this program; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1817 */
1918 #include "advapi32.h"
2019 #include "kernel32.h"
@@ -3244,14 +3243,11 @@
32443243 p = g_strchr (utf8str, '\\');
32453244 if (p)
32463245 *p = '\0';
3247- for (j = g_list_length (glist) - 1; j >= 0; j--)
3248- if (g_ascii_strcasecmp (g_list_nth_data (glist, j),
3249- utf8str) == 0)
3250- break;
3251- if (j < 0)
3246+ if (g_list_find_custom (glist, utf8str,
3247+ (GCompareFunc)g_ascii_strcasecmp))
3248+ g_free (utf8str);
3249+ else
32523250 glist = g_list_append (glist, utf8str);
3253- else
3254- g_free (utf8str);
32553251 }
32563252 g_free (tmp);
32573253 g_strfreev (groups);
@@ -3264,7 +3260,6 @@
32643260 /* RegEnumKeyExA ordinal = 409, argument = 32 */
32653261 LONG WINAPI RegEnumKeyExA (HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
32663262 {
3267- gint i;
32683263 GList *glist;
32693264 LONG lResult = ERROR_NO_MORE_ITEMS;
32703265
@@ -3288,8 +3283,7 @@
32883283 }
32893284 g_free (mb);
32903285 }
3291- for (i = g_list_length (glist) - 1; i >= 0; i--)
3292- g_free (g_list_nth_data (glist, i));
3286+ g_list_foreach (glist, (GFunc)g_free, NULL);
32933287 g_list_free (glist);
32943288 return lResult;
32953289 }
@@ -3298,7 +3292,6 @@
32983292 /* RegEnumKeyExW ordinal = 410, argument = 32 */
32993293 LONG WINAPI RegEnumKeyExW (HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcName, LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
33003294 {
3301- gint i;
33023295 GList *glist;
33033296 LONG lResult = ERROR_NO_MORE_ITEMS;
33043297
@@ -3323,8 +3316,7 @@
33233316 }
33243317 g_free (wc);
33253318 }
3326- for (i = g_list_length (glist) - 1; i >= 0; i--)
3327- g_free (g_list_nth_data (glist, i));
3319+ g_list_foreach (glist, (GFunc)g_free, NULL);
33283320 g_list_free (glist);
33293321 return lResult;
33303322 }
@@ -3376,17 +3368,11 @@
33763368 name = advapi32_reg_name_from_key (keys[k]);
33773369 if (name)
33783370 {
3379- gint l;
3380-
3381- for (l = g_list_length (glist) - 1; l >= 0; l--)
3382- if (g_ascii_strcasecmp
3383- (g_list_nth_data (glist, l), name) == 0)
3384- break;
3385- if (l < 0)
3371+ if (g_list_find_custom (glist, name,
3372+ (GCompareFunc)g_ascii_strcasecmp))
3373+ g_free (name);
3374+ else
33863375 glist = g_list_append (glist, name);
3387- else
3388- g_free (name);
3389-
33903376 }
33913377 }
33923378 g_strfreev (keys);
@@ -3403,7 +3389,6 @@
34033389 /* RegEnumValueA ordinal = 412, argument = 32 */
34043390 LONG WINAPI RegEnumValueA (HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
34053391 {
3406- gint i;
34073392 GList *glist = NULL;
34083393 LONG lResult = ERROR_NO_MORE_ITEMS;
34093394
@@ -3426,8 +3411,7 @@
34263411 }
34273412 g_free (mb);
34283413 }
3429- for (i = g_list_length (glist) - 1; i >= 0; i--)
3430- g_free (g_list_nth_data (glist, i));
3414+ g_list_foreach (glist, (GFunc)g_free, NULL);
34313415 g_list_free (glist);
34323416 return lResult;
34333417 }
@@ -3436,7 +3420,6 @@
34363420 /* RegEnumValueW ordinal = 413, argument = 32 */
34373421 LONG WINAPI RegEnumValueW (HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
34383422 {
3439- gint i;
34403423 GList *glist = NULL;
34413424 LONG lResult = ERROR_NO_MORE_ITEMS;
34423425
@@ -3460,8 +3443,7 @@
34603443 }
34613444 g_free (wc);
34623445 }
3463- for (i = g_list_length (glist) - 1; i >= 0; i--)
3464- g_free (g_list_nth_data (glist, i));
3446+ g_list_foreach (glist, (GFunc)g_free, NULL);
34653447 g_list_free (glist);
34663448 return lResult;
34673449 }
--- vmaid/trunk/configure.ac (revision 312)
+++ vmaid/trunk/configure.ac (revision 313)
@@ -5,7 +5,7 @@
55 dnl version number
66 MAJOR_VERSION=2
77 MINOR_VERSION=2
8-MICRO_VERSION=1
8+MICRO_VERSION=2
99 EXTRA_VERSION=
1010 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
1111
--- vmaid/trunk/orz/orzaccel.c (revision 312)
+++ vmaid/trunk/orz/orzaccel.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 orzaccel
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -65,10 +65,7 @@
6565 }
6666 if (accel->gslist)
6767 {
68- GSList *gslist;
69-
70- for (gslist = accel->gslist; gslist; gslist = gslist->next)
71- g_object_unref (gslist->data);
68+ g_slist_foreach (accel->gslist, (GFunc)g_object_unref, NULL);
7269 g_slist_free (accel->gslist);
7370 accel->gslist = NULL;
7471 }
--- vmaid/trunk/orz/orzmdi.c (revision 312)
+++ vmaid/trunk/orz/orzmdi.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 orzmdi
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -98,8 +98,7 @@
9898 file_add_edit (OrzMdi *mdi,
9999 OrzMdiTab *tab0)
100100 {
101- gint i;
102- GList *glist;
101+ GList *gl, *glist;
103102 OrzMdiTab *tab1;
104103
105104 tab0->same = -2;
@@ -106,10 +105,10 @@
106105 /* ja:ファイル名を調べる */
107106 glist = gtk_container_get_children (GTK_CONTAINER (mdi));
108107 /* ja:同名同パスを調べる */
109- for (i = g_list_length (glist) - 1; i >= 0; i--)
108+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
110109 {
111110 tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
112- (GTK_NOTEBOOK (mdi), g_list_nth_data (glist, i))), "user_data");
111+ (GTK_NOTEBOOK (mdi), gl->data)), "user_data");
113112 if (tab1 && tab0 != tab1 && g_strfilecmp (tab0->file, tab1->file) == 0)
114113 {
115114 if (tab1->same < 0)
@@ -128,10 +127,10 @@
128127 /* ja:同名同パスはないとき */
129128 /* ja:同名異パスを調べる */
130129 name0 = g_path_get_basename (tab0->file);
131- for (i = g_list_length (glist) - 1; i >= 0; i--)
130+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
132131 {
133132 tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
134- (GTK_NOTEBOOK (mdi), g_list_nth_data (glist, i))), "user_data");
133+ (GTK_NOTEBOOK (mdi), gl->data)), "user_data");
135134 if (tab1 && tab0 != tab1)
136135 {
137136 gchar *name1;
@@ -151,7 +150,7 @@
151150 }
152151 }
153152 g_free (name0);
154- if (i >= 0)
153+ if (gl)
155154 tab0->same = -1;
156155 }
157156 g_list_free (glist);
@@ -163,18 +162,18 @@
163162 OrzMdiTab *tab0,
164163 const gchar *file)
165164 {
166- gint i, count0 = 0, count1 = 0;
165+ gint count0 = 0, count1 = 0;
167166 gchar *name0, *name1;
168- GList *glist;
167+ GList *gl, *glist;
169168 OrzMdiTab *tab1;
170169
171170 /* ja:ファイル名を調べる */
172171 glist = gtk_container_get_children (GTK_CONTAINER (mdi));
173172 name0 = g_path_get_basename (tab0->file);
174- for (i = g_list_length (glist) - 1; i >= 0; i--)
173+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
175174 {
176175 tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
177- (GTK_NOTEBOOK (mdi), g_list_nth_data (glist, i))), "user_data");
176+ (GTK_NOTEBOOK (mdi), gl->data)), "user_data");
178177 if (tab1 && tab0 != tab1)
179178 {
180179 /* ja:同名同パスを調べる */
@@ -194,12 +193,11 @@
194193 name2 = file ? g_path_get_basename (file) : NULL;
195194 if (!name2 || g_strfilecmp (name0, name2) != 0)
196195 /* 名前が変わっているとき */
197- for (i = g_list_length (glist) - 1; i >= 0; i--)
196+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
198197 {
199198 /* ja:同名のファイルを通常表示に変更する */
200199 tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
201- (GTK_NOTEBOOK (mdi), g_list_nth_data (glist, i))),
202- "user_data");
200+ (GTK_NOTEBOOK (mdi), gl->data)), "user_data");
203201 if (tab1 && tab0 != tab1)
204202 {
205203 /* ja:同名を調べる */
@@ -215,18 +213,21 @@
215213 g_free (name2);
216214 }
217215 else if (count0 == 1)/* ja:同名同パスが1つだけある(異パスは複数)とき */
218- for (i = g_list_length (glist) - 1; i >= 0; i--)
219- {
220- /* ja:同名同パスのファイルをフルパスに変更する */
221- tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
222- (GTK_NOTEBOOK (mdi), g_list_nth_data (glist, i))), "user_data");
223- /* ja:同名同パスを調べる */
224- if (tab1 && tab0 != tab1 && g_strfilecmp (tab0->file, tab1->file) == 0)
225- {
226- tab1->same = -1;
227- orz_mdi_label_markup (tab1);
228- }
229- }
216+ {
217+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
218+ {
219+ /* ja:同名同パスのファイルをフルパスに変更する */
220+ tab1 = g_object_get_data (G_OBJECT (gtk_notebook_get_tab_label
221+ (GTK_NOTEBOOK (mdi), gl->data)), "user_data");
222+ /* ja:同名同パスを調べる */
223+ if (tab1 && tab0 != tab1
224+ && g_strfilecmp (tab0->file, tab1->file) == 0)
225+ {
226+ tab1->same = -1;
227+ orz_mdi_label_markup (tab1);
228+ }
229+ }
230+ }
230231 g_free (name0);
231232 g_list_free (glist);
232233 }
--- vmaid/trunk/orz/orzcomm.c (revision 312)
+++ vmaid/trunk/orz/orzcomm.c (revision 313)
@@ -152,18 +152,17 @@
152152 DWORD dwData1,
153153 DWORD dwData2)
154154 {
155- guint i, length;
155+ GList *gl;
156156
157157 # ifdef USE_THREAD
158158 G_LOCK (critical);
159159 critical = TRUE;
160160 # endif /* USE_THREAD */
161- length = g_list_length (glist);
162- for (i = 0; i < length; i++)
161+ for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
163162 {
164163 OrzComm *comm;
165164
166- comm = g_list_nth_data (glist, i);
165+ comm = g->data;
167166 if (!comm)
168167 break;
169168 switch (uType)
--- vmaid/trunk/orz/orzhistory.c (revision 312)
+++ vmaid/trunk/orz/orzhistory.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 orzhistory
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -347,15 +347,10 @@
347347
348348 if (history)
349349 {
350- gint i;
350+ GList *gl;
351351
352- for (i = g_list_length (history->glist) - 1; i >= 0; i--)
353- {
354- OrzHistoryItem *history_item;
355-
356- history_item = g_list_nth_data (history->glist, i);
357- glist = g_list_prepend (glist, history_item->file);
358- }
352+ for (gl = g_list_first (history->glist); gl; gl = g_list_next (gl))
353+ glist = g_list_append (glist, ((OrzHistoryItem *)gl->data)->file);
359354 }
360355 return glist;
361356 }
@@ -382,10 +377,10 @@
382377 {
383378 if (history)
384379 {
385- gint i;
386-
387380 if (history->menu_shell)
388381 {
382+ GList *glist;
383+
389384 if (history->handler_destroy)
390385 {
391386 g_signal_handler_disconnect (G_OBJECT (history->menu_shell),
@@ -392,22 +387,17 @@
392387 history->handler_destroy);
393388 history->handler_destroy = 0;
394389 }
395- if (history->glist)
396- for (i = g_list_length (history->glist) - 1; i >= 0; i--)
397- {
398- OrzHistoryItem *history_item;
399-
400- history_item = g_list_nth_data (history->glist, i);
401- if (history_item->menu_item)
402- gtk_container_remove (GTK_CONTAINER (history->menu_shell),
403- history_item->menu_item);
404- }
390+ for (glist = g_list_first (history->glist);
391+ glist; glist = g_list_next (glist))
392+ if (((OrzHistoryItem *)glist->data)->menu_item)
393+ gtk_container_remove (GTK_CONTAINER (history->menu_shell),
394+ ((OrzHistoryItem *)glist->data)->menu_item);
405395 }
406396 history->menu_shell = menu_shell;
407397 history->position = position;
408398 if (history->menu_shell)
409399 {
410- GList *glist;
400+ GList *gl, *glist;
411401
412402 history->handler_destroy
413403 = g_signal_connect (G_OBJECT (menu_shell), "destroy",
@@ -414,11 +404,11 @@
414404 G_CALLBACK (orz_history_destroy_menu_shell), history);
415405 glist = history->glist;
416406 history->glist = NULL;
417- for (i = g_list_length (glist) - 1; i >= 0; i--)
407+ for (gl = g_list_last (glist); gl; gl = g_list_previous (gl))
418408 {
419409 OrzHistoryItem *history_item;
420410
421- history_item = g_list_nth_data (glist, i);
411+ history_item = gl->data;
422412 orz_history_add_file (history, history_item->file);
423413 g_free (history_item->file);
424414 g_free (history_item);
--- vmaid/trunk/orz/orzwinmenu.c (revision 312)
+++ vmaid/trunk/orz/orzwinmenu.c (revision 313)
@@ -1,6 +1,6 @@
11 /*
22 orzwinmenu
3- copyright (c) 1998-2008 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2009 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -171,7 +171,7 @@
171171 if (winmenu && winmenu->mdi == mdi && winmenu->menu_shell && winmenu->glist)
172172 {
173173 gchar *label;
174- gint i;
174+ GList *glist;
175175 GtkWidget *child;
176176
177177 child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (mdi), page_num);
@@ -181,15 +181,11 @@
181181 label = g_filename_to_utf8 (orz_mdi_get_file (mdi, page_num), -1,
182182 NULL, NULL, NULL);
183183 #endif /* not GLIB_CHECK_VERSION(2,6,0) */
184- for (i = g_list_length (winmenu->glist) - 1; i >= 0; i--)
185- {
186- GtkWidget *menu_item;
187-
188- menu_item = g_list_nth_data (winmenu->glist, i);
189- if (g_object_get_data (G_OBJECT (menu_item), "user_data") == child)
190- gtk_label_set_text (GTK_LABEL (gtk_bin_get_child
191- (GTK_BIN (menu_item))), label);
192- }
184+ for (glist = g_list_first (winmenu->glist);
185+ glist; glist = g_list_next (glist))
186+ if (g_object_get_data (G_OBJECT (glist->data), "user_data") == child)
187+ gtk_label_set_text (GTK_LABEL (gtk_bin_get_child
188+ (GTK_BIN (glist->data))), label);
193189 g_free (label);
194190 }
195191 }
@@ -203,13 +199,14 @@
203199 {
204200 if (winmenu && winmenu->mdi == mdi && winmenu->menu_shell && winmenu->glist)
205201 {
206- gint i;
202+ GList *glist;
207203 GtkWidget *child, *menu_item;
208204
209205 child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (mdi), page_num);
210- for (i = g_list_length (winmenu->glist) - 1; i >= 0; i--)
206+ for (glist = g_list_first (winmenu->glist);
207+ glist; glist = g_list_next (glist))
211208 {
212- menu_item = g_list_nth_data (winmenu->glist, i);
209+ menu_item = glist->data;
213210 if (g_object_get_data (G_OBJECT (menu_item), "user_data") == child)
214211 {
215212 g_object_ref (G_OBJECT (menu_item));
@@ -219,10 +216,9 @@
219216 break;
220217 }
221218 }
222- if (i >= 0)
219+ if (glist)
223220 {
224- gint length, position;
225- GList *glist;
221+ gint i, length, position;
226222
227223 glist = gtk_container_get_children
228224 (GTK_CONTAINER (winmenu->menu_shell));
@@ -263,13 +259,16 @@
263259 {
264260 if (winmenu && winmenu->mdi == mdi && winmenu->menu_shell && winmenu->glist)
265261 {
266- gint i;
267- GtkWidget *child, *menu_item;
262+ GList *glist;
263+ GtkWidget *child;
268264
269265 child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (mdi), page_num);
270- for (i = g_list_length (winmenu->glist) - 1; i >= 0; i--)
266+ for (glist = g_list_first (winmenu->glist);
267+ glist; glist = g_list_next (glist))
271268 {
272- menu_item = g_list_nth_data (winmenu->glist, i);
269+ GtkWidget *menu_item;
270+
271+ menu_item = glist->data;
273272 if (g_object_get_data (G_OBJECT (menu_item), "user_data") == child)
274273 {
275274 gtk_container_remove (GTK_CONTAINER (winmenu->menu_shell),
@@ -294,12 +293,12 @@
294293 }
295294 if (GTK_IS_MENU (winmenu->menu_shell))
296295 {
297- GList *glist;
298-
299296 glist = gtk_container_get_children
300297 (GTK_CONTAINER (winmenu->menu_shell));
301298 if (g_list_length (glist) <= 0)
302299 {
300+ GtkWidget *menu_item;
301+
303302 menu_item = gtk_menu_get_attach_widget
304303 (GTK_MENU (winmenu->menu_shell));
305304 if (menu_item)
@@ -320,22 +319,20 @@
320319 {
321320 if (winmenu && winmenu->mdi == mdi && winmenu->menu_shell && winmenu->glist)
322321 {
323- gint i;
324- GtkWidget *child, *menu_item;
322+ GList *glist;
323+ GtkWidget *child;
325324
326325 child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (mdi), page_num);
327- for (i = g_list_length (winmenu->glist) - 1; i >= 0; i--)
328- {
329- menu_item = g_list_nth_data (winmenu->glist, i);
330- if (g_object_get_data (G_OBJECT (menu_item), "user_data") == child)
331- {
332- g_object_set_data (G_OBJECT (menu_item), "user_data", NULL);
333- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
334- TRUE);
335- g_object_set_data (G_OBJECT (menu_item), "user_data", child);
336- break;
337- }
338- }
326+ for (glist = g_list_first (winmenu->glist);
327+ glist; glist = g_list_next (glist))
328+ if (g_object_get_data (G_OBJECT (glist->data), "user_data") == child)
329+ {
330+ g_object_set_data (G_OBJECT (glist->data), "user_data", NULL);
331+ gtk_check_menu_item_set_active
332+ (GTK_CHECK_MENU_ITEM (glist->data), TRUE);
333+ g_object_set_data (G_OBJECT (glist->data), "user_data", child);
334+ break;
335+ }
339336 }
340337 }
341338
Show on old repository browser