* Re: [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89)
@ 2009-08-21 14:54 Marius Storm-Olsen
0 siblings, 0 replies; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 14:54 UTC (permalink / raw)
To: Frank Li; +Cc: Johannes.Schindelin, msysgit, git
From: Frank Li <lznuaa@gmail.com>
> size_t
> -regerror (errcode, preg, errbuf, errbuf_size)
> - int errcode;
> - const regex_t *preg;
> - char *errbuf;
> - size_t errbuf_size;
> +regerror(int errcode, const regex_t *preg,
> + char *errbuf, size_t errbuf_size)
> {
>
> The true reason is MSVC type define errcode as int.
Ok, will reword it.. Thanks.
--
.marius @ phone
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RFC/PATCH 00/14] Build git with MSVC
@ 2009-08-21 13:30 Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 01/14] Fix non-constant array creation Marius Storm-Olsen
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
So, Frank Li started this series, and I took it upon my self to help
out a bit; cleaning, reorganizing, rebasing the series. Hopefully
we're now a bit closer to including the series into mainline..
Here's a summary of what has happend:
1) This series is rebased ontop of git.git 'next', which needed an
extra patch to avoid a non-constant array creation, which
mscv doesn't like.
2) I've polished (tied to anyways) the commit messages a bit.
3) I've applied much of the feedback provided to the first round of
the patches.
4) I've split, merged and reordered some of the patches, so things
that belong together are in the same commits, and in a order of
'importance'
5) I've removed the
#define func _func
stuff, as it's not needed and Microsoft cannot really kill the
compatibility functions anyways. So, adding the define
_CRT_NONSTDC_NO_DEPRECATE
will kill the warnings seen without the defines above.
6) ..probably much more as well, but I forget..
Note: I did not sign off on the last two commits, which involve the
adding of the vcproj files, since I don't agree on adding them as is.
We need a Makefile way of compiling primarily, and second, a script
to generate the vcproj, as already discussed. But the commits are
included for completeness, at to let others compile and play with it.
I've kept the original author as is, and just signed the patches..
Thanks for watching, now bring on the comments!
Frank Li (11):
Avoid declaration after statement
Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
Change regerror() declaration from K&R style to ANSI C (C89)
mingw.c: Use the O_BINARY flag to open files
Fix __stdcall/WINAPI placement and function prototype
Test for WIN32 instead of __MINGW32_
Avoid including windows.h in winansi.c for MSVC build
Add MinGW header files to build git with MSVC
Add platform files for MSVC porting
Add MSVC project files
Add README and gitignore file for MSVC build
Marius Storm-Olsen (3):
Fix non-constant array creation
Add define guards to compat/win32.h
Add empty header files for MSVC port
builtin-apply.c | 3 +-
compat/mingw.c | 20 +-
compat/msvc.c | 35 +
compat/msvc.h | 102 +++
compat/regex/regex.c | 7 +-
compat/snprintf.c | 2 +-
compat/vcbuild/.gitignore | 3 +
compat/vcbuild/README | 13 +
compat/vcbuild/git/git.vcproj | 197 +++++
compat/vcbuild/include/arpa/inet.h | 1 +
compat/vcbuild/include/dirent.h | 128 ++++
compat/vcbuild/include/grp.h | 1 +
compat/vcbuild/include/inttypes.h | 1 +
compat/vcbuild/include/netdb.h | 1 +
compat/vcbuild/include/netinet/in.h | 1 +
compat/vcbuild/include/netinet/tcp.h | 1 +
compat/vcbuild/include/pwd.h | 1 +
compat/vcbuild/include/sys/ioctl.h | 1 +
compat/vcbuild/include/sys/param.h | 1 +
compat/vcbuild/include/sys/poll.h | 1 +
compat/vcbuild/include/sys/select.h | 1 +
compat/vcbuild/include/sys/socket.h | 1 +
compat/vcbuild/include/sys/time.h | 1 +
compat/vcbuild/include/sys/utime.h | 34 +
compat/vcbuild/include/sys/wait.h | 1 +
compat/vcbuild/include/unistd.h | 92 +++
compat/vcbuild/include/utime.h | 1 +
compat/vcbuild/libgit/libgit.vcproj | 1359 ++++++++++++++++++++++++++++++++++
compat/win32.h | 5 +
compat/winansi.c | 2 +
git-compat-util.h | 3 +
help.c | 5 +-
pager.c | 4 +-
run-command.c | 12 +-
run-command.h | 2 +-
setup.c | 2 +-
36 files changed, 2020 insertions(+), 25 deletions(-)
create mode 100644 compat/msvc.c
create mode 100644 compat/msvc.h
create mode 100644 compat/vcbuild/.gitignore
create mode 100644 compat/vcbuild/README
create mode 100644 compat/vcbuild/git/git.vcproj
create mode 100644 compat/vcbuild/include/arpa/inet.h
create mode 100644 compat/vcbuild/include/dirent.h
create mode 100644 compat/vcbuild/include/grp.h
create mode 100644 compat/vcbuild/include/inttypes.h
create mode 100644 compat/vcbuild/include/netdb.h
create mode 100644 compat/vcbuild/include/netinet/in.h
create mode 100644 compat/vcbuild/include/netinet/tcp.h
create mode 100644 compat/vcbuild/include/pwd.h
create mode 100644 compat/vcbuild/include/sys/ioctl.h
create mode 100644 compat/vcbuild/include/sys/param.h
create mode 100644 compat/vcbuild/include/sys/poll.h
create mode 100644 compat/vcbuild/include/sys/select.h
create mode 100644 compat/vcbuild/include/sys/socket.h
create mode 100644 compat/vcbuild/include/sys/time.h
create mode 100644 compat/vcbuild/include/sys/utime.h
create mode 100644 compat/vcbuild/include/sys/wait.h
create mode 100644 compat/vcbuild/include/unistd.h
create mode 100644 compat/vcbuild/include/utime.h
create mode 100644 compat/vcbuild/libgit/libgit.vcproj
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 01/14] Fix non-constant array creation
2009-08-21 13:30 [RFC/PATCH 00/14] Build git with MSVC Marius Storm-Olsen
@ 2009-08-21 13:30 ` Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 02/14] Avoid declaration after statement Marius Storm-Olsen
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
MSVC doesn't munge the non-constant expression, so use xmalloc instead.
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
builtin-apply.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index ae11b41..0f19965 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img,
size_t imgoff = 0;
size_t preoff = 0;
size_t postlen = postimage->len;
- size_t imglen[preimage->nr];
+ size_t *imglen = xmalloc(sizeof(size_t) * preimage->nr);
for (i = 0; i < preimage->nr; i++) {
size_t prelen = preimage->line[i].len;
@@ -1901,6 +1901,7 @@ static int match_fragment(struct image *img,
memcpy(fixed_buf, img->buf + try, imgoff);
for (i = 0; i < preimage->nr; i++)
preimage->line[i].len = imglen[i];
+ free(imglen);
/*
* Update the preimage buffer and the postimage context lines.
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 02/14] Avoid declaration after statement
2009-08-21 13:30 ` [PATCH 01/14] Fix non-constant array creation Marius Storm-Olsen
@ 2009-08-21 13:30 ` Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Marius Storm-Olsen
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
From: Frank Li <lznuaa@gmail.com>
Microsoft Visual C++ does not understand this C99 style
Signed-off-by: Frank Li <lznuaa@gmail.com>
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
compat/mingw.c | 14 ++++++++++----
help.c | 3 ++-
run-command.c | 2 ++
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index bed4178..e4e0e60 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...)
{
va_list args;
unsigned mode;
+ int fd;
+
va_start(args, oflags);
mode = va_arg(args, int);
va_end(args);
if (!strcmp(filename, "/dev/null"))
filename = "nul";
- int fd = open(filename, oflags, mode);
+
+ fd = open(filename, oflags, mode);
+
if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
DWORD attrs = GetFileAttributes(filename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
@@ -580,10 +584,11 @@ static char **get_path_split(void)
static void free_path_split(char **path)
{
+ char **p = path;
+
if (!path)
return;
- char **p = path;
while (*p)
free(*p++);
free(path);
@@ -1108,9 +1113,9 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
#undef signal
sig_handler_t mingw_signal(int sig, sig_handler_t handler)
{
+ sig_handler_t old = timer_fn;
if (sig != SIGALRM)
return signal(sig, handler);
- sig_handler_t old = timer_fn;
timer_fn = handler;
return old;
}
@@ -1197,8 +1202,9 @@ struct dirent *mingw_readdir(DIR *dir)
if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
{
+ DWORD lasterr;
handle = FindFirstFileA(dir->dd_name, &buf);
- DWORD lasterr = GetLastError();
+ lasterr = GetLastError();
dir->dd_handle = (long)handle;
if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
errno = err_win_to_posix(lasterr);
diff --git a/help.c b/help.c
index 294337e..fd51b8e 100644
--- a/help.c
+++ b/help.c
@@ -127,7 +127,7 @@ static int is_executable(const char *name)
return 0;
#ifdef __MINGW32__
- /* cannot trust the executable bit, peek into the file instead */
+{ /* cannot trust the executable bit, peek into the file instead */
char buf[3] = { 0 };
int n;
int fd = open(name, O_RDONLY);
@@ -140,6 +140,7 @@ static int is_executable(const char *name)
st.st_mode |= S_IXUSR;
close(fd);
}
+}
#endif
return st.st_mode & S_IXUSR;
}
diff --git a/run-command.c b/run-command.c
index f3e7abb..efac7ad 100644
--- a/run-command.c
+++ b/run-command.c
@@ -134,6 +134,7 @@ fail_pipe:
error("cannot fork() for %s: %s", cmd->argv[0],
strerror(failed_errno = errno));
#else
+{
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
const char **sargv = cmd->argv;
char **env = environ;
@@ -200,6 +201,7 @@ fail_pipe:
dup2(s1, 1), close(s1);
if (s2 >= 0)
dup2(s2, 2), close(s2);
+}
#endif
if (cmd->pid < 0) {
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
2009-08-21 13:30 ` [PATCH 02/14] Avoid declaration after statement Marius Storm-Olsen
@ 2009-08-21 13:30 ` Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 04/14] Add define guards to compat/win32.h Marius Storm-Olsen
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
From: Frank Li <lznuaa@gmail.com>
The Microsoft C runtime's vsnprintf function does not add NUL at
the end of the buffer.
Signed-off-by: Frank Li <lznuaa@gmail.com>
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
compat/snprintf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/compat/snprintf.c b/compat/snprintf.c
index 6c0fb05..37b1edf 100644
--- a/compat/snprintf.c
+++ b/compat/snprintf.c
@@ -6,7 +6,7 @@
* number of characters to write without the trailing NUL.
*/
#ifndef SNPRINTF_SIZE_CORR
-#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4
+#if (defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4) || defined(_MSC_VER)
#define SNPRINTF_SIZE_CORR 1
#else
#define SNPRINTF_SIZE_CORR 0
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 04/14] Add define guards to compat/win32.h
2009-08-21 13:30 ` [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Marius Storm-Olsen
@ 2009-08-21 13:30 ` Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
compat/win32.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/compat/win32.h b/compat/win32.h
index c26384e..e8c178d 100644
--- a/compat/win32.h
+++ b/compat/win32.h
@@ -1,3 +1,6 @@
+#ifndef WIN32_H
+#define WIN32_H
+
/* common Win32 functions for MinGW and Cygwin */
#include <windows.h>
@@ -32,3 +35,5 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd
return ENOENT;
}
}
+
+#endif
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89)
2009-08-21 13:30 ` [PATCH 04/14] Add define guards to compat/win32.h Marius Storm-Olsen
@ 2009-08-21 13:30 ` Marius Storm-Olsen
2009-08-21 14:37 ` Frank Li
0 siblings, 1 reply; 3+ messages in thread
From: Marius Storm-Olsen @ 2009-08-21 13:30 UTC (permalink / raw)
To: Johannes.Schindelin; +Cc: msysgit, git, lznuaa, Marius Storm-Olsen
From: Frank Li <lznuaa@gmail.com>
The MSVC compiler doesn't like K&R style.
Signed-off-by: Frank Li <lznuaa@gmail.com>
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
compat/regex/regex.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index 5ea0075..67d5c37 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -4852,11 +4852,8 @@ regexec (preg, string, nmatch, pmatch, eflags)
from either regcomp or regexec. We don't use PREG here. */
size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
+regerror(int errcode, const regex_t *preg,
+ char *errbuf, size_t errbuf_size)
{
const char *msg;
size_t msg_size;
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-21 14:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-21 14:54 [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
-- strict thread matches above, loose matches on Subject: below --
2009-08-21 13:30 [RFC/PATCH 00/14] Build git with MSVC Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 01/14] Fix non-constant array creation Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 02/14] Avoid declaration after statement Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 04/14] Add define guards to compat/win32.h Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
2009-08-21 14:37 ` Frank Li
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).