X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/1c62ab240a76122afb95c6df7de19ec5ba5cee1a..00aeebe8d2754ebcd5ca6ba82e6c553e5a5ae5a3:/apt-pkg/policy.cc diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 35a50425b..98576fc91 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -23,9 +23,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/policy.h" -#endif #include #include #include @@ -242,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 @@ -262,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");