Skip to content

Commit ed85652

Browse files
committed
fix for win32
1 parent b018573 commit ed85652

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/autoupdate.c

+1
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ int autoupdate(
597597
_wexeclp(L"cmd", L"cmd", L"/c", L"ping", L"127.0.0.1", L"-n", L"3", L">nul", L"&", L"del", selftmpf, NULL);
598598
// we should never reach here
599599
assert(0);
600+
return 3;
600601
}
601602

602603
#else

src/autoupdate_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ wchar_t* autoupdate_tmpf(wchar_t *tmpdir, const char *ext_name);
3838

3939
char* autoupdate_tmpdir();
4040
char* autoupdate_tmpf(char *tmpdir, const char *ext_name);
41-
int autoupdate_exepath(char* buffer, size_t* size);
4241

4342
#endif // _WIN32
4443

4544
short autoupdate_should_proceed();
45+
int autoupdate_exepath(char* buffer, size_t* size);
4646

4747
#endif /* end of include guard: AUTOUPDATE_INTERNAL_H_A40E122A */

tests/main.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* For full terms see the included LICENSE file
66
*/
77

8+
#include "autoupdate.h"
9+
#include "autoupdate_internal.h"
10+
811
#include <limits.h>
9-
#ifdef __linux__
10-
#include <linux/limits.h>
11-
#endif
1212
#include <assert.h>
1313
#include <sys/stat.h>
1414
#include <stdint.h>
@@ -17,6 +17,14 @@
1717
#include <stdlib.h>
1818
#include <string.h>
1919

20+
#ifdef _WIN32
21+
#include <Windows.h>
22+
#endif
23+
24+
#ifdef __linux__
25+
#include <linux/limits.h>
26+
#endif
27+
2028
#define EXPECT(condition) expect(condition, __FILE__, __LINE__)
2129

2230
static void expect(short condition, const char *file, int line)
@@ -40,14 +48,18 @@ int main()
4048
char* exec_path;
4149

4250
// test autoupdate_exepath
51+
#ifdef _WIN32
52+
exec_path_len = 2 * MAX_PATH;
53+
#else
4354
exec_path_len = 2 * PATH_MAX;
55+
#endif
4456
exec_path = malloc(exec_path_len);
4557
ret = autoupdate_exepath(exec_path, &exec_path_len);
4658
EXPECT(0 == ret);
4759

4860
ret = stat(exec_path, &statbuf);
4961
EXPECT(0 == ret);
50-
EXPECT(S_ISREG(statbuf.st_mode));
62+
EXPECT(S_IFREG == (S_IFMT & statbuf.st_mode));
5163

5264
return 0;
5365
}

0 commit comments

Comments
 (0)