summaryrefslogtreecommitdiff
path: root/libguile/srfi-13.c
AgeCommit message (Collapse)AuthorFilesLines
2012-03-07micro-optimizations to string-trim-both, and to (web http)Andy Wingo1-4/+7
* 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-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-3/+3
* 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-01-08Avoid calling scm_i_string_start_writing if no chars will be mutatedMark H Weaver1-75/+95
* 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.
2011-03-20Make VM string literals immutable.Ludovic Courtès1-13/+13
* 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-10Fix bug to make `string=' much fasterMark H Weaver1-1/+3
* 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-02-09fix typos in the manual bits generated from source comments.Ralf Wildenhues1-12/+12
* 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-02Enclose SRFI-13 deprecation handling in `#if SCM_ENABLE_DEPRECATED == 1'.Ludovic Courtès1-2/+6
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Enclose deprecated call convention handling in `#if SCM_ENABLE_DEPRECATED == 1'.
2011-01-04Improve doc of `string-index', `string-index-right', and `string-rindex'.Ludovic Courtès1-4/+7
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.
2010-11-19fix string-filter and string-delete argument orderAndy Wingo1-6/+35
* 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-07-13Fix type-checking in the optimized path of `string=?'.Ludovic Courtès1-1/+2
* 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-04Optimize `string=' for the common case.Ludovic Courtès1-1/+23
* libguile/srfi-13.c (scm_string_eq): Add a fast path for the common case.
2009-12-22Improved support for Unicode title case in Guile's string and character APIs.Julian Graham1-1/+1
* 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-01remove uses of trampolines within guile itselfAndy Wingo1-53/+52
* 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-11-14fix bug in string comparisonAndy Wingo1-4/+4
* 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-08-20type limits error in string-tabulateMichael Gran1-1/+1
* libguile/srfi-13.c (scm_string_tabulate): test range of signed integer before casting it to unsigned size_t
2009-08-19Update srfi-13 functions for UnicodeMichael Gran1-913/+593
* 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-08Add Unicode strings and symbolsMichael Gran1-9/+14
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-06-17Change Guile license to LGPLv3+Neil Jerram1-6/+7
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-1/+5
2006-04-17merge from 1.8 branchKevin Ryde1-71/+83
2005-11-30(scm_string_append_shared): No copying if just oneKevin Ryde1-9/+23
non-empty string in args.
2005-08-12(scm_string_for_each_index): Correction to docstring.Kevin Ryde1-2/+16
2005-08-06(scm_string_any, scm_string_every, scm_string_tabulate,Kevin Ryde1-35/+62
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-07-11(scm_string_filter, scm_string_delete): Strip leading andKevin Ryde1-9/+50
trailing deletions, so as to return a substring if those are the only changes.
2005-06-24(scm_string_filter, scm_string_delete): Partial revertKevin Ryde1-9/+9
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-10(scm_string_filter, scm_string_delete): For char andKevin Ryde1-50/+121
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-05(scm_string_split): Compare char/char in scan. Mixing anKevin Ryde1-1/+1
unsigned int SCM_CHAR and a char string meant an 8-bit char was never matched.
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-05-12* unif.c (scm_i_read_array): Declare rank as ssize_t, to guaranteeNeil Jerram1-1/+1
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-04-10(scm_string_concatenate, scm_string_concatenate_shared):Kevin Ryde1-1/+3
Validate list argument, scm_string_append and scm_string_append_shared don't do that to their rest argument (in a normal build).
2005-03-04Docstring updates.Marius Vollmer1-26/+31
2004-12-14(string-any, string-every): Use a schemeKevin Ryde1-2/+2
wrapper around the C code so for the final call to the predicate procedure is a tail call, per SRFI-13 spec.
2004-09-22*** empty log message ***Marius Vollmer1-7/+7
2004-09-22(scm_string_contains, scm_string_contains_ci): Reworded logic a bit soMarius Vollmer1-33/+35
that #f is returned immediately when s1 is too short to contain s2.
2004-09-20(scm_string_any, scm_string_every,Marius Vollmer1-23/+28
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-142004-09-13 Jan Nieuwenhuizen <janneke@gnu.org>Han-Wen Nienhuys1-2/+2
* 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-07(scm_string_trim_right, scm_string_xcopy_x): Correctly use size_t forMarius Vollmer1-2/+2
some locals instead of int.
2004-08-25* srfi-13.c: First cut at thread-safeness and proper use ofMarius Vollmer1-212/+264
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(scm_string_rindex): Export to Scheme, as it has always been.Marius Vollmer1-3/+16
2004-08-24* srfi-13.c, srfi-13.h, srfi-14.c, srfi-14.h: New files.Marius Vollmer1-0/+3323
* strop.h, strop.c: Removed, they are now empty. * Makefile.am: Updated for new and removed files.