Correct command purge

This commit is contained in:
louis 2015-03-01 16:30:13 +01:00
parent f0adc8e48b
commit a682b8cb48
3 changed files with 8 additions and 14 deletions

View file

@ -51,8 +51,11 @@ void purge(void)
MIN_ARGUMENTS(1); MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_symbol); ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
if (!_heap->erase(string(getn()))) string name(((symbol*)_stack->back())->_value);
if (!_heap->erase(name))
ERR_CONTEXT(ret_unknown_variable); ERR_CONTEXT(ret_unknown_variable);
else
_stack->pop_back();
} }
void vars(void) void vars(void)

View file

@ -723,15 +723,6 @@ private:
_stack->push_back(&num, num.size(), cmd_binary); _stack->push_back(&num, num.size(), cmd_binary);
} }
// care: return value must be used before pushing something else in stack
char* getn()
{
/* warning, caller must check object type before */
char* a = ((ostring*)_stack->back())->_value;
_stack->pop_back();
return a;
}
int stack_size() int stack_size()
{ {
return _stack->size(); return _stack->size();

View file

@ -251,7 +251,7 @@ public:
return false; return false;
} }
bool erase(const string name) bool erase(const string& name)
{ {
map<string, struct local_var*>::iterator i = _map.find(name); map<string, struct local_var*>::iterator i = _map.find(name);
if (i != _map.end()) if (i != _map.end())