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) { cs.add_command("escape", "s", [](CsState &cs, char *s) {
auto x = ostd::appender<ostd::String>(); auto x = ostd::appender<ostd::String>();
util::escape_string(x, s); 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)); 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>>(); auto r = ostd::appender<ostd::Vector<char>>();
ostd::format(r, "0x%.*X", ostd::max(*p, 1), *n); ostd::format(r, "0x%.*X", ostd::max(*p, 1), *n);
r.put('\0'); 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)); 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 { struct StackedValue: TaggedValue {
IdentStack stack;
Ident *id; Ident *id;
bool pushed;
StackedValue(Ident *id = nullptr): StackedValue(Ident *id = nullptr):
TaggedValue(), stack(), id(id), pushed(false) {} TaggedValue(), id(id), p_stack(), p_pushed(false) {}
~StackedValue() { ~StackedValue() {
pop(); pop();
} }
bool push() { bool push() {
if (pushed || !id) return false; if (p_pushed || !id) return false;
id->push_arg(*this, stack); id->push_arg(*this, p_stack);
pushed = true; p_pushed = true;
return true; return true;
} }
bool pop() { bool pop() {
if (!pushed || !id) return false; if (!p_pushed || !id) return false;
id->pop_arg(); id->pop_arg();
pushed = false; p_pushed = false;
return true; return true;
} }
private:
IdentStack p_stack;
bool p_pushed;
}; };
namespace util { namespace util {