ppd parsing fix

Huw D M Davies h.davies1 at physics.ox.ac.uk
Wed Feb 7 05:59:22 CST 2001


This one also includes Marcus's "Manual" -> DMBIN_MANUAL patch.

	Huw D M Davies <hdavies at codeweavers.com>
	Spaces do not have to come after the ':' that ends a keyword.
	Map bin name ManualEnv to DMBIN_ENVMANUAL.
-- 
   Dr. Huw D M Davies              | Clarendon Laboratory
   h.davies1 at physics.ox.ac.uk      | Parks Road
   Tel: +44 1865 272390            | Oxford OX1 3PU
   Fax: +44 1865 272400            | UK
-------------- next part --------------
Index: dlls/wineps/ppd.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/ppd.c,v
retrieving revision 1.2
diff -u -r1.2 ppd.c
--- dlls/wineps/ppd.c	2001/01/28 23:12:52	1.2
+++ dlls/wineps/ppd.c	2001/02/07 11:44:19
@@ -166,6 +166,8 @@
   {"Envelope",		DMBIN_ENVELOPE},
   {"LargeCapacity",	DMBIN_LARGECAPACITY},
   {"Lower",		DMBIN_LOWER},
+  {"Manual",            DMBIN_MANUAL},
+  {"ManualEnv",         DMBIN_ENVMANUAL},
   {"ManualFeed",        DMBIN_MANUAL},
   {"Middle",            DMBIN_MIDDLE},
   {"OnlyOne",		DMBIN_ONLYONE},
@@ -356,7 +358,7 @@
  */
 static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
 {
-    char line[257], *opt = NULL, *cp, *trans;
+    char line[257], *opt = NULL, *cp, *trans, *endkey;
     BOOL gotoption = TRUE;
 
     memset(tuple, 0, sizeof(*tuple));
@@ -373,25 +375,29 @@
 	return FALSE;
     }
 
-    for(cp = line; !isspace(*cp); cp++)
+    for(cp = line; !isspace(*cp) && *cp != ':'; cp++)
         ;
 
-    if(*(cp-1) == ':') {
-        cp--;
+    endkey = cp;
+    if(*cp == ':') { /* <key>: */
         gotoption = FALSE;
     } else {
-        opt = cp;
+	while(isspace(*cp))
+	    cp++;
+	if(*cp == ':') { /* <key>  : */
+	    gotoption = FALSE;
+	} else { /* <key> <option> */
+	    opt = cp;
+	}
     }
 
-    tuple->key = HeapAlloc( PSDRV_Heap, 0, cp - line + 1 );
+    tuple->key = HeapAlloc( PSDRV_Heap, 0, endkey - line + 1 );
     if(!tuple->key) return FALSE;
 
-    memcpy(tuple->key, line, cp - line);
-    tuple->key[cp - line] = '\0';
+    memcpy(tuple->key, line, endkey - line);
+    tuple->key[endkey - line] = '\0';
 
-    if(gotoption) {
-        while(isspace(*opt))
-	    opt++;
+    if(gotoption) { /* opt points to 1st non-space character of the option */
         cp = strpbrk(opt, ":/");
 	if(!cp) {
 	    ERR("Error in line '%s'?\n", line);
@@ -417,7 +423,8 @@
 	    HeapFree( PSDRV_Heap, 0, buf );
 	}
     }
-    while(!isspace(*cp))
+
+    /* cp should point to a ':', so we increment past it */
         cp++;
 
     while(isspace(*cp))


More information about the wine-patches mailing list