]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
implement arch+= and arch-= for sources.list
[apt.git] / apt-pkg / aptconfiguration.cc
index d763546f85b464f6387caf49981d914c54faebb3..37c8465822d394146f7acdec717803d5a5514617 100644 (file)
@@ -234,17 +234,21 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
        // override the configuration settings vector of languages.
        string const forceLang = _config->Find("Acquire::Languages","");
        if (forceLang.empty() == false) {
-               if (forceLang == "environment") {
-                       codes = environment;
-               } else if (forceLang != "none")
-                       codes.push_back(forceLang);
-               else //if (forceLang == "none")
-                       builtin.clear();
-               allCodes = codes;
-               for (std::vector<string>::const_iterator b = builtin.begin();
-                    b != builtin.end(); ++b)
-                       if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
-                               allCodes.push_back(*b);
+               if (forceLang == "none") {
+                       codes.clear();
+                       allCodes.clear();
+                       allCodes.push_back("none");
+               } else {
+                       if (forceLang == "environment")
+                               codes = environment;
+                       else
+                               codes.push_back(forceLang);
+                       allCodes = codes;
+                       for (std::vector<string>::const_iterator b = builtin.begin();
+                            b != builtin.end(); ++b)
+                               if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
+                                       allCodes.push_back(*b);
+               }
                if (All == true)
                        return allCodes;
                else
@@ -315,6 +319,17 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                return codes;
 }
                                                                        /*}}}*/
+// checkLanguage - are we interested in the given Language?            /*{{{*/
+bool const Configuration::checkLanguage(std::string Lang, bool const All) {
+       // the empty Language is always interesting as it is the original
+       if (Lang.empty() == true)
+               return true;
+       // filenames are encoded, so undo this
+       Lang = SubstVar(Lang, "%5f", "_");
+       std::vector<std::string> const langs = getLanguages(All, true);
+       return (std::find(langs.begin(), langs.end(), Lang) != langs.end());
+}
+                                                                       /*}}}*/
 // getArchitectures - Return Vector of prefered Architectures          /*{{{*/
 std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
        using std::string;
@@ -386,8 +401,8 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
                close(external[1]);
 
                FILE *dpkg = fdopen(external[0], "r");
-               char buf[1024];
                if(dpkg != NULL) {
+                       char buf[1024];
                        while (fgets(buf, sizeof(buf), dpkg) != NULL) {
                                char* arch = strtok(buf, " ");
                                while (arch != NULL) {