summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-06-09 17:33:22 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-06-09 17:33:22 +0200
commit81e9789b12374073e848c73c79e235f82c14df44 (patch)
tree419a706fb1a4544cdab44dbd2fd3bf3fcd76ba35 /apt-pkg/policy.cc
parenteac9121ea9d2b4180399f4b63f88491f8e0f1a8a (diff)
[ABI break] support '#' in apt.conf and /etc/apt/preferences
(closes: #189866)
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 8b083fd44..98576fc91 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -239,7 +239,21 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
return 0;
}
/*}}}*/
-
+// PreferenceSection class - Overriding the default TrimRecord method /*{{{*/
+// ---------------------------------------------------------------------
+/* The preference file is a user generated file so the parser should
+ therefore be a bit more friendly by allowing comments and new lines
+ all over the place rather than forcing a special format */
+class PreferenceSection : public pkgTagSection
+{
+ void TrimRecord(bool BeforeRecord, const char* &End)
+ {
+ for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++)
+ if (Stop[0] == '#')
+ Stop = (const char*) memchr(Stop,'\n',End-Stop);
+ }
+};
+ /*}}}*/
// ReadPinFile - Load the pin file into a Policy /*{{{*/
// ---------------------------------------------------------------------
/* I'd like to see the preferences file store more than just pin information
@@ -259,7 +273,7 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
if (_error->PendingError() == true)
return false;
- pkgTagSection Tags;
+ PreferenceSection Tags;
while (TF.Step(Tags) == true)
{
string Name = Tags.FindS("Package");