mirror of
https://github.com/git/git.git
synced 2026-02-04 15:04:45 +00:00
Win32: move main macro to a function
The code in the MinGW main macro is getting more and more complex, move to a separate initialization function for readabiliy and extensibility. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
This commit is contained in:
committed by
Stepan Kasal
parent
70878a74ea
commit
0b710a0898
@@ -1823,3 +1823,18 @@ pid_t waitpid(pid_t pid, int *status, int options)
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void mingw_startup()
|
||||
{
|
||||
/* copy executable name to argv[0] */
|
||||
__argv[0] = xstrdup(_pgmptr);
|
||||
|
||||
/* initialize critical section for waitpid pinfo_t list */
|
||||
InitializeCriticalSection(&pinfo_cs);
|
||||
|
||||
/* set up default file mode and file modes for stdin/out/err */
|
||||
_fmode = _O_BINARY;
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
_setmode(_fileno(stdout), _O_BINARY);
|
||||
_setmode(_fileno(stderr), _O_BINARY);
|
||||
}
|
||||
|
||||
@@ -363,22 +363,16 @@ void free_environ(char **env);
|
||||
extern CRITICAL_SECTION pinfo_cs;
|
||||
|
||||
/*
|
||||
* A replacement of main() that ensures that argv[0] has a path
|
||||
* and that default fmode and std(in|out|err) are in binary mode
|
||||
* A replacement of main() that adds win32 specific initialization.
|
||||
*/
|
||||
|
||||
void mingw_startup();
|
||||
#define main(c,v) dummy_decl_mingw_main(); \
|
||||
static int mingw_main(c,v); \
|
||||
int main(int argc, char **argv) \
|
||||
int main(c,v) \
|
||||
{ \
|
||||
extern CRITICAL_SECTION pinfo_cs; \
|
||||
_fmode = _O_BINARY; \
|
||||
_setmode(_fileno(stdin), _O_BINARY); \
|
||||
_setmode(_fileno(stdout), _O_BINARY); \
|
||||
_setmode(_fileno(stderr), _O_BINARY); \
|
||||
argv[0] = xstrdup(_pgmptr); \
|
||||
InitializeCriticalSection(&pinfo_cs); \
|
||||
return mingw_main(argc, argv); \
|
||||
mingw_startup(); \
|
||||
return mingw_main(__argc, __argv); \
|
||||
} \
|
||||
static int mingw_main(c,v)
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
static const char http_fetch_usage[] = "git http-fetch "
|
||||
"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **av)
|
||||
{
|
||||
struct walker *walker;
|
||||
int commits_on_stdin = 0;
|
||||
int commits;
|
||||
const char **argv = (const char **)av;
|
||||
const char **write_ref = NULL;
|
||||
char **commit_id;
|
||||
char *url = NULL;
|
||||
|
||||
@@ -938,9 +938,10 @@ static void parse_push(struct strbuf *buf)
|
||||
free(specs);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **av)
|
||||
{
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
const char **argv = (const char **)av;
|
||||
int nongit;
|
||||
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
Reference in New Issue
Block a user