* libguile/symbols.c (lookup_uninterned_symbol)
(lookup_interned_latin1_symbol, lookup_interned_utf8_symbol)
(scm_i_str2symbol): Take an `obarray' argument. All callers changed.
(scm_make_obarray, scm_find_symbol, scm_intern, scm_unintern)
(scm_obarray_for_each): New functions.
* libguile/strings.c (scm_from_utf8_stringn): Use 'u8_mbtoucr' and check
for a decoding error by its 'nbytes' return value. Previously we used
'u8_mbtouc' and improperly assumed that a U+FFFD character indicated a
decoding error.
* libguile/symbols.c (utf8_string_equals_wide_string): Likewise.
* test-suite/tests/bytevectors.test (exception:decoding-error): New
variable.
("2.9 Operations on Strings"): Add tests.
* libguile/strings.c (scm_from_utf8_stringn):
* libguile/symbols.c (utf8_string_equals_wide_string): The "bad UTF8"
return from u8_mbtouc is a 0xfffd character, not a negative byte
length. Fixes a bug in which invalid UTF-8 would not be caught.
* libguile/bytevectors.c (scm_utf8_to_string): Use scm_from_utf8_stringn
directly. Just a little cleanup.
* test-suite/tests/iconv.test ("narrow non-ascii string"): Add test for
parsing bad utf-8 with substitution.
This reverts commit ad432bc831.
Not all gensyms need to be universally-unique: most of them just need to
be unique within some portion of a Guile session. We'll take a
different tack on this problem in the next commit.
* libguile/symbols.c (scm_gensym): Make the gensym counter a 128-bit
thread-local, initialized to a random number upon the first call to
`gensym' within a given thread. This counter is rendered as a 22 byte
suffix of mostly base64 digits.
* libguile/threads.h (scm_i_thread): Add a thread-local gensym_counter.
* libguile/threads.c (guilify_self_1): Initialize gensym_counter to NULL.
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
The old SCM2PTR and PTR2SCM were defined in such a way that
round-tripping through a pointer could lose precision, even in the
case in which you weren't interested in actually dereferencing the
pointer, it was simply that you needed to plumb a SCM through APIs
that take pointers. These new macros are more like SCM_PACK and
SCM_UNPACK, but for pointer types. The bit representation of the
pointer should be the same as the scm_t_bits representation.
* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
pointers. We are going to try tagging the SCM object itself in the
future, and I don't think that keeping this support is worth its
cost. It probably doesn't work anyway.
* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
* libguile/symbols.c (symbols_lock): Rename from intern_lock.
(lookup_interned_symbol, lookup_interned_latin1_symbol): Instead of
faith-based programming, just use the mutex. Though I haven't seen
this break, Ken is right!
* libguile/symbols.c (default_gensym_prefix): New variable.
(scm_gensym): Use it. Use `scm_from_latin1_stringn' instead of
`scm_from_locale_stringn'.
(scm_init_symbols): Initialize DEFAULT_GENSYM_PREFIX.
* libguile/symbols.c (lookup_interned_latin1_symbol): New helper.
(scm_from_latin1_symboln): Use lookup_interned_latin1_symbol, so we
avoid allocating a string in that case.
* libguile/hash.c (scm_i_string_hash): new function
(scm_hasher): don't unpack string: use scm_i_string_hash
* libguile/hash.h: new declaration for scm_i_string_hash
* libguile/print.c (quote_keywordish_symbol): use symbol accessors
(scm_i_print_symbol_name): new function
(scm_print_symbol_name): call scm_i_print_symbol_name
(iprin1): use scm_i_print_symbol_name to print symbols
* libguile/print.h: new declaration for scm_i_print_symbol_name
* libguile/symbols.c (lookup_interned_symbol): now takes scheme string
instead of c string; callers changed
(lookup_interned_symbol): add wide symbol support
(scm_i_c_mem2symbol): removed
(scm_i_mem2symbol): removed and replaced with scm_i_str2symbol
(scm_i_str2symbol): new function
(scm_i_mem2uninterned_symbol): removed and replaced with
scm_i_str2uninterned_symbol
(scm_i_str2uninterned_symbol): new function
(scm_make_symbol, scm_string_to_symbol, scm_from_locale_symbol)
(scm_from_locale_symboln): use scm_i_str2symbol
* test-suite/tests/symbols.test: new tests
* libguile/symbols.c (intern_symbol): New function, with code formerly
duplicated in `scm_i_c_mem2symbol ()' and `scm_i_mem2symbol ()'.
(scm_i_c_mem2symbol, scm_i_mem2symbol): Use it.
(scm_take_locale_symboln): Use `intern_symbol ()'. This fixes
bug #25865.
* test-suite/standalone/Makefile.am
(test_scm_take_locale_symbol_SOURCES,
test_scm_take_locale_symbol_CFLAGS,
test_scm_take_locale_symbol_LDADD): New variables.
(check_PROGRAMS, TESTS): Add `test-scm-take-locale-symbol'.
* libguile/symbols.c (lookup_interned_symbol): When a deleted weak pair
is encountered, remove it and update the hashtable's item count. Also,
check the hash table threshold and trigger a rehashing if needed.
(scm_i_c_mem2symbol): Allocate CELL using `scm_weak_car_pair ()' rather
than `scm_cons ()'.
(scm_i_mem2symbol): Likewise.
(scm_symbols_prehistory): Don't invoke `scm_permanent_object ()' for
SYMBOLS.
git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-44
* libguile/symbols.c (lookup_interned_symbol): When checking for `NULL',
use `SCM2PTR' rather than `SCM_UNPACK' (this fixes a warning).
git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-31
* symbols.h, symbols.c (SCM_I_F_SYMBOL_UNINTERNED,
scm_i_symbol_is_interned, scm_i_mem2symbol,
scm_i_mem2uninternedsymbol): Use it to store uninternedness flag.
(SCM_VALIDATE_STRING_COPY): Deprecated. Replaced all uses with
SCM_VALIDATE_STRING plus SCM_I_STRING_CHARS or
scm_to_locale_string, etc.
(SCM_VALIDATE_SUBSTRING_SPEC_COPY): Deprecated. Replaced as
above, plus scm_i_get_substring_spec.
* regex-posix.c, read.c, random.c, ramap.c, print.c, numbers.c,
hash.c, gc.c, gc-card.c, convert.i.c, backtrace.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, ports.c: Use
SCM_I_STRING_CHARS, SCM_I_STRING_UCHARS, and SCM_I_STRING_LENGTH
instead of SCM_STRING_CHARS, SCM_STRING_UCHARS, and
SCM_STRING_LENGTH, respectively. Also, replaced scm_return_first
with more explicit scm_remember_upto_here_1, etc, or introduced
them in the first place.
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
update, for thread safety.
(gensym_counter): Move into scm_gensym which is its only user.
(scm_init_symbols): No need to explicitly initialize gensym_counter.
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP
and SCM_I_INUM, respectively and adding deprecated versions to
deprecated.h and deprecated.c. Changed all uses to either use the
SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.
SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h".
Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and
scm_is_bool, respectively.