summaryrefslogtreecommitdiff
path: root/libguile/print.c
AgeCommit message (Collapse)AuthorFilesLines
2012-03-06optimize symbol printingAndy Wingo1-20/+59
* libguile/print.h: Remove internal declaration of scm_i_print_symbol_name. * libguile/print.c (symbol_has_extended_read_syntax): Optimize to avoid calling symbol_to_string if we know the symbol cannot be mistaken for a number. (print_normal_symbol): Optimize to call display_string directly, instead of jumping through scm_display. (print_symbol): Rename from scm_i_print_symbol_name. (scm_print_symbol_name, iprin1): Adapt to print_symbol name change.
2012-03-03the dynamic stack is really a stack now, instead of a listAndy Wingo1-6/+0
* libguile/dynstack.h: * libguile/dynstack.c: New files, implementing the dynamic stack as a true stack instead of a linked list. This lowers the cost of dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind. For the most part, we allocate these items directly on the stack. * libguile/dynwinds.h: * libguile/dynwinds.c: Adapt all manipulators of the wind stack to use interfaces from dynstack.c. Remove heap-allocated winder and frame object types. (scm_dowinds, scm_i_dowinds): Remove these. The first was exported, but it was not a public interface. * libguile/continuations.c: * libguile/continuations.h (scm_t_contregs): Continuation objects reference scm_t_dynstack* values now. Adapt to the new interfaces. * libguile/control.c: * libguile/control.h: There is no longer a scm_tc7_prompt kind of object that can be allocated on the heap. Instead, the prompt flags, key, and registers are pushed on the dynwind stack. (The registers are still on the heap.) Also, since the vm_cont will reference the dynwinds, make the partial continuation stub take just one extra arg, instead of storing the intwinds separately in the object table. * libguile/fluids.c: * libguile/fluids.h: No more with-fluids objects; instead, the fluids go on the dynstack. The values still have to be on the heap, though. (scm_prepare_fluids, scm_swap_fluids): New internal functions, replacing scm_i_make_with_fluids and scm_i_swap_with_fluids. * libguile/print.c: Remove prompt and with-fluids printers. * libguile/tags.h: Revert prompt and with-fluids tc7 values to what they were before they were allocated. * libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the intwinds will not be passed as a second arg. Rewind the dynamic stack from within the VM, so that any rewinder sees valid prompt entries. (call_cc, tail_call_cc): Adapt to pass the dynstack to scm_i_vm_capture_stack. (prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new interfaces. * libguile/vm.h (scm_i_capture_current_stack): Rename from scm_i_vm_capture_continuation. (scm_i_vm_capture_stack): Take a dynstack as an argument. * libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as that could result in winders seeing invalid prompts. * libguile/eval.c: * libguile/root.c: * libguile/stacks.c: * libguile/threads.c: * libguile/threads.h: * libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-02-24port i/o optimizations for iso-8859-1Andy Wingo1-2/+51
* libguile/ports.h (scm_t_port_encoding_mode): * libguile/ports.c (scm_c_make_port_with_encoding): (scm_i_set_port_encoding_x): Add special treatment for latin1 encoding. (get_latin1_codepoint, get_codepoint): Add latin1 fast-path. * libguile/print.c (display_string_as_latin1): Add latin1 fastpath.
2012-02-14refactor port encoding modes: utf-8 and iconvAndy Wingo1-10/+5
* libguile/ports.h (struct scm_t_port): Add a flag for the port encoding mode: UTF8 or iconv. The iconv descriptors are now in a separate structure so that we can avoid attaching finalizers to the ports themselves, in some cases. * libguile/ports.c (scm_c_make_port_with_encoding): Init the encoding mode. (scm_i_remove_port): Adapt to call close_iconv_descriptors. (finalize_iconv_descriptors, open_iconv_descriptors): (close_iconv_descriptors): New infrastructure to manage iconv descriptors. (scm_i_port_iconv_descriptors): New internal helper. (scm_i_set_port_encoding_x): Use open_iconv_descriptors, if needed. (get_iconv_codepoint): Use pt->iconv_descriptors. (get_codepoint): Check the port encoding mode flags. * libguile/print.c (display_string_using_iconv): Use scm_i_port_iconv_descriptors. (display_string): Use pt->encoding_mode flag.
2012-02-08Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+1
Conflicts: GUILE-VERSION libguile/gc-malloc.c libguile/ports.c
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-1/+1
* 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-30Merge commit '9b0975f1dc41ddd10d81fb5b0965b9e9a54ef37a'Andy Wingo1-1/+2
Conflicts: libguile/foreign.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2012-01-12fix array printingAndy Wingo1-1/+2
* libguile/print.c (iprin1): Fix unmatched ENTER_NESTED_DATA. Fixes http://debbugs.gnu.org/10482. Thanks to Daniel Llorens for the report.
2012-01-10Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-4/+10
Conflicts: libguile/__scm.h libguile/array-map.c libguile/procprop.c libguile/tags.h module/ice-9/deprecated.scm module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm test-suite/standalone/test-num2integral.c test-suite/tests/regexp.test
2012-01-09allocate a tc7 to bitvectorsAndy Wingo1-0/+3
* libguile/tags.h (scm_tc7_bitvector): Allocate a tc7 to bitvectors. * libguile/print.c (iprin1): * libguile/goops.c: * libguile/evalext.c (scm_self_evaluating_p): * libguile/eq.c (scm_equal_p): Add cases for bitvectors. * libguile/bitvectors.h: Declare internal print and equal? helpers. * libguile/bitvectors.c: Use a tc7 instead of a smob type.
2012-01-09allocate a tc7 to arraysAndy Wingo1-4/+7
* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays. * libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array. The previous definition was not externally usable because scm_i_tc16_array was internal. (scm_i_print_array): Declare, though internally. * libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7 instead of NEWSMOB. (scm_i_print_array): Make not static. (SCM_ARRAY_IMPLEMENTATION): Adapt. (scm_init_arrays): Remove array smob declaration. * libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and bytevector cases in the switch. Add a case for arrays. * libguile/goops.c: Add <array> declarations. * libguile/print.c (iprin1): Call scm_i_print_array as needed. * libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays.
2011-12-06Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-9/+14
Conflicts: libguile/deprecation.c libguile/load.c libguile/print.c
2011-12-06port locking refactorAndy Wingo1-2/+2
* libguile/ports.h (struct scm_t_port): Make the lock into a pointer field instead of an inline field. It should be possible to make unlocked ports by having a NULL lock field. (scm_c_lock_port, scm_c_try_lock_port): Return the mutex if the port was actually locked. (scm_c_unlock_port): Remove. * libguile/ports.c (scm_c_make_port_with_encoding): For now, leave `lock' set to 0. Change scm_c_lock_port callers to pay attention to the new API. * libguile/print.c (scm_write, scm_display): Fix call to dynwind-lock-port for ports-with-print-states.
2011-12-04new print option escape-newlines, defaults to #tAndy Wingo1-9/+14
* libguile/private-options.h (SCM_PRINT_ESCAPE_NEWLINES_P): * libguile/print.c: Add new escape-newlines print option, defaulting to on. (write_character): For newlines, if SCM_PRINT_ESCAPE_NEWLINES_P, then print them as \n. (scm_init_print): Refactor print options initialization.
2011-11-24no gc_register_root in scm_init_printAndy Wingo1-2/+0
* libguile/print.c (scm_init_print): No need to gc_register_root here.
2011-11-24simplify scm_init_printAndy Wingo1-5/+3
* libguile/print.c (scm_init_print): Simplify creation of print-state vtable.
2011-11-08lock ports in `write' and `display'Andy Wingo1-0/+8
* libguile/print.c (scm_write, scm_display): Lock the port during `display' and `write' calls. Fixes https://savannah.gnu.org/bugs/?33996.
2011-11-08locking for write, lfwriteAndy Wingo1-12/+12
* libguile/ports.c (scm_c_write_unlocked, scm_c_write) (scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked variants. Change uses to _unlocked.
2011-11-08locking for putc, putsAndy Wingo1-30/+30
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-11-07threadsafe access to scm_ptobsAndy Wingo1-5/+3
* libguile/ports.h (SCM_PORT_DESCRIPTOR): New macro, to get at a port descriptor in the third word of a port instead of looking it up in a table. (scm_c_port_type_ref, scm_c_port_type_add_x): New API for working with numbered ptob descriptors. (SCM_PTOBNAME): Implement in terms of scm_c_port_type_ref. (scm_get_byte_or_eof, scm_peek_byte_or_eof): Use SCM_PORT_DESCRIPTOR. * libguile/ports.c (scm_c_num_port_types, scm_c_port_type_ref) (scm_c_port_type_add_x, scm_make_port_type): Protect scm_ptobs access with a mutex. Have it be an array of pointers instead of an array of structures. Adapt users to the new APIs. (scm_c_make_port_with_encoding): Allocate ports with three words. The third word is the ptob descriptor. * libguile/backtrace.c: * libguile/goops.c: * libguile/ioext.c: * libguile/print.c: Adapt to use scm_c_port_type_ref and SCM_PORT_DESCRIPTOR.
2011-10-25most uses of scm_from_locale_symbol become scm_from_utf8_symbolAndy Wingo1-1/+1
* libguile/array-handle.c: * libguile/chars.c: * libguile/expand.c: * libguile/feature.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/instructions.c: * libguile/load.c: * libguile/macros.c: * libguile/memoize.c: * libguile/modules.c: * libguile/options.c: * libguile/print.c: * libguile/smob.c: * libguile/snarf.h: Change most uses of scm_from_locale_symbol to scm_from_utf8_symbol, as the symbols really are not locale-dependent.
2011-10-24remove weak pairs, rewrite weak vectorsAndy Wingo1-25/+6
* libguile/weak-vector.c: * libguile/weak-vector.h: Renamed from weaks.[ch]. Remove weak pairs. They were not safe to access with `car' and `cdr'. Remove weak alist vectors, as we have weak tables and sets. Reimplement weak vectors, moving the implementation here. * libguile/vectors.c: * libguile/vectors.h: Remove the extra header word. Use scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak vectors. * libguile/snarf.h: Remove the extra header word in vectors. * libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock): Instead of weak pairs, store thread-owned mutexes in a list of one-element weak vectors. * libguile/guardians.c (finalize_guarded): Similarly, store object guardians in a list of one-element weak vectors. * libguile/modules.c (scm_module_reverse_lookup): We no longer need to handle the case of weak references. * libguile/print.c (iprin1): Use the standard vector accessor to print vectors. * libguile.h: * libguile/Makefile.am: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/goops.c: * libguile/init.c: * libguile/objprop.c: * libguile/struct.c: Update includes. * module/ice-9/weak-vector.scm: Load weak vector definitions using an extension instead of %init-weaks-builtins. * test-suite/tests/weaks.test: Use the make-...-hash-table names instead of the old alist vector names.
2011-10-24add weak table implementationAndy Wingo1-0/+3
* libguile/weak-table.c: * libguile/weak-table.h: New files, implementing open-addressed weak hash tables, similar to the implementation of weak sets. This will let us remove weak pairs. * libguile.h: * libguile/Makefile.am: * libguile/evalext.c: * libguile/gc.c: * libguile/init.c: * libguile/print.c: * libguile/tags.h: Update all the pieces for the new files and tc7.
2011-10-23add weak setsAndy Wingo1-0/+3
* libguile/weak-set.c: * libguile/weak-set.h: New files, implementing weak sets, for use in the symbol table and port set. Eventually we will be able to remove weak pairs. * libguile.h: * libguile/Makefile.am: Add new files. * libguile/evalext.c: * libguile/gc.c: * libguile/init.c: * libguile/print.c: * libguile/tags.h: Add support for the new types.
2011-05-15scm_wta_* procedures replace SCM_WTA_* macrosAndy Wingo1-1/+1
* libguile/__scm.h: Move all the SCM_WTA and SCM_GASSERT macros out of here. Also remove the scm_call_generic declarations. * libguile/deprecated.h (SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1): (SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_N): Deprecate. See below for their replacements. (SCM_GASSERT0, SCM_GASSERT1, SCM_GASSERT2, SCM_GASSERTn): Deprecate these too. (SCM_WTA_DISPATCH_1_SUBR): Deprecate this strange thing. (scm_call_generic_0, scm_call_generic_1, scm_call_generic_2): (scm_call_generic_3, scm_apply_generic): Remove, indicating their replacements. * libguile/print.c (iprin1): * libguile/eq.c (scm_equal_p): Use scm_call_2 instead of scm_call_generic_2. * libguile/goops.h: * libguile/goops.c: Remove scm_{call,apply}_generic definitions. (scm_wta_dispatch_0, scm_wta_dispatch_1, scm_wta_dispatch_2): (scm_wta_dispatch_n): New procedures, replacing the SCM_WTA macros. * libguile/numbers.c (scm_lcm): * libguile/procs.c (scm_setter): Remove uses of SCM_GASSERT. * libguile/numbers.c (scm_lcm): * libguile/procs.c (scm_setter): * libguile/vectors.c: Use the procedural scm_wta routines instead of the SCM_WTA macros.
2011-05-13more care regarding SCM_PACK and SCM_UNPACKAndy Wingo1-1/+1
* libguile/control.c (reify_partial_continuation): * libguile/eval.c (RETURN_BOOT_CLOSURE): * libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x) * libguile/frames.h (SCM_FRAME_SET_RETURN_ADDRESS): (SCM_FRAME_SET_MV_RETURN_ADDRESS, SCM_FRAME_SET_DYNAMIC_LINK): * libguile/goops.c (scm_class_of, scm_primitive_generic_generic) (scm_c_extend_primitive_generic, compute_getters_n_setters) (scm_sys_initialize_object): * libguile/guardians.c (finalize_guarded): * libguile/list.c (SCM_I_CONS): * libguile/macros.c (scm_i_make_primitive_macro) (scm_make_syntax_transformer): * libguile/memoize.c (MAKMEMO, SCM_MAKE_MEMOIZER) (SCM_MAKE_REST_MEMOIZER): * libguile/modules.c (scm_module_reverse_lookup) * libguile/print.c (iprin1): * libguile/promises.c (scm_make_promise) * libguile/srcprop.c (scm_make_srcprops): * libguile/vectors.c (scm_c_vector_ref): * libguile/vm-engine.c (vm_engine) * libguile/vm-i-scheme.c (REL, add1, sub1): * libguile/vm-i-system.c (new_frame, call_cc) * libguile/weaks.h (SCM_WEAK_PAIR_WORD_DELETED_P): Be more careful about SCM_PACK / SCM_UNPACK.
2011-05-13allow iflags to be constant expressions with typing-strictness==2Andy Wingo1-3/+3
* libguile/tags.h (SCM_MAKE_ITAG8_BITS): New helper, produces a scm_t_bits instead of a SCM, because SCM_UNPACK is not a constant expression with SCM_DEBUG_TYPING_STRICTNESS==2. (SCM_MAKIFLAG_BITS): Remove SCM_MAKIFLAG, and replace with this, which returns bits. (SCM_BOOL_F_BITS, SCM_ELISP_NIL_BITS, SCM_EOL_BITS, SCM_BOOL_T_BITS): (SCM_UNSPECIFIED_BITS, SCM_UNDEFINED_BITS, SCM_EOF_VAL_BITS): (SCM_UNBOUND_BITS): New definitions. Defined SCM_BOOL_F, etc in terms of them. (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0): (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_1): (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_2): (SCM_XXX_ANOTHER_LISP_FALSE_DONT_USE): Be bits instead of SCM values. (SCM_BITS_DIFFER_IN_EXACTLY_ONE_BIT_POSITION): (SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS): Rename from SCM_VALUES_DIFFER_..., and take unpacked bits as the args. * libguile/boolean.c: Update verify block to use SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS et al. * libguile/debug.c (scm_debug_opts): * libguile/print.c (scm_print_opts): * libguile/read.c (scm_read_opts): Use iflags bits for initializers. * libguile/hash.c (scm_hasher): Use _BITS for iflags as case labels. * libguile/pairs.c: Nil/null compile-time check uses SCM_ELISP_NIL_BITS.
2011-05-06Special-case UTF-8 ports to bypass `iconv' entirely.Ludovic Courtès1-15/+69
* libguile/ports.c (update_port_lf): Handle EOF. (get_utf8_codepoint, get_iconv_codepoint): New functions. (get_codepoint): Use them. (scm_i_set_port_encoding_x): Don't open conversion descriptors when ENCODING is "UTF-8". * libguile/print.c (display_string_as_utf8, display_string_using_iconv): New functions. (display_string): Use them. * test-suite/tests/ports.test ("string ports")[#xc2 #x41 #x42]: Add a note that this is not the wrong behavior per Unicode 6.0.0.
2011-04-11symbols with odd characters print better in #{}#Andy Wingo1-41/+35
* libguile/print.c (symbol_has_extended_read_syntax): Use a more general, unicode-appropriate algorithm. Hopefully doesn't cause any current #{}# cases to be unescaped. (print_extended_symbol): Use more appropriate unicode algorithm, and emit unicode hex escapes instead of our own lame escapes. * test-suite/tests/symbols.test: Add tests.
2011-04-11refactor scm_i_print_symbol_nameAndy Wingo1-86/+110
* libguile/print.c (symbol_has_extended_read_syntax) (print_normal_symbol, print_extended_symbol, scm_i_print_symbol_name): Factor scm_i_print_symbol_name into separate routines. Add comments. There are a number of bugs here.
2011-03-06Let `scm_mkstrport' allocate buffers on the caller's behalf.Ludovic Courtès1-2/+1
* libguile/strports.c (INITIAL_BUFFER_SIZE): New macro. (scm_mkstrport): If STR is false, allocate a bytevector on the caller's behalf. (scm_object_to_string, scm_call_with_output_string, scm_open_output_string): Pass SCM_BOOL_F as the STR argument of `scm_mkstrport'. * libguile/backtrace.c (scm_display_application, display_backtrace_body): Likewise. * libguile/gdbint.c (scm_init_gdbint): Likewise. * libguile/print.c (scm_simple_format): Likewise.
2011-02-24errno saving in display_stringAndy Wingo1-1/+3
* libguile/print.c (display_string): Fix a case in which perhaps `errno' could have been stompled.
2011-02-02Change `scm_encoding_error' to pass the port and faulty character.Ludovic Courtès1-7/+3
* libguile/strings.c (scm_encoding_error): Remove the `from', `to', and `string_or_bv' parameters; add `port' and `chr'. (scm_to_stringn): Update accordingly. * libguile/strings.h (scm_encoding_error): Update accordingly. * libguile/ports.c (scm_ungetc): Update accordingly. * libguile/print.c (iprin1, scm_write_char): Update accordingly. * test-suite/tests/encoding-escapes.test ("display output errors")["ultima", "Rashomon"]: Check the arguments of `encoding-error'. ["tekniko"]: New test. * test-suite/tests/ports.test ("string ports")["wrong encoding"]: Adjust to new `encoding-error' arguments.
2011-02-02Upon port encoding error, always write as much as possible.Ludovic Courtès1-8/+8
* libguile/print.c (display_string): Upon error, always write the OUTPUT_LEN bytes of output, regardless of the conversion strategy.
2011-01-23Rewrite `read-char', `display', etc. using iconv calls instead of libunistring.Ludovic Courtès1-166/+265
Thanks to Bruno Haible for his suggestions. See <http://lists.gnu.org/archive/html/bug-libunistring/2010-09/msg00007.html>, for details. * libguile/ports.c (register_finalizer_for_port): Always register a finalizer for PORT. (finalize_port): Close ENTRY->input_cd and ENTRY->output_cd. (scm_new_port_table_entry): Initialize the `input_cd' and `output_cd' fields. (utf8_to_codepoint): New function. (get_codepoint): Rewrite to use `iconv' instead of libunistring. (scm_i_set_port_encoding_x): Initialize the `input_cd' and `output_cd' fields. (update_port_lf): Move upward. Use `switch' instead of `if's. * libguile/ports.h (scm_t_port)[input_cd, output_cd]: New fields. * libguile/print.c (codepoint_to_utf8, display_string): New functions. (display_character): Use `display_string'. (write_combining_character): Likewise. (iprin1): Use `display_string' instead of `scm_lfwrite_str', and `display_character' instead of `scm_putc'. (write_character): Likewise. (write_character_escaped): New function. * test-suite/tests/encoding-escapes.test ("display output escapes")["Rashomon"]: Use lower-case escapes. ["fake escape"]: New test.
2011-01-07use scm_from_latin1_symboln for string literals and load-symbolAndy Wingo1-4/+4
* 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.
2010-11-19fix a number of assumptions that a pointer could fit into a longAndy Wingo1-3/+3
* libguile/debug.c: * libguile/eval.c: * libguile/frames.c: * libguile/objcodes.c: * libguile/print.c: * libguile/programs.c: * libguile/read.c: * libguile/struct.c: * libguile/vm.c: Fix a number of instances in which we assumed we could fit a pointer into a long.
2010-10-01remove unused print-optionsAndy Wingo1-4/+0
* libguile/private-options.h (SCM_PRINT_CLOSURE, SCM_PRINT_SOURCE_P): * libguile/print.c (scm_print_opts): * doc/ref/api-options.texi (Printing options): Remove source and closure-hook print options.
2010-09-26Favor non-hex string escapes over hex escapes when writing stringsMichael Gran1-1/+9
The characters U+0007 to U+000D have non-hex forms for their escapes when in written strings. * libguile/print.c (write_character): use non-hex escapes * test-suite/tests/reader.test (write R6RS string escapes): adjust test
2010-09-15Fix write-beyond-end-of-string error in the conversion to R6RS string escapes.Ludovic Courtès1-2/+11
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-15Re-introduce pretty-printing of combining characters.Ludovic Courtès1-1/+49
This had been removed by commit 07f49ac786e0f1c007eb336e2fb7a572e8405316 ("Factorize and optimize `write' for strings and characters."). Thanks Mike! * libguile/print.c (write_combining_character): New procedure. (write_character): Use it. * test-suite/tests/chars.test ("basic char handling")["combining accent is pretty-printed", "combining X is pretty-printed"]: New tests. * test-suite/tests/encoding-iso88591.test ("characters")["write A followed by combining accent"]: New test. * test-suite/tests/encoding-utf8.test ("characters")["write A followed by combining accent"]: New test.
2010-09-14Remove commented out code from `print.c'.Ludovic Courtès1-24/+0
* libguile/print.c (scm_write, scm_display, scm_write_char): Remove `#if 0'-d code.
2010-09-14Factorize and optimize `write' for strings and characters.Ludovic Courtès1-202/+199
According to `write.bm', this makes `write' 2.6 times faster for strings. * libguile/print.c (iprin1): Use `write_character' when `SCM_WRITINGP (pstate)' and `SCM_CHARP (exp)' or `scm_is_string (exp)'. (scm_i_charprint): Remove. (display_character, write_character): New functions. (scm_write_char): Use `display_character' instead of `scm_i_charprint'. * libguile/print.h (scm_i_charprint): Remove declaration. * benchmark-suite/benchmarks/write.bm: New file. * benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add `benchmarks/write.bm'.
2010-07-28Use "pointer" instead of "foreign" when dealing with wrapped pointers.Ludovic Courtès1-2/+2
* libguile/foreign.h (scm_t_foreign_finalizer): Rename to... (scm_t_pointer_finalizer): ... this. (SCM_FOREIGN_P): Rename to... (SCM_POINTER_P): this. (SCM_VALIDATE_FOREIGN): Rename to... (SCM_VALIDATE_POINTER): ... this. (SCM_FOREIGN_HAS_FINALIZER): Rename to... (SCM_POINTER_HAS_FINALIZER): ... this. (scm_take_foreign_pointer): Rename to... (scm_from_pointer): ... this. (scm_foreign_address): Rename to... (scm_pointer_address): ... this. (scm_foreign_to_bytevector): Rename to... (scm_pointer_to_bytevector): ... this. (scm_foreign_set_finalizer_x): Rename to... (scm_set_pointer_finalizer_x): ... this. (scm_bytevector_to_foreign): Rename to... (scm_bytevector_to_pointer): ... this. (scm_i_foreign_print): Rename to... (scm_i_pointer_print): ... this. * libguile/foreign.c: Update accordingly. * libguile/tags.h (scm_tc7_foreign): Rename to... (scm_tc7_pointer): ... this. * libguile/foreign.c, libguile/deprecated.c, libguile/dynl.c, libguile/evalext.c, libguile/gc.c, libguile/goops.c, libguile/gsubr.c, libguile/gsubr.h, libguile/print.c, libguile/snarf.h, libguile/vm-i-system.c, module/system/foreign.scm, test-suite/standalone/test-ffi, test-suite/tests/foreign.test: Update accordingly.
2010-04-09remove libguile/lang.h, deprecate %nil (in favor of #nil)Andy Wingo1-1/+0
* libguile/Makefile.am: * libguile/init.c: * libguile/lang.c: * libguile/lang.h: Remove lang.c and lang.h. * libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here. * module/ice-9/deprecated.scm (%nil): %nil definition moved here. * libguile/alist.c: * libguile/async.c: * libguile/backtrace.c: * libguile/boolean.c: * libguile/dynl.c: * libguile/eval.c: * libguile/filesys.c: * libguile/fluids.c: * libguile/list.c: * libguile/load.c: * libguile/options.c: * libguile/posix.c: * libguile/print.c: * libguile/promises.c: * libguile/sort.c: * libguile/throw.c: * libguile/trees.c: * libguile/vectors.c: * libguile/vm.c: * libguile/weaks.c: * srfi/srfi-1.c: <libguile/lang.h> references removed.
2010-03-28Renumber IFLAGSs so the first 8 are reserved for lisp booleans.Mark H Weaver1-1/+3
This enables more efficient implementations of several operations, e.g. scm_is_lisp_bool, canonicalize_boolean, fast_boolean_not, converting SCM booleans to C booleans, etc. * libguile/tags.h: Renumber IFLAGs. * libguile/print.c: Renumber iflagnames to match. * libguile/boolean.c: * libguile/boolean.h: SCM_XXX_ANOTHER_BOOLEAN_DONT_USE --> SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0
2010-03-04add printers for prompts and with-fluids objectsAndy Wingo1-0/+7
* libguile/control.c: * libguile/control.h (scm_i_prompt_print): * libguile/fluids.c: * libguile/fluids.h (scm_i_with_fluids_print): * libguile/print.c (iprin1): Add printers for prompts and with-fluids objects.
2010-01-12Reader option for R6RS hex escapesMichael Gran1-33/+73
This adds a reader option 'r6rs-hex-escapes that modifies the behavior of numeric escapes in characters and strings. When enabled, variable-length character hex escapes (#\xNNN) are allowed and become the default output format for numerically-escaped characters. Also, string hex escapes switch to a semicolon terminated hex escape (\xNNNN;). * libguile/print.c (PRINT_CHAR_ESCAPE): new macro (iprin1): use new macro PRINT_CHAR_ESCAPE * libguile/private-options.h (SCM_R6RS_ESCAPES_P): new #define * libguile/read.c (scm_read_opts): add new option r6rs-hex-escapes (SCM_READ_HEX_ESCAPE): modify to take a terminator parameter (scm_read_string): parse R6RS hex string escapes (scm_read_character): parse R6RS hex character escapes * test-suite/tests/chars.test (with-read-options): new procedure (R6RS hex escapes): new tests * test-suite/tests/strings.test (with-read-options): new procedure (R6RS hex escapes): new tests
2010-01-07remove scm_tc7_gsubrAndy Wingo1-11/+0
* libguile/tags.h (scm_tc7_gsubr): Return to the pool of unused tc7s, as there are no more gsubrs. Yay :) * libguile/programs.h (SCM_F_PROGRAM_IS_PRIMITIVE): (SCM_PROGRAM_IS_PRIMITIVE): New flag and accessor. * libguile/gsubr.c (create_gsubr): * libguile/snarf.h (SCM_STATIC_PROGRAM): Give subrs a PRIMITIVE flag. * libguile/smob.h: * libguile/smob.c (scm_i_smob_arity): New internal procedure. Uses the old GSUBR type macros, local to the file. * libguile/procprop.c (scm_i_procedure_arity): Call out to scm_i_smob_arity, and remove a gsubr case. * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/vm.c (apply_foreign): * libguile/hash.c (scm_hasher): * libguile/debug.c (scm_procedure_name): * libguile/print.c (iprin1): Remove gsubr cases. * libguile/gsubr.h (SCM_PRIMITIVE_P): Fix to work with the new VM program regimen. (SCM_GSUBR_TYPE, SCM_GSUBR_MAKTYPE, SCM_GSUBR_MAX, SCM_GSUBR_REQ) (SCM_GSUBR_OPT, SCM_GSUBR_REST): Remove these macros, that are no longer useful. * libguile/gsubr.c (scm_i_gsubr_apply, scm_i_gsubr_apply_list) (scm_i_gsubr_apply_array): Remove internal gsubr application functions.
2010-01-07tc7 tags for vm-related dataAndy Wingo1-0/+13
* libguile/tags.h (scm_tc7_frame, scm_tc7_objcode, scm_tc7_vm) (scm_tc7_vm_cont): Take more tc7s for VM-related data structures. * libguile/evalext.c (scm_self_evaluating_p): * libguile/gc.c (scm_i_tag_name): * libguile/goops.c (scm_class_of, create_standard_classes): * libguile/print.c (iprin1): Add cases for the new tc7s. * libguile/frames.c: * libguile/frames.h: * libguile/objcodes.c: * libguile/objcodes.h: * libguile/vm.c: * libguile/vm.h: Desmobify. * libguile/vm.c (scm_vm_apply): Export to Scheme, because VM objects are no longer applicable. * module/system/repl/command.scm (profile): * module/system/vm/trace.scm (vm-trace): * module/system/vm/vm.scm (vm-load): Call vm-apply to run a program in a VM instead of treating the VM as applicable.