1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

64 commits

Author SHA1 Message Date
Rob Browning
859cd4eb9b doc: Fix composition describing scm_reverse_list_to_string
* libguile/srfi-13.c (scm_reverse_list_to_string): Replace string->list
  with list->string in the composition explaning how it works.  Thanks
  to Andrey Ivanov for reporting the problem.

Closes: 34457
2021-01-17 13:15:45 -06:00
Arun Isaac
67f5b451b0 doc: Document default delimiter of string-join.
* doc/ref/api-data.texi (String Constructors): Document default
delimiter of the string-join function.
* libguile/srfi-13.c (scm_string_join): Adjust docstring accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-06-18 00:30:30 +02:00
Andy Wingo
253cf3dc6f Revert "Revert scm_c_make_char rename"
My reversion of Mark's commit was in error; the supposed ABI change was
never released.

This reverts commit 3925a64682.
2019-08-24 11:57:39 +02:00
Andy Wingo
3925a64682 Revert scm_c_make_char rename
This was, I think, an unintentional ABI change.
Reverts 579dd2da44.
2019-08-02 15:19:17 +02:00
Mark H Weaver
d5c420a888 Add 'scm_c_make_char' and use it where appropriate.
This reverts the change to SCM_MAKE_CHAR made in the previous commit
63818453ad, which used an arithmetic trick
to avoid evaluating its argument more than once.

Here, we restore the previous implementation of SCM_MAKE_CHAR, which
evaluates its argument twice.  Instead, we introduce a new inlinable
function 'scm_c_make_char' and replace uses of SCM_MAKE_CHAR with calls
to 'scm_c_make_char' where appropriate.

* libguile/chars.h (scm_c_make_char): New inline function.
* libguile/inline.c: Include chars.h.
* libguile/srfi-13.c (REF_IN_CHARSET, scm_string_any, scm_string_every)
(scm_string_trim, scm_string_trim_right, scm_string_trim_both)
(scm_string_index, scm_string_index_right, scm_string_skip)
(scm_string_skip_right, scm_string_count, string_titlecase_x)
(string_reverse_x, scm_string_fold, scm_string_fold_right)
(scm_string_for_each, scm_string_filter, scm_string_delete):
Use 'scm_c_make_char' instead of 'SCM_MAKE_CHAR' in cases where the
argument calls a function.
* libguile/chars.c (scm_char_upcase, scm_char_downcase, scm_char_titlecase),
libguile/ports.c (scm_port_decode_char),
libguile/print.c (scm_simple_format),
libguile/read.c (scm_read_character),
libguile/strings.c (scm_string_ref, scm_c_string_ref),
2019-05-23 17:48:46 +02:00
Mark H Weaver
3ae69f3063 Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.
Partial fix for <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.

Fix several instances of the mistake of using 'scm_from_locale_*' for C
strings that originally came from a C string literal.  Change several
uses of 'scm_from_latin1_*' as well, to promote the practice of writing
code that works for arbitrary C string literals.

Also add missing years to the copyright notices of changed files, based
on the git history.

* libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c,
libguile/eval.c, libguile/expand.c, libguile/extensions.c,
libguile/filesys.c, libguile/init.c, libguile/load.c,
libguile/modules.c, libguile/pairs.c, libguile/posix.c,
libguile/print.c, libguile/random.c, libguile/read.c,
libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c,
libguile/stacks.c, libguile/stime.c, libguile/strports.c,
libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2019-05-23 16:41:53 +02:00
Andy Wingo
1234bb1850 Update license notices in all C files
Update to newest recommended license notices from the FSF.  Everything
stays LGPLv3+ except guile-readline which is GPLv3+.
2018-06-20 20:07:34 +02:00
Andy Wingo
791eb0c01a Remove (C) from copyright statements
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.'  It does take up
space though!  For that reason, we remove it here from our C files.
2018-06-20 19:17:06 +02:00
Andy Wingo
b8d757732f Rationalize include order in C files
Include config.h first, then system includes, then libguile includes, in
alphabetical order, then the include for the file in question.
2018-06-20 18:31:24 +02:00
Andy Wingo
3068bc7384 Make libguile header inclusion consistent within libguile c files
Change from '#include "libguile/foo.h"' and '#include <libguile/foo.h>'
to '#include "foo.h"'.
2018-06-20 17:19:31 +02:00
Andy Wingo
40ade0886e Remove _scm.h
* libguile/_scm.h: Remove.  An internal header, never installed.
* libguile/__scm.h: Remove horrible documentation.
* libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  Remove _scm.h.
* libguile/alist.c:
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/async.c:
* libguile/atomic.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/boolean.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/debug-malloc.c:
* libguile/debug.c:
* libguile/deprecated.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/dynstack.c:
* libguile/dynwind.c:
* libguile/eq.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/extensions.c:
* libguile/fdes-finalizers.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/gen-scmconfig.c:
* libguile/generalized-arrays.c:
* libguile/generalized-vectors.c:
* libguile/gettext.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/init.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/keywords.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/null-threads.c:
* libguile/numbers.c:
* libguile/objprop.c:
* libguile/options.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports-internal.h:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srcprop.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/srfi-60.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/strorder.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/unicode.c:
* libguile/uniform.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Remove _scm.h includes.
2018-06-20 14:26:01 +02:00
Andy Wingo
a7bcd66f6f Devolve symbols.h from _scm.h
* libguile/_scm.h: Remove symbols.h.
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/keywords.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/read.c:
* libguile/socket.c:
* libguile/srcprop.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/strings.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vm.c: Add symbols.h.
2018-06-20 12:19:12 +02:00
Andy Wingo
bf15afa6bf Move subr snarfing macros to gsubr.h.
* libguile/snarf.h: Remove gsubr include and subr snarfers.
* libguile/gsubr.h (SCM_DEFINE_GSUBR, SCM_DEFINE, SCM_PRIMITIVE_GENERIC):
  (SCM_DEFINE_PUBLIC, SCM_PROC, SCM_REGISTER_PROC, SCM_GPROC): Move
  here.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/async.c:
* libguile/atomic.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/boolean.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/debug-malloc.c:
* libguile/debug.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/eq.c:
* libguile/error.c:
* libguile/error.h:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/extensions.c:
* libguile/fdes-finalizers.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/generalized-arrays.c:
* libguile/generalized-vectors.c:
* libguile/gettext.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/keywords.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/numbers.c:
* libguile/objprop.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srcprop.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/srfi-60.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/strorder.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/unicode.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Add gsubr includes.
2018-06-20 09:04:55 +02:00
Andy Wingo
d3cfabd89b Devolve numbers.h from _scm.h.
* libguile/_scm.h: Remove numbers.h.
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/debug-malloc.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/generalized-arrays.c:
* libguile/gettext.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/list.c:
* libguile/memoize.c:
* libguile/net_db.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/posix-w32.c:
* libguile/posix.c:
* libguile/procprop.c:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/srcprop.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-table.c: Add numbers.h.
2018-06-19 15:37:23 +02:00
Andy Wingo
27df59415e Devolve procs.h include from _scm.h.
* libguile/_scm.h: Remove procs.h include.
* libguile/arrays.c:
* libguile/foreign-object.c:
* libguile/ports.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/scmsigs.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/strports.c:
* libguile/weak-table.c: Add procs includes.
2018-06-19 09:36:25 +02:00
Andy Wingo
730cfd80e2 Devolve pairs.h
* libguile/_scm.h: Remove pairs.h.
* libguile/alist.c:
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/async.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/debug.c:
* libguile/deprecation.c:
* libguile/dynwind.c:
* libguile/eq.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/fdes-finalizers.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/gc.c:
* libguile/generalized-arrays.c:
* libguile/goops.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/ioext.c:
* libguile/keywords.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/numbers.c:
* libguile/objprop.c:
* libguile/options.c:
* libguile/ports-internal.h:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/print.h:
* libguile/procprop.c:
* libguile/programs.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srcprop.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-60.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/strorder.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/values.c:
* libguile/vectors.c:
* libguile/vm.c:
* libguile/weak-list.h:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Add pairs.h.
2018-06-18 22:03:13 +02:00
Andy Wingo
1a99bd10f8 Devolve boolean.h include.
* libguile/_scm.h: Remove boolean.h include.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/dynwind.c:
* libguile/eq.c:
* libguile/eval.c:
* libguile/expand.c:
* libguile/fdes-finalizers.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/generalized-arrays.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/guardians.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/intrinsics.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/numbers.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.h:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/scmsigs.c:
* libguile/sort.c:
* libguile/srcprop.h:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-14.h:
* libguile/srfi-4.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strorder.c:
* libguile/struct.c:
* libguile/struct.h:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vports.c: Add boolean.h includes.
2018-06-18 21:38:44 +02:00
Andy Wingo
c248ea10be Remove all deprecated code
* module/ice-9/debug.scm:
* module/ice-9/mapping.scm:
* module/ice-9/syncase.scm: Delete these deprecated files.
* module/Makefile.am: Remove deleted files.
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/backtrace.c:
* libguile/goops.c:
* libguile/numbers.c:
* libguile/socket.c:
* libguile/srfi-13.c:
* module/ice-9/deprecated.scm:
* module/ice-9/format.scm:
* module/oop/goops.scm:
* module/statprof.scm:
* module/texinfo/reflection.scm:
* module/web/client.scm:
* module/web/uri.scm: Remove deprecated code.
2017-05-22 13:36:42 +02:00
Andy Wingo
c38b9625c8 Remove unnecessary scm_i_string_start_writing calls
* libguile/strings.c (scm_string, scm_c_make_string):
* libguile/srfi-13.c (scm_reverse_list_to_string, scm_string_map)
  (scm_string_unfold, scm_string_unfold_right, scm_xsubstring)
  (scm_string_filter, scm_string_delete): Remove
  scm_i_string_start_writing / scm_i_string_stop_writing calls around
  fresh strings that aren't visible to other threads.
2017-02-16 10:43:23 +01:00
Mark H Weaver
793e8a9317 Fix 'string-copy!' to work properly with overlapping src/dest.
* libguile/srfi-13.c (scm_string_copy_x): Fix to work properly with
  overlapping src/dest.

* test-suite/tests/srfi-13.test ("string-copy!"): Add tests.
2014-01-08 21:42:24 -05:00
Mark H Weaver
de2bc673bb scm_string_join: properly sequence operations in ADD_TO_APPEND_LIST
* libguile/srfi-13.c (scm_string_join): Properly sequence operations in
  ADD_TO_APPEND_LIST macro.
2013-04-01 05:31:08 -04:00
Mark H Weaver
786ab4258f Optimize 'string-join'.
* libguile/srfi-13.c (string-join): Rewrite to call 'scm_string_append'
  only once.
2013-04-01 03:47:29 -04:00
Mark H Weaver
3b80c35852 Fix typos in 'string-join' docs: 'string-infix' -> 'strict-infix'.
* doc/ref/api-data.texi (String Constructors): In definition of
  'string-join', change 'string-infix' -> 'strict-infix'.

* libguile/srfi-13.c (scm_string_join): In docstring, change
  'string-infix' -> 'strict-infix'.
2013-04-01 01:21:30 -04:00
Daniel Hartwig
5f085775ab In string-split, add support for character sets and predicates.
* libguile/srfi-13.c (string-split): Add support for splitting on
  character sets and predicates, like string-index and others.
* test-suite/tests/strings.test (string-split): Add tests covering
  the new argument types.
* doc/ref/api-data.texi (string-split): Update.

Signed-off-by: Mark H Weaver <mhw@netris.org>
2012-10-12 08:15:08 -04:00
Andy Wingo
47153f29b0 micro-optimizations to string-trim-both, and to (web http)
* libguile/srfi-13.c (scm_string_trim, scm_string_trim_right)
  (scm_string_trim_both): Take the whitespace fast-path if the char_pred
  is scm_char_set_whitespace.

* module/web/http.scm (read-header, split-and-trim, parse-quality-list):
  (parse-param-component, parse-credentials, "Content-Type"):
  (read-request-line, read-response-line): Use char-set:whitespace
  instead of char-whitespace?.  It avoids recursing into the VM.
2012-03-22 09:55:28 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/generalized-arrays.c:
* libguile/hashtab.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/promises.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Make the variable names in the C docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:22:10 +01:00
Mark H Weaver
b2fb40a903 Avoid calling scm_i_string_start_writing if no chars will be mutated
* libguile/srfi-13.c (scm_string_copy_x, scm_substring_fill_x,
  string_upcase_x, string_downcase_x, string_titlecase_x,
  string_reverse_x, scm_string_xcopy_x): Avoid calling
  `scm_i_string_start_writing' if the range of indices to be modified is
  empty.  This avoids the error that would be raised by
  `scm_i_string_start_writing' if the string is not mutable.
  Thanks to Bruce Korb <bkorb@gnu.org> for reporting this problem
  and suggesting the fix.
2012-01-08 20:10:11 -05:00
Ludovic Courtès
190d4b0d93 Make VM string literals immutable.
* libguile/strings.c (scm_i_make_string, scm_i_make_wide_string): Add
  `read_only_p' parameter.  All callers updated.

* libguile/vm-i-loader.c (load_string, load_wide_string): Push read-only
  strings.

* test-suite/tests/strings.test ("literals"): New test prefix.
2011-03-20 23:34:42 +01:00
Mark H Weaver
06fc34c23f Fix bug to make `string=' much faster
* libguile/srfi-13.c (scm_string_eq): Fix a bug which caused the slow
  general string_compare function to be used for strings of unequal
  lengths.
2011-03-10 17:38:26 -05:00
Ralf Wildenhues
ffb62a43dc fix typos in the manual bits generated from source comments.
* libguile/bitvectors.c, libguile/chars.c,
libguile/deprecated.c, libguile/numbers.c, libguile/random.c,
libguile/read.c, libguile/root.c, libguile/srfi-1.c,
libguile/srfi-13.c, libguile/srfi-14.c, libguile/uniform.c:
Fix typos, add missing newlines.
2011-02-09 22:28:49 +00:00
Ludovic Courtès
215e03127d Enclose SRFI-13 deprecation handling in `#if SCM_ENABLE_DEPRECATED == 1'.
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Enclose
  deprecated call convention handling in `#if SCM_ENABLE_DEPRECATED == 1'.
2011-02-02 22:02:09 +01:00
Ludovic Courtès
bf7c2e964e Improve doc of string-index', string-index-right', and `string-rindex'.
Suggested by Noah Lavine <noah.b.lavine@gmail.com>.

* doc/ref/api-data.texi (String Searching): Mention the return value of
  `string-index', `string-index-right', and `string-rindex' when no
  match is found.

* libguile/srfi-13.c (scm_string_index, scm_string_index_right,
  scm_string_rindex): Adjust docstring accordingly.
2011-01-04 18:08:58 +01:00
Andy Wingo
9fe717e23c fix string-filter and string-delete argument order
* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
  char_pred and s argument order, to comply with SRFI-13. There is a
  back-compat shim that will detect programs that used the old,
  erroneous interface, while giving a warning.

* doc/ref/api-data.texi: Update docs.
2010-11-19 17:08:36 +01:00
Ludovic Courtès
7614c983a5 Fix type-checking in the optimized path of `string=?'.
* libguile/srfi-13.c (scm_string_eq): Properly type-check S1 and S2.

* test-suite/tests/strings.test ("string=?")["1st argument EOF", "2nd
  argument EOF"]: New tests exposing the problem.
2010-07-13 00:08:09 +02:00
Ludovic Courtès
0cc92ac41b Optimize `string=' for the common case.
* libguile/srfi-13.c (scm_string_eq): Add a fast path for the common
  case.
2010-07-04 18:44:08 +02:00
Julian Graham
820f33aaed Improved support for Unicode title case in Guile's string and character APIs.
* doc/ref/api-data.texi (Characters): Documentation for `char-titlecase'.
* doc/ref/api-i18n.texi (Character Case Mapping): Documentation for
  `char-locale-titlecase' and `string-locale-titlecase'.

* libguile/chars.c, libguile/chars.h (scm_char_titlecase, scm_c_titlecase): New
  functions.

* libguile/i18n.c, libguile/i18n.h (chr_to_case, scm_char_locale_titlecase,
  str_to_case, scm_string_locale_titlecase): New functions.
* libguile/i18n.c (scm_char_locale_downcase, scm_char_locale_upcase,
  scm_string_locale_downcase, scm_string_locale_upcase): Refactor to share code
  via chr_to_case and str_to_case, as appropriate.
* module/ice-9/i18n.scm (char-locale-title-case, string-locale-titlecase): New
  functions.

* libguile/srfi-13.c (string_titlecase_x): Use uc_totitle instead of uc_toupper.

* test-suite/tests/chars.test: Tests for `char-titlecase'.
* test-suite/tests/i18n.test: Tests for `char-locale-titlecase' and
  `string-locale-titlecase'.
* test-suite/tests/srfi-13.test: Tests for `string-titlecase'.
2009-12-22 00:19:56 -05:00
Andy Wingo
6c9e8a5354 remove uses of trampolines within guile itself
* libguile/eval.c (scm_map, scm_for_each)
* libguile/hashtab.c (scm_hash_for_each_handle)
* libguile/list.c (scm_filter, scm_filter_x)
* libguile/quicksort.i.c:
* libguile/sort.c (scm_restricted_vector_sort_x, scm_sorted_p)
  (scm_merge, scm_merge_list_x, scm_merge_x)
  (scm_merge_list_step, scm_sort_x, scm_sort, scm_merge_vector_x)
  (scm_merge_vector_step, scm_stable_sort_x, scm_sort_list_x)
  (scm_sort_list)nn
* libguile/srfi-13.c (scm_string_any, scm_string_every)
  (scm_string_tabulate, scm_string_trim, string_trim_right)
  (scm_string_trim_both, scm_string_index, scm_string_index_right)
  (scm_string_skip, scm_string_skip_right, scm_string_count)
  (scm_string_map, scm_string_map_x, scm_string_for_each)
  (scm_string_for_each_index, scm_string_filter, scm_string_delete):
  Remove uses of trampolines.
2009-12-01 21:00:25 +01:00
Andy Wingo
4b1c3f0e06 fix bug in string comparison
* libguile/srfi-13.c (compare_strings): Switch the "longer" and
  "shorter" arguments. All the callers of this function assumed that
  shorter came first. Fixes (string<? "abc" "abcd").
2009-11-14 13:25:00 +01:00
Michael Gran
53a468dd8c type limits error in string-tabulate
* libguile/srfi-13.c (scm_string_tabulate): test range of signed integer
  before casting it to unsigned size_t
2009-08-20 08:14:28 -07:00
Michael Gran
f846bd1a8f Update srfi-13 functions for Unicode
* libguile/srfi-13.c (MY_SUBF_VALIDATE_SUBSTRING_SPEC): new macro
  (MY_VALIDATE_SUBSTRING_SPEC_COPY): now unused, removed
  (MY_VALIDATE_SUBSTRING_SPEC_UCOPY): now unused, removed
  (REF_IN_CHARSET): new macro
  (race_error)[0]: unused, removed
  (scm_string_any, scm_string_every, scm_string_tabulate)
  (scm_substring_to_list, scm_reverse_string_to_list)
  (scm_reverse_list_to_string, scm_string_join)
  (s_scm_srfi13_substring_copy, scm_string_copy, scm_string_copy_x)
  (scm_string_pad, scm_string_pad_right, scm_string_trim)
  (scm_string_trim_right, scm_string_trim_both, scm_substring_fill_x):
  (scm_string_compare, scm_string_compare_ci): modified for
  both wide and narrow strings
  (compare_string): new function
  (scm_string_eq, scm_string_neq, scm_string_lt, scm_string_gt)
  (scm_string_le, scm_string_ge, scm_string_ci_eq, scm_string_ci_neq)
  (scm_string_ci_lt, scm-string_ci_gt, scm_string_ci_le, scm_string_ci_gt)
  (scm_substring_hash, scm_string_prefix_length, scm_string_suffix_length)
  (scm_string_prefix_length_ci, scm_string_suffix_length_ci)
  (scm_string_prefix_p, scm_string_prefix_ci_p, scm_string_suffix_p)
  (scm_string_suffix_ci_p, scm_string_index, scm_string_index_right)
  (scm_string_skip, scm_string_skip_right, scm_string_count)
  (scm_string_contains, scm_string_contains_ci, string_upcase_x)
  (scm_substring_upcase_x, scm_substring_upcase, string_downcase_x)
  (scm_string_downcase_x, scm_string_downcase, scm_string_titlecase_x)
  (scm_string_titlecase, scm_string_capitalize, scm_string_reverse)
  (scm_string_reverse_x, scm_string_map, scm_string_map_x)
  (scm_string_fold, scm_string_fold_right, scm_string_unfold)
  (scm_string_unfold_right, scm_xsubstring, scm_string_xcopy_x)
  (scm_string_replace, scm_string_tokenize, scm_string_split)
  (scm_string_filter, scm_string_delete): modified for both wide and
  narrow strings
2009-08-19 23:21:39 -07:00
Michael Gran
9c44cd4559 Add Unicode strings and symbols
This adds full Unicode strings as a datatype, and it adds some
minimal functionality.  The terminal and port encoding is assumed
to be ISO-8859-1.  Non-ISO-8859-1 characters are written or
input as string character escapes.

The string character escapes now have 3 forms: \xXX \uXXXX and
\UXXXXXX, for unprintable characters that have 2, 4 or 6 hex digits.

The process for writing to strings has been modified.  There is now a
function scm_i_string_start_writing that does the copy-on-write
conversion if necessary.

To compile strings that may be wide, the VM storage of strings and
string-likes has changed.

Most string-using functions have not yet been updated and may break
when used with wide strings.


        * module/language/assembly/compile-bytecode.scm (write-bytecode):
        use variable width string bytecode format

        * module/language/assembly.scm (byte-length): use variable width
        bytecode format

        * libguile/vm-i-loader.c (load-string, load-symbol):
        (load-keyword, define): use variable-width bytecode format

        * libguile/vm-engine.h (FETCH_WIDTH): new macro

        * libguile/strings.h: new declarations

        * libguile/strings.c (make_wide_stringbuf): new function
        (widen_stringbuf): new function
        (scm_i_make_wide_string): new function
        (scm_i_is_narrow_string): new function
        (scm_i_string_wide_chars): new function
        (scm_i_string_start_writing): new function
        (scm_i_string_ref): new function
        (scm_i_string_set_x): new function
        (scm_i_is_narrow_symbol): new function
        (scm_i_symbol_wide_chars, scm_i_symbol_ref): new function
        (scm_string_width): new function
        (unistring_escapes_to_guile_escapes): new function
        (scm_to_stringn): new function
        (scm_i_stringbuf_free): modify for wide strings
        (scm_i_substring_copy): modify for wide strings
        (scm_i_string_chars, scm_string_append): modify for wide strings
        (scm_i_make_symbol, scm_to_locale_stringn): modify for wide strings
        (scm_string_dump, scm_symbol_dump, scm_to_locale_stringbuf):
        (scm_string, scm_i_deprecated_string_chars): modify for wide strings
        (scm_from_locale_string, scm_from_locale_stringn): add null test

        * libguile/srfi-13.c: add calls for scm_i_string_start_writing for
        each call of scm_i_string_stop_writing
        (scm_string_for_each): modify for wide strings

        * libguile/socket.c: add calls for scm_i_string_start_writing for each
        call of scm_i_string_stop_writing

        * libguile/rw.c: add calls for scm_i_string_start_writing for each
        call of scm_i_string_stop_writing

        * libguile/read.c (scm_read_string): allow reading of wide strings

        * libguile/print.h: add declaration for scm_charprint

        * libguile/print.c (iprin1): print wide strings and add new string
        escapes
        (scm_charprint): new function

        * libguile/ports.h: new declarations for scm_lfwrite_substr and
        scm_lfwrite_str

        * libguile/ports.c (update_port_lf): new function
        (scm_lfwrite): use update_port_lf
        (scm_lfwrite_substr): new function
        (scm_lfwrite_str): new function

        * test-suite/tests/asm-to-bytecode.test ("compiler"): add string
        width byte to sting-like asm tests
2009-08-08 02:35:00 -07:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Ludovic Courtès
dbb605f575 Include <config.h> in all C files; use #ifdef HAVE_CONFIG_H' rather than #if'. 2008-09-13 15:35:27 +02:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Kevin Ryde
a003f3eb60 (scm_string_append_shared): No copying if just one
non-empty string in args.
2005-11-30 00:26:08 +00:00
Kevin Ryde
1729055bcf (scm_string_for_each_index): Correction to docstring. 2005-08-12 01:14:02 +00:00
Kevin Ryde
3540b91548 (scm_string_any, scm_string_every, scm_string_tabulate,
scm_string_trim, scm_string_trim_right, scm_string_trim_both,
scm_string_index, scm_string_index_right, scm_string_skip,
scm_string_skip_right, scm_string_count, scm_string_map,
scm_string_map_x, scm_string_for_each, scm_string_for_each_index,
scm_string_filter, scm_string_delete): Use scm_t_trampoline_1 for
procedures called in loops.
2005-08-06 01:44:30 +00:00
Kevin Ryde
8591234398 (scm_string_filter, scm_string_delete): Strip leading and
trailing deletions, so as to return a substring if those are the only
changes.
2005-07-11 23:59:57 +00:00
Kevin Ryde
8230ee411d (scm_string_filter, scm_string_delete): Partial revert
last change, use plain copy-on-write substrings, the individual
descriptions in the srfi don't mention shared storage (only the
introduction does).
2005-06-24 21:53:10 +00:00
Kevin Ryde
8753a993c1 (scm_string_filter, scm_string_delete): For char and
charset cases, count chars kept and build a string in a second pass,
rather than using a cons cell for every char kept.  Use a shared
substring when nothing removed (such sharing is allowed by the srfi).
2005-06-10 22:34:59 +00:00