forked from premiere/premiere-libtorrent
factor out error handling in lazy_bdecode
This commit is contained in:
parent
f015c0604a
commit
e0e5a55f10
|
@ -44,20 +44,29 @@ namespace
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
#define TORRENT_FAIL_BDECODE(code) \
|
namespace
|
||||||
{ \
|
{
|
||||||
ec = make_error_code(code); \
|
int fail(int* error_pos
|
||||||
while (!stack.empty()) { \
|
, std::vector<lazy_entry*>& stack
|
||||||
top = stack.back(); \
|
, char const* start
|
||||||
if (top->type() == lazy_entry::dict_t || top->type() == lazy_entry::list_t) { \
|
, char const* orig_start)
|
||||||
top->pop(); \
|
{
|
||||||
break; \
|
while (!stack.empty()) {
|
||||||
} \
|
lazy_entry* top = stack.back();
|
||||||
stack.pop_back(); \
|
if (top->type() == lazy_entry::dict_t || top->type() == lazy_entry::list_t)
|
||||||
} \
|
{
|
||||||
if (error_pos) *error_pos = start - orig_start; \
|
top->pop();
|
||||||
return -1; \
|
break;
|
||||||
|
}
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
if (error_pos) *error_pos = start - orig_start;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TORRENT_FAIL_BDECODE(code) do { ec = make_error_code(code); return fail(error_pos, stack, start, orig_start); } while (false)
|
||||||
|
|
||||||
namespace { bool numeric(char c) { return c >= '0' && c <= '9'; } }
|
namespace { bool numeric(char c) { return c >= '0' && c <= '9'; } }
|
||||||
|
|
||||||
// fills in 'val' with what the string between start and the
|
// fills in 'val' with what the string between start and the
|
||||||
|
|
Loading…
Reference in New Issue