aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-22 13:07:10 +0100
committerMattias Andrée <m@maandree.se>2026-02-22 13:07:10 +0100
commite577f9bf50664f21c7fbbb77f894602348202282 (patch)
treed7e348e273e32f0a5dfedf4b5108c124a88580e5
parentUpdate e-mail (diff)
downloadbfind-3.0.2.tar.gz
bfind-3.0.2.tar.bz2
bfind-3.0.2.tar.xz
misc fixesHEAD3.0.2master
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--README10
-rw-r--r--bfind.112
-rw-r--r--bfind.c42
-rw-r--r--config.mk4
4 files changed, 35 insertions, 33 deletions
diff --git a/README b/README
index 759089a..7a4c7ea 100644
--- a/README
+++ b/README
@@ -6,16 +6,16 @@ SYNOPSIS
DESCRIPTION
bfind is a minimalistic alternative to find(1) that is
- designed to be efficient that locating files. To
+ designed to be efficient at locating files. To
accomplish this, bfind uses breadth-first crawling
instead of depth-first crawling.
- bfind is only includes the bare minimum, a few options
- for restricting the crawlspace and an option to output
+ bfind includes only the bare minimum: a few options
+ for restricting the crawl space and an option to output
visited files in a safe format rather than a human-friendly
format. bfind will never include all features of find(1)
- because they are excessive and some other than makes not
- since to have in the program and can be outright dangerous.
+ because they are excessive, and some of them do not make
+ sense to have in the program and can be outright dangerous.
OPTIONS
-0
diff --git a/bfind.1 b/bfind.1
index 3aa03f8..89af5e4 100644
--- a/bfind.1
+++ b/bfind.1
@@ -1,6 +1,6 @@
.TH BFIND 1 bfind
.SH NAME
-bfind - minimalitic find using breadth-first crawling
+bfind - minimalistic find using breadth-first crawling
.SH SYNOPSIS
.BR bfind
@@ -11,21 +11,21 @@ bfind - minimalitic find using breadth-first crawling
.BR bfind
is a minimalistic alternative to
.BR find (1)
-that is designed to be efficient that locating files.
+that is designed to be efficient at locating files.
To accomplish this,
.BR bfind
uses breadth-first crawling instead of depth-first crawling.
.PP
.BR bfind
-is only includes the bare minimum, a few options for
-restricting the crawlspace and an option to output
+includes only the bare minimum: a few options for
+restricting the crawl space and an option to output
visited files in a safe format rather than a human-friendly
format.
.BR bfind
will never include all features of
.BR find (1)
-because they are excessive and some other than makes
-not since to have in the program and can be outright
+because they are excessive, and some of them do not make
+sense to have in the program and can be outright
dangerous.
.SH OPTIONS
diff --git a/bfind.c b/bfind.c
index 7ca2001..60ae7c1 100644
--- a/bfind.c
+++ b/bfind.c
@@ -219,6 +219,7 @@ main(int argc, char *argv[])
struct stat st;
dev_t start_dev = 0; /* compiler incorrectly thinks its may be uninitialised if not assigned */
size_t i;
+ void *new;
ARGBEGIN {
case '0':
@@ -260,7 +261,7 @@ main(int argc, char *argv[])
else
enqueue_dir(NULL);
- while ((path = dequeue())) {
+ for (; (path = dequeue()); free(path)) {
printf("%s%c", path, ending);
if (stat(path, &st)) {
if (errno != ENOENT && errno != ELOOP) {
@@ -269,28 +270,29 @@ main(int argc, char *argv[])
}
continue;
}
- if (S_ISDIR(st.st_mode)) {
- if (!xdev && st.st_dev != start_dev)
- continue;
- if (hardlinks) {
- for (i = 0; i < ndevices; i++)
- if (devices[i].dev == st.st_dev)
- break;
- if (i == ndevices) {
- devices = realloc(devices, (ndevices + 1) * sizeof(*devices));
- if (!devices) {
- fprintf(stderr, "%s: realloc: %s\n", argv0, strerror(errno));
- status = 1;
- }
- memset(&devices[ndevices], 0, sizeof(*devices));
- devices[ndevices++].dev = st.st_dev;
- }
- if (visit_inode(&devices[i], st.st_ino))
+ if (!S_ISDIR(st.st_mode))
+ continue;
+ if (!xdev && st.st_dev != start_dev)
+ continue;
+ if (hardlinks) {
+ for (i = 0; i < ndevices; i++)
+ if (devices[i].dev == st.st_dev)
+ break;
+ if (i == ndevices) {
+ new = realloc(devices, (ndevices + 1) * sizeof(*devices));
+ if (!new) {
+ fprintf(stderr, "%s: realloc: %s\n", argv0, strerror(errno));
+ status = 1;
continue;
+ }
+ devices = new;
+ memset(&devices[ndevices], 0, sizeof(*devices));
+ devices[ndevices++].dev = st.st_dev;
}
- enqueue_dir(path);
+ if (visit_inode(&devices[i], st.st_ino))
+ continue;
}
- free(path);
+ enqueue_dir(path);
}
if (fflush(stdout) || ferror(stdout) || fclose(stdout)) {
diff --git a/config.mk b/config.mk
index 2176f52..956f807 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,8 @@
PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
-CC = cc
+CC = c99
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
-CFLAGS = -std=c99 -Wall -O2
+CFLAGS = -O2
LDFLAGS =