mirror of
https://github.com/janet-lang/janet
synced 2026-09-20 16:12:00 +00:00
Fix a compiler bug in the do special form.
This commit is contained in:
+3
-2
@@ -31,7 +31,7 @@ DstKV *dst_struct_begin(int32_t count) {
|
||||
|
||||
/* Calculate capacity as power of 2 after 2 * count. */
|
||||
int32_t capacity = dst_tablen(2 * count);
|
||||
if (capacity < 0) capacity = dst_tablen(count);
|
||||
if (capacity < 0) capacity = dst_tablen(count + 1);
|
||||
|
||||
size_t s = sizeof(int32_t) * 4 + (capacity * sizeof(DstKV));
|
||||
char *data = dst_gcalloc(DST_MEMORY_STRUCT, s);
|
||||
@@ -40,6 +40,7 @@ DstKV *dst_struct_begin(int32_t count) {
|
||||
dst_struct_length(st) = count;
|
||||
dst_struct_capacity(st) = capacity;
|
||||
dst_struct_hash(st) = 0;
|
||||
(dst_struct_raw(st)[3]) = 0;
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ const DstKV *dst_struct_end(DstKV *st) {
|
||||
/* Get an item from a struct */
|
||||
Dst dst_struct_get(const DstKV *st, Dst key) {
|
||||
const DstKV *kv = dst_struct_find(st, key);
|
||||
if (NULL == kv || dst_checktype(kv->key, DST_NIL)) {
|
||||
if (NULL == kv) {
|
||||
return dst_wrap_nil();
|
||||
} else {
|
||||
return kv->value;
|
||||
|
||||
+4
-5
@@ -216,7 +216,7 @@ static void inc_counter(uint8_t *digits, int base, int len) {
|
||||
}
|
||||
|
||||
/* Generate a unique symbol. This is used in the library function gensym. The
|
||||
* symbol will be of the format prefix--XXXXXX, where X is a base64 digit, and
|
||||
* symbol will be of the format prefix_XXXXXX, where X is a base64 digit, and
|
||||
* prefix is the argument passed. */
|
||||
const uint8_t *dst_symbol_gen(const uint8_t *buf, int32_t len) {
|
||||
const uint8_t **bucket = NULL;
|
||||
@@ -224,15 +224,14 @@ const uint8_t *dst_symbol_gen(const uint8_t *buf, int32_t len) {
|
||||
uint8_t counter[6] = {63, 63, 63, 63, 63, 63};
|
||||
/* Leave spaces for 6 base 64 digits and two dashes. That means 64^6 possible suffixes, which
|
||||
* is enough for resolving collisions. */
|
||||
int32_t newlen = len + 8;
|
||||
int32_t newlen = len + 7;
|
||||
int32_t newbufsize = newlen + 2 * sizeof(int32_t) + 1;
|
||||
uint8_t *str = (uint8_t *)dst_gcalloc(DST_MEMORY_SYMBOL, newbufsize) + 2 * sizeof(int32_t);
|
||||
dst_string_length(str) = newlen;
|
||||
memcpy(str, buf, len);
|
||||
str[len] = '-';
|
||||
str[len + 1] = '-';
|
||||
str[len] = '_';
|
||||
str[newlen] = 0;
|
||||
uint8_t *saltbuf = str + len + 2;
|
||||
uint8_t *saltbuf = str + len + 1;
|
||||
int status = 1;
|
||||
while (status) {
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user