From 8ce60a877d2c989e394eb4bc525e3847256ae36d Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Mon, 13 Aug 2018 10:34:32 +0200 Subject: [PATCH] Polishing and optimizing includes which resolves #290. --- src/hashset.c | 1 - src/hstr.c | 29 ----------------------------- src/hstr_blacklist.c | 5 ----- src/hstr_favorites.c | 5 ----- src/hstr_history.c | 5 ----- src/hstr_regexp.c | 2 -- src/hstr_utils.c | 2 -- src/include/hashset.h | 5 +---- src/include/hstr.h | 18 ++++++++++++++++++ src/include/hstr_blacklist.h | 2 -- src/include/hstr_favorites.h | 2 -- src/include/hstr_history.h | 12 ++++-------- src/include/hstr_regexp.h | 2 -- src/include/hstr_utils.h | 1 + src/include/radixsort.h | 5 +---- 15 files changed, 25 insertions(+), 71 deletions(-) diff --git a/src/hashset.c b/src/hashset.c index da60eec..ae86018 100644 --- a/src/hashset.c +++ b/src/hashset.c @@ -17,7 +17,6 @@ */ #include "include/hashset.h" -#include "include/hstr_utils.h" unsigned int hashmap_hash(const char *str) { diff --git a/src/hstr.c b/src/hstr.c index c2c4a7e..b7d0cea 100644 --- a/src/hstr.c +++ b/src/hstr.c @@ -18,35 +18,6 @@ #define _GNU_SOURCE -#include -#include -#ifdef __APPLE__ -#include -#elif defined(__FreeBSD__) -#include -#else -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/hashset.h" -#include "include/hstr_curses.h" -#include "include/hstr_blacklist.h" -#include "include/hstr_favorites.h" -#include "include/hstr_history.h" -#include "include/hstr_regexp.h" -#include "include/hstr_utils.h" - #include "include/hstr.h" #define SELECTION_CURSOR_IN_PROMPT -1 diff --git a/src/hstr_blacklist.c b/src/hstr_blacklist.c index ea6efec..f167adb 100644 --- a/src/hstr_blacklist.c +++ b/src/hstr_blacklist.c @@ -16,12 +16,7 @@ limitations under the License. */ -#include -#include -#include - #include "include/hstr_blacklist.h" -#include "include/hstr_utils.h" static const char *defaultCommandBlacklist[] = { "ls", "pwd", "cd", "cd ..", "hh", "mc", diff --git a/src/hstr_favorites.c b/src/hstr_favorites.c index b93f3ed..159eff2 100644 --- a/src/hstr_favorites.c +++ b/src/hstr_favorites.c @@ -16,12 +16,7 @@ limitations under the License. */ -#include -#include -#include - #include "include/hstr_favorites.h" -#include "include/hstr_utils.h" #define FAVORITE_SEGMENT_SIZE 10 diff --git a/src/hstr_history.c b/src/hstr_history.c index cb16fda..384e298 100644 --- a/src/hstr_history.c +++ b/src/hstr_history.c @@ -16,12 +16,7 @@ limitations under the License. */ -#include -#include -#include -#include #include "include/hstr_history.h" -#include "include/hstr_regexp.h" #define NDEBUG #include diff --git a/src/hstr_regexp.c b/src/hstr_regexp.c index df56f9e..308053e 100644 --- a/src/hstr_regexp.c +++ b/src/hstr_regexp.c @@ -18,8 +18,6 @@ #include "include/hstr_regexp.h" -#include "include/hstr_utils.h" - #define REGEXP_MATCH_BUFFER_SIZE 1 void hstr_regexp_init(HstrRegexp *hstrRegexp) diff --git a/src/hstr_utils.c b/src/hstr_utils.c index 9c50f90..9185260 100644 --- a/src/hstr_utils.c +++ b/src/hstr_utils.c @@ -18,8 +18,6 @@ #include "include/hstr_utils.h" -#include - #define DEFAULT_COMMAND "pwd" #define PROC_HOSTNAME "/proc/sys/kernel/hostname" // TODO PID_BUFFER 20+ characters might be enough diff --git a/src/include/hashset.h b/src/include/hashset.h index a4ad621..a5f744d 100644 --- a/src/include/hashset.h +++ b/src/include/hashset.h @@ -19,10 +19,7 @@ #ifndef _HASHSET_H_ #define _HASHSET_H_ -#include -#include -#include -#include +#include "hstr_utils.h" #define HASH_MAP_SIZE 10007 diff --git a/src/include/hstr.h b/src/include/hstr.h index 174120f..8c8b4ee 100644 --- a/src/include/hstr.h +++ b/src/include/hstr.h @@ -19,6 +19,24 @@ #ifndef HSTR_H_ #define HSTR_H_ +#include +#include +#ifdef __APPLE__ + #include +#elif defined(__FreeBSD__) + #include +#else + #include +#endif +#include +#include +#include +#include + +#include "hstr_curses.h" +#include "hstr_blacklist.h" +#include "hstr_history.h" + int hstr_main(int argc, char* argv[]); #endif diff --git a/src/include/hstr_blacklist.h b/src/include/hstr_blacklist.h index 9e078e0..692c9eb 100644 --- a/src/include/hstr_blacklist.h +++ b/src/include/hstr_blacklist.h @@ -19,8 +19,6 @@ #ifndef HSTR_BLACKLIST_H_ #define HSTR_BLACKLIST_H_ -#include -#include #include "hashset.h" #define ENV_VAR_USER "USER" diff --git a/src/include/hstr_favorites.h b/src/include/hstr_favorites.h index 5c9e8f6..025780c 100644 --- a/src/include/hstr_favorites.h +++ b/src/include/hstr_favorites.h @@ -19,8 +19,6 @@ #ifndef _HSTR_FAVORITES_H_ #define _HSTR_FAVORITES_H_ -#include -#include #include "hashset.h" #define ENV_VAR_USER "USER" diff --git a/src/include/hstr_history.h b/src/include/hstr_history.h index d960efd..5874473 100644 --- a/src/include/hstr_history.h +++ b/src/include/hstr_history.h @@ -19,17 +19,13 @@ #ifndef _HSTR_HISTORY_H_ #define _HSTR_HISTORY_H_ -#include -#include #include -#include -#include -#include +#include +#include -#include "hstr_favorites.h" -#include "hstr_utils.h" -#include "hashset.h" +#include "hstr_regexp.h" #include "radixsort.h" +#include "hstr_favorites.h" #define ENV_VAR_HISTFILE "HISTFILE" diff --git a/src/include/hstr_regexp.h b/src/include/hstr_regexp.h index 46ffa8c..0a2f761 100644 --- a/src/include/hstr_regexp.h +++ b/src/include/hstr_regexp.h @@ -20,8 +20,6 @@ #define _HSTR_REGEXP_H #include -#include -#include #include "hashset.h" diff --git a/src/include/hstr_utils.h b/src/include/hstr_utils.h index b5b637b..93dafe7 100644 --- a/src/include/hstr_utils.h +++ b/src/include/hstr_utils.h @@ -19,6 +19,7 @@ #ifndef _HSTR_UTILS_H #define _HSTR_UTILS_H +#include #include #include #include diff --git a/src/include/radixsort.h b/src/include/radixsort.h index 6181655..8e417c4 100644 --- a/src/include/radixsort.h +++ b/src/include/radixsort.h @@ -19,12 +19,9 @@ #ifndef RADIXSORT_H_ #define RADIXSORT_H_ -#include -#include -#include #include -#include #include + #include "hstr_utils.h" #define RADIX_SLOT_SIZE 1000