summaryrefslogtreecommitdiff
path: root/libguile/strings.c
AgeCommit message (Collapse)AuthorFilesLines
2011-01-26Optimize `scm_{to,from}_latin1_string'.Ludovic Courtès1-2/+29
* libguile/strings.c (scm_from_latin1_stringn): Directly return a narrow string instead of going through `scm_from_stringn'. (scm_to_latin1_stringn): Directly return a copy of STR's raw bytes when it's narrow.
2011-01-23Hide the string escaping hacks.Ludovic Courtès1-7/+11
* libguile/strings.c (scm_i_unistring_escapes_to_guile_escapes): Rename to... (unistring_escapes_to_guile_escapes): ... this. Make `static'. (scm_i_unistring_escapes_to_r6rs_escapes): Rename to... (unistring_escapes_to_r6rs_escapes): ... this. Make `static'. * libguile/strings.h (scm_i_unistring_escapes_to_guile_escapes, scm_i_unistring_escapes_to_r6rs_escapes): Remove declarations.
2011-01-07fix scm_from_stringn empty string caseAndy Wingo1-3/+3
* libguile/strings.c (scm_from_stringn): Fix empty string case (oops...).
2011-01-07use scm_from_latin1_symboln for string literals and load-symbolAndy Wingo1-24/+24
* libguile/bytevectors.c: * libguile/eval.c: * libguile/goops.c: * libguile/i18n.c: * libguile/load.c: * libguile/memoize.c: * libguile/modules.c: * libguile/ports.c: * libguile/print.c: * libguile/procs.c: * libguile/programs.c: * libguile/read.c: * libguile/script.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/strings.c: * libguile/throw.c: * libguile/vm.c: Use scm_from_latin1_symboln to make symbols from string literals, because they aren't in the user's locale -- they are in ASCII, and we can optimize this case. * libguile/vm-i-loader.c: Also use scm_from_latin1_symboln when loading narrow symbols.
2011-01-07add scm_{to,from}_{utf8,latin1}_string{n,}Andy Wingo1-32/+49
* libguile/strings.h: * libguile/strings.c (scm_from_latin1_string, scm_to_latin1_string): New functions, in terms of the latin1_stringn variants. (scm_from_utf8_string, scm_from_utf8_stringn) (scm_to_utf8_string, scm_to_utf8_stringn): New functions. (scm_i_from_utf8_string, scm_i_to_utf8_string): Removed these internal functions. (scm_from_stringn): Handle -1 as a length. Unlike the previous behavior of scm_from_locale_string (NULL), which returned the empty string, we now raise an error. The null pointer is not the same as the empty string. * libguile/stime.c (scm_strftime, scm_strptime): Adapt to publishing of utf8 functions.
2010-12-16Inline `scm_is_string'.Ludovic Courtès1-5/+0
* libguile/strings.c (scm_is_string): Move to... * libguile/inline.h (scm_is_string): ... here. Inline.
2010-12-04make-string et al nulls memory if not given an initializerAndy Wingo1-3/+7
* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the memory block, so users need to make sure it is initialized. * libguile/bitvectors.c (scm_c_make_bitvector): * libguile/bytevectors.c (scm_make_bytevector): * libguile/strings.c (scm_c_make_string): If no initializer is given, initialize the bytes to 0. Prevents information leakage if an app uses make-string et al without initializers. * libguile/foreign.c (make_cif): Initialize this too, to prevent leakage in the struct holes. Paranoia...
2010-11-19Include <alloca.h> wherever `alloca' is used.Ludovic Courtès1-0/+1
Patch provided by <carlo.bramix@libero.it> (tiny change). * libguile/control.c, libguile/fluids.c, libguile/foreign.c, libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.
2010-09-15Fix write-beyond-end-of-string error in the conversion to R6RS string escapes.Ludovic Courtès1-4/+16
Reported by Mike Gran <spk121@yahoo.com>. * libguile/strings.c (scm_i_unistring_escapes_to_guile_escapes, scm_i_unistring_escapes_to_r6rs_escapes): Augment comments. (scm_to_stringn): When `handler == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE && SCM_R6RS_ESCAPES_P', realloc BUF so that it's large enough for the worst case. * libguile/print.c (display_character): When `result != NULL && strategy == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE && SCM_R6RS_ESCAPES_P', make LOCALE_ENCODED large enough to hold an R6RS escape.
2010-09-14Internally expose `scm_i_unistring_escapes_to_{guile,r6rs}_escapes'.Ludovic Courtès1-11/+11
* libguile/strings.c (unistring_escapes_to_guile_escapes): Rename to... (scm_i_unistring_escapes_to_guile_escapes): ... this. Change `char **bufp' to `char *buf'; leave realloc responsibility to the caller. Update caller. (unistring_escapes_to_r6rs_escapes): Rename to... (scm_i_unistring_escapes_to_r6rs_escapes): ... this. Likewise.
2010-09-12Provide non-locale C/Scheme string conversion functionsMichael Gran1-0/+11
* doc/ref/api-data.texi: document scm_to_stringn, scm_from_stringn, scm_to_latin1_stringn, and scm_from_latin1_stringn * libguile/strings.h (scm_to_stringn): make public (scm_to_latin1_stringn): new declaration (scm_from_latin1_stringn): new declaration * libguile/strings.c (scm_to_latin1_stringn): new function (scm_from_latin1_stringn): new function
2010-07-15Expose `scm_encoding_error'.Ludovic Courtès1-1/+1
* libguile/strings.c (scm_encoding_error): Make public. * libguile/strings.h (scm_encoding_error): New internal declaration.
2010-07-04Add `scm_i_string_data'.Ludovic Courtès1-3/+21
* libguile/strings.c (STRINGBUF_CONTENTS): New macro. (STRINGBUF_CHARS, STRINGBUF_WIDE_CHARS): Use it. (scm_i_string_data): New function. * libguile/strings.h (scm_i_string_data): New declaration.
2010-03-18Improve encoding error reporting.Ludovic Courtès1-23/+34
* libguile/strings.c (scm_encoding_error): Change arguments to convey more information. Raise the error with `scm_throw ()', passing all the information to the handler. (scm_from_stringn, scm_to_stringn): Update accordingly. * test-suite/tests/ports.test ("string ports")["wrong encoding"]: Check the arguments passed to the `throw' handler. * test-suite/tests/r6rs-ports.test ("7.2.11 Binary Output")["put-bytevector with wrong-encoding string port"]: Likewise.
2010-01-23R6RS string escapes broken on string outputMichael Gran1-11/+87
scm_to_stringn failed to do the necessary escape conversion for R6RS hex escapes * libguile/strings.c (unistring_escapes_to_r6rs_escapes): new function (scm_to_stringn): use new function when r6rs hex escapes are enabled * test-suite/tests/reader.test: new test for string display
2010-01-07Use `encoding-error' instead of `misc-error' for string encoding errors.Ludovic Courtès1-13/+23
* libguile/strings.c (scm_encoding_error): New function. (scm_from_stringn, scm_to_stringn): Use it instead of `scm_misc_error ()'. * test-suite/lib.scm (exception:encoding-error): Adjust accordingly. * test-suite/tests/encoding-escapes.test (exception:conversion): Remove. Use `exception:encoding-error' instead. * test-suite/tests/encoding-iso88591.test: Likewise. * test-suite/tests/encoding-iso88597.test: Likewise. * test-suite/tests/encoding-utf8.test: Likewise.
2010-01-07Add in-source documentation of `scm_to_stringn ()'.Ludovic Courtès1-2/+5
* libguile/strings.c (scm_to_stringn): Add documentation comment.
2010-01-06Attempt to narrow normalized strings.Julian Graham1-1/+6
* libguile/strings.c (normalize_str): Clean up indentation. Add call to scm_i_try_narrow_string.
2010-01-03Support for Unicode string normalization functionsJulian Graham1-0/+73
* libguile/strings.c, libguile/strings.h (normalize_str, scm_string_normalize_nfc, scm_string_normalize_nfd, scm_normalize_nfkc, scm_string_normalize_nfkd): New functions. * test-suite/tests/strings.test: Unit tests for `string-normalize-nfc', `string-normalize-nfd', `string-normalize-nfkc', and `string-normalize-nfkd'. * doc/ref/api-data.texi (String Comparison): Documentation for normalization functions.
2009-12-29fix bug in string array implementation type maskAndy Wingo1-1/+1
* libguile/strings.c (SCM_ARRAY_IMPLEMENTATION): The mask for the string array implementation should be 0x7f, without masking out 0x2. Otherwise numbers were being thought to be vectors! * test-suite/tests/unif.test: Add test. * libguile/vectors.c (SCM_ARRAY_IMPLEMENTATION): Only register one implementation, because weak vectors can be checked with the mask & ~2, and the functions are the same.
2009-12-15Remove extraneous semicolon after `SCM_ARRAY_IMPLEMENTATION' & co.Ludovic Courtès1-2/+2
* libguile/bitvectors.c, libguile/srfi-4.c, libguile/strings.c, libguile/vectors.c: Remove extraneous semicolon after `SCM_ARRAY_IMPLEMENTATION' and `SCM_VECTOR_IMPLEMENTATION' invocations.
2009-12-05decruftify scm_sys_protectsAndy Wingo1-0/+2
* libguile/root.h * libguile/root.c (scm_sys_protects): It used to be that for some reason we'd define a special array of "protected" values. This was a little silly, always, but with the BDW GC it's completely unnecessary. Also many of these variables were unused, and none of them were good API. So remove this array, and either eliminate, make static, or make internal the various values. * libguile/snarf.h: No need to generate calls to scm_permanent_object. * guile-readline/readline.c (scm_init_readline): No need to call scm_permanent_object. * libguile/array-map.c (ramap, rafe): Remove the dubious nullvect optimizations. * libguile/async.c (scm_init_async): No need to init scm_asyncs, it is no more. * libguile/eval.c (scm_init_eval): No need to init scm_listofnull, it is no more. * libguile/gc.c: Make scm_protects a static var. (scm_storage_prehistory): Change the sanity check to use the address of protects. (scm_init_gc_protect_object): No need to clear the scm_sys_protects, as it is no more. * libguile/keywords.c: Make the keyword obarray a static var. * libguile/numbers.c: Make flo0 a static var. * libguile/objprop.c: Make object_whash a static var. * libguile/properties.c: Make properties_whash a static var. * libguile/srcprop.h: * libguile/srcprop.c: Make scm_source_whash a global with internal linkage. * libguile/strings.h: * libguile/strings.c: Make scm_nullstr a global with internal linkage. * libguile/vectors.c (scm_init_vectors): No need to init scm_nullvect, it's unused.
2009-11-17Fix stylistic issues revealed by "make syntax-check".Ludovic Courtès1-5/+5
* libguile/gc-malloc.c (scm_must_free): Remove unnecessary `if' before `free ()'. * libguile/stime.c (scm_localtime, scm_mktime): Likewise. * libguile/eval.i.c (ceval): Don't cast the result of alloca(3). * libguile/i18n.c (SCM_STRING_TO_U32_BUF): Likewise. * test-suite/standalone/test-unwind.c: Likewise. * libguile/strings.c (scm_i_deprecated_string_chars): Don't end error message in period.
2009-11-17Remove references to undefined macros.Ludovic Courtès1-6/+10
The intent is to allow compilation with `-Wundef', which in turn should make it easier to catch erroneous uses of nonexistent macros. * libguile/__scm.h: Don't assume `BUILDING_LIBGUILE' is defined. * libguile/conv-uinteger.i.c (SCM_TO_TYPE_PROTO): Remove unneeded CPP conditional on `TYPE_MIN == 0'. * libguile/fports.c: Check for the definition of `HAVE_CHSIZE' and `HAVE_FTRUNCATE', not for their value. * libguile/ports.c: Likewise. * libguile/numbers.c (guile_ieee_init): Likewise with `HAVE_DINFINITY' and `HAVE_DQNAN'. * test-suite/standalone/test-conversion.c (ieee_init): Likewise. * libguile/strings.c: Likewise with `SCM_STRING_LENGTH_HISTOGRAM'. * libguile/strings.h: Likewise. * libguile/tags.h: Likewise with `HAVE_INTTYPES_H' and `HAVE_STDINT_H'. * libguile/threads.c: Likewise with `HAVE_PTHREAD_GET_STACKADDR_NP'. * libguile/vm-engine.c (VM_NAME): Likewise with `VM_CHECK_IP'. * libguile/gen-scmconfig.c (main): Use "#ifdef HAVE_", not "#if HAVE_". * libguile/socket.c (scm_setsockopt): Likewise.
2009-11-01Merge branch 'bdw-gc-static-alloc'Ludovic Courtès1-7/+12
Conflicts: acinclude.m4 libguile/__scm.h libguile/bdw-gc.h libguile/eval.c
2009-09-09Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-2/+7
Conflicts: libguile/gc_os_dep.c
2009-09-09Make scm_i_from_stringn into API for use with libguilereadlineMichael Gran1-4/+4
* libguile/strings.c (scm_i_from_stringn): renamed to scm_from_stringn. All callers changed. * libguile/strings.h: change declaration of scm_i_from_stringn to scm_from_stringn * libguile/strports.c (scm_strport_to_string): scm_i_from_stringn -> scm_from_stringn * guile-readline/readline.c (internal_readline): scm_i_from_stringn -> scm_from_stringn
2009-09-02Merge branch 'boehm-demers-weiser-gc' into bdw-gc-static-allocLudovic Courtès1-203/+1023
Conflicts: acinclude.m4 libguile/strings.c
2009-09-01Remove the distinction between inline/outline storage for stringbufs.Ludovic Courtès1-129/+90
* libguile/strings.c (STRINGBUF_HEADER_SIZE, STRINGBUF_HEADER_BYTES): New macros. (STRINGBUF_F_INLINE, STRINGBUF_INLINE, STRINGBUF_OUTLINE_CHARS, STRINGBUF_OUTLINE_LENGTH, STRINGBUF_INLINE_CHARS, STRINGBUF_INLINE_LENGTH, STRINGBUF_MAX_INLINE_LEN): Remove. (STRINGBUF_CHARS, STRINGBUF_WIDE_CHARS): Adjust to return a fixed location. (STRINGBUF_LENGTH): Get the length from word 1. (make_stringbuf, make_wide_stringbuf): Adjust to use a contiguous memory region. (wide_stringbuf): Renamed from `widen_stringbuf'. Adjust similarly. Return the new stringbuf. Callers updated. (narrow_stringbuf): Likewise. (scm_sys_string_dump, scm_sys_symbol_dump): Remove `stringbuf-inline' pair. * test-suite/tests/strings.test ("string internals")["null strings are inlined", "short Latin-1 encoded strings are inlined", "long Latin-1 encoded strings are not inlined", "short UCS-4 encoded strings are not inlined", "long UCS-4 encoded strings are not inlined"]: Remove. * test-suite/tests/symbols.test ("symbol internals")["null symbols are inlined", "short Latin-1 encoded symbols are inlined", "long Latin-1 encoded symbols are not inlined", "short UCS-4 encoded symbols are not inlined", "long UCS-4 encoded symbols are not inlined"]: Remove.
2009-09-01Fix leaky handling of `scm_take_locale_{symbol,string} ()'.Ludovic Courtès1-37/+6
* libguile/strings.c (scm_i_take_stringbufn, scm_i_c_take_symbol): Remove. (scm_take_locale_stringn): Rewrite in terms of `scm_from_locale_stringn ()'. * libguile/strings.h (scm_i_c_take_symbol, scm_i_take_stringbufn): Remove declarations.
2009-08-30Fix escape sequence normalization for wide stringsMichael Gran1-0/+2
* libguile/strings.c (scm_to_stringn): convert unistring escapes to guile escapes for both wide and narrow strings
2009-08-30Fix encoding errors with strings returned by string portsMichael Gran1-6/+9
String ports, being 8-bit, store strings using the character encoding of the port. This fixes a bug where the default character encoding, and not the port's encoding, was being used to convert the string port data back to a string. * libguile/strports.c: extra comments (scm_strport_to_string): use port's encoding when converting port data to a string * libguile/strings.c (scm_i_from_stringn): renamed from scm_from_stringn and made internal. All callers changed. (scm_from_stringn): renamed to scm_i_from_stringn. * libguile/strings.h: declaration for scm_i_from_stringn
2009-08-28Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-50/+338
Conflicts: libguile/Makefile.am libguile/bytevectors.c libguile/gc-card.c libguile/gc-mark.c libguile/programs.c libguile/srcprop.c libguile/srfi-14.c libguile/symbols.c libguile/threads.c libguile/unif.c libguile/vm.c
2009-08-25Merge commit 'origin/master'Andy Wingo1-26/+238
Conflicts: libguile/unif.c
2009-08-25Merge wip-array refactor, up to cd43fdc5b7a7cAndy Wingo1-0/+31
Conflicts: NEWS libguile/print.c
2009-08-25Add full Unicode capability to ports and the default readerMichael Gran1-43/+132
Ports are given two additional properties: a character encoding and a conversion failure strategy. These properties have getters and setters. The new properties are used to convert any locale text to/from the internal representation of strings. If unspecified, ports use a default value. The default value of these properties is held in a fluid. The default character encoding can be modified by calling setlocale. ISO-8859-1 is treated specially. Since it is a native encoding of strings, it can be processed more quickly. Source code is assumed to be ISO-8859-1 unless otherwise specified. The encoding of a source code file can be given as 'coding: XXXXX' in a magic comment at the top of a file. The C functions that deal with encoding often use a null pointer as shorthand for the native Latin-1 encoding, for efficiency's sake. * test-suite/tests/encoding-iso88591.test: new tests * test-suite/tests/encoding-iso88597.test: new tests * test-suite/tests/encoding-utf8.test: new tests * test-suite/tests/encoding-escapes.test: new tests * test-suite/tests/numbers.test: declare 'binary' encoding * test-suite/tests/ports.test: declare 'binary' encoding * test-suite/tests/r6rs-ports.test: declare 'binary' encoding * module/system/base/compile.scm (compile-file): use source-code file's self-declared encoding when compiling files * libguile/strports.c: store string ports in locale encoding (scm_strport_to_locale_u8vector, scm_call_with_output_locale_u8vector) (scm_open_input_locale_u8vector, scm_get_output_locale_u8vector): new functions * libguile/strings.h: new declaration for scm_i_string_contains_char * libguile/strings.c (scm_i_string_contains_char): new function (scm_from_stringn, scm_to_stringn): use NULL for Latin-1 (scm_from_locale_stringn, scm_to_locale_stringn): respect character encoding of input and output ports * libguile/read.h: declaration for scm_scan_for_encoding * libguile/read.c: (read_token): now takes scheme string instead of C string/length (read_complete_token): new function (scm_read_sexp, scm_read_number, scm_read_mixed_case_symbol) (scm_read_number_and_radix, scm_read_quote, scm_read_semicolon_comment) (scm_read_srfi4_vector, scm_read_bytevector, scm_read_guile_bit_vector) (scm_read_scsh_block_comment, scm_read_commented_expression) (scm_read_extended_symbol, scm_read_sharp_extension, scm_read_shart) (scm_read_expression): use scm_t_wchar for char type, use read_complete_token (scm_scan_for_encoding): new function to find a file's character encoding (scm_file_encoding): new function to find a port's character encoding * libguile/rdelim.c: don't unpack strings * libguile/print.h: declaration for modified function scm_i_charprint * libguile/print.c: use locale when printing characters and strings (scm_i_charprint): input parameter is now scm_t_wchar (scm_simple_format): don't unpack strings * libguile/posix.h: new declaration for scm_setbinary. * libguile/posix.c (scm_setlocale): set default and stdio port encodings based on the locale's character encoding (scm_setbinary): new function * libguile/ports.h (scm_t_port): add encoding and failed conversion handler to port type. Declarations for new or modified functions scm_getc, scm_unget_byte, scm_ungetc, scm_i_get_port_encoding, scm_i_set_port_encoding_x, scm_port_encoding, scm_set_port_encoding_x, scm_i_get_conversion_strategy, scm_i_set_conversion_strategy_x, scm_port_conversion_strategy, scm_set_port_conversion_strategy_x. * libguile/ports.c: assign the current ports to zero on startup so we can see if they've been set. (scm_current_input_port, scm_current_output_port, scm_current_error_port): return #f if the port is not yet initialized (scm_new_port_table_entry): set up a new port's encoding and illegal sequence handler based on the thread's current defaults (scm_i_remove_port): free port encoding name when port is removed (scm_i_mode_bits_n): now takes a scheme string instead of a c string and length. All callers changed. (SCM_MBCHAR_BUF_SIZE): new const (scm_getc): new function, since the scm_getc in inline.h is now scm_get_byte_or_eof. This pulls one codepoint from a port. (scm_lfwrite_substr, scm_lfwrite_str): now uses port's encoding (scm_unget_byte): new function, incorportaing the low-level functionality of scm_ungetc (scm_ungetc): uses scm_unget_byte * libguile/numbers.h (scm_t_wchar): compilation order problem with scm_t_wchar being use in functions in multiple headers. Forward declare scm_t_wchar. * libguile/load.c (scm_primitive_load): scan for file encoding at top of file and use it to set the load port's encoding * libguile/inline.h (scm_get_byte_or_eof): new function incorporating most of the functionality of scm_getc. * libguile/fports.c (fport_fill_input): now returns scm_t_wchar * libguile/chars.h (scm_t_wchar): avoid compilation order problem with declaration of scm_t_wchar
2009-08-23Modify socket and time functions for wide stringsMichael Gran1-10/+133
* libguile/socket.c (scm_recv): receive the message without holding the stringbuf writing lock (scm_send): try to narrow a string before using it * libguile/stime.c (strftime): convert string to UTF-8 so that it can be safely passed to strftime (strptime): convert input string to UTF-8 so that it can be safely passed through strptime * libguile/strings.c (narrow_stringbuf): new function (scm_i_try_narrow_string): new function * libguile/strings.h: new declaration for scm_i_try_narrow_string
2009-08-21Use string accessors for string->number conversionMichael Gran1-0/+23
* libguile/numbers.c (scm_i_print_fraction): use string accessors (XDIGIT2UINT): use libunistring function (mem2uinteger, mem2integer, mem2decimal_from_point, mem2ureal) (mem2complex): take scheme string instead of c string; use accessors (scm_i_string_to_number): new function (scm_c_locale_string_to_number): use scm_i_string_to_number * libguile/numbers.h: declaration for scm_i_string_to_number * libguile/strings.c (scm_i_string_strcmp): new function * libguile/strings.h: declaration for scm_i_string_strcmp
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