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

28 commits

Author SHA1 Message Date
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
Kevin Ryde
994f151dc3 (scm_string_split): Compare char/char in scan. Mixing an
unsigned int SCM_CHAR and a char string meant an 8-bit char was never
matched.
2005-06-05 21:10:13 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Neil Jerram
5a6d139b35 * unif.c (scm_i_read_array): Declare rank as ssize_t, to guarantee
that it is signed.

* strports.c (st_resize_port): Add unsigned char cast.
(scm_mkstrport): Make read/write_buf cast unsigned.

* srfi-13.c (string_titlecase_x): Add unsigned char cast.

* rdelim.c (scm_read_line): Initialize slen.

* load.c (scm_search_path): Remove weird >=1, and add
parentheses to clarify conditions.

* hash.c (scm_hasher): Add const unsigned char cast.

* gh_data.c (gh_chars2byvect): Add scm_t_int8 cast.
2005-05-12 06:39:50 +00:00
Kevin Ryde
57d9803440 (scm_string_concatenate, scm_string_concatenate_shared):
Validate list argument, scm_string_append and scm_string_append_shared
don't do that to their rest argument (in a normal build).
2005-04-10 22:14:15 +00:00
Marius Vollmer
69d2000d93 Docstring updates. 2005-03-04 17:55:49 +00:00
Kevin Ryde
fdc6aebfaf (string-any, string-every): Use a scheme
wrapper around the C code so for the final call to the predicate
procedure is a tail call, per SRFI-13 spec.
2004-12-14 00:21:25 +00:00
Marius Vollmer
d2e53ed6f8 *** empty log message *** 2004-09-22 17:41:37 +00:00
Marius Vollmer
4a310f1c92 (scm_string_contains, scm_string_contains_ci): Reworded logic a bit so
that #f is returned immediately when s1 is too short to contain s2.
2004-09-22 15:03:17 +00:00
Marius Vollmer
1a82a4606c (scm_string_any, scm_string_every,
scm_string_tabulate, string_upcase_x, string_down_case_x,
string_titlecase_x, string_reverse_x, scm_string_tokenize): Use
size_t instead of int for indices into strings.  Make sure that no
over- or underflow occurs.  Thanks to Andreas Vögele!
(scm_xsubstring, scm_string_xcopy_x): Use ints for 'extended'
indices, which can also be negative.
2004-09-20 22:50:31 +00:00
Han-Wen Nienhuys
adba74f3a6 2004-09-13 Jan Nieuwenhuizen <janneke@gnu.org>
* srfi-13.c (scm_string_contains, s_scm_string_contains_ci):
	Bugfix: when subtracting unsigned values, make sure that result
	does not wrap.
2004-09-14 21:10:56 +00:00
Marius Vollmer
616775edb7 (scm_string_trim_right, scm_string_xcopy_x): Correctly use size_t for
some locals instead of int.
2004-09-07 13:48:49 +00:00
Marius Vollmer
3731fc6718 * srfi-13.c: First cut at thread-safeness and proper use of
scm_i_string_chars et al.  Copious scm_remember_upto_heres have
been inserted.  Made sure that no internal string pointer is used
across a SCM_TICK or a possible GC.
2004-08-25 16:04:09 +00:00
Marius Vollmer
2562032b61 (scm_string_rindex): Export to Scheme, as it has always been. 2004-08-25 13:42:04 +00:00
Marius Vollmer
63181a97f5 * srfi-13.c, srfi-13.h, srfi-14.c, srfi-14.h: New files.
* strop.h, strop.c: Removed, they are now empty.
* Makefile.am: Updated for new and removed files.
2004-08-24 22:12:08 +00:00