master
Daniel Kolesa 2015-08-13 23:18:48 +01:00
parent bc6a85d49c
commit a8ca0b376f
2 changed files with 12 additions and 10 deletions

View File

@ -4714,7 +4714,7 @@ void init_lib_string(CsState &cs) {
cs.add_command("escape", "s", [](CsState &cs, char *s) {
auto x = ostd::appender<ostd::String>();
util::escape_string(x, s);
ostd::Size len = x.get().size();
ostd::Size len = x.size();
cs.result->set_str(ostd::CharRange(x.get().disown(), len));
});
@ -4763,7 +4763,7 @@ void init_lib_string(CsState &cs) {
auto r = ostd::appender<ostd::Vector<char>>();
ostd::format(r, "0x%.*X", ostd::max(*p, 1), *n);
r.put('\0');
ostd::Size len = r.get().size() - 1;
ostd::Size len = r.size() - 1;
cs.result->set_str(ostd::CharRange(r.get().disown(), len));
});

View File

@ -433,30 +433,32 @@ inline bool check_alias(Ident *id) {
}
struct StackedValue: TaggedValue {
IdentStack stack;
Ident *id;
bool pushed;
StackedValue(Ident *id = nullptr):
TaggedValue(), stack(), id(id), pushed(false) {}
TaggedValue(), id(id), p_stack(), p_pushed(false) {}
~StackedValue() {
pop();
}
bool push() {
if (pushed || !id) return false;
id->push_arg(*this, stack);
pushed = true;
if (p_pushed || !id) return false;
id->push_arg(*this, p_stack);
p_pushed = true;
return true;
}
bool pop() {
if (!pushed || !id) return false;
if (!p_pushed || !id) return false;
id->pop_arg();
pushed = false;
p_pushed = false;
return true;
}
private:
IdentStack p_stack;
bool p_pushed;
};
namespace util {