summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bf74a88)
raw | patch | inline | side by side (parent: bf74a88)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Mon, 21 Jul 2008 19:19:57 +0000 (21:19 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 26 Jul 2008 00:41:13 +0000 (17:41 -0700) |
Since the exec-path on Windows is derived from the program invocation path,
we must ensure that argv[0] always has a path. Unfortunately, if a program
is invoked from CMD, argv[0] has no path. But on the other hand, the
C runtime offers a global variable, _pgmptr, that always has the full path
to the program. We hook into main() with a preprocessor macro, where we
replace argv[0].
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
we must ensure that argv[0] always has a path. Unfortunately, if a program
is invoked from CMD, argv[0] has no path. But on the other hand, the
C runtime offers a global variable, _pgmptr, that always has the full path
to the program. We hook into main() with a preprocessor macro, where we
replace argv[0].
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.h | patch | blob | history |
diff --git a/compat/mingw.h b/compat/mingw.h
index 8ffec51e73f49a54d82dd40f1e301e9c5479ffcf..290a9e6f822df97984b9f769508aab36419eaf02 100644 (file)
--- a/compat/mingw.h
+++ b/compat/mingw.h
char **copy_environ(void);
void free_environ(char **env);
char **env_setenv(char **env, const char *name);
+
+/*
+ * A replacement of main() that ensures that argv[0] has a path
+ */
+
+#define main(c,v) main(int argc, const char **argv) \
+{ \
+ static int mingw_main(); \
+ argv[0] = xstrdup(_pgmptr); \
+ return mingw_main(argc, argv); \
+} \
+static int mingw_main(c,v)