From: Stepan Kasal <kasal@ucw.cz>
To: GIT Mailing-list <git@vger.kernel.org>
Cc: Erik Faye-Lund <kusmabite@gmail.com>,
msysgit@googlegroups.com, Karsten Blees <karsten.blees@gmail.com>
Subject: [PATCH 1/2] Win32: move main macro to a function
Date: Thu, 29 May 2014 12:45:52 +0200 [thread overview]
Message-ID: <20140529104552.GB24021@camelia.ucw.cz> (raw)
In-Reply-To: <20140529104329.GA24021@camelia.ucw.cz>
From: Karsten Blees <blees@dcon.de>
Date: Fri, 7 Jan 2011 19:47:23 +0100
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>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
---
compat/mingw.c | 15 +++++++++++++++
compat/mingw.h | 14 ++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index a0e13bc..c03bafa 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1847,3 +1847,18 @@ int mingw_offset_1st_component(const char *path)
return offset + is_dir_sep(path[offset]);
}
+
+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);
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index 3eaf822..15f0c9d 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -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) \
{ \
- 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)
--
1.9.2.msysgit.0.496.g23aa553
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2014-05-29 10:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 10:43 [PATCH 0/2] mingw: macro main(), const warnings Stepan Kasal
2014-05-29 10:45 ` Stepan Kasal [this message]
2014-05-29 10:47 ` [PATCH 2/2] mingw: avoid const warning Stepan Kasal
2014-06-06 15:08 ` Karsten Blees
2014-06-06 19:13 ` Junio C Hamano
2014-06-06 21:15 ` Karsten Blees
2014-06-07 6:46 ` [PATCH v2 0/2] mingw: macro main(), const warnings Stepan Kasal
2014-06-07 6:46 ` [PATCH v2 1/2] Win32: move main macro to a function Stepan Kasal
2014-06-07 6:46 ` [PATCH v2 2/2] mingw: avoid const warning Stepan Kasal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140529104552.GB24021@camelia.ucw.cz \
--to=kasal@ucw.cz \
--cc=git@vger.kernel.org \
--cc=karsten.blees@gmail.com \
--cc=kusmabite@gmail.com \
--cc=msysgit@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).