Commit 92324d84921721035458ba8d128dea48436525ec

Patrick Steinhardt 2018-02-16T11:28:53

util: clean up header includes While "util.h" declares the macro `git__tolower`, which simply resorts to tolower(3P) on Unix-like systems, the <ctype.h> header is only being included in "util.c". Thus, anybody who has included "util.h" without having <ctype.h> included will fail to compile as soon as the macro is in use. Furthermore, we can clean up additional includes in "util.c" and simply replace them with an include for "common.h".

diff --git a/src/util.c b/src/util.c
index b984b99..34841df 100644
--- a/src/util.c
+++ b/src/util.c
@@ -7,10 +7,7 @@
 
 #include "util.h"
 
-#include "git2.h"
-#include <stdio.h>
-#include <ctype.h>
-#include "posix.h"
+#include "common.h"
 
 #ifdef GIT_WIN32
 # include "win32/w32_buffer.h"
diff --git a/src/util.h b/src/util.h
index 63ffa13..f6d19cf 100644
--- a/src/util.h
+++ b/src/util.h
@@ -9,12 +9,16 @@
 
 #include "common.h"
 
+#ifndef GIT_WIN32
+# include <ctype.h>
+#endif
+
 #include "git2/buffer.h"
-#include "buffer.h"
-#include "thread-utils.h"
 
+#include "buffer.h"
 #include "common.h"
 #include "strnlen.h"
+#include "thread-utils.h"
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 #define bitsizeof(x) (CHAR_BIT * sizeof(x))