gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/rc.cpp


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog libbase/rc.cpp
Date: Sun, 27 Apr 2008 14:30:59 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/04/27 14:30:59

Modified files:
        .              : ChangeLog 
        libbase        : rc.cpp 

Log message:
                * libbase/rc.cpp: (updateFile) save to the last file specified
                  in GNASHRC by default.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6417&r2=1.6418
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.71&r2=1.72

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6417
retrieving revision 1.6418
diff -u -b -r1.6417 -r1.6418
--- ChangeLog   27 Apr 2008 14:11:48 -0000      1.6417
+++ ChangeLog   27 Apr 2008 14:30:58 -0000      1.6418
@@ -1,3 +1,8 @@
+2008-04-27 Benjamin Wolsey <address@hidden>
+
+       * libbase/rc.cpp: (updateFile) save to the last file specified
+         in GNASHRC by default.
+
 2008-04-27 Sandro Santilli <address@hidden>
 
        * libbase/Makefile.am: clean_hook seems unused, CLEANFILE

Index: libbase/rc.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- libbase/rc.cpp      27 Apr 2008 09:12:37 -0000      1.71
+++ libbase/rc.cpp      27 Apr 2008 14:30:59 -0000      1.72
@@ -133,7 +133,7 @@
     char *home = getenv("HOME");
     if (home) {
         loadfile = home;
-        loadfile += "/.gnashrc";
+        loadfile.append("/.gnashrc");
         parseFile(loadfile);
     }
 
@@ -562,6 +562,12 @@
 RcInitFile::updateFile()
 {
 
+    // We don't want to try writing to /etc/ et cetera, since
+    // these are likely to be system-wide defaults set by administrators
+    // or distros, useful for a model rcfile. They are likely to have
+    // no write permission anyway unless you are running Gnash with
+    // administrative privileges, and that is a bad idea.
+
     std::string writefile;
 
     // The file specified in GNASHRC environment variable
@@ -570,32 +576,45 @@
     // preferences, you'll obviously overwrite that file.
     char *gnashrc = getenv("GNASHRC");
     if (gnashrc) {
-        writefile = gnashrc;
-        return updateFile(writefile);
-    }
+        std::string filelist(gnashrc);
 
+        if (filelist.empty()) return false;
+        
+        std::string::size_type pos = filelist.find_last_of(':');
+        
+        if (pos == std::string::npos)
+        {
+            // no separator: just one file.
+            writefile = filelist;
+        }
+        else
+        {
+            writefile = filelist.substr(pos + 1);
+        }
+    }
+    else
+    {
     // Check the users home directory
     char *home = getenv("HOME");
     if (home) {
         writefile = home;
         writefile.append("/.gnashrc");
-        return updateFile(writefile);
+        }
     }
 
-    // We don't want to try writing to /etc/ et cetera, since
-    // these are likely to be system-wide defaults set by administrators
-    // or distros, useful for a model rcfile. They are likely to have
-    // no write permission anyway unless you are running Gnash with
-    // administrative privileges, and that is a bad idea.
-    return false;
+    if (writefile.empty()) return false;
+
+    return updateFile(writefile);
 
 }
+
+
 // Write the changed settings to the config file
 bool
 RcInitFile::updateFile(const std::string& filespec)
 {
 
-    if (filespec == "") {
+    if (filespec.empty()) {
         return false;
     }
 
@@ -604,7 +623,7 @@
     out.open(filespec.c_str());
         
     if (!out) {
-        cerr << boost::format(_("Couldn't open file %s for writing")) % 
filespec;
+        cerr << boost::format(_("Couldn't open file %s for writing")) % 
filespec << endl;
         return false;
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]