Avoid declaration after statement
MSVC does not understand this C99 style. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	va_list args;
 | 
						va_list args;
 | 
				
			||||||
	unsigned mode;
 | 
						unsigned mode;
 | 
				
			||||||
 | 
						int fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_start(args, oflags);
 | 
						va_start(args, oflags);
 | 
				
			||||||
	mode = va_arg(args, int);
 | 
						mode = va_arg(args, int);
 | 
				
			||||||
	va_end(args);
 | 
						va_end(args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!strcmp(filename, "/dev/null"))
 | 
						if (!strcmp(filename, "/dev/null"))
 | 
				
			||||||
		filename = "nul";
 | 
							filename = "nul";
 | 
				
			||||||
	int fd = open(filename, oflags, mode);
 | 
					
 | 
				
			||||||
 | 
						fd = open(filename, oflags, mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
 | 
						if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
 | 
				
			||||||
		DWORD attrs = GetFileAttributes(filename);
 | 
							DWORD attrs = GetFileAttributes(filename);
 | 
				
			||||||
		if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
 | 
							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)
 | 
					static void free_path_split(char **path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						char **p = path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!path)
 | 
						if (!path)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char **p = path;
 | 
					 | 
				
			||||||
	while (*p)
 | 
						while (*p)
 | 
				
			||||||
		free(*p++);
 | 
							free(*p++);
 | 
				
			||||||
	free(path);
 | 
						free(path);
 | 
				
			||||||
@ -1120,9 +1125,9 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
 | 
				
			|||||||
#undef signal
 | 
					#undef signal
 | 
				
			||||||
sig_handler_t mingw_signal(int sig, sig_handler_t handler)
 | 
					sig_handler_t mingw_signal(int sig, sig_handler_t handler)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						sig_handler_t old = timer_fn;
 | 
				
			||||||
	if (sig != SIGALRM)
 | 
						if (sig != SIGALRM)
 | 
				
			||||||
		return signal(sig, handler);
 | 
							return signal(sig, handler);
 | 
				
			||||||
	sig_handler_t old = timer_fn;
 | 
					 | 
				
			||||||
	timer_fn = handler;
 | 
						timer_fn = handler;
 | 
				
			||||||
	return old;
 | 
						return old;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1209,8 +1214,9 @@ struct dirent *mingw_readdir(DIR *dir)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
 | 
						if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
							DWORD lasterr;
 | 
				
			||||||
		handle = FindFirstFileA(dir->dd_name, &buf);
 | 
							handle = FindFirstFileA(dir->dd_name, &buf);
 | 
				
			||||||
		DWORD lasterr = GetLastError();
 | 
							lasterr = GetLastError();
 | 
				
			||||||
		dir->dd_handle = (long)handle;
 | 
							dir->dd_handle = (long)handle;
 | 
				
			||||||
		if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
 | 
							if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
 | 
				
			||||||
			errno = err_win_to_posix(lasterr);
 | 
								errno = err_win_to_posix(lasterr);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								help.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								help.c
									
									
									
									
									
								
							@ -127,7 +127,7 @@ static int is_executable(const char *name)
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __MINGW32__
 | 
					#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 };
 | 
						char buf[3] = { 0 };
 | 
				
			||||||
	int n;
 | 
						int n;
 | 
				
			||||||
	int fd = open(name, O_RDONLY);
 | 
						int fd = open(name, O_RDONLY);
 | 
				
			||||||
@ -140,6 +140,7 @@ static int is_executable(const char *name)
 | 
				
			|||||||
				st.st_mode |= S_IXUSR;
 | 
									st.st_mode |= S_IXUSR;
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	return st.st_mode & S_IXUSR;
 | 
						return st.st_mode & S_IXUSR;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -134,6 +134,7 @@ fail_pipe:
 | 
				
			|||||||
		error("cannot fork() for %s: %s", cmd->argv[0],
 | 
							error("cannot fork() for %s: %s", cmd->argv[0],
 | 
				
			||||||
			strerror(failed_errno = errno));
 | 
								strerror(failed_errno = errno));
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	int s0 = -1, s1 = -1, s2 = -1;	/* backups of stdin, stdout, stderr */
 | 
						int s0 = -1, s1 = -1, s2 = -1;	/* backups of stdin, stdout, stderr */
 | 
				
			||||||
	const char **sargv = cmd->argv;
 | 
						const char **sargv = cmd->argv;
 | 
				
			||||||
	char **env = environ;
 | 
						char **env = environ;
 | 
				
			||||||
@ -197,6 +198,7 @@ fail_pipe:
 | 
				
			|||||||
		dup2(s1, 1), close(s1);
 | 
							dup2(s1, 1), close(s1);
 | 
				
			||||||
	if (s2 >= 0)
 | 
						if (s2 >= 0)
 | 
				
			||||||
		dup2(s2, 2), close(s2);
 | 
							dup2(s2, 2), close(s2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd->pid < 0) {
 | 
						if (cmd->pid < 0) {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user