1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

16114 commits

Author SHA1 Message Date
Mark H Weaver
9c90a81bb5 Bump 'copyright-year' to 2013.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
  2013.
2013-04-06 15:52:08 -04:00
Ian Price
4ad329cbca Remove duplicate definitions of call/ec' and let/ec'.
* module/language/tree-il/peval.scm (let/ec): Remove. Import
  (ice-9 control).
* module/sxml/match.scm (%call/ec-prompt, call/ec, let/ec):
  Remove. Import (ice-9 control).

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-06 15:40:19 +02:00
Ludovic Courtès
47ed3ca43a Update `NEWS'. 2013-04-06 13:07:01 +02:00
Ludovic Courtès
004094d378 doc: Document `--language'.
* doc/ref/guile-invoke.texi (Command-line Options): Document `--language'.
2013-04-06 13:07:01 +02:00
Ludovic Courtès
66750b78c7 doc: Document file name separator procedures.
* doc/ref/posix.texi (File System): Document
  `system-file-name-convention', `file-name-separator?',
  `absolute-file-name?', and `file-name-separator-string'.
2013-04-06 13:07:01 +02:00
Chris K. Jester-Young
3f1362adb5 Use a fresh cons for %stream-null.
* module/srfi/srfi-41.scm (%stream-null): Use a fresh cons rather than
  a literal cons. You never know what peval constant-folding could do
  with the latter, either now or in the future.
2013-04-06 03:06:37 -04:00
Ludovic Courtès
a24cda1d26 Update `NEWS'. 2013-04-05 22:54:15 +02:00
Daniel Llorens
d09b201d59 Deprecate scm_array_fill_int()
* libguile/array-map.h, libgule/array-map.c: move scm_array_fill_int
  to the deprecated section.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05 22:54:14 +02:00
Daniel Llorens
ab1ca17986 Remove double indirection in array-fill!
* 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-05 22:54:14 +02:00
Daniel Llorens
b5159a471a Tests for array-copy!
* 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-05 22:54:14 +02:00
Ludovic Courtès
55e26a49db Add call/ec' and let/ec'.
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-05 22:54:14 +02:00
Ludovic Courtès
d888b53168 tests: Add pass-if-equal' support in c&e'.
* test-suite/test-suite/lib.scm (c&e): Add case for `pass-if-equal'.
2013-04-05 22:54:14 +02:00
Mark H Weaver
96965a6ecb Use 'c_strcasecmp' instead of 'strcasecmp'.
* libguile/ports.c (scm_new_port_table_entry, get_codepoint,
  scm_i_set_default_port_encoding, scm_i_port_iconv_descriptors,
  scm_i_set_port_encoding_x):
* libguile/print.c (display_string_using_iconv):
* libguile/read.c (scm_i_scan_for_encoding): Use 'c_strcasecmp'.
2013-04-05 14:10:28 -04:00
Mark H Weaver
e501f2111e Import 'c-strcase' from Gnulib.
* lib/Makefile.am:
* m4/gnulib-cache.m4: Add 'c-strcase' Gnulib module.
2013-04-05 13:59:29 -04:00
Chris K. Jester-Young
4b76acfa38 Revert "Add record type printers for srfi-41 and srfi-45."
This reverts commit 4a1cdc9d5d, which was
prematurely pushed.
2013-04-05 13:31:12 -04:00
Chris K. Jester-Young
4a1cdc9d5d Add record type printers for srfi-41 and srfi-45.
* module/srfi/srfi-41.scm: Add record type printer for streams.
* module/srfi/srfi-45.scm: Add record type printer for promises.
2013-04-04 22:22:43 -04:00
Mark H Weaver
cdd3d6c9f4 Improve handling of Unicode byte-order marks (BOMs).
* 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-04 21:40:28 -04:00
Mark H Weaver
45c0878b86 Peeks do not consume EOFs.
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-04 17:48:37 -04:00
Mark H Weaver
0426b3f8f8 Nicer docstring syntax for case-lambda.
* 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-04 15:22:18 -04:00
Mark H Weaver
71539c1cd3 Cross reference 'SRFI-9 Records' directly instead of 'SRFI-9'.
* doc/ref/api-compound.texi (Record Overview, Records):
  doc/ref/api-modules.texi (Included Guile Modules):
  doc/ref/r6rs.texi (R6RS Records): Cross reference 'SRFI-9 Records'
  directly instead of 'SRFI-9'.
2013-04-04 03:21:40 -04:00
Mark H Weaver
4120539225 Preserve the case of the user-specified port encoding string.
* libguile/ports.c (scm_i_set_port_encoding_x): Always copy the
  user-provided port encoding string, so that its case will be preserved
  and returned exactly by subsequent calls to 'port-encoding'.
2013-04-03 16:07:34 -04:00
Daniel Llorens
c3e3ef6eb6 Remove double indirection for 1st arg of array-for-each
* libguile/array-map.c: (rafe): factor GVREF out of rank-1 loop for ra0.
2013-04-03 21:46:27 +02:00
Ludovic Courtès
3220b08049 tests: Add `array-for-each' tests for one-dimensional traversals.
* test-suite/tests/ramap.test ("array-for-each")["1 source"]: New test
  prefix.
2013-04-03 21:46:27 +02:00
Ludovic Courtès
0d7f3a6d95 tests: Use `pass-if-equal' in ramap.test.
* test-suite/tests/ramap.test ("array-for-each"): Use `pass-if-equal'
  instead of `(pass-if ... (equal? ...))'.
2013-04-03 21:46:27 +02:00
Daniel Llorens
51a1763f65 Remove double indirection in array-map! with <2 args
* libguile/array-map.c: (ramap): factor GVSET/GVREF out of rank-1 loop
  for ra0 and the first element of ras.
2013-04-03 21:46:27 +02:00
Daniel Llorens
9a68d7b388 Avoid per-element cons for 1-arg case of array-map!
* libguile/array-map.c: (ramap): special case when ras is a 1-element list.
2013-04-03 21:46:27 +02:00
Daniel Llorens
75a1b26c5d Deprecate dead code in array-map.c
* libguile/array-map.c, libguile/array-map.h: deprecate scm_ra_eqp,
  scm_ra_lessp, scm_ra_leqp, scm_ra_grp, scm_ra_greqp, scm_ra_sum,
  scm_ra_product, scm_ra_difference, scm_ra_divide, scm_array_identity.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-03 21:46:27 +02:00
Mark H Weaver
7290de89fb Use 'strcasecmp' to compare encoding names.
Reported by Ludovic Courtès <ludo@gnu.org>.

* libguile/ports.c (scm_new_port_table_entry,
  scm_i_set_default_port_encoding, scm_i_set_port_encoding_x):
  libguile/read.c (scm_i_scan_for_encoding): Use 'strcasecmp' to compare
  encoding names.
2013-04-03 13:31:51 -04:00
Daniel Llorens
72e2b5923a Remove double indirection in element access in array-copy!
* libguile/array-map.c: (racp): factor scm_generalized_vector_ref,
  scm_generalized_vector_set_x out of the rank-1 loop.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-03 14:21:49 +02:00
Mark H Weaver
9a31a54561 Remove BOM tests that depend on GNU iconv behavior.
* 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-02 20:47:30 -04:00
Mark H Weaver
e00793d7a9 Rename 'scm_i_get_byte_or_eof' et al; mark them as SCM_API.
* libguile/ports.c (scm_i_get_byte_or_eof, scm_i_peek_byte_or_eof):
  Rename to 'scm_slow_get_byte_or_eof' and 'scm_slow_peek_byte_or_eof',
  respectively.

* libguile/ports.h (scm_i_get_byte_or_eof, scm_i_peek_byte_or_eof):
  Rename to 'scm_slow_get_byte_or_eof' and 'scm_slow_peek_byte_or_eof',
  respectively, and mark them as SCM_API.

* libguile/inline.h (scm_get_byte_or_eof, scm_peek_byte_or_eof): Adjust
  to use the new names.
2013-04-02 19:35:43 -04:00
Mark H Weaver
1fa89aaf61 Remove uses of GC_PTR in 'finalize_iconv_descriptors'.
* libguile/ports.c (finalize_iconv_descriptors): Change GC_PTR to
  (void *) in parameter types.
2013-04-02 18:02:56 -04:00
Mark H Weaver
1ee237d9a1 Rewrite get_iconv_codepoint to fix a bug involving byte-order marks.
* 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-02 17:45:50 -04:00
Mark H Weaver
8a2b596579 Move slow path out of 'scm_get_byte_or_eof' et al.
Suggested by Andy Wingo.

* libguile/inline.h (scm_get_byte_or_eof, scm_peek_byte_or_eof): Keep
  only the fast path here, with fallback to 'scm_i_get_byte_or_eof' and
  'scm_i_peek_byte_or_eof'.

* libguile/ports.c (scm_i_get_byte_or_eof, scm_i_peek_byte_or_eof):
  New internal functions.

* libguile/ports.h (scm_i_get_byte_or_eof, scm_i_peek_byte_or_eof): Add
  prototypes.
2013-04-02 13:43:20 -04:00
Mark H Weaver
187fa0b9e7 Add a static version of 'scm_fill_input' to ports.c.
* libguile/ports.c (scm_i_fill_input): New static function, containing
  the code that was previously in 'scm_fill_input'.
  (scm_fill_input): Simply call 'scm_i_fill_input'.
  (scm_c_read): Use 'scm_i_fill_input'.
2013-04-02 13:43:04 -04:00
Mark H Weaver
05d7f76296 Move the port alist from the hash table to the internal port structure.
* libguile/ports-internal.h (struct scm_port_internal): Add 'alist'
  member.

* libguile/ports.c (scm_i_port_alist, scm_i_set_port_alist_x): New
  internal functions.
  (scm_i_port_weak_hash): Update comment: the hash table is no longer
  used to store the port's alist.
  (scm_new_port_table_entry): Initialize 'alist'.  Store SCM_BOOL_F in
  the port weak hash, not SCM_EOL.

* libguile/ports.h (scm_i_port_alist, scm_i_set_port_alist_x): Add
  protoypes.

* libguile/read.c (set_port_read_option, init_read_options): Access the
  port's alist via 'scm_i_port_alist' and 'scm_i_set_port_alist_x'.
2013-04-01 17:09:17 -04:00
Mark H Weaver
21bbe22a14 Optimize 'get-bytevector-some'; it may now read less than possible.
* 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.
2013-04-01 16:46:25 -04:00
Mark H Weaver
337edc591f Refactor port encoding modes: utf-8 and iconv
Based on 6c98257f2e by Andy Wingo.

* libguile/ports-internal.h (struct scm_port_internal): 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 the future.
  (enum scm_port_encoding_mode): New enum.
  (struct scm_iconv_descriptors): New struct.
  (scm_i_port_iconv_descriptors): Add prototype.

* libguile/ports.c (finalize_port): Don't close iconv descriptors here.
  (scm_new_port_table_entry): Adapt to the iconv descriptors being
  moved.  Initialize 'encoding_mode'.
  (scm_i_remove_port): Adapt to call 'close_iconv_descriptors'.
  (close_iconv_descriptors): New static function.
  (get_iconv_codepoint): Use 'scm_i_port_iconv_descriptors'.
  (get_codepoint): Check the port 'encoding_mode'.
  (finalize_iconv_descriptors, open_iconv_descriptors,
  close_iconv_descriptors, scm_i_port_iconv_descriptors): New static
  functions.
  (scm_i_set_port_encoding_x): Adapt to iconv descriptors being moved
  to separate structure, to set the 'encoding_mode' flag, and to use
  'open_iconv_descriptors' and 'close_iconv_descriptors'.

* libguile/print.c (display_string_using_iconv): Use
  'scm_i_port_iconv_descriptors'.
  (display_string): Use 'encoding_mode' flag.
2013-04-01 16:23:26 -04:00
Mark H Weaver
e459855936 Add internal-only port structure and move iconv descriptors there.
* libguile/ports-internal.h: New file.

* libguile/Makefile.am (noinst_HEADERS): Add ports-internal.h.

* libguile/ports.h (scm_t_port): Add a comment mentioning that the
  'input_cd' and 'output_cd' fields of the public structure are no
  longer what they seem to be.

* libguile/ports.c: Include ports-internal.h.

  (finalize_port, scm_i_remove_port, get_iconv_codepoint, get_codepoint,
  scm_i_set_port_encoding_x): Access 'input_cd' and 'output_cd' via the
  new internal port structure.

  (scm_new_port_table_entry): Allocate and initialize the internal port
  structure.

* libguile/print.c: Include ports-internal.h.

  (display_string_using_iconv, display_string): Access 'input_cd' and
  'output_cd' via 'internal' pointer.
2013-04-01 16:13:47 -04:00
Mark H Weaver
663780bb1c Add 'scm_gc_typed_calloc' macro.
* libguile/gc.h (scm_gc_typed_calloc): New macro.
2013-04-01 16:09:57 -04:00
Mark H Weaver
369294866d Fix broken texinfo markup in (ice-9 iconv) docs.
* doc/ref/api-data.texi (Representing Strings as Bytes): Fix broken
  @deffn syntax.
2013-04-01 12:35:24 -04:00
Mark H Weaver
1e05106562 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/r6rs-ports.c
2013-04-01 05:42:31 -04:00
Mark H Weaver
de2bc673bb scm_string_join: properly sequence operations in ADD_TO_APPEND_LIST
* libguile/srfi-13.c (scm_string_join): Properly sequence operations in
  ADD_TO_APPEND_LIST macro.
2013-04-01 05:31:08 -04:00
Mark H Weaver
786ab4258f Optimize 'string-join'.
* libguile/srfi-13.c (string-join): Rewrite to call 'scm_string_append'
  only once.
2013-04-01 03:47:29 -04:00
Mark H Weaver
2f13a46672 Make 'string-append' more efficient and robust.
* libguile/strings.c (scm_string_append): Check for numerical overflow
  while computing the length of the result.  Double-check that we don't
  overflow the result string, and that it is the correct length in the
  end (in case another thread changed the list).  When copying a narrow
  string to a wide result, avoid calling 'scm_i_string_length' and
  'scm_i_string_chars' on each character.
2013-04-01 03:47:09 -04:00
Mark H Weaver
3b80c35852 Fix typos in 'string-join' docs: 'string-infix' -> 'strict-infix'.
* doc/ref/api-data.texi (String Constructors): In definition of
  'string-join', change 'string-infix' -> 'strict-infix'.

* libguile/srfi-13.c (scm_string_join): In docstring, change
  'string-infix' -> 'strict-infix'.
2013-04-01 01:21:30 -04:00
Mark H Weaver
47f2bce5ae Avoid unnecessary peeks for EOF in r6rs-ports.
* libguile/r6rs-ports.c (scm_get_bytevector_n, scm_get_bytevector_n_x,
  scm_get_bytevector_some, scm_get_bytevector_all): Avoid peeking for
  EOF when we already know.
2013-03-31 21:12:31 -04:00
Mark H Weaver
86cf4773ff Merge remote-tracking branch 'origin/stable-2.0' 2013-03-30 22:56:27 -04:00
Mark H Weaver
b05257b923 Add -C command-line option to adjust %load-compiled-path.
* module/ice-9/command-line.scm (compile-shell-switches):
  Implement -C option.
  (*usage*): Add -C option.

* doc/ref/guile-invoke.texi (Command-line Options): Add docs.
2013-03-30 22:49:46 -04:00
Ludovic Courtès
beac49b8e1 Augment `.gitignore'. 2013-03-29 19:20:01 +01:00