summaryrefslogtreecommitdiff
path: root/test-suite/tests
AgeCommit message (Collapse)AuthorFilesLines
2013-06-27remove @call-with-current-continuation memoizerAndy Wingo1-3/+3
* module/ice-9/boot-9.scm (call-with-current-continuation): Change to primcall call-with-current-continuation. * libguile/memoize.h: * libguile/expand.c (scm_sym_atcall_cc): Remove. * libguile/memoize.c (memoize): Memoize call/cc primcalls to SCM_M_CONT. (m_call_cc): Remove. (unmemoize): Unmemoize to call-with-current-continuation. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update to call-with-current-continuation without @ prefix, and fix fallback case. * module/language/tree-il/primitives.scm (*multiply-valued-primitives*): (*interesting-primitive-names*): Remove @call-with-current-continuation. (call/cc): Expand to call-with-current-continuation. * test-suite/tests/tree-il.test ("call/cc"): Update to use and expect call-with-current-continuation primcalls / toplevel refs.
2013-06-27remove @apply memoizerAndy Wingo4-17/+17
* libguile/memoize.c (memoize): Recognize a primcall to 'apply as SCM_M_APPLY. (@apply): Remove @apply memoizer. (unmemoize): Unmemoize using "apply", not "@apply". * libguile/memoize.h: * libguile/expand.c (scm_sym_atapply): Remove. * module/ice-9/boot-9.scm (apply): Re-implement using apply primcall. Use case-lambda, so as to give an appropriate minimum arity. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Compile a primcall of "apply" specially, not "@apply". * module/language/tree-il/peval.scm (peval): Match primcalls to "apply", not "@apply". Residualize "apply" primcalls. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*multiply-valued-primitives*): Remove @apply, and apply primitive expander. * test-suite/tests/peval.test: * test-suite/tests/tree-il.test: Update tests to expect residualized "apply". * test-suite/tests/procprop.test ("procedure-arity"): Update test for better apply arity. * test-suite/tests/strings.test ("string"): Update expected error.
2013-06-23psyntax: ((@@ primitive NAME) ARG ...) in (guile) module is a primcallAndy Wingo1-0/+33
* ice-9/psyntax.scm (@@): Recognize new form, (@@ primitive NAME), which in operator position expands to a primcall. This expansion is only available for forms in the (guile) module. Added an argument to @@ and @ procedures, the module, for use by expanded syntax objects; adapted callers. (analyze-variable): Error when accessing a primitive for value. (get-global-definition-hook): Primitives are not macros. (syntax-type): A form with a primitive in the car is a primitive-call. (expand-expr): Residualize primitive calls as primcalls. (syntax-local-binding): Return 'primitive as the type for primitives.
2013-06-16tests: Don't rely on `scm_call_2' being visible.Ludovic Courtès1-14/+17
* test-suite/tests/coverage.test ("procedure-execution-count")["called from C"]: Throw 'unresolved when `scm_call_2' cannot be resolved. Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16tests: Remove symlink only when it exists.Ludovic Courtès1-1/+2
* test-suite/tests/filesys.test: Delete (test-symlink) only if it exists---i.e., not on Windows. Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16tests: Skip FFI tests that use `qsort' when it's not accessible.Ludovic Courtès1-6/+10
* test-suite/tests/foreign.test ("procedure->pointer")[qsort]: Wrap in `false-if-exception'. ["qsort", "qsort, wrong return type", "qsort, wrong arity"]: Throw 'unresolved when QSORT if #f. Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16<dynwind> no longer has "pre" or "post" fieldsAndy Wingo1-17/+39
* module/language/tree-il.scm (<tree-il>): Remove pre and post fields from <dynwind>. A dynwind now assumes that in normal entry and exit, that the code runs the winders and unwinders using <seq> and <let-values> and such things. (parse-tree-il, unparse-tree-il, make-tree-il-folder, pre-post-order): Adapt <dynwind> users. * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (flatten-lambda-case): * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/effects.scm (make-effects-analyzer): Adapt. * module/language/tree-il/peval.scm (peval): * module/language/tree-il/primitives.scm (*primitive-expand-table*): Produce tree-il that calls the winder and unwinder. Recognize singly-valued dynamic-wind expressions. * test-suite/tests/peval.test ("partial evaluation"): Add tests.
2013-06-16Reduce call-with-values to let for singly-valued producersAndy Wingo1-0/+9
* module/language/tree-il/peval.scm (singly-valued-expression?): Add support for conditionals. In the future we should add more expressions here. (peval): Don't inline values into the body of a dynwind, as that could cause the consumer to run in the wrong dynamic context. If the producer is singly-valued and the consumer just has a rest arg, reduce to "let" and cons up a list in the consumer. This may reduce further. * test-suite/tests/peval.test ("partial evaluation"): Add a test.
2013-06-10Implement tree-il-fold in terms of make-tree-il-folder.Andy Wingo1-19/+16
* module/language/tree-il.scm (tree-il-fold): Implement using make-tree-il-folder. This is an incompatible change: there is no more "leaf" procedure, and tree-il-fold only works on tree-il and not lists. * module/language/tree-il/analyze.scm (<tree-analysis>, analyze-tree): Adapt to tree-il-fold change, losing the "leaf" handler. (unused-variable-analysis, unused-toplevel-analysis) (unbound-variable-analysis, arity-analysis): Adapt to tree-analysis change. * module/language/tree-il/canonicalize.scm (tree-il-any) * module/language/tree-il/cse.scm (build-assigned-var-table) * module/language/tree-il/peval.scm (tree-il-any, build-var-table) (peval): Adapt to tree-il-fold change. * test-suite/tests/tree-il.test ("tree-il-fold"): Adapt tests for new interface and expectations.
2013-06-10Pre-order tree-il rewrites are now non-destructiveAndy Wingo3-4/+4
* module/language/tree-il.scm (pre-order): Re-implement in terms of pre-post-order, and rename from pre-order!. * module/language/tree-il/primitives.scm (expand-primitives): Adapt to pre-order change, and rename from expand-primitives!. * module/language/tree-il/optimize.scm (optimize): Adapt to expand-primitives! change, and rename from optimize!. * module/language/tree-il/compile-glil.scm: * module/system/repl/common.scm: * test-suite/tests/cse.test: * test-suite/tests/peval.test: * test-suite/tests/tree-il.test: Adapt to expand-primitives and optimize changes.
2013-06-10Tree-il post-order rewriter no longer destructiveAndy Wingo3-9/+11
* module/language/tree-il.scm (pre-post-order): New helper, like pre-order! and post-order! but not destructive. (post-order): Implement in terms of pre-post-order, and rename from post-order!. * module/ice-9/compile-psyntax.scm (squeeze-tree-il): * module/language/tree-il/canonicalize.scm (canonicalize): * module/language/tree-il/fix-letrec.scm (fix-letrec): * module/language/tree-il/primitives.scm (resolve-primitives): Use post-order, and rename from the destructive variants (squeeze-tree-il!, canonicalize!, etc). Adapt callers. * test-suite/tests/tree-il.test (strip-source): Adapt to post-order. * test-suite/tests/cse.test: * test-suite/tests/peval.test: * module/language/tree-il/optimize.scm: Adapt callers.
2013-06-10Simplify let-values to let if consumer binds only one variableAndy Wingo1-1/+6
* module/language/tree-il/peval.scm (peval): let-values with a consumer that has only one argument is the same as let. * test-suite/tests/peval.test ("partial evaluation"): Add test.
2013-06-10fix linker.testAndy Wingo1-12/+6
* test-suite/tests/linker.test (link-elf-with-one-main-section): Fix test after string table change.
2013-06-09procedure-properties for RTL functionsAndy Wingo1-0/+52
* module/system/vm/assembler.scm (link-procprops, link-objects): Arrange to write procedure property links out to a separate section. * libguile/procprop.c (scm_procedure_properties): * libguile/programs.h: * libguile/programs.c (scm_i_rtl_program_properties): * module/system/vm/debug.scm (find-program-properties): Wire up procedure-properties for RTL procedures. Yeah! Fistpumps! :) * module/system/vm/debug.scm (find-program-debug-info): Return #f if the string is "", as it is if we don't have a name. Perhaps elf-symbol-name should return #f in that case... * test-suite/tests/rtl.test: Add some tests.
2013-06-09procedure-documentation works on RTL proceduresAndy Wingo1-0/+11
* libguile/procprop.h: * libguile/procprop.c (scm_procedure_documentation): Move here from procs.c, and to make the logic more similar to that of procedure-name, which allows RTL programs to dispatch to rtl-program-documentation. * libguile/programs.c (scm_i_rtl_program_documentation): * libguile/programs.h: * module/system/vm/program.scm (rtl-program-documentation): New plumbing. * module/system/vm/debug.scm (find-program-docstring): New interface to grovel ELF for a docstring.
2013-06-09Wire up ability to print RTL program aritiesAndy Wingo1-0/+30
* libguile/procprop.c (scm_i_procedure_arity): Allow RTL programs to dispatch to scm_i_program_arity. * libguile/programs.c (scm_i_program_print): Refactor reference to write-program. (scm_i_rtl_program_minimum_arity): New procedure, dispatches to Scheme. (scm_i_program_arity): Dispatch to scm_i_rtl_program_minimum_arity if appropriate. * module/system/vm/debug.scm (program-minimum-arity): New export. * module/system/vm/program.scm (rtl-program-minimum-arity): New internal function. (program-arguments-alists): New helper, implemented also for RTL procedures. (write-program): Refactor a bit, and call program-arguments-alists. * test-suite/tests/rtl.test ("simply procedure arity"): Add tests that arities make it all the way to cold ELF and back to warm Guile.
2013-06-09Beginnings of tracking of procedure arities in assemblerAndy Wingo1-20/+40
* module/system/vm/assembler.scm (<meta>, <arity>): Assembler now tracks arities of a function. (begin-standard-arity, begin-opt-arity, begin-kw-arity, end-arity): New macro-assemblers. * test-suite/tests/rtl.test: Adapt all tests to use begin-standard-arity and end-arity.
2013-06-09add procedure prelude macro-instructionsAndy Wingo1-20/+20
* module/system/vm/assembler.scm (pack-flags): New helper. (standard-prelude, opt-prelude, kw-prelude): New macro-instructions. * test-suite/tests/rtl.test: Update tests to use standard-prelude.
2013-06-09begin-program takes properties alistAndy Wingo1-20/+38
* module/system/vm/assembler.scm (assert-match): New helper macro to check argument types. (<meta>): Add properties field. Rename name field to "label" to indicate that it should be unique. (make-meta, meta-name): New helpers. (begin-program): Take additional properties argument. (emit-init-constants): Adapt to begin-program change. (link-symtab): Allow for anonymous procedures. * test-suite/tests/rtl.test: Adapt tests.
2013-06-09RTL programs print with their nameAndy Wingo1-0/+10
* libguile/print.c (iprin1): Use scm_i_program_print for RTL programs too. * libguile/procprop.c (scm_procedure_name): For RTL programs, call scm_i_rtl_program_name if there is no override. * libguile/programs.h: * libguile/programs.c (scm_i_rtl_program_name): New helper, dispatches to (system vm program). (scm_i_program_print): For RTL programs, the fallback prints the code pointer too. * module/system/vm/program.scm (rtl-program-name): Use the debug info to get an RTL program name. (write-program): Work with RTL programs too. * test-suite/tests/rtl.test ("procedure name"): Add test.
2013-06-09Add runtime support for reading debug information from ELFAndy Wingo1-1/+22
* module/Makefile.am: * module/system/vm/debug.scm: New module. * module/system/vm/elf.scm (elf-section-by-name): New helper. (elf-symbol-table-len): New helper. * test-suite/tests/rtl.test: Add test for finding debug info.
2013-06-09Add RTL assemblerAndy Wingo1-0/+249
* module/Makefile.am: * module/system/vm/assembler.scm: New module, implementing an assembler for RTL. * test-suite/Makefile.am: * test-suite/tests/rtl.test: New test suite. * module/system/vm/elf.scm (make-elf-symbol*): Add constructor; export as make-elf-symbol. (elf-symbol-len): New export. (write-elf32-symbol, write-elf64-symbol): New helpers. (write-elf-symbol): New export.
2013-06-05Report the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.Ludovic Courtès1-0/+16
Reported by Mark H. Weaver. * libguile/keywords.c (scm_c_bind_keyword_arguments): Use `scm_error_scm' instead of `scm_error'. Pass the faulty keyword enclosed in a list as the last argument. * test-suite/tests/optargs.test ("scm_c_bind_keyword_arguments"): New test prefix.
2013-06-04Print the faulty object upon invalid-keyword errors.Ludovic Courtès1-23/+15
* libguile/vm.c (vm_error_kwargs_invalid_keyword, vm_error_kwargs_unrecognized_keyword): Add parameter. Pass it enclosed in a list as the last argument to `scm_error_scm'. * libguile/vm-i-system.c (bind_kwargs): Adjust accordingly. * libguile/eval.c (error_invalid_keyword, error_unrecognized_keyword): Add parameter. (prepare_boot_closure_env_for_apply): Adjust accordingly. * module/ice-9/eval.scm (primitive-eval): Likewise. * libguile/error.c (scm_error_scm): Mention `keyword-argument-error' in docstring. * module/ice-9/boot-9.scm (keyword-error-printer): New procedure; use it. * test-suite/tests/optargs.test (c&e, with-test-prefix/c&e): Remove. ("define*")["unrecognized keyword"]: Test the value passed along the `keyword-argument-error' exception. ["invalid keyword"]: New test. * doc/ref/api-control.texi (Error Reporting): Update `scm-error' description.
2013-05-23refactor linker to lay out ELF files and memory in the same wayAndy Wingo1-2/+3
* module/system/vm/linker.scm (make-linker-object): (linker-object-section-symbol): (linker-object-symbols*): Create a symbol to the start of a linker object. Hide it from the external linker-object-symbols* accessor. (segment-kind, count-segments): Sections without SHF_ALLOC don't get segments. (collate-objects-into-segments): Allow for #f segment types. If two sections have the same type and flags, leave them in the same order. (align): Allow for 0 alignment. (add-elf-objects): New helper: puts the ELF data structures (header, segment table, and section table) in sections of their own. This lends a nice clarity and conceptual unity to the linker. (relocate-section-header, allocate-segment): Lay out segments with congruent, contiguous addresses, so that we can just mmap the file and if debugging sections that are not in segments are present, they can be lazily paged in if needed by the kernel's VM system. (link-elf): Refactor to use the new interfaces. * test-suite/tests/linker.test: Update to expect the additional sections for the header and section table.
2013-05-23ELF refactor and consequent linker simplificationsAndy Wingo1-3/+4
* module/system/vm/elf.scm: Add commentary. (make-elf): Add a constructor similar to make-elf-segment and make-elf-section. (write-elf32-header, write-elf64-header, write-elf-header): Take an <elf> instead of all the fields separately. (<elf-segment>, <elf-section>): Add "index" property. Adapt constructors accordingly. * module/language/objcode/elf.scm (bytecode->elf): Arrange to set the section indexes when creating ELF sections. * module/system/vm/linker.scm (fold-values): New helper. (alloc-segment, relocate-section-header): Arrange to set segment and section indexes. (find-shstrndx): New helper, replaces compute-sections-by-name. Now that sections know their indexes, this is easier. (allocate-elf, write-elf): New helpers, factored out of link-elf. Easier now that sections have indexes. (link-elf): Simplify. Check that the incoming objects have sensible numbers. * test-suite/tests/linker.test: Update to set #:index on the linker objects.
2013-05-23split linker out of elf moduleAndy Wingo1-0/+86
* module/Makefile.am: * module/system/vm/linker.scm: New file, split out of (system vm elf). (make-string-table, string-table-intern): Export under their bare names, instead of make-elf-string-table and elf-string-table-intern. * module/system/vm/elf.scm: Remove linking capabilities. (string-table-ref): Export. * module/language/objcode/elf.scm (bytecode->elf): Adapt to use (system vm linker). * test-suite/tests/linker.test: New test.
2013-05-02web: uri-encode hexadecimal percent-encoding is now uppercaseAleix Conchillo Flaque1-2/+2
* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH is now uppercased as suggested by RFC3986: "For consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings." * test-suite/tests/web-uri.test ("encode"): update tests.
2013-04-14Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver11-170/+959
Conflicts: GUILE-VERSION libguile/array-map.c libguile/fports.h libguile/gc.h libguile/inline.h libguile/ports.c libguile/ports.h libguile/print.c libguile/r6rs-ports.c libguile/read.c test-suite/tests/00-socket.test
2013-04-14Using 'pass-if-equal' in coding.test.Mark H Weaver1-56/+56
* test-suite/tests/coding.test ("block comments", "line comments"): Use 'pass-if-equal'.
2013-04-14Adjust BOM tests to reflect the fact that big endian is used by default.Mark H Weaver1-12/+2
* test-suite/tests/ports.test ("BOM not discarded unless at start of UTF-16 stream", "BOM not discarded unless at start of UTF-32 stream"): Adjust tests to reflect the fact that, in the absence of a BOM, big endian will be used by default for the "UTF-16" and "UTF-32" encodings.
2013-04-10Add 2012 and 2013 to copyright notice on numbers.test.Mark H Weaver1-1/+2
* test-suite/tests/numbers.test: Add 2012 and 2013 to copyright notice. It was modified both of those years.
2013-04-09tests: Skip FFI tests involving `scm_is_pair' when `dynamic-func' fails.Ludovic Courtès1-4/+6
* test-suite/tests/foreign.test ("make-pointer")["equal? modulo finalizer", "equal? modulo finalizer (set-pointer-finalizer!)"]: Wrap `dynamic-func' in `false-if-exception' (static builds on NetBSD 5.1 raise "Symbol not found" here.)
2013-04-09tests: Skip IPv6 socket tests when OS support is missing.Ludovic Courtès1-1/+10
Reported by Samuel Thibault <samuel.thibault@gnu.org> and Peter Simons <simons@cryp.to>. * test-suite/tests/00-socket.test ("AF_INET6/SOCK_STREAM"): Throw `unresolved' when `bind' throws EADDRNOTAVAIL.
2013-04-08Miscellaneous 'sendfile' fixes and improved tests.Mark H Weaver1-26/+40
* libguile/filesys.c (scm_sendfile): In Linux-style sendfile(2) code, if EINTR or EAGAIN occurs, set result to 1 (not 0) so that we actually keep going. In non-sendfile(2) code, deal gracefully with short reads due to EOF. * test-suite/tests/filesys.test ("sendfile"): Use 'let*' to guarantee the needed order of operations: write (test-file) and then read it. Add code to check the written data (not just the returned length) in all tests, including the cases that hit EOF prematurely.
2013-04-07Change `sendfile' to loop until everything has been sent.Ludovic Courtès1-59/+71
* libguile/filesys.c (scm_sendfile)[HAVE_SYS_SENDFILE_H && HAVE_SENDFILE]: Compare RESULT with C_COUNT. Loop until C_COUNT bytes have been sent. * doc/ref/posix.texi (File System): Update the description. Explain the new semantics. * test-suite/tests/filesys.test ("sendfile"): Rewrite using `pass-if-equal'. Check the return value for all the tests. ["file with offset past the end", "file with offset near the end"]: New tests.
2013-04-07Add keyword arguments to file opening procedures.Mark H Weaver1-2/+283
* libguile/fports.c (scm_open_file_with_encoding): New API function, containing the code previously found in 'scm_open_file', but modified to accept the new 'guess_encoding' and 'encoding' arguments. (scm_open_file): Now just a simple wrapper that calls 'scm_open_file_with_encoding'. (scm_i_open_file): New implementation of 'open-file' that accepts keyword arguments '#:guess-encoding' and '#:encoding', and calls 'scm_open_file_with_encoding'. (scm_init_fports_keywords): New initialization function that gets called after keywords are initialized. * libguile/fports.h (scm_open_file_with_encoding, scm_init_fports_keywords): Add prototypes. * libguile/init.c (scm_i_init_guile): Call 'scm_init_fports_keywords'. * module/ice-9/boot-9.scm: Add enhanced versions of 'open-input-file', 'open-output-file', 'call-with-input-file', 'call-with-output-file', 'with-input-from-file', 'with-output-to-file', and 'with-error-to-file', that accept keyword arguments '#:binary', '#:encoding', and (for input port constructors) '#:guess-encoding'. * doc/ref/api-io.texi (File Ports): Update documentation. * test-suite/tests/ports.test ("keyword arguments for file openers"): Add tests.
2013-04-07Implement efficient 'scm_unget_bytes' and 'unget-bytevector'.Mark H Weaver1-2/+19
* libguile/ports.c (scm_i_unget_bytes): New static function. (scm_unget_bytes): New API function. (scm_unget_byte): Rewrite to simply call 'scm_i_unget_bytes'. (scm_ungetc, scm_peek_char, looking_at_bytes): Use 'scm_i_unget_bytes'. * libguile/ports.h: Add prototype for 'scm_unget_bytes'. * libguile/fports.c (scm_setvbuf): Use 'scm_unget_bytes'. * libguile/r6rs-ports.c (scm_unget_bytevector): New procedure. * module/ice-9/binary-ports.scm (unget-bytevector): New export. * doc/ref/api-io.texi (R6RS Binary Input): Add documentation. (R6RS I/O Ports): Update brief description of (ice-9 binary-ports) to reflect the new reality: it is no longer a subset of (rnrs io ports). * test-suite/tests/ports.test ("unget-bytevector"): Add test.
2013-04-07Do not scan for coding declarations in open-file.Mark H Weaver2-5/+4
* libguile/fports.c (scm_open_file): Do not scan for coding declarations. Replace 'use_encoding' local variable with 'binary'. Update documentation string. * module/ice-9/psyntax.scm (include): Add the same file-encoding logic that's used in compile-file and scm_primitive_load. * module/ice-9/psyntax-pp.scm: Regenerate. * doc/ref/api-io.texi (File Ports): Update docs. * test-suite/tests/ports.test: Change "open-file HONORS file coding declarations" test to "open-file IGNORES file coding declaration". * test-suite/tests/coding.test (scan-coding): Use 'file-encoding' to scan for the encoding, since 'open-input-file' no longer does so.
2013-04-05Remove double indirection in array-fill!Daniel Llorens1-1/+9
* libguile/array-map.c: new function rafill, like scm_array_fill_int, but factors GVSET out of the loop. Use it in scm_array_fill_x instead of scm_array_fill_int. * test-suite/tests/arrays.test: add test for array-fill! with stride != 1. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05Tests for array-copy!Daniel Llorens1-0/+40
* test-suite/tests/arrays.test: tests for arguments of rank 0, 1 and 2. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05Add `call/ec' and `let/ec'.Ludovic Courtès1-2/+28
Based on a patch by Nala Ginrut <nalaginrut@gmail.com>, with suggestions from Mark H. Weaver. * module/ice-9/control.scm (call-with-escape-continuation, call/ec): New procedures. (let-escape-continuation, let/ec): New macros. * module/ice-9/futures.scm (let/ec): Remove. * test-suite/tests/control.test ("escape-only continuations")["call/ec", "let/ec"]: New tests. * doc/ref/api-control.texi (Prompt Primitives): Document `call/ec', `let/ec', and their long names.
2013-04-04Improve handling of Unicode byte-order marks (BOMs).Mark H Weaver1-2/+282
* libguile/ports-internal.h (struct scm_port_internal): Add new members 'at_stream_start_for_bom_read' and 'at_stream_start_for_bom_write'. (SCM_UNICODE_BOM): New macro. (scm_i_port_iconv_descriptors): Add 'mode' parameter to prototype. * libguile/ports.c (scm_new_port_table_entry): Initialize 'at_stream_start_for_bom_read' and 'at_stream_start_for_bom_write'. (get_iconv_codepoint): Pass new 'mode' parameter to 'scm_i_port_iconv_descriptors'. (get_codepoint): After reading a codepoint at stream start, record that we're no longer at stream start, and consume a BOM where appropriate. (scm_seek): Set the stream start flags according to the new position. (looking_at_bytes): New static function. (scm_utf8_bom, scm_utf16be_bom, scm_utf16le_bom, scm_utf32be_bom, scm_utf32le_bom): New static const arrays. (decide_utf16_encoding, decide_utf32_encoding): New static functions. (scm_i_port_iconv_descriptors): Add new 'mode' parameter. If the specified encoding is UTF-16 or UTF-32, make that precise by deciding what byte order to use, and construct iconv descriptors based on the precise encoding. (scm_i_set_port_encoding_x): Record that we are now at stream start. Do not open the new iconv descriptors immediately; let them be initialized lazily. * libguile/print.c (display_string_using_iconv): Record that we're no longer at stream start. Write a BOM if appropriate. * doc/ref/api-io.texi (BOM Handling): New node. * test-suite/tests/ports.test ("set-port-encoding!, wrong encoding"): Adapt test to cope with the fact that 'set-port-encoding!' does not immediately open the iconv descriptors. (bv-read-test): New procedure. ("unicode byte-order marks (BOMs)"): New test prefix.
2013-04-04Peeks do not consume EOFs.Mark H Weaver1-0/+84
Fixes <http://bugs.gnu.org/12216>. * libguile/ports-internal.h (struct scm_port_internal): Add 'pending_eof' flag. * libguile/ports.c (scm_i_set_pending_eof, scm_i_clear_pending_eof): New static functions. (scm_new_port_table_entry): Initialize 'pending_eof'. (scm_i_fill_input): Check for 'pending_eof'. (scm_i_peek_byte_or_eof): Set 'pending_eof' flag before returning EOF. (scm_end_input, scm_unget_byte, scm_seek, scm_truncate): Clear 'pending_eof'. (scm_peek_char): Set 'pending_eof' flag before returning EOF. * test-suite/tests/ports.test ("pending EOF behavior"): Add tests.
2013-04-04Nicer docstring syntax for case-lambda.Mark H Weaver1-1/+17
* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Allow a docstring to be placed immediately after the 'case-lambda' or 'case-lambda*'. * module/ice-9/psyntax-pp.scm: Regenerate. * doc/ref/api-procedures.texi (Case-lambda): Update docs. * test-suite/tests/optargs.test ("case-lambda", "case-lambda*"): Add tests.
2013-04-03tests: Add `array-for-each' tests for one-dimensional traversals.Ludovic Courtès1-0/+30
* test-suite/tests/ramap.test ("array-for-each")["1 source"]: New test prefix.
2013-04-03tests: Use `pass-if-equal' in ramap.test.Ludovic Courtès1-12/+16
* test-suite/tests/ramap.test ("array-for-each"): Use `pass-if-equal' instead of `(pass-if ... (equal? ...))'.
2013-04-02Remove BOM tests that depend on GNU iconv behavior.Mark H Weaver1-92/+0
* test-suite/tests/ports.test ("unicode byte-order marks (BOMs)"): Remove tests that depend on GNU iconv behavior. We will add them back when we have portable BOM support.
2013-04-02Rewrite get_iconv_codepoint to fix a bug involving byte-order marks.Mark H Weaver1-0/+92
* libguile/ports.c (get_iconv_codepoint): Rewrite to fix a bug and improve efficiency and clarity. Previously, it incorrectly assumed that iconv would never consume input without producing output, which led to a buffer overrun and subsequent assertion failure. This happens when a byte-order mark is consumed by iconv at the beginning of the stream when using the UTF-16 or UTF-32 encodings. * test-suite/tests/ports.test (unicode byte-order marks (BOMs)): Add tests.
2013-04-01Optimize 'get-bytevector-some'; it may now read less than possible.Mark H Weaver1-24/+0
* libguile/r6rs-ports.c (scm_get_bytevector_some): Rewrite to efficiently take the contents of the read/putback buffers. In the docstring, clarify that it might not return all available bytes. * doc/ref/api-io.texi (R6RS Binary Input): Clarify that 'get-bytevector-some' might not return all available bytes. * test-suite/tests/r6rs-ports.test ("get-bytevector-some [only-some]"): Remove bogus test, which requires more than the R6RS requires.