summaryrefslogtreecommitdiff
path: root/libguile/strings.c
AgeCommit message (Collapse)AuthorFilesLines
2009-08-19Try to optimize scm_string for speedMichael Gran1-10/+32
* libguile/strings.c (scm_string): optimize for speed
2009-08-19Rename string-width to string-bytes-per-charMichael Gran1-2/+2
* libguile/strings.h: rename scm_string_width to scm_string_bytes_per_char * libguile/strings.c (scm_string_width): renamed to scm_string_bytes_per_char (scm_string_bytes_per_char): renamed from scm_string_width * module/language/assembly/compile-bytecode.scm (write-bytecode): string-width -> string-bytes-per-char * module/language/glil/compile-assembly.scm (dump-object): string-width -> string-bytes-per-char
2009-08-19Misleading error message text in scm_i_string_writable_wide_charsMichael Gran1-1/+1
* libguile/strings.c (scm_i_string_writable_wide_chars): change error text
2009-08-18Avoid double-casts of stringbufMichael Gran1-11/+11
Conversion from char to scm_t_wchar require an intermediate cast to unsigned char. By changing the return type of SCM_STRINGBUF_INLINE_CHARS to unsigned char *, doublecasts in the code can be avoided. Also, some clarification of return types. * libguile/strings.c (STRINGBUF_OUTLINE_CHARS) (STRINGBUF_INLINE_CHARS): now returns unsigned char *; all callers changed.
2009-08-18Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-139/+743
Conflicts: lib/Makefile.am libguile/Makefile.am libguile/frames.c libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc_os_dep.c libguile/load.c libguile/macros.c libguile/objcodes.c libguile/programs.c libguile/strings.c libguile/vm.c m4/gnulib-cache.m4 m4/gnulib-comp.m4 m4/inline.m4
2009-08-12Don't include libunistring headers in Guile public headersMichael Gran1-4/+6
This requres the creation of a new type scm_t_string_failed_conversion_handler to replace libunistring's enum iconveh_ilseq_handler. * libguile/strings.h: don't include <uniconv.h> (scm_t_string_failed_conversion_handler): new enum type (SCM_FAILED_CONVERSION_ERROR, SCM_FAILED_CONVERSION_QUESTION_MARK): (SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE): new enum type values * libguile/strings.c (scm_to_stringn): now takes type scm_t_string_failed_conversion_handler. All callers changed. * libguile/print.c: include <uniconv.h> * libguile/ports.c (scm_lfwrite_substr): use scm_t_string_conversion_handler's constants * libguile/gen-scmconfig.c (SCM_ICONVEH_ERROR): (SCM_ICONVEH_QUESTION_MARK, SCM_ICONVEH_ESCAPE_SEQUENCE): store iconveh_ilseq_hander constants as #define's
2009-08-12Regression, scm_string fails to test for circular listsMichael Gran1-1/+2
* libguile/string.c (scm_string): Restores the functionality where scm_string tests for circular lists * test-suite/tests/strings.test: add test for circular lists
2009-08-12Some signed/unsigned comparison and conversionsMichael Gran1-1/+1
* libguile/ports.c (scm_lfwrite_str, scm_lfwrite_substr): signed/unsigned conversion and comparison * libguile/strings.c (scm_string_append): signed/unsigned comparison
2009-08-11Avoid unitialized and unused warnings in scm_string_appendMichael Gran1-9/+13
* libguile/strings.c (scm_string_append): avoid warnings
2009-08-11Only pass ints to tolower and toupperMichael Gran1-8/+8
* libguile/strings.c (unistring_escapes_to_guile_escapes): cast tolower's parameter to int * libguile/read.c (CHAR_DOWNCASE): cast tolower's parameter to int
2009-08-10Fix %string-dump and %symbol-dump fieldsMichael Gran1-11/+13
* libguile/strings.c (scm_sys_string_dump): don't print stringbuf. Print read-only status. (scm_sys_symbol_dump): don't print stringbuf. Print interned status.
2009-08-10Improve %string-dump and %symbol-dumpMichael Gran1-57/+173
%string-dump and %symbol-dump are modified to return assocation lists of string and symbol attributes instead of printing to stderr. They are no longer conditional on SCM_DEBUG. * libguile/strings.c (scm_sys_string_dump) (scm_sys_symbol_dump): now returns alist of properties. No longer require that SCM_DEBUG be defined. (scm_sys_stringbuf_hist): now conditional on SCM_STRING_LENGTH_HISTOGRAM * libguile/strings.h: scm_sys_string_dump and scm_sys_symbol dump are now declared as API
2009-08-09More comments for string functionsMichael Gran1-16/+59
* libguile/strings.c: comments
2009-08-08Add Unicode strings and symbolsMichael Gran1-104/+545
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-07-19add registry of vector constructors, make-generalized-vectorAndy Wingo1-0/+2
* libguile/generalized-vectors.h: * libguile/generalized-vectors.c: Add a registry of vector constructors. (scm_make_generalized_vector): New public function, constructs a vector of a given type. * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/srfi-4.c: * libguile/strings.c: * libguile/vectors.c: Register vector constructors. * libguile/extensions.c (scm_init_extensions): No need to NULL the list of registered extensions here, the static init does it for us. Allows scm_c_register_extension to be called before scm_init_extensions. * libguile/init.c (scm_i_init_guile): Move array initialization earlier, so e.g. scm_init_strings has access to a valid list of array element types when registering its vector constructor.
2009-07-19add generic array implementation facilityAndy Wingo1-1/+30
* libguile/array-handle.c (scm_i_register_array_implementation): (scm_i_array_implementation_for_obj): Add generic array facility, which will (in a few commits) detangle the array code. (scm_array_get_handle): Use the generic array facility. Note that scm_t_array_handle no longer has ref and set function pointers; instead it has a pointer to the array implementation. It is unlikely that code out there used these functions, however, as the supported way was through scm_array_handle_ref/set_x. (scm_array_handle_pos): Move this function here from arrays.c. (scm_array_handle_element_type): New function, returns a Scheme value representing the type of element stored in this array. * libguile/array-handle.h (scm_t_array_element_type): New enum, for generically determining the type of an array. (scm_array_handle_rank): (scm_array_handle_dims): These are now just #defines. * libguile/arrays.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/srfi-4.c: * libguile/strings.c: * libguile/vectors.c: Register array implementations for all of these. * libguile/inline.h: Update for array_handle_ref/set change. * libguile/deprecated.h: Need to include arrays.h now.
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/* )
2009-05-20Fix `explicitely' typos, should be `explicitly'Neil Jerram1-1/+1
2009-02-01Fix invalid writes to read-only stringbufs.Ludovic Courtès1-2/+9
* libguile/strings.c (SET_STRINGBUF_SHARED): Don't modify BUF if it's already marked as shared since it might be a read-only stringbuf. This error can be caught when linking with GNU ld with "-z relro".
2009-01-19Merge branch 'boehm-demers-weiser-gc' into bdw-gc-static-allocLudovic Courtès1-17/+14
2009-01-18Use `scm_gc malloc_pointerless ()' in `scm_i allocate_string_pointers ()'.Ludovic Courtès1-18/+15
* libguile/dynl.c (free_string_pointers): Remove. (scm_dynamic_args_call): Remove reference to `free_string_pointers ()' and remove dynwind. * libguile/posix.c (free_string_pointers): Remove. (scm_execl, scm_execlp, scm_execle, scm_environ): Remove references to `free_string_pointers ()'. * libguile/simpos.c (free_string_pointers): Remove. (scm_system_star): Remove reference to `free_string_pointers ()', remove enclosing dynwind. * libguile/strings.c (scm_i_allocate_string_pointers): Use `scm_gc_malloc_pointerless ()' and `scm_gc_malloc ()' instead of `scm_malloc ()' and `scm_to_locale_string ()', so that the result is automatically GC'd when no longer referenced. Remove unneeded dynwind. (scm_i_free_string_pointers): Remove. * libguile/strings.h (scm_i_free_string_pointers): Remove declaration.
2009-01-13Expose some of the string/stringbuf internal flags and tags.Ludovic Courtès1-4/+4
* libguile/strings.h (scm_tc7_ro_string, SCM_I_STRINGBUF_F_SHARED, SCM_I_STRINGBUF_F_INLINE): New macros. * libguile/strings.c (STRINGBUF_F_SHARED): Alias for `SCM_I_STRINGBUF_F_SHARED'. (STRINGBUF_F_INLINE): Alias for `SCM_I_STRINGBUF_F_INLINE'. (RO_STRING_TAG): Alias for `scm_tc7_ro_string'.
2008-12-14Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-2/+16
Conflicts: lib/Makefile.am libguile/struct.c libguile/threads.c m4/gnulib-cache.m4 m4/gnulib-comp.m4
2008-12-02Fix sloppy bound checking in `string-{ref,set!}' with the empty string.Ludovic Courtès1-2/+16
* libguile/strings.c (scm_string_ref): Add proper range checking for the empty string. (scm_string_set_x): Likewise. Reported by Bill Schottstaedt <bil@ccrma.Stanford.EDU>. * test-suite/tests/strings.test ("string-ref"): New test prefix. ("string-set!")["empty string", "empty string and non-zero index", "out of range", "negative index", "regular string"]: New tests. * NEWS: Update.
2008-10-11Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-28/+9
Conflicts: libguile/Makefile.am libguile/threads.c
2008-10-09Revert "Make literal strings (i.e., returned by `read') read-only."Ludovic Courtès1-28/+9
This reverts commit fb2f8886c4d537b0c7d3e9e78a8d4e5e272a36f4. The rationale is that `read' must return mutable strings, as reported by szgyg <szgyg@ludens.elte.hu>.
2008-09-23Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-10/+29
2008-09-23Make literal strings (i.e., returned by `read') read-only.Ludovic Courtès1-9/+28
* libguile/read.c (scm_read_string): Use `scm_i_make_read_only_string ()' to return a read-only string, as mandated by R5RS. Reported by Bill Schottstaedt <bil@ccrma.Stanford.EDU>. * libguile/strings.c (scm_i_make_read_only_string): New function. (scm_i_shared_substring_read_only): Special-case the empty string so that the read-only and read-write empty strings are `eq?'. This optimization is relied on by the `substring/shared' `empty string' test case in `srfi-13.test'. * libguile/strings.h (scm_i_make_read_only_string): New declaration. * test-suite/tests/strings.test ("string-set!")["literal string"]: New test. * NEWS: Update.
2008-09-23Make `symbol->string' return a read-only string.Ludovic Courtès1-1/+1
* libguile/strings.c (scm_i_symbol_substring): Return a read-only string since R5RS requires `symbol->string' to return a read-only string. Reported by Bill Schottstaedt <bil@ccrma.Stanford.EDU>. * test-suite/tests/symbols.test: Add `define-module' clause. (exception:immutable-string): Adjust to current exception. ("symbol->string")["result is an immutable string"]: Use `pass-if-exception' instead of `expect-fail-exception'. * NEWS: Update.
2008-09-17Remove use of `scm_i_thread_put_to_sleep ()' in the string code.Ludovic Courtès1-5/+9
* libguile/strings.c (scm_i_string_writable_chars): Remove use of `scm_i_thread_put_to_sleep ()'. This leaves a race condition, which is hopefully not harmful.
2008-09-16Use immutable double-cells for symbols.Ludovic Courtès1-2/+2
* libguile/strings.c (scm_i_make_symbol): Use `scm_immutable_double_cell ()'.
2008-09-15Remove unused GC string/symbol functions.Ludovic Courtès1-39/+1
* libguile/strings.c (scm_i_stringbuf_mark, scm_i_stringbuf_free, scm_i_string_mark, scm_i_string_free, scm_i_symbol_mark, scm_i_symbol_free): Remove. * libguile/strings.h: Remove corresponding declarations.
2008-09-13Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-0/+3
Conflicts: lib/Makefile.am libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc.c libguile/gc.h libguile/gc_os_dep.c libguile/private-gc.h m4/.cvsignore m4/gnulib-cache.m4 m4/gnulib-comp.m4
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-0/+3
2008-09-10Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-2/+12
Conflicts: libguile/Makefile.am libguile/coop-defs.h libguile/gc-card.c libguile/gc-freelist.c libguile/gc-malloc.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc.c libguile/gc.h libguile/gc_os_dep.c libguile/hashtab.c libguile/hashtab.h libguile/inline.h libguile/private-gc.h libguile/struct.c libguile/struct.h libguile/threads.c libguile/threads.h libguile/vectors.h libguile/weaks.h test-suite/tests/gc.test
2008-09-05Added `scm_gc_malloc_pointerless ()', equivalent to `GC_MALLOC_ATOMIC ()'.Ludovic Courtes1-2/+1
* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Tidied. (scm_gc_unregister_collectable_memory): Likewise. (scm_gc_malloc_pointerless): New. * libguile/gc.h (scm_gc_malloc_pointer_less): New declaration. * libguile/strings.c (make_stringbuf): Use it. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-5
2008-09-05Small fixes. Gets to the REPL and `abort ()'s soon after.Ludovic Courtes1-1/+2
* libguile/inline.h (scm_cell): Re-added comment about the assignment order of CAR/CDR. * libguile/srcprop.c (scm_make_srcprops): Use `scm_gc_malloc ()' instead of `malloc' + `scm_gc_register_collectable_memory ()'. * libguile/threads.c (guilify_self_1): Likewise. (guilify_self_2): Likewise. * libguile/strings.c (make_stringbuf): Use `GC_MALLOC_ATOMIC ()' instead of `scm_gc_malloc ()'. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-2
2008-07-05Add `scm_c_symbol_length ()'.Ludovic Courtès1-0/+10
2008-02-07More compilation fixes with Sun CC (bug #21378).Ludovic Courtès1-2/+2
2006-05-27Replace SCM_C_INLINE with SCM_C_INLINE_KEYWORD. Thanks to Mark Gran!Marius Vollmer1-1/+1
2006-04-17merge from 1.8 branchKevin Ryde1-4/+4
2006-01-29Renamed the "frames" that are related to dynamic-wind to "dynamicMarius Vollmer1-3/+3
contexts. Renamed all functions from scm_frame_ to scm_dynwind_. Updated documentation.
2006-01-24patches by Ludovic Courtès for symbol generation.Han-Wen Nienhuys1-3/+35
2005-06-24(scm_take_locale_stringn): Use realloc to make room forKevin Ryde1-17/+17
null-terminator, rather than mallocing a whole new block. (scm_take_locale_string): Use scm_take_locale_stringn len==-1.
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-03-02See ChangeLog from 2005-03-02.Marius Vollmer1-13/+13
2005-01-24Reverted changed from 2005/01/24 19:14:54, which was a commit to theMarius Vollmer1-13/+13
wrong branch. Sorry.
2005-01-24Threading changes.Marius Vollmer1-13/+13
2005-01-12Turn all deprecated features that once were macros but are nowMarius Vollmer1-3/+3
functions back into macros.
2004-09-29(SCM_STRING_CHARS): Explicitely reject read-only strings with an errorMarius Vollmer1-0/+15
message that blames SCM_STRING_CHARS.