From a9b0a055c82ca7f8afd510f8719c3418f336c976 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Oct 2006 02:00:37 +0000 Subject: Moved get_resource_id_quoted around a bit and added another FIXME comment svn-id: r24328 --- engines/scumm/he/resource_he.cpp | 29 ++++++++++++++++------------- engines/scumm/he/resource_he.h | 3 ++- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index 1ac91c9516..de566ac928 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -245,6 +245,20 @@ const char *Win32ResExtractor::res_type_string_to_id(const char *type) { return type; } +/* return the resource id quoted if it's a string, otherwise just return it */ +char *Win32ResExtractor::WinResource::get_resource_id_quoted() { + // FIXME: Using a static var here is EVIL and in fact, broken when + // used multiple times in a row, e.g. in a single call to printf() + // or debug()... which is in fact how we use this function... :-) + static char tmp[WINRES_ID_MAXLEN+2]; + + if (numeric_id || id[0] == '\0') + return id; + + sprintf(tmp, "'%s'", id); + return tmp; +} + int Win32ResExtractor::extract_resources(WinLibrary *fi, WinResource *wr, WinResource *type_wr, WinResource *name_wr, WinResource *lang_wr, byte **data) { @@ -271,9 +285,9 @@ int Win32ResExtractor::extract_resources(WinLibrary *fi, WinResource *wr, type = res_type_id_to_string(id); debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s%s%s [size=%d]", - get_resource_id_quoted(name_wr), + name_wr->get_resource_id_quoted(), (lang_wr->id[0] != '\0' ? " language: " : ""), - get_resource_id_quoted(lang_wr), size); + lang_wr->get_resource_id_quoted(), size); return size; } @@ -536,17 +550,6 @@ int Win32ResExtractor::do_resources_recurs(WinLibrary *fi, WinResource *base, return size; } -/* return the resource id quoted if it's a string, otherwise just return it */ -char *Win32ResExtractor::get_resource_id_quoted(WinResource *wr) { - static char tmp[WINRES_ID_MAXLEN+2]; - - if (wr->numeric_id || wr->id[0] == '\0') - return wr->id; - - sprintf(tmp, "'%s'", wr->id); - return tmp; -} - bool Win32ResExtractor::compare_resource_id(WinResource *wr, const char *id) { if (wr->numeric_id) { int32 cmp1, cmp2; diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h index 634d5d9494..768e7b1fff 100644 --- a/engines/scumm/he/resource_he.h +++ b/engines/scumm/he/resource_he.h @@ -189,6 +189,8 @@ class Win32ResExtractor : public ResExtractor { int level; bool numeric_id; bool is_directory; + + char *get_resource_id_quoted(); }; @@ -482,7 +484,6 @@ class Win32ResExtractor : public ResExtractor { WinResource *list_pe_resources(WinLibrary *, Win32ImageResourceDirectory *, int, int *); int calc_vma_size(WinLibrary *); int do_resources_recurs(WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *, const char *, char *, char *, int, byte **); - char *get_resource_id_quoted(WinResource *); WinResource *find_with_resource_array(WinLibrary *, WinResource *, const char *); bool check_offset(byte *, int, const char *, void *, int); -- cgit v1.2.3