diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-03-15 19:45:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-03-15 19:45:43 -0700 |
commit | a16253f78cea60a6a9696f20c8839f80f105c29f (patch) | |
tree | 159ea5c4c2b4fdd4439e2f16396776d320716690 | |
parent | ccb946d7e3a64dd501f21e5859de81fc127f816b (diff) | |
download | txr-a16253f78cea60a6a9696f20c8839f80f105c29f.tar.gz txr-a16253f78cea60a6a9696f20c8839f80f105c29f.tar.bz2 txr-a16253f78cea60a6a9696f20c8839f80f105c29f.zip |
umask: arg optional, return old value.
* sysif.c (umask_wrap): Return the prior value of the umask
rather than the symbol t. If the argument is missing, then
just return the current value without altering the umask.
Unfortunately, this is implemented by temporarily changing
the umask and then putting it back.
(sysif_init): Change registration of umask to reflect
optional argument.
-rw-r--r-- | sysif.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -718,8 +718,12 @@ val statf(val stream) static val umask_wrap(val mask) { - (void) umask(c_num(mask)); - return t; + if (missingp(mask)) { + mode_t m = umask(0777); + (void) umask(m); + return num(m); + } + return num(umask(c_num(mask))); } #endif @@ -1755,7 +1759,7 @@ void sysif_init(void) #endif #if HAVE_SYS_STAT - reg_fun(intern(lit("umask"), user_package), func_n1(umask_wrap)); + reg_fun(intern(lit("umask"), user_package), func_n1o(umask_wrap, 0)); #endif #if HAVE_FNMATCH |