utils: move some MSVC compat stuff to common place
authorRan Benita <ran@unusedvar.com>
Sat, 24 Sep 2022 07:37:06 +0000 (10:37 +0300)
committerRan Benita <ran@unusedvar.com>
Sat, 24 Sep 2022 09:31:53 +0000 (12:31 +0300)
Signed-off-by: Ran Benita <ran@unusedvar.com>
src/context.c
src/utils.h
test/context.c

index 71c2275..5701a74 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
-#ifdef _MSC_VER
-# include <direct.h>
-# include <io.h>
-# ifndef S_ISDIR
-#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# endif
-#else
-# include <unistd.h>
-#endif
 
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
index 7557dab..c263635 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #if HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
 #else
 /* Required on Windows where unistd.h doesn't exist */
-#define R_OK    4               /* Test for read permission.  */
-#define W_OK    2               /* Test for write permission.  */
-#define X_OK    1               /* Test for execute permission.  */
-#define F_OK    0               /* Test for existence.  */
+# define R_OK    4               /* Test for read permission.  */
+# define W_OK    2               /* Test for write permission.  */
+# define X_OK    1               /* Test for execute permission.  */
+# define F_OK    0               /* Test for existence.  */
+#endif
+
+#ifdef _MSC_VER
+# include <direct.h>
+# include <io.h>
+# ifndef S_ISDIR
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# endif
 #endif
 
 #include "darray.h"
index f91be54..9f6cad7 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/types.h>
-#ifdef _MSC_VER
-# include <io.h>
-# include <direct.h>
-# ifndef S_ISDIR
-#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# endif
-#else
-# include <unistd.h>
-#endif
 
 /* keeps a cache of all makedir/maketmpdir directories so we can free and
  * rmdir them in one go, see unmakedirs() */