Refactor enmasse() and recurse() to reflect depth

The HLP-changes to sbase have been a great addition of functionality,
but they kind of "polluted" the enmasse() and recurse() prototypes.
As this will come in handy in the future, knowing at which "depth"
you are inside a recursing function is an important functionality.

Instead of having a special HLP-flag passed to enmasse, each sub-
function needs to provide it on its own and can calculate results
based on the current depth (for instance, 'H' implies 'P' at
depth > 0).
A special case is recurse(), because it actually depends on the
follow-type. A new flag "recurse_follow" brings consistency into
what used to be spread across different naming conventions (fflag,
HLP_flag, ...).

This also fixes numerous bugs with the behaviour of HLP in the
tools using it.
This commit is contained in:
FRIGN
2015-03-02 21:43:56 +01:00
parent 274e86e1aa
commit 8dc92fbd6c
13 changed files with 71 additions and 59 deletions

View File

@@ -9,7 +9,7 @@
#include "../util.h"
void
enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, char), char ff)
enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, int))
{
char *buf, *dir;
int i, len;
@@ -18,7 +18,7 @@ enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, char), cha
size_t dlen;
if (argc == 2 && !(stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))) {
fnck(argv[0], argv[1], fn, ff);
fnck(argv[0], argv[1], fn, 0);
return;
} else {
dir = (argc == 1) ? "." : argv[--argc];
@@ -35,7 +35,7 @@ enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, char), cha
eprintf("%s/%s: filename too long\n", dir,
basename(argv[i]));
}
fnck(argv[i], buf, fn, ff);
fnck(argv[i], buf, fn, 0);
}
free(buf);
}