Add keyword arguments to file opening procedures.
authorMark H Weaver <mhw@netris.org>
Sun, 7 Apr 2013 03:19:55 +0000 (23:19 -0400)
committerMark H Weaver <mhw@netris.org>
Sun, 7 Apr 2013 19:37:23 +0000 (15:37 -0400)
commit3ace9a8e4e1de7082ceec4aea0813a6adaa913bf
treeaa9c4ad234e0cdbda23966b36f5abec0e96b0e11
parentb6e374e535597448cb09588300d76b5d270d5d3a
Add keyword arguments to file opening procedures.

* 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.
doc/ref/api-io.texi
libguile/fports.c
libguile/fports.h
libguile/init.c
module/ice-9/boot-9.scm
test-suite/tests/ports.test