From 3fcc1b8b1b826d689ace5e3b98be10a46bf4ae56 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Nov 2022 07:53:25 -0800 Subject: 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. --- ftw.c | 6 +++--- txr.1 | 22 +++++++++++++++++++++- 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 -- cgit v1.2.3