]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/error.cc
show in madison command again also source packages (LP: #614589)
[apt.git] / apt-pkg / contrib / error.cc
index 837d9e615345e4079960c32d81dea448d0a3bb64..e2e8d6e57c39c13afa9f22b754c5317c62d1009f 100644 (file)
@@ -92,13 +92,20 @@ bool GlobalError::DebugE(const char *Function,const char *Description,...) {
        return InsertErrno(DEBUG, Function, Description, args);
 }
                                                                        /*}}}*/
+// GlobalError::InsertErrno - Get part of the errortype string from errno/*{{{*/
+bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
+                               const char *Description,...) {
+       va_list args;
+       va_start(args,Description);
+       return InsertErrno(type, Function, Description, args);
+}
+                                                                       /*}}}*/
 // GlobalError::InsertErrno - formats an error message with the errno  /*{{{*/
 bool GlobalError::InsertErrno(MsgType type, const char* Function,
-                             const char* Description, va_list const &args) {
+                             const char* Description, va_list &args) {
        char S[400];
-       vsnprintf(S,sizeof(S),Description,args);
-       snprintf(S + strlen(S),sizeof(S) - strlen(S),
-                " - %s (%i: %s)", Function, errno, strerror(errno));
+       snprintf(S, sizeof(S), "%s - %s (%i: %s)", Description,
+                Function, errno, strerror(errno));
        return Insert(type, S, args);
 }
                                                                        /*}}}*/
@@ -139,9 +146,17 @@ bool GlobalError::Debug(const char *Description,...)
        return Insert(DEBUG, Description, args);
 }
                                                                        /*}}}*/
+// GlobalError::Insert - Add a errotype message to the list            /*{{{*/
+bool GlobalError::Insert(MsgType const &type, const char *Description,...)
+{
+       va_list args;
+       va_start(args,Description);
+       return Insert(type, Description, args);
+}
+                                                                       /*}}}*/
 // GlobalError::Insert - Insert a new item at the end                  /*{{{*/
 bool GlobalError::Insert(MsgType type, const char* Description,
-                        va_list const &args) {
+                        va_list &args) {
        char S[400];
        vsnprintf(S,sizeof(S),Description,args);
 
@@ -181,10 +196,16 @@ bool GlobalError::PopMessage(std::string &Text) {
 }
                                                                        /*}}}*/
 // GlobalError::DumpErrors - Dump all of the errors/warns to cerr      /*{{{*/
-void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold) {
+void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
+                            bool const &mergeStack) {
+       if (mergeStack == true)
+               for (std::list<MsgStack>::const_reverse_iterator s = Stacks.rbegin();
+                    s != Stacks.rend(); ++s)
+                       Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());
+
        for (std::list<Item>::const_iterator m = Messages.begin();
             m != Messages.end(); m++)
-               if (m->Type >= trashhold)
+               if (m->Type >= threshold)
                        out << (*m) << std::endl;
        Discard();
 }
@@ -211,3 +232,27 @@ bool GlobalError::empty(MsgType const &trashhold) const {
        return true;
 }
                                                                        /*}}}*/
+// GlobalError::PushToStack                                            /*{{{*/
+void GlobalError::PushToStack() {
+       MsgStack pack(Messages, PendingFlag);
+       Stacks.push_back(pack);
+       Discard();
+}
+                                                                       /*}}}*/
+// GlobalError::RevertToStack                                          /*{{{*/
+void GlobalError::RevertToStack() {
+       Discard();
+       MsgStack pack = Stacks.back();
+       Messages = pack.Messages;
+       PendingFlag = pack.PendingFlag;
+       Stacks.pop_back();
+}
+                                                                       /*}}}*/
+// GlobalError::MergeWithStack                                         /*{{{*/
+void GlobalError::MergeWithStack() {
+       MsgStack pack = Stacks.back();
+       Messages.insert(Messages.begin(), pack.Messages.begin(), pack.Messages.end());
+       PendingFlag = PendingFlag || pack.PendingFlag;
+       Stacks.pop_back();
+}
+                                                                       /*}}}*/