Skip to content

Commit

Permalink
* core/table.c: fix Tuple(put) to allow negative numbers or pushing …
Browse files Browse the repository at this point in the history
…onto the end of the array.

 * core/potion.c: avoid use of the multiline ending, since it hasn't been introduced yet in the new parser.
  • Loading branch information
_why committed Aug 11, 2009
1 parent 6496b91 commit 07388f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/potion.c
Expand Up @@ -243,7 +243,8 @@ int main(int argc, char *argv[]) {
" if (obj kind == Error):\n" \
" obj string print." \
" else: ('=> ', obj, \"\\n\") join print.\n" \
"_ loop"));
" .\n"
"."));
potion_destroy(P);
return 0;
}
6 changes: 4 additions & 2 deletions core/table.c
Expand Up @@ -208,11 +208,13 @@ PN potion_tuple_pop(Potion *P, PN cl, PN self, PN key) {
PN potion_tuple_put(Potion *P, PN cl, PN self, PN key, PN value) {
if (PN_IS_NUM(key)) {
long i = PN_INT(key), len = PN_TUPLE_LEN(self);
if (i <= len) {
if (i < 0) i += len;
if (i < len) {
PN_TUPLE_AT(self, i) = value;
PN_TOUCH(self);
return self;
}
} else if (i == len)
return potion_tuple_push(P, self, value);
}
return potion_table_put(P, PN_NIL, potion_table_cast(P, self), key, value);
}
Expand Down

0 comments on commit 07388f3

Please sign in to comment.