reorder includes: add <config.h> if needed and include it at first
[ntk/apt.git] / apt-pkg / sourcelist.cc
index a860c7e..d4eec5c 100644 (file)
@@ -8,15 +8,17 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include<config.h>
+
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 
-#include <apti18n.h>
-
 #include <fstream>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 
 using namespace std;
@@ -94,6 +96,13 @@ bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
         if (option.length() < 3)
            return _error->Error(_("Malformed line %lu in source list %s ([option] too short)"),CurLine,File.c_str());
 
+        // accept options even if the last has no space before the ]-end marker
+        if (option.at(option.length()-1) == ']')
+        {
+           for (; *Buffer != ']'; --Buffer);
+           option.resize(option.length()-1);
+        }
+
         size_t const needle = option.find('=');
         if (needle == string::npos)
            return _error->Error(_("Malformed line %lu in source list %s ([%s] is not an assignment)"),CurLine,File.c_str(), option.c_str());
@@ -190,17 +199,17 @@ bool pkgSourceList::ReadMainList()
    string Main = _config->FindFile("Dir::Etc::sourcelist");
    string Parts = _config->FindDir("Dir::Etc::sourceparts");
    
-   if (FileExists(Main) == true)
+   if (RealFileExists(Main) == true)
       Res &= ReadAppend(Main);
-   else if (FileExists(Parts) == false)
+   else if (DirectoryExists(Parts) == false)
       // Only warn if there are no sources.list.d.
-      _error->WarningE("FileExists",_("Unable to read %s"),Main.c_str());
+      _error->WarningE("DirectoryExists", _("Unable to read %s"), Parts.c_str());
 
-   if (FileExists(Parts) == true)
+   if (DirectoryExists(Parts) == true)
       Res &= ReadSourceDir(Parts);
-   else if (FileExists(Main) == false)
+   else if (RealFileExists(Main) == false)
       // Only warn if there is no sources.list file.
-      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+      _error->WarningE("RealFileExists", _("Unable to read %s"), Main.c_str());
 
    return Res;
 }