// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: policy.cc,v 1.9 2002/11/06 06:43:14 jgg Exp $
+// $Id: policy.cc,v 1.10 2003/08/12 00:17:37 mdz Exp $
/* ######################################################################
Package Version Policy implementation
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/policy.h"
-#endif
#include <apt-pkg/policy.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/tagfile.h>
#include <apti18n.h>
#include <iostream>
+#include <sstream>
/*}}}*/
using namespace std;
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
if (_error->PendingError() == true)
return false;
- pkgTagSection Tags;
+ PreferenceSection Tags;
while (TF.Step(Tags) == true)
{
string Name = Tags.FindS("Package");
}
for (; Word != End && isspace(*Word) != 0; Word++);
- Plcy.CreatePin(Type,Name,string(Word,End),
- Tags.FindI("Pin-Priority"));
+ short int priority = Tags.FindI("Pin-Priority", 0);
+ if (priority == 0)
+ {
+ _error->Warning(_("No priority (or zero) specified for pin"));
+ continue;
+ }
+
+ istringstream s(Name);
+ string pkg;
+ while(!s.eof())
+ {
+ s >> pkg;
+ Plcy.CreatePin(Type, pkg, string(Word,End),priority);
+ };
}
Plcy.InitDefaults();