diff --git a/NEWS b/NEWS index 15ab4c9ee..cc6190050 100644 --- a/NEWS +++ b/NEWS @@ -334,6 +334,10 @@ Instead, use scm_c_memq or scm_memq, scm_memv, scm_member. * return 0 if the request is for 0 bytes, with no end-of-file check +** New function: object->string OBJ + +Return a Scheme string obtained by printing a given object. + ** New function: port? X Returns a boolean indicating whether X is a port. Equivalent to @@ -622,6 +626,10 @@ Use scm_make_smob_type and scm_set_smob_XXX instead. This can be used to set an apply function to a smob type. +** Deprecated function: scm_strprint_obj + +Use scm_object_to_string instead. + Changes since Guile 1.3.4: diff --git a/RELEASE b/RELEASE index 54471fc05..8e797adf0 100644 --- a/RELEASE +++ b/RELEASE @@ -78,6 +78,7 @@ In release 1.6: strictly scsh-compatible version which uses multiple values. For interactive use it would be easy to load the module in ~/.guile. - remove scm_close_all_ports_except +- remove scm_strprint_obj Modules sort.c and random.c should be factored out into separate modules (but still be distributed with guile-core) when we get a new diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 320af3503..8371560ff 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2001-03-12 Keisuke Nishida + + * strports.c (scm_object_to_string): New procedure. + (scm_strprint_obj): Deprecated. + * strports.h: Reflect the changes. + 2001-03-12 Dirk Herrmann * goops.h (SCM_VALIDATE_PUREGENERIC): New macro. diff --git a/libguile/strports.c b/libguile/strports.c index 8a99e618b..5dad27063 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -311,6 +311,31 @@ SCM scm_strport_to_string (SCM port) return scm_makfromstr ((char *) pt->read_buf, pt->read_buf_size, 0); } +SCM_DEFINE (scm_object_to_string, "object->string", 1, 0, 0, + (SCM obj), + "Return a Scheme string obtained by printing a given object.") +#define FUNC_NAME s_scm_object_to_string +{ + SCM str; + SCM port; + + str = scm_makstr (0, 0); + port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_WRTNG, "scm_strprint_obj"); + scm_prin1 (obj, port, 1); + return scm_strport_to_string (port); +} +#undef FUNC_NAME + +#if (SCM_DEBUG_DEPRECATED == 0) + +SCM +scm_strprint_obj (SCM obj) +{ + return scm_object_to_string (obj); +} + +#endif /* (SCM_DEBUG_DEPRECATED == 0) */ + SCM_DEFINE (scm_call_with_output_string, "call-with-output-string", 1, 0, 0, (SCM proc), "Calls the one-argument procedure @var{proc} with a newly created output\n" @@ -330,29 +355,6 @@ SCM_DEFINE (scm_call_with_output_string, "call-with-output-string", 1, 0, 0, } #undef FUNC_NAME - - -/* Return a Scheme string obtained by printing a given object. - */ - - -SCM -scm_strprint_obj (SCM obj) -{ - SCM str; - SCM port; - - str = scm_makstr (0, 0); - port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_WRTNG, "scm_strprint_obj"); - scm_prin1 (obj, port, 1); - { - return scm_strport_to_string (port); - } -} - - - - SCM_DEFINE (scm_call_with_input_string, "call-with-input-string", 2, 0, 0, (SCM str, SCM proc), "Calls the one-argument procedure @var{proc} with a newly created input\n" diff --git a/libguile/strports.h b/libguile/strports.h index 28bae69b4..917b73f60 100644 --- a/libguile/strports.h +++ b/libguile/strports.h @@ -50,14 +50,20 @@ extern SCM scm_mkstrport (SCM pos, SCM str, long modes, const char * caller); extern SCM scm_strport_to_string (SCM port); +extern SCM scm_object_to_string (SCM obj); extern SCM scm_call_with_output_string (SCM proc); -extern SCM scm_strprint_obj (SCM obj); extern SCM scm_call_with_input_string (SCM str, SCM proc); extern SCM scm_read_0str (char *expr); extern SCM scm_eval_0str (const char *expr); extern SCM scm_eval_string (SCM string); extern void scm_init_strports (void); +#if (SCM_DEBUG_DEPRECATED == 0) + +extern SCM scm_strprint_obj (SCM obj); + +#endif /* SCM_DEBUG_DEPRECATED == 0 */ + #endif /* STRPORTSH */ /*