Permalink
Browse files

Merge branch 'master' into word

  • Loading branch information...
2 parents 935a262 + 472658f commit 4a486c90663e26ffff574a78fd317716684932d7 @ggreer committed Aug 18, 2012
Showing with 9 additions and 5 deletions.
  1. +4 −4 src/search.c
  2. +5 −1 src/util.h
View
8 src/search.c
@@ -192,8 +192,8 @@ void search_file(const pcre *re, const pcre_extra *re_extra, const char *file_fu
}
}
-/* TODO: append matches to some data structure instead of just printing them out
- * then there can be sweet summaries of matches/files scanned/time/etc
+/* TODO: Append matches to some data structure instead of just printing them out.
+ * Then ag can have sweet summaries of matches/files scanned/time/etc.
*/
void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, const int depth) {
struct dirent **dir_list = NULL;
@@ -208,7 +208,7 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
int i;
/* find agignore/gitignore/hgignore/etc files to load ignore patterns from */
-#ifdef AG_OS_BSD
+#ifdef SCANDIR_CONST
results = scandir(path, &dir_list, &ignorefile_filter, &alphasort);
#else
results = scandir(path, &dir_list, (int (*)(const struct dirent *))&ignorefile_filter, &alphasort);
@@ -237,7 +237,7 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
free(dir_list);
dir_list = NULL;
-#ifdef AG_OS_BSD
+#ifdef SCANDIR_CONST
results = scandir(path, &dir_list, &filename_filter, &alphasort);
#else
results = scandir(path, &dir_list, (int (*)(const struct dirent *))&filename_filter, &alphasort);
View
6 src/util.h
@@ -60,8 +60,12 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream);
char * strndup (const char *s, size_t n);
#endif
+/*
+ * This is just to squelch a compiler warning.
+ * Most BSDs want the 3rd parameter to scandir() to be const. Linux doesn't.
+ */
#if defined __NetBSD__ || defined __OpenBSD__ || defined __FreeBSD__ || defined __bsdi__ || defined __DragonFly__ || defined BSD || defined _SYSTYPE_BSD || defined __APPLE__
-#define AG_OS_BSD
+#define SCANDIR_CONST
#endif
#endif

0 comments on commit 4a486c9

Please sign in to comment.