From 022ea8cfd80b97221abfbf2ba09110c0ecef3dc6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Feb 2020 23:30:57 -0800 Subject: fstat: turn into true alias. We can get rid of fstat_wrap entirely and make the lstat and fstat function bindings point to the same function. * parser.c (load_rcfile): Call stat_wrap instead of fstat_wrap. * sysif.c (stat_wrap): Static function becomes extern. Useless forward declaration removed. (fstat_wrap): Static function removed. (sysif_init): Bind fstat and lstat to the same function object. * sysif.h (fstat_wrap): Declaration removed. (stat_wrap): Declaration added. --- sysif.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'sysif.c') diff --git a/sysif.c b/sysif.c index def72149..d117729b 100644 --- a/sysif.c +++ b/sysif.c @@ -556,8 +556,6 @@ static val mkfifo_wrap(val path, val mode) enum chm_state { chm_who, chm_perm, chm_nxtop, chm_comma }; enum chm_op { chm_add, chm_sub, chm_set }; -static val stat_wrap(val path); - static val chmod_wrap(val target, val mode) { val self = lit("chmod"); @@ -1128,7 +1126,7 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *), #endif } -static val stat_wrap(val path) +val stat_wrap(val path) { return stat_impl(path, do_stat, lit("stat"), path); } @@ -1138,11 +1136,6 @@ static val lstat_wrap(val path) return stat_impl(path, do_lstat, lit("lstat"), path); } -val fstat_wrap(val stream) -{ - return stat_impl(stream, do_stat, lit("fstat"), nil); -} - #if HAVE_FILE_STAMP_CHANGE #if HAVE_FUTIMENS @@ -2372,9 +2365,12 @@ void sysif_init(void) reg_fun(intern(lit("lutimes"), user_package), func_n5(wrap_lutimes)); #endif - reg_fun(intern(lit("stat"), user_package), func_n1(stat_wrap)); + { + val fn = func_n1(stat_wrap); + reg_fun(intern(lit("stat"), user_package), fn); + reg_fun(intern(lit("fstat"), user_package), fn); + } reg_fun(intern(lit("lstat"), user_package), func_n1(lstat_wrap)); - reg_fun(intern(lit("fstat"), user_package), func_n1(fstat_wrap)); #if HAVE_SYS_STAT #ifndef S_IFSOCK -- cgit v1.2.3