summaryrefslogtreecommitdiff
path: root/libguile/fports.h
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2013-04-06 23:19:55 -0400
committerMark H Weaver <mhw@netris.org>2013-04-07 15:37:23 -0400
commit3ace9a8e4e1de7082ceec4aea0813a6adaa913bf (patch)
treeaa9c4ad234e0cdbda23966b36f5abec0e96b0e11 /libguile/fports.h
parentb6e374e535597448cb09588300d76b5d270d5d3a (diff)
downloadguile-3ace9a8e4e1de7082ceec4aea0813a6adaa913bf.tar.gz
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.
Diffstat (limited to 'libguile/fports.h')
-rw-r--r--libguile/fports.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libguile/fports.h b/libguile/fports.h
index cbef0f8ec..c32ed9579 100644
--- a/libguile/fports.h
+++ b/libguile/fports.h
@@ -51,9 +51,12 @@ SCM_API scm_t_bits scm_tc16_fport;
SCM_API SCM scm_setbuf0 (SCM port);
SCM_API SCM scm_setvbuf (SCM port, SCM mode, SCM size);
SCM_API void scm_evict_ports (int fd);
+SCM_API SCM scm_open_file_with_encoding (SCM filename, SCM modes,
+ SCM guess_encoding, SCM encoding);
SCM_API SCM scm_open_file (SCM filename, SCM modes);
SCM_API SCM scm_fdes_to_port (int fdes, char *mode, SCM name);
SCM_API SCM scm_file_port_p (SCM obj);
+SCM_INTERNAL void scm_init_fports_keywords (void);
SCM_INTERNAL void scm_init_fports (void);
/* internal functions */