summaryrefslogtreecommitdiff
path: root/libguile/filesys.c
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2021-01-21 09:37:49 -0800
committerMichael Gran <spk121@yahoo.com>2021-01-21 10:33:08 -0800
commit32bf48e4b799a36276198a70b8ce48740100634e (patch)
tree57cce95d03d785ff6e9b2b54f115ef851698a69a /libguile/filesys.c
parentc67cbc501face03ed0a4d1445e196c3893f0fb3d (diff)
downloadguile-32bf48e4b799a36276198a70b8ce48740100634e.tar.gz
Replace mutating mkdtemp! with non-mutating mkdtemp
* doc/ref/posix.texi: replace mkdtemp! and scm_mkdtemp_x documentation with documentation for mkdtemp and scm_mkdtemp * libguile/filesys.c (scm_mkdtemp_x): procedure mkdtemp! removed (scm_mkdtemp): new procedure mkdtemp * libguile/filesys.h: Remove declaration for scm_mkdtemp_x. New declaration scm_mkdtemp. * test-suite/tests/filesys.test: Remove mkdtemp! tests. Add tests for mkdtemp.
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r--libguile/filesys.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c
index baff7b4c2..1b0af6e14 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1545,41 +1545,35 @@ scm_mkstemp (SCM tmpl)
}
#if HAVE_MKDTEMP
-SCM_DEFINE (scm_mkdtemp_x, "mkdtemp!", 1, 0, 0,
+SCM_DEFINE (scm_mkdtemp, "mkdtemp", 1, 0, 0,
(SCM tmpl),
"Create a new unique directory in the file system named in\n"
- "accordance with @var{tmpl}. The last 6 characters of the\n"
- "template must be XXXXXX\n"
+ "accordance with @var{tmpl}. The last six characters of the\n"
+ "template must be 'XXXXXX'.\n"
"\n"
- "Upon success, the template string, which must be mutable, will\n"
- "be modified in place with the name of the directory created.\n"
- "The return value is unspecified.\n"
+ "Upon success, this procedure returns the name of the\n"
+ "directory created.\n"
"\n"
"An error may be thrown if the template is incorrect or if\n"
"the directory could not be created.\n")
-#define FUNC_NAME s_scm_mkdtemp_x
+#define FUNC_NAME s_scm_mkdtemp
{
char *c_tmpl;
char *rv;
+ SCM new_dirname;
SCM_VALIDATE_STRING (SCM_ARG1, tmpl);
- /* Ensure tmpl is mutable. */
- scm_i_string_start_writing (tmpl);
- scm_i_string_stop_writing ();
-
scm_dynwind_begin (0);
c_tmpl = scm_to_locale_string (tmpl);
scm_dynwind_free (c_tmpl);
SCM_SYSCALL (rv = mkdtemp (c_tmpl));
if (rv == NULL)
SCM_SYSERROR;
- scm_substring_move_x (scm_from_locale_string (c_tmpl),
- SCM_INUM0, scm_string_length (tmpl),
- tmpl, SCM_INUM0);
+ new_dirname = scm_from_locale_string (c_tmpl);
scm_dynwind_end ();
- return SCM_UNSPECIFIED;
+ return new_dirname;
}
#undef FUNC_NAME
#endif /* HAVE_MKDTEMP */