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: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/rc.cpp
Date: Sat, 26 Apr 2008 08:33:29 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/26 08:33:29

Modified files:
        .              : ChangeLog 
        libbase        : rc.cpp 

Log message:
        * libbase/rc.cpp: add support for 'include' directive,
          cleanup parser to recognize empty lines and comments
          not starting on first column and to be more verbose
          about syntax errors (include line number).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6401&r2=1.6402
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.68&r2=1.69

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6401
retrieving revision 1.6402
diff -u -b -r1.6401 -r1.6402
--- ChangeLog   26 Apr 2008 08:31:19 -0000      1.6401
+++ ChangeLog   26 Apr 2008 08:33:27 -0000      1.6402
@@ -1,5 +1,9 @@
 2008-04-26 Sandro Santilli <address@hidden>
 
+       * libbase/rc.cpp: add support for 'include' directive,
+         cleanup parser to recognize empty lines and comments
+         not starting on first column and to be more verbose
+         about syntax errors (include line number).
        * gui/gtk.cpp: initialize members in constructor.
 
 2008-04-26 Sandro Santilli <address@hidden>

Index: libbase/rc.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- libbase/rc.cpp      26 Apr 2008 07:58:16 -0000      1.68
+++ libbase/rc.cpp      26 Apr 2008 08:33:28 -0000      1.69
@@ -351,35 +351,57 @@
     
     if (stat(filespec.c_str(), &stats) != 0)
     {
-        cerr << "RcInitFile::parseFile: couldn't open file: " << filespec << 
endl;
+        cerr << "RcInitFile: couldn't open file: " << filespec << endl;
         return false;
     }
 
     in.open(filespec.c_str());
     
     if (!in) {
-            cerr << "RcInitFile::parseFile: couldn't open file: " << filespec 
<< endl;
+            cerr << "RcInitFile: couldn't open file: " << filespec << endl;
             return false;
     }
 
     cout << "RcInitFile: parsing " << filespec << endl;
         
     // Read in each line and parse it
+    size_t lineno=0;
     while (getline(in, line)) {
 
-        // Ignore comment lines        
-        if (line[0] == '#') continue;
+       ++lineno;
+       //cout << "Line: " << line << endl;
+
+        // Ignore comment and empty lines
+        if (line.empty() || line[0] == '#') continue;
     
         std::istringstream ss(line);
         
         // Get the first token
-        ss >> action;
+        if ( ! (ss >> action) )
+       {
+               // Empty line 
+               continue;
+       }
+       //cout << " " << lineno << ": '" << action << "'" << endl;
+        
+       // 'action' should never be empty, or (ss >> action) above would have 
failed
+       //if ( action.empty() ) continue;
+
+       if ( action[0] == '#' ) continue; // discard comments
         
         // Get second token
         ss >> variable;
 
+        if (noCaseCompare(action, "set") || noCaseCompare(action, "append") )
+        {
+
         // The rest of the line is the value
-        if (!getline (ss, value)) continue;
+             if (!getline (ss, value))
+             {
+                 cerr << _("Warning: missing value for variable \"") << 
variable 
+                      << _("\" in rcfile ") << filespec << " line " << lineno 
<< endl;
+                 continue;
+             }
 
         // Erase leading spaces.
         // If there are nothing but spaces in the value,
@@ -387,7 +409,6 @@
         // so value.erase(0, string::npos) is correct.
         value.erase(0, value.find_first_not_of(' '));
 
-        if (noCaseCompare(action, "set") || noCaseCompare(action, "append") ) {
 
             if (noCaseCompare(variable, "urlOpenerFormat")) {
                 _urlOpenerFormat = value;
@@ -504,8 +525,42 @@
                  extractSetting(_ignoreFSCommand, "ignoreFsCommand", variable, 
value)
             ||
                  cerr << _("Warning: unrecognized directive \"") << variable 
-                      << _("\" in rcfile.") << endl;
+                      << _("\" in rcfile ") << filespec << " line " << lineno 
<< endl;
+            }
+        }
+        else if (noCaseCompare(action, "include") )
+       {
+               //cout << "Include directive in " << filespec << endl; 
+               // TODO: resolve relative paths ?
+               // TODO: skip parsing if already parsed ?
+               //       (would mess up user-requested parsing order, but
+               //       would be safe in case of circular includes)
+               //
+               if ( variable.empty() )
+               {
+                    cerr << _("Warning: empty include specification") 
+                         << " " << _("in rcfile") << " " <<
+                         filespec << " " << _("line") << " " << lineno << endl;
+               }
+               else
+               {
+                       if ( variable[0] != '/' )
+                       {
+                           cerr << _("Warning: include specification must be 
an absolute path") 
+                                << " " << _("in rcfile") << " " <<
+                                filespec << " " << _("line") << " " << lineno 
<< endl;
+                       }
+                       else
+                       {
+                               parseFile(variable);
+                       }
+               }
             }
+       else
+       {
+            cerr << _("Warning: unrecognized action \"") << action
+                 << "\" " << _("in rcfile") << " " <<
+                 filespec << " " << _("line") << " " << lineno << endl;
         }
     }
 




reply via email to

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