Updated patch for PROFILE_GetString

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This update to my earlier patch handles the case when entry is NULL and 
no keys are found in the section.

Josh

Index: wine/files/profile.c
===================================================================
RCS file: /home/wine/wine/files/profile.c,v
retrieving revision 1.70
diff -u -r1.70 profile.c
--- wine/files/profile.c	20 Jun 2002 23:21:27 -0000	1.70
+++ wine/files/profile.c	22 Jun 2002 17:26:03 -0000
@@ -841,6 +841,7 @@
 static INT PROFILE_GetString( LPCSTR section, LPCSTR key_name,
 			      LPCSTR def_val, LPSTR buffer, UINT len )
 {
+    int i;
     PROFILEKEY *key = NULL;
 
     if(!buffer) return 0;
@@ -848,9 +849,11 @@
     if (!def_val) def_val = "";
     if (key_name)
     {
-	if (!key_name[0])
+        if (!key_name[0])
+        {
             /* Win95 returns 0 on keyname "". Tested with Likse32 bon 000227 */
             return 0;
+        }
         key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE);
         PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val,
                            len, FALSE );
@@ -863,9 +866,23 @@
     {
         PROFILE_GetSection(CurProfile->section, section, buffer, len,
 				FALSE, FALSE);
-	if (!buffer[0]) /* no luck -> def_val */
-	    PROFILE_CopyEntry(buffer, def_val, len, FALSE);
-	return strlen(buffer);
+        if (!buffer[0]) 
+        {
+            /* no luck -> def_val */
+            PROFILE_CopyEntry(buffer, def_val, len, FALSE);
+        }
+        else if(!key_name) 
+        {
+            /* 
+             * Return the number of characters copied not including the 
+             * second null character of the two null character termination. 
+             */
+            for(i = 1; i < len; i++) 
+            {
+                if(!buffer[i] && !buffer[i - 1]) return i;
+            }
+        }
+        return strlen(buffer);
     }
     buffer[0] = '\0';
     return 0;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux