mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-06-07 11:25:07 +02:00
fixing a simple offby1 error in intern previously hidden by the
prevalence of huffman-coded symbols.
This commit is contained in:
parent
667e8959e0
commit
17e4f63f94
1 changed files with 2 additions and 2 deletions
4
sexp.c
4
sexp.c
|
@ -708,7 +708,7 @@ sexp sexp_intern(sexp ctx, char *str) {
|
||||||
#else
|
#else
|
||||||
bucket = 0;
|
bucket = 0;
|
||||||
#endif
|
#endif
|
||||||
len = strlen(str);
|
len = strlen(str) + 1; /* include the trailing NULL in the comparison */
|
||||||
for (ls=sexp_context_symbols(ctx)[bucket]; sexp_pairp(ls); ls=sexp_cdr(ls))
|
for (ls=sexp_context_symbols(ctx)[bucket]; sexp_pairp(ls); ls=sexp_cdr(ls))
|
||||||
if (! strncmp(str, sexp_string_data(sexp_symbol_string(sexp_car(ls))), len))
|
if (! strncmp(str, sexp_string_data(sexp_symbol_string(sexp_car(ls))), len))
|
||||||
return sexp_car(ls);
|
return sexp_car(ls);
|
||||||
|
@ -717,7 +717,7 @@ sexp sexp_intern(sexp ctx, char *str) {
|
||||||
sexp_gc_preserve1(ctx, sym);
|
sexp_gc_preserve1(ctx, sym);
|
||||||
sym = sexp_alloc_type(ctx, symbol, SEXP_SYMBOL);
|
sym = sexp_alloc_type(ctx, symbol, SEXP_SYMBOL);
|
||||||
if (sexp_exceptionp(sym)) return sym;
|
if (sexp_exceptionp(sym)) return sym;
|
||||||
sexp_symbol_string(sym) = sexp_c_string(ctx, str, len);
|
sexp_symbol_string(sym) = sexp_c_string(ctx, str, len-1);
|
||||||
sexp_push(ctx, sexp_context_symbols(ctx)[bucket], sym);
|
sexp_push(ctx, sexp_context_symbols(ctx)[bucket], sym);
|
||||||
sexp_gc_release1(ctx);
|
sexp_gc_release1(ctx);
|
||||||
return sym;
|
return sym;
|
||||||
|
|
Loading…
Add table
Reference in a new issue