Remove apathmax() and implicitly agetcwd()
pathconf() is just an insane interface to use. All sane operating- systems set sane values for PATH_MAX. Due to the by-runtime-nature of pathconf(), it actually weakens the programs depending on its values. Given over 3 years it has still not been possible to implement a sane and easy to use apathmax()-utility-function, and after discussing this on IRC, we'll dump this garbage. We are careful enough not to overflow PATH_MAX and even if, any user is able to set another limit in config.mk if he so desires.
This commit is contained in:
@@ -12,9 +12,9 @@ void
|
||||
enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, int))
|
||||
{
|
||||
struct stat st;
|
||||
char *buf, *dir;
|
||||
char buf[PATH_MAX], *dir;
|
||||
int i, len;
|
||||
size_t size, dlen;
|
||||
size_t dlen;
|
||||
|
||||
if (argc == 2 && !(stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))) {
|
||||
fnck(argv[0], argv[1], fn, 0);
|
||||
@@ -23,18 +23,16 @@ enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, int))
|
||||
dir = (argc == 1) ? "." : argv[--argc];
|
||||
}
|
||||
|
||||
apathmax(&buf, &size);
|
||||
for (i = 0; i < argc; i++) {
|
||||
dlen = strlen(dir);
|
||||
if (dlen > 0 && dir[dlen - 1] == '/')
|
||||
len = snprintf(buf, size, "%s%s", dir, basename(argv[i]));
|
||||
len = snprintf(buf, sizeof(buf), "%s%s", dir, basename(argv[i]));
|
||||
else
|
||||
len = snprintf(buf, size, "%s/%s", dir, basename(argv[i]));
|
||||
if (len < 0 || len >= size) {
|
||||
len = snprintf(buf, sizeof(buf), "%s/%s", dir, basename(argv[i]));
|
||||
if (len < 0 || len >= sizeof(buf)) {
|
||||
eprintf("%s/%s: filename too long\n", dir,
|
||||
basename(argv[i]));
|
||||
}
|
||||
fnck(argv[i], buf, fn, 0);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user