summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-11-10 07:53:25 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-11-10 07:53:25 -0800
commit3fcc1b8b1b826d689ace5e3b98be10a46bf4ae56 (patch)
treed377fa1d4a37662af4d7bcadddc15dc3ec4aa74e
parentf9298daa51f5800f31ee7cdca5797ee57ae2e163 (diff)
downloadtxr-3fcc1b8b1b826d689ace5e3b98be10a46bf4ae56.tar.gz
txr-3fcc1b8b1b826d689ace5e3b98be10a46bf4ae56.tar.bz2
txr-3fcc1b8b1b826d689ace5e3b98be10a46bf4ae56.zip
ftw: default flags to ftw-phys
More often than not, you want the FTW_PHYS flag when calling the nftw function. Let's make that the default in TXR's wrapper. * ftw.c (ftw_wrap): Default to FTW_PHYS when flags argument not given, rather than zero, subject to compatibility option. (ftw_init): Don't check for FTW_PHYS with ifdef, since we relied on it being present. And anyway, any nftw implementation must have that. * txr.1: Documented.
-rw-r--r--ftw.c6
-rw-r--r--txr.122
2 files changed, 24 insertions, 4 deletions
diff --git a/ftw.c b/ftw.c
index 6984b7ff..43cfb9b9 100644
--- a/ftw.c
+++ b/ftw.c
@@ -43,6 +43,7 @@
#include "signal.h"
#include "unwind.h"
#include "sysif.h"
+#include "txr.h"
#include "ftw.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -111,7 +112,8 @@ val ftw_wrap(val dirpath, val fn, val flags_in, val nopenfd_in)
return ret;
} else {
int nopenfd = c_num(default_arg(nopenfd_in, num_fast(20)), self);
- int flags = c_num(default_arg(flags_in, zero), self);
+ val flags_dfl = if3(opt_compat && opt_compat <= 283, zero, num(FTW_PHYS));
+ int flags = c_num(default_arg(flags_in, flags_dfl), self);
char *dirpath_u8 = utf8_dup_to(c_str(dirpath, self));
int res = (s_callback = fn,
nftw(dirpath_u8, ftw_callback, nopenfd, flags));
@@ -144,9 +146,7 @@ void ftw_init(void)
prot1(&s_callback);
/* ftw flags */
-#ifdef FTW_PHYS
reg_varl(intern(lit("ftw-phys"), user_package), num_fast(FTW_PHYS));
-#endif
#ifdef FTW_MOUNT
reg_varl(intern(lit("ftw-mount"), user_package), num_fast(FTW_MOUNT));
#endif
diff --git a/txr.1 b/txr.1
index 69b5e903..3f585b29 100644
--- a/txr.1
+++ b/txr.1
@@ -74306,9 +74306,22 @@ and
arguments are reversed with respect to the C language interface.
They are both optional;
.meta flags
-defaults to zero, and
+defaults to the value of
+.code ftw-phys
+and
.meta nopenfd
defaults to 20.
+If an argument is given to
+.metn flags ,
+then the presence of the
+.code ftw-phys
+is no longer implied; the flag must be explicitly
+included in the argument in order to be present.
+
+Compatibility Note: the
+.meta flags
+parameter defaults to an argument value of zero in \*(TX
+versions 283 or lower.
The
.meta path-or-list
@@ -89972,6 +89985,13 @@ of these version values, the described behaviors are provided if
is given an argument which is equal or lower. For instance
.code "-C 103"
selects the behaviors described below for version 105, but not those for 102.
+.IP 283
+In \*(TX 283 and older versions, the
+.meta flags
+parameter of the
+.code ftw
+function defaults to zero, rather than
+.codn ftw-phys .
.IP 275
In \*(TX 275 and older versions, the FFI type operator
.code align