}
+char *delete_chars(char *s, const char *bad) {
+ char *f, *t;
+
+ /* Drops all whitespace, regardless where in the string */
+
+ for (f = s, t = s; *f; f++) {
+ if (strchr(bad, *f))
+ continue;
+
+ *(t++) = *f;
+ }
+
+ *t = 0;
+
+ return s;
+}
+
char *file_in_same_dir(const char *path, const char *filename) {
char *e, *r;
size_t k;
return -errno;
while ((de = readdir(d))) {
- int fd;
+ int fd = -1;
if (de->d_name[0] == '.')
continue;
continue;
}
- if ((r = close_nointr(fd)) < 0)
- goto finish;
+ if ((r = close_nointr(fd)) < 0) {
+ /* Valgrind has its own FD and doesn't want to have it closed */
+ if (errno != EBADF)
+ goto finish;
+ }
}
+ r = 0;
+
finish:
closedir(d);
return r;