Huw Davies : wineps: Move the installed font list to a standard list.

Alexandre Julliard julliard at winehq.org
Wed Apr 11 12:56:46 CDT 2012


Module: wine
Branch: master
Commit: 4ff9b7f11a92091c0485504f1a750e9b37844064
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4ff9b7f11a92091c0485504f1a750e9b37844064

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Apr 11 12:36:14 2012 +0100

wineps: Move the installed font list to a standard list.

---

 dlls/wineps.drv/init.c  |    3 ++-
 dlls/wineps.drv/ppd.c   |   32 ++++++++++++--------------------
 dlls/wineps.drv/psdrv.h |    7 ++++---
 3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c
index 0c06ecb..affbcbc 100644
--- a/dlls/wineps.drv/init.c
+++ b/dlls/wineps.drv/init.c
@@ -773,7 +773,8 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
 
     pi->Fonts = NULL;
 
-    for(font = pi->ppd->InstalledFonts; font; font = font->next) {
+    LIST_FOR_EACH_ENTRY( font, &pi->ppd->InstalledFonts, FONTNAME, entry )
+    {
         afm = PSDRV_FindAFMinList(PSDRV_AFMFontList, font->Name);
 	if(!afm) {
 	    TRACE( "Couldn't find AFM file for installed printer font '%s' - "
diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c
index c2c422d..3f2c473 100644
--- a/dlls/wineps.drv/ppd.c
+++ b/dlls/wineps.drv/ppd.c
@@ -631,7 +631,9 @@ PPD *PSDRV_ParsePPD(char *fname)
     }
 
     ppd->ColorDevice = CD_NotSpecified;
-    list_init(&ppd->PageSizes);
+
+    list_init( &ppd->InstalledFonts );
+    list_init( &ppd->PageSizes );
 
     /*
      *	The Windows PostScript drivers create the following "virtual bin" for
@@ -678,23 +680,13 @@ PPD *PSDRV_ParsePPD(char *fname)
                 WARN("failed to parse DefaultResolution %s\n", debugstr_a(tuple.value));
 	}
 
-	else if(!strcmp("*Font", tuple.key)) {
-	    FONTNAME *fn;
-
-	    for(fn = ppd->InstalledFonts; fn && fn->next; fn = fn->next)
-	        ;
-	    if(!fn) {
-	        ppd->InstalledFonts = HeapAlloc(PSDRV_Heap,
-					       HEAP_ZERO_MEMORY, sizeof(*fn));
-		fn = ppd->InstalledFonts;
-	    } else {
-	       fn->next = HeapAlloc(PSDRV_Heap,
-					       HEAP_ZERO_MEMORY, sizeof(*fn));
-	       fn = fn->next;
-	    }
-	    fn->Name = tuple.option;
-	    tuple.option = NULL;
-	}
+        else if(!strcmp("*Font", tuple.key))
+        {
+            FONTNAME *fn = HeapAlloc( PSDRV_Heap, 0, sizeof(*fn) );
+            fn->Name = tuple.option;
+            tuple.option = NULL;
+            list_add_tail( &ppd->InstalledFonts, &fn->entry );
+        }
 
 	else if(!strcmp("*DefaultFont", tuple.key)) {
 	    ppd->DefaultFont = tuple.value;
@@ -985,8 +977,8 @@ PPD *PSDRV_ParsePPD(char *fname)
 	OPTION *option;
 	OPTIONENTRY *optionEntry;
 
-	for(fn = ppd->InstalledFonts; fn; fn = fn->next)
-	    TRACE("'%s'\n", fn->Name);
+        LIST_FOR_EACH_ENTRY( fn, &ppd->InstalledFonts, FONTNAME, entry )
+            TRACE("'%s'\n", fn->Name);
 
 	LIST_FOR_EACH_ENTRY(page, &ppd->PageSizes, PAGESIZE, entry) {
 	    TRACE("'%s' aka '%s' (%d) invoked by '%s'\n", page->Name,
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index df86c70..a4ac759 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -118,9 +118,10 @@ typedef struct _tagFONTFAMILY {
 extern FONTFAMILY   *PSDRV_AFMFontList DECLSPEC_HIDDEN;
 extern const AFM    *const PSDRV_BuiltinAFMs[] DECLSPEC_HIDDEN;     /* last element is NULL */
 
-typedef struct _tagFONTNAME {
+typedef struct
+{
+    struct list          entry;
     char		*Name;
-    struct _tagFONTNAME *next;
 } FONTNAME;
 
 typedef struct {
@@ -213,7 +214,7 @@ typedef struct {
     char		*JCLToPSInterpreter;
     char		*JCLEnd;
     char		*DefaultFont;
-    FONTNAME		*InstalledFonts; /* ptr to a list of FontNames */
+    struct list         InstalledFonts;
     struct list         PageSizes;
     PAGESIZE            *DefaultPageSize;
     OPTION		*InstalledOptions;




More information about the wine-cvs mailing list