Revert "grep: remove tautological condition"

This reverts commit f6d6c66889.

Gremlins snuck into my tree and injected some WIP.
This commit is contained in:
Kyle Evans 2023-03-08 23:52:23 -06:00
parent f6d6c66889
commit c816aea7ab
4 changed files with 2 additions and 62 deletions

View file

@ -186,7 +186,8 @@ grep_open(const char *path)
if (filebehave == FILE_MMAP) {
struct stat st;
if (fstat(f->fd, &st) == -1 || !S_ISREG(st.st_mode))
if ((fstat(f->fd, &st) == -1) || (st.st_size > OFF_MAX) ||
(!S_ISREG(st.st_mode)))
filebehave = FILE_STDIO;
else {
int flags = MAP_PRIVATE | MAP_NOCORE | MAP_NOSYNC;

View file

@ -567,58 +567,3 @@ config_finish(void) {
for (i = 0; i < CONFIG_SIZE; i++)
free(c[i].value);
}
static int
config_value(const char *key)
{
const struct config_entry *cp;
for (size_t i = 0; i < nitems(c); i++) {
cp = &c[i];
if (strcmp(cp->key, key) == 0) {
switch (cp->type) {
case PKG_CONFIG_STRING: {
const char *val;
(void)config_string(i, &val);
printf("%s\n", val);
break;
}
case PKG_CONFIG_BOOL: {
bool val;
(void)config_bool(i, &val);
printf("%s\n", val ? "yes" : "no");
break;
}
}
return (0);
}
}
return (ENOENT);
}
int
config_show(int argc, char *argv[])
{
int error;
if (argc != 1) {
fprintf(stderr, "Usage: pkg -N config <name>\n");
return (1);
}
config_init(NULL);
error = config_value(argv[0]);
config_finish();
if (error == ENOENT) {
fprintf(stderr, "pkg: No such configuration options: %s\n",
argv[0]);
}
return (error);
}

View file

@ -62,7 +62,6 @@ typedef enum {
int config_init(const char *);
void config_finish(void);
int config_show(int, char *[]);
int config_string(pkg_config_key, const char **);
int config_bool(pkg_config_key, bool *);

View file

@ -1195,11 +1195,6 @@ main(int argc, char *argv[])
else if (strcmp(command, "bootstrap") == 0) {
bootstrap_only = true;
}
else if (strcmp(command, "config") == 0 &&
activation_test) {
exit(config_show(argc - optind,
argv + optind));
}
}
// bootstrap doesn't accept other arguments
else if (bootstrap_only) {