Reset: Don't add empty lines when writing out profile files

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

 



Changelog:
	wine/files/profile.c: PROFILE_Save
	Don't add lines for empty sections
-- 
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/files/profile.c
===================================================================
RCS file: /home/wine/wine/files/profile.c,v
retrieving revision 1.86
diff -u -7 -r1.86 profile.c
--- wine/files/profile.c	30 Mar 2003 01:35:07 -0000	1.86
+++ wine/files/profile.c	6 May 2003 19:16:49 -0000
@@ -160,19 +160,18 @@
 static void PROFILE_Save( FILE *file, PROFILESECTION *section )
 {
     PROFILEKEY *key;
     char buffer[PROFILE_MAX_LINE_LEN];
 
     for ( ; section; section = section->next)
     {
-        if (section->name[0])
-        {
-            WideCharToMultiByte(CP_ACP, 0, section->name, -1, buffer, sizeof(buffer), NULL, NULL);
-            fprintf( file, "\r\n[%s]\r\n", buffer );
-        }
+        if (!section->name[0])
+	    continue;
+	WideCharToMultiByte(CP_ACP, 0, section->name, -1, buffer, sizeof(buffer), NULL, NULL);
+	fprintf( file, "[%s]\r\n", buffer );
         for (key = section->key; key; key = key->next)
         {
             WideCharToMultiByte(CP_ACP, 0, key->name, -1, buffer, sizeof(buffer), NULL, NULL);
             fprintf( file, "%s", buffer );
             if (key->value)
             {
                  WideCharToMultiByte(CP_ACP, 0, key->value, -1, buffer, sizeof(buffer), NULL, NULL);
@@ -554,14 +553,15 @@
     WCHAR *newdos_name;
     WCHAR *name, *name_lwr;
     char *p;
     FILE *file = NULL;
     int i,j;
     struct stat buf;
     PROFILE *tempProfile;
+    BOOL no_full_name = TRUE;
 
     /* First time around */
 
     if(!CurProfile)
        for(i=0;i<N_CACHED_PROFILES;i++)
          {
           MRUProfile[i]=HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILE) );
@@ -576,14 +576,15 @@
 
     /* Check for a match */
 
     if (strchrW( filename, '/' ) || strchrW( filename, '\\' ) ||
         strchrW( filename, ':' ))
     {
         if (!DOSFS_GetFullName( filename, FALSE, &full_name )) return FALSE;
+        no_full_name = FALSE;
     }
     else
     {
         static const WCHAR bkslashW[] = {'\\',0};
         WCHAR windirW[MAX_PATH];
 
         GetWindowsDirectoryW( windirW, MAX_PATH );
@@ -631,32 +632,36 @@
     /* OK, now that CurProfile is definitely free we assign it our new file */
     newdos_name = HeapAlloc( GetProcessHeap(), 0, (strlenW(full_name.short_name)+1) * sizeof(WCHAR) );
     strcpyW( newdos_name, full_name.short_name );
     CurProfile->dos_name  = newdos_name;
     CurProfile->filename  = HeapAlloc( GetProcessHeap(), 0, (strlenW(filename)+1) * sizeof(WCHAR) );
     strcpyW( CurProfile->filename, filename );
 
-    /* Try to open the profile file, first in $HOME/.wine */
+    /* Try to open the profile file, first in $HOME/.wine , but
+     * only when no full path was given
+     */
 
-    /* FIXME: this will need a more general solution */
-    strcpy( buffer, wine_get_config_dir() );
-    p = buffer + strlen(buffer);
-    *p++ = '/';
-    *p = 0; /* make strlen() below happy */
-    name = strrchrW( newdos_name, '\\' ) + 1;
-
-    /* create a lower cased version of the name */
-    name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
-    strcpyW(name_lwr, name);
-    strlwrW(name_lwr);
-    WideCharToMultiByte(DRIVE_GetCodepage(full_name.drive), 0, name_lwr, -1,
-                        p, sizeof(buffer) - strlen(buffer), NULL, NULL);
-    HeapFree(GetProcessHeap(), 0, name_lwr);
+    if (no_full_name)
+    {
+        /* FIXME: this will need a more general solution */
+        strcpy( buffer, wine_get_config_dir() );
+        p = buffer + strlen(buffer);
+        *p++ = '/';
+        *p = 0; /* make strlen() below happy */
+        name = strrchrW( newdos_name, '\\' ) + 1;
 
-    if ((file = fopen( buffer, "r" )))
+        /* create a lower cased version of the name */
+        name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
+        strcpyW(name_lwr, name);
+        strlwrW(name_lwr);
+        WideCharToMultiByte(DRIVE_GetCodepage(full_name.drive), 0, name_lwr, -1,
+	                    p, sizeof(buffer) - strlen(buffer), NULL, NULL);
+        HeapFree(GetProcessHeap(), 0, name_lwr);
+    }
+    if (no_full_name && (file = fopen( buffer, "r" )))
     {
         TRACE("(%s): found it in %s\n", debugstr_w(filename), buffer );
         CurProfile->unix_name = HeapAlloc( GetProcessHeap(), 0, strlen(buffer)+1 );
         strcpy( CurProfile->unix_name, buffer );
     }
     else
     {


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

  Powered by Linux