diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 11 | ||||
-rw-r--r-- | extension/filefuncs.3am | 13 | ||||
-rw-r--r-- | extension/filefuncs.c | 14 |
3 files changed, 31 insertions, 7 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog index 68043632..1abe1b1c 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -8,6 +8,10 @@ * intdiv.c (do_intdiv): Print a warning about loss of precision if MPFR arguments are received when not compiled with MPFR support. +2018-02-11 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.3am: Fix some typos. + 2018-02-08 Andrew J. Schorr <aschorr@telemetry-investments.com> * configure.ac (pkgextensiondir): This must be set to @@ -23,6 +27,13 @@ revtwoway.3am, rwarray.3am, time.3am: Add vim modeline at the bottom to set the file type for syntax coloring. +2018-02-02 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c (FTS_SKIP): New constant. + (process): Additional arg skipset. When true (based on if + FTS_SKIP was passed) and at level 0, use fts_set to set + FTS_SKIP on the directory. + 2018-01-11 Arnold D. Robbins <arnold@skeeve.com> * compile, config.guess, config.rpath, config.sub, diff --git a/extension/filefuncs.3am b/extension/filefuncs.3am index 95f8bbd4..e033f918 100644 --- a/extension/filefuncs.3am +++ b/extension/filefuncs.3am @@ -1,4 +1,4 @@ -.TH FILEFUNCS 3am "Jan 15 2013" "Free Software Foundation" "GNU Awk Extension Modules" +.TH FILEFUNCS 3am "Feb 02 2018" "Free Software Foundation" "GNU Awk Extension Modules" .SH NAME filefuncs \- provide some file related functionality to gawk .SH SYNOPSIS @@ -230,6 +230,9 @@ This option causes entries for ``..'' to also be included. .TP .B FTS_XDEV During a traversal, do not cross onto a different mounted filesystem. +.TP +.B FTS_SKIP +When set, causes top level directories to not be descended into. .RE .TP .B filedata @@ -315,12 +318,16 @@ heirarchy and its information. .PP Nothing prevents AWK code from changing the predefined .BI FTS_ xx -values, but doing so is may cause strange results when +values, but doing so may cause strange results when the changed values are passed to .BR fts() . .SH BUGS There are many more file-related functions for which AWK interfaces would be desirable. +.PP +It's not clear why I thought adding +.B FTS_SKIP +was a good idea. .SH EXAMPLE See .B test/fts.awk @@ -346,7 +353,7 @@ distribution for an example. Arnold Robbins, .BR arnold@skeeve.com . .SH COPYING PERMISSIONS -Copyright \(co 2012, 2013, +Copyright \(co 2012, 2013, 2018, Free Software Foundation, Inc. .PP Permission is granted to make and distribute verbatim copies of diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 99b5eda2..15f15473 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2001, 2004, 2005, 2010-2017 + * Copyright (C) 2001, 2004, 2005, 2010-2018 * the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the @@ -575,6 +575,7 @@ init_filefuncs(void) ENTRY(FTS_PHYSICAL), ENTRY(FTS_SEEDOT), ENTRY(FTS_XDEV), + ENTRY(FTS_SKIP), { NULL, 0 } }; @@ -690,7 +691,7 @@ fill_default_elements(awk_array_t element_array, const FTSENT *const fentry, awk /* process --- process the heirarchy */ static void -process(FTS *heirarchy, awk_array_t destarray, int seedot) +process(FTS *heirarchy, awk_array_t destarray, int seedot, int skipset) { FTSENT *fentry; awk_value_t index, value; @@ -705,7 +706,12 @@ process(FTS *heirarchy, awk_array_t destarray, int seedot) switch (fentry->fts_info) { case FTS_D: /* directory */ + + if (skipset && fentry->fts_level == 0) + fts_set(heirarchy, fentry, FTS_SKIP); + /* create array to hold entries */ + /* this will be empty if doing FTS_SKIP */ newdir_array = create_array(); if (newdir_array == NULL) { warning(ext_id, _("fts-process: could not create array")); @@ -826,7 +832,7 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func *unused) int ret = -1; static const int mask = ( FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR | FTS_PHYSICAL - | FTS_SEEDOT | FTS_XDEV); + | FTS_SEEDOT | FTS_XDEV | FTS_SKIP); assert(result != NULL); fts_errors = 0; /* ensure a fresh start */ @@ -894,7 +900,7 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func *unused) /* let's do it! */ if ((heirarchy = fts_open(pathvector, flags, NULL)) != NULL) { - process(heirarchy, dest.array_cookie, (flags & FTS_SEEDOT) != 0); + process(heirarchy, dest.array_cookie, (flags & FTS_SEEDOT) != 0, (flags & FTS_SKIP) != 0); fts_close(heirarchy); if (fts_errors == 0) |