Browse Source

Several mingw/msvc/cross-compilation fixes

They boil down to:
 - MS_WINDOWS is dead and replaced with _WIN32, but we let a few
   instances creep in when we merged Esteban's tests.
 - Capitalizing windows header names confuses mingw.
 - #ifdef 0 ain't C.
 - One unit test wasn't compiled on windows, but was being listed
   anyway.
 - One unit test was checking for the wrong value.

Gisle Vanem found and fixed the latter 3 issues.
Nick Mathewson 13 years ago
parent
commit
9dddfe83f3
3 changed files with 12 additions and 7 deletions
  1. 5 0
      changes/mingw-fixes
  2. 1 1
      src/common/util.c
  3. 6 6
      src/test/test_util.c

+ 5 - 0
changes/mingw-fixes

@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - Fix cross-compilation isssues with mingw. Bugfixes on
+      0.2.3.6-alpha and 0.2.3.12-alpha.
+    - Fix compilation with MSVC, which had defined MS_WINDOWS.  Bugfix
+      on 0.2.3.13-alpha; found and fixed by Gisle Vanem.

+ 1 - 1
src/common/util.c

@@ -31,7 +31,7 @@
 #include <direct.h>
 #include <direct.h>
 #include <process.h>
 #include <process.h>
 #include <tchar.h>
 #include <tchar.h>
-#include <Winbase.h>
+#include <winbase.h>
 #else
 #else
 #include <dirent.h>
 #include <dirent.h>
 #include <pwd.h>
 #include <pwd.h>

+ 6 - 6
src/test/test_util.c

@@ -540,7 +540,7 @@ test_util_config_line_escaped_content(void)
   tor_free(v);
   tor_free(v);
 }
 }
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 static void
 static void
 test_util_expand_filename(void)
 test_util_expand_filename(void)
 {
 {
@@ -1525,21 +1525,19 @@ test_util_path_is_relative(void)
   test_eq(0, path_is_relative("/dir/"));
   test_eq(0, path_is_relative("/dir/"));
 
 
   /* Windows */
   /* Windows */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* I don't have Windows so I can't test this, hence the "#ifdef
   /* I don't have Windows so I can't test this, hence the "#ifdef
      0". These are tests that look useful, so please try to get them
      0". These are tests that look useful, so please try to get them
      running and uncomment if it all works as it should */
      running and uncomment if it all works as it should */
-#ifdef 0
   test_eq(1, path_is_relative("dir"));
   test_eq(1, path_is_relative("dir"));
   test_eq(1, path_is_relative("dir\\"));
   test_eq(1, path_is_relative("dir\\"));
   test_eq(1, path_is_relative("dir\\a:"));
   test_eq(1, path_is_relative("dir\\a:"));
   test_eq(1, path_is_relative("dir\\a:\\"));
   test_eq(1, path_is_relative("dir\\a:\\"));
+  test_eq(1, path_is_relative("http:\\dir"));
 
 
   test_eq(0, path_is_relative("\\dir"));
   test_eq(0, path_is_relative("\\dir"));
   test_eq(0, path_is_relative("a:\\dir"));
   test_eq(0, path_is_relative("a:\\dir"));
   test_eq(0, path_is_relative("z:\\dir"));
   test_eq(0, path_is_relative("z:\\dir"));
-  test_eq(0, path_is_relative("http:\\dir"));
-#endif
 #endif
 #endif
 
 
  done:
  done:
@@ -1926,7 +1924,7 @@ test_util_listdir(void *ptr)
   test_eq(0, write_str_to_file(fname1, "X\n", 0));
   test_eq(0, write_str_to_file(fname1, "X\n", 0));
   test_eq(0, write_str_to_file(fname2, "Y\n", 0));
   test_eq(0, write_str_to_file(fname2, "Y\n", 0));
   test_eq(0, write_str_to_file(fname3, "Z\n", 0));
   test_eq(0, write_str_to_file(fname3, "Z\n", 0));
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   r = mkdir(dir1);
   r = mkdir(dir1);
 #else
 #else
   r = mkdir(dir1, 0700);
   r = mkdir(dir1, 0700);
@@ -2887,7 +2885,9 @@ struct testcase_t util_tests[] = {
   UTIL_LEGACY(config_line_quotes),
   UTIL_LEGACY(config_line_quotes),
   UTIL_LEGACY(config_line_comment_character),
   UTIL_LEGACY(config_line_comment_character),
   UTIL_LEGACY(config_line_escaped_content),
   UTIL_LEGACY(config_line_escaped_content),
+#ifndef _WIN32
   UTIL_LEGACY(expand_filename),
   UTIL_LEGACY(expand_filename),
+#endif
   UTIL_LEGACY(strmisc),
   UTIL_LEGACY(strmisc),
   UTIL_LEGACY(pow2),
   UTIL_LEGACY(pow2),
   UTIL_LEGACY(gzip),
   UTIL_LEGACY(gzip),