projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests: fix external solver/planner directory setup
[apt.git]
/
apt-pkg
/
contrib
/
error.cc
diff --git
a/apt-pkg/contrib/error.cc
b/apt-pkg/contrib/error.cc
index 18810d2a47f6234dbcbf2c90f3eb0678224fa567..8a87e16e9e1fbdb404bfb289f936152fbaad2f07 100644
(file)
--- a/
apt-pkg/contrib/error.cc
+++ b/
apt-pkg/contrib/error.cc
@@
-13,19
+13,23
@@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/error.h>
#include <apt-pkg/error.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <list>
#include <iostream>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
#include <string>
#include <cstring>
#include <string>
#include <cstring>
+#include <algorithm>
-#include "config.h"
- /*}}}*/
+ /*}}}*/
// Global Error Object /*{{{*/
/* If the implementation supports posix threads then the accessor function
// Global Error Object /*{{{*/
/* If the implementation supports posix threads then the accessor function
@@
-66,9
+70,10
@@
bool GlobalError::NAME (const char *Function, const char *Description,...) { \
int const errsv = errno; \
while (true) { \
va_start(args,Description); \
int const errsv = errno; \
while (true) { \
va_start(args,Description); \
- if (InsertErrno(TYPE, Function, Description, args, errsv, msgSize) == false) \
- break; \
+ bool const retry = InsertErrno(TYPE, Function, Description, args, errsv, msgSize); \
va_end(args); \
va_end(args); \
+ if (retry == false) \
+ break; \
} \
return false; \
}
} \
return false; \
}
@@
-87,9
+92,10
@@
bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
int const errsv = errno;
while (true) {
va_start(args,Description);
int const errsv = errno;
while (true) {
va_start(args,Description);
- if (InsertErrno(type, Function, Description, args, errsv, msgSize) == false)
- break;
+ bool const retry = InsertErrno(type, Function, Description, args, errsv, msgSize);
va_end(args);
va_end(args);
+ if (retry == false)
+ break;
}
return false;
}
}
return false;
}
@@
-193,7
+199,7
@@
bool GlobalError::PopMessage(std::string &Text) {
// check if another error message is pending
for (std::list<Item>::const_iterator m = Messages.begin();
// check if another error message is pending
for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end();
m++
)
+ m != Messages.end();
++m
)
if (m->Type == ERROR || m->Type == FATAL)
return Ret;
if (m->Type == ERROR || m->Type == FATAL)
return Ret;
@@
-207,12
+213,13
@@
void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
if (mergeStack == true)
for (std::list<MsgStack>::const_reverse_iterator s = Stacks.rbegin();
s != Stacks.rend(); ++s)
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());
+ std::copy(s->Messages.begin(), s->Messages.end(), std::front_inserter(Messages));
+
+ std::for_each(Messages.begin(), Messages.end(), [&threshold, &out](Item const &m) {
+ if (m.Type >= threshold)
+ out << m << std::endl;
+ });
- for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end(); m++)
- if (m->Type >= threshold)
- out << (*m) << std::endl;
Discard();
}
/*}}}*/
Discard();
}
/*}}}*/
@@
-220,28
+227,24
@@
void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
void GlobalError::Discard() {
Messages.clear();
PendingFlag = false;
void GlobalError::Discard() {
Messages.clear();
PendingFlag = false;
-}
;
+}
/*}}}*/
// GlobalError::empty - does our error list include anything? /*{{{*/
/*}}}*/
// GlobalError::empty - does our error list include anything? /*{{{*/
-bool GlobalError::empty(MsgType const &t
rash
hold) const {
+bool GlobalError::empty(MsgType const &t
hres
hold) const {
if (PendingFlag == true)
return false;
if (Messages.empty() == true)
return true;
if (PendingFlag == true)
return false;
if (Messages.empty() == true)
return true;
- for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end(); m++)
- if (m->Type >= trashhold)
- return false;
-
- return true;
+ return std::find_if(Messages.begin(), Messages.end(), [&threshold](Item const &m) {
+ return m.Type >= threshold;
+ }) == Messages.end();
}
/*}}}*/
// GlobalError::PushToStack /*{{{*/
void GlobalError::PushToStack() {
}
/*}}}*/
// GlobalError::PushToStack /*{{{*/
void GlobalError::PushToStack() {
- MsgStack pack(Messages, PendingFlag);
- Stacks.push_back(pack);
+ Stacks.emplace_back(Messages, PendingFlag);
Discard();
}
/*}}}*/
Discard();
}
/*}}}*/
@@
-257,7
+260,7
@@
void GlobalError::RevertToStack() {
// GlobalError::MergeWithStack /*{{{*/
void GlobalError::MergeWithStack() {
MsgStack pack = Stacks.back();
// GlobalError::MergeWithStack /*{{{*/
void GlobalError::MergeWithStack() {
MsgStack pack = Stacks.back();
- Messages.
insert(Messages.begin(), pack.Messages.begin(), pack.Messages.end()
);
+ Messages.
splice(Messages.begin(), pack.Messages
);
PendingFlag = PendingFlag || pack.PendingFlag;
Stacks.pop_back();
}
PendingFlag = PendingFlag || pack.PendingFlag;
Stacks.pop_back();
}