mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-28 15:57:48 +00:00
* w32/*: Remove TABs from the source code.
I know whitespace commits are annoying, but having these TABs is causing me to miss things when I search through the code. This doesn't try to change the w32 code to meet GNU coding standards.
This commit is contained in:
parent
889303cdfe
commit
a4937bc897
8 changed files with 1166 additions and 1166 deletions
|
@ -27,180 +27,180 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
|
|||
DIR*
|
||||
opendir(const char* pDirName)
|
||||
{
|
||||
struct stat sb;
|
||||
DIR* pDir;
|
||||
char* pEndDirName;
|
||||
int nBufferLen;
|
||||
struct stat sb;
|
||||
DIR* pDir;
|
||||
char* pEndDirName;
|
||||
int nBufferLen;
|
||||
|
||||
/* sanity checks */
|
||||
if (!pDirName) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (stat(pDirName, &sb) != 0) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if ((sb.st_mode & S_IFMT) != S_IFDIR) {
|
||||
errno = ENOTDIR;
|
||||
return NULL;
|
||||
}
|
||||
/* sanity checks */
|
||||
if (!pDirName) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (stat(pDirName, &sb) != 0) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if ((sb.st_mode & S_IFMT) != S_IFDIR) {
|
||||
errno = ENOTDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* allocate a DIR structure to return */
|
||||
pDir = (DIR *) malloc(sizeof (DIR));
|
||||
/* allocate a DIR structure to return */
|
||||
pDir = (DIR *) malloc(sizeof (DIR));
|
||||
|
||||
if (!pDir)
|
||||
return NULL;
|
||||
if (!pDir)
|
||||
return NULL;
|
||||
|
||||
/* input directory name length */
|
||||
nBufferLen = strlen(pDirName);
|
||||
/* input directory name length */
|
||||
nBufferLen = strlen(pDirName);
|
||||
|
||||
/* copy input directory name to DIR buffer */
|
||||
strcpy(pDir->dir_pDirectoryName, pDirName);
|
||||
/* copy input directory name to DIR buffer */
|
||||
strcpy(pDir->dir_pDirectoryName, pDirName);
|
||||
|
||||
/* point to end of the copied directory name */
|
||||
pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
|
||||
/* point to end of the copied directory name */
|
||||
pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
|
||||
|
||||
/* if directory name did not end in '/' or '\', add '/' */
|
||||
if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
|
||||
pEndDirName++;
|
||||
*pEndDirName = '/';
|
||||
}
|
||||
/* if directory name did not end in '/' or '\', add '/' */
|
||||
if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
|
||||
pEndDirName++;
|
||||
*pEndDirName = '/';
|
||||
}
|
||||
|
||||
/* now append the wildcard character to the buffer */
|
||||
pEndDirName++;
|
||||
*pEndDirName = '*';
|
||||
pEndDirName++;
|
||||
*pEndDirName = '\0';
|
||||
/* now append the wildcard character to the buffer */
|
||||
pEndDirName++;
|
||||
*pEndDirName = '*';
|
||||
pEndDirName++;
|
||||
*pEndDirName = '\0';
|
||||
|
||||
/* other values defaulted */
|
||||
pDir->dir_nNumFiles = 0;
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_ulCookie = __DIRENT_COOKIE;
|
||||
/* other values defaulted */
|
||||
pDir->dir_nNumFiles = 0;
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_ulCookie = __DIRENT_COOKIE;
|
||||
|
||||
return pDir;
|
||||
return pDir;
|
||||
}
|
||||
|
||||
void
|
||||
closedir(DIR *pDir)
|
||||
{
|
||||
/* got a valid pointer? */
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
/* got a valid pointer? */
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
FindClose(pDir->dir_hDirHandle);
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
FindClose(pDir->dir_hDirHandle);
|
||||
|
||||
free(pDir);
|
||||
free(pDir);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
readdir(DIR* pDir)
|
||||
{
|
||||
WIN32_FIND_DATA wfdFindData;
|
||||
WIN32_FIND_DATA wfdFindData;
|
||||
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pDir->dir_nNumFiles == 0) {
|
||||
pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
|
||||
if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
} else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
|
||||
return NULL;
|
||||
if (pDir->dir_nNumFiles == 0) {
|
||||
pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
|
||||
if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
} else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
|
||||
return NULL;
|
||||
|
||||
/* bump count for next call to readdir() or telldir() */
|
||||
pDir->dir_nNumFiles++;
|
||||
/* bump count for next call to readdir() or telldir() */
|
||||
pDir->dir_nNumFiles++;
|
||||
|
||||
/* fill in struct dirent values */
|
||||
pDir->dir_sdReturn.d_ino = (ino_t)-1;
|
||||
strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
|
||||
/* fill in struct dirent values */
|
||||
pDir->dir_sdReturn.d_ino = (ino_t)-1;
|
||||
strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
|
||||
|
||||
return &pDir->dir_sdReturn;
|
||||
return &pDir->dir_sdReturn;
|
||||
}
|
||||
|
||||
void
|
||||
rewinddir(DIR* pDir)
|
||||
{
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
if (!FindClose(pDir->dir_hDirHandle))
|
||||
errno = EBADF;
|
||||
/* close the WINDOWS32 directory handle */
|
||||
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
|
||||
if (!FindClose(pDir->dir_hDirHandle))
|
||||
errno = EBADF;
|
||||
|
||||
/* reset members which control readdir() */
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_nNumFiles = 0;
|
||||
/* reset members which control readdir() */
|
||||
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
|
||||
pDir->dir_nNumFiles = 0;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
telldir(DIR* pDir)
|
||||
{
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!pDir) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* return number of times readdir() called */
|
||||
return pDir->dir_nNumFiles;
|
||||
/* return number of times readdir() called */
|
||||
return pDir->dir_nNumFiles;
|
||||
}
|
||||
|
||||
void
|
||||
seekdir(DIR* pDir, long nPosition)
|
||||
{
|
||||
if (!pDir)
|
||||
return;
|
||||
if (!pDir)
|
||||
return;
|
||||
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE)
|
||||
return;
|
||||
/* sanity check that this is a DIR pointer */
|
||||
if (pDir->dir_ulCookie != __DIRENT_COOKIE)
|
||||
return;
|
||||
|
||||
/* go back to beginning of directory */
|
||||
rewinddir(pDir);
|
||||
/* go back to beginning of directory */
|
||||
rewinddir(pDir);
|
||||
|
||||
/* loop until we have found position we care about */
|
||||
for (--nPosition; nPosition && readdir(pDir); nPosition--);
|
||||
/* loop until we have found position we care about */
|
||||
for (--nPosition; nPosition && readdir(pDir); nPosition--);
|
||||
|
||||
/* flag invalid nPosition value */
|
||||
if (nPosition)
|
||||
errno = EINVAL;
|
||||
/* flag invalid nPosition value */
|
||||
if (nPosition)
|
||||
errno = EINVAL;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,16 +36,16 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
struct dirent
|
||||
{
|
||||
ino_t d_ino; /* unused - no equivalent on WINDOWS32 */
|
||||
ino_t d_ino; /* unused - no equivalent on WINDOWS32 */
|
||||
char d_name[NAME_MAX+1];
|
||||
};
|
||||
|
||||
typedef struct dir_struct {
|
||||
ULONG dir_ulCookie;
|
||||
HANDLE dir_hDirHandle;
|
||||
DWORD dir_nNumFiles;
|
||||
char dir_pDirectoryName[NAME_MAX+1];
|
||||
struct dirent dir_sdReturn;
|
||||
ULONG dir_ulCookie;
|
||||
HANDLE dir_hDirHandle;
|
||||
DWORD dir_nNumFiles;
|
||||
char dir_pDirectoryName[NAME_MAX+1];
|
||||
struct dirent dir_sdReturn;
|
||||
} DIR;
|
||||
|
||||
DIR *opendir(const char *);
|
||||
|
|
|
@ -32,17 +32,17 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
EXTERN_DECL(HANDLE process_init, (VOID_DECL));
|
||||
EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth,
|
||||
HANDLE stderrh));
|
||||
HANDLE stderrh));
|
||||
EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp,
|
||||
char *exec_path, char *as_user));
|
||||
char *exec_path, char *as_user));
|
||||
EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data,
|
||||
int stdin_data_len));
|
||||
int stdin_data_len));
|
||||
EXTERN_DECL(long process_file_io, (HANDLE proc));
|
||||
EXTERN_DECL(void process_cleanup, (HANDLE proc));
|
||||
EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus));
|
||||
EXTERN_DECL(void process_register, (HANDLE proc));
|
||||
EXTERN_DECL(HANDLE process_easy, (char** argv, char** env,
|
||||
int outfd, int errfd));
|
||||
int outfd, int errfd));
|
||||
EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal));
|
||||
EXTERN_DECL(int process_used_slots, (VOID_DECL));
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ convert_vpath_to_windows32(char *Path, char to_delim)
|
|||
{
|
||||
char *etok; /* token separator for old Path */
|
||||
|
||||
/*
|
||||
* Convert all spaces to delimiters. Note that pathnames which
|
||||
* contain blanks get trounced here. Use 8.3 format as a workaround.
|
||||
*/
|
||||
for (etok = Path; etok && *etok; etok++)
|
||||
if (isblank ((unsigned char) *etok))
|
||||
*etok = to_delim;
|
||||
/*
|
||||
* Convert all spaces to delimiters. Note that pathnames which
|
||||
* contain blanks get trounced here. Use 8.3 format as a workaround.
|
||||
*/
|
||||
for (etok = Path; etok && *etok; etok++)
|
||||
if (isblank ((unsigned char) *etok))
|
||||
*etok = to_delim;
|
||||
|
||||
return (convert_Path_to_windows32(Path, to_delim));
|
||||
return (convert_Path_to_windows32(Path, to_delim));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -79,7 +79,7 @@ convert_Path_to_windows32(char *Path, char to_delim)
|
|||
if (etok) {
|
||||
*etok = to_delim;
|
||||
p = ++etok;
|
||||
} else
|
||||
} else
|
||||
p += strlen(p);
|
||||
} else {
|
||||
/* found another one, no drive letter */
|
||||
|
@ -114,14 +114,14 @@ w32ify(const char *filename, int resolve)
|
|||
char *
|
||||
getcwd_fs(char* buf, int len)
|
||||
{
|
||||
char *p = getcwd(buf, len);
|
||||
char *p = getcwd(buf, len);
|
||||
|
||||
if (p) {
|
||||
char *q = w32ify(buf, 0);
|
||||
strncpy(buf, q, len);
|
||||
}
|
||||
if (p) {
|
||||
char *q = w32ify(buf, 0);
|
||||
strncpy(buf, q, len);
|
||||
}
|
||||
|
||||
return p;
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef unused
|
||||
|
|
|
@ -24,59 +24,59 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
/*
|
||||
* Description: Convert a NULL string terminated UNIX environment block to
|
||||
* an environment block suitable for a windows32 system call
|
||||
* an environment block suitable for a windows32 system call
|
||||
*
|
||||
* Returns: TRUE= success, FALSE=fail
|
||||
*
|
||||
* Notes/Dependencies: the environment block is sorted in case-insensitive
|
||||
* order, is double-null terminated, and is a char *, not a char **
|
||||
* order, is double-null terminated, and is a char *, not a char **
|
||||
*/
|
||||
int _cdecl compare(const void *a1, const void *a2)
|
||||
{
|
||||
return _stricoll(*((char**)a1),*((char**)a2));
|
||||
return _stricoll(*((char**)a1),*((char**)a2));
|
||||
}
|
||||
bool_t
|
||||
arr2envblk(char **arr, char **envblk_out)
|
||||
{
|
||||
char **tmp;
|
||||
int size_needed;
|
||||
int arrcnt;
|
||||
char *ptr;
|
||||
char **tmp;
|
||||
int size_needed;
|
||||
int arrcnt;
|
||||
char *ptr;
|
||||
|
||||
arrcnt = 0;
|
||||
while (arr[arrcnt]) {
|
||||
arrcnt++;
|
||||
}
|
||||
arrcnt = 0;
|
||||
while (arr[arrcnt]) {
|
||||
arrcnt++;
|
||||
}
|
||||
|
||||
tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
|
||||
if (!tmp) {
|
||||
return FALSE;
|
||||
}
|
||||
tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
|
||||
if (!tmp) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
arrcnt = 0;
|
||||
size_needed = 0;
|
||||
while (arr[arrcnt]) {
|
||||
tmp[arrcnt] = arr[arrcnt];
|
||||
size_needed += strlen(arr[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
size_needed++;
|
||||
arrcnt = 0;
|
||||
size_needed = 0;
|
||||
while (arr[arrcnt]) {
|
||||
tmp[arrcnt] = arr[arrcnt];
|
||||
size_needed += strlen(arr[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
size_needed++;
|
||||
|
||||
qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
|
||||
qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
|
||||
|
||||
ptr = *envblk_out = calloc(size_needed, 1);
|
||||
if (!ptr) {
|
||||
free(tmp);
|
||||
return FALSE;
|
||||
}
|
||||
ptr = *envblk_out = calloc(size_needed, 1);
|
||||
if (!ptr) {
|
||||
free(tmp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
arrcnt = 0;
|
||||
while (tmp[arrcnt]) {
|
||||
strcpy(ptr, tmp[arrcnt]);
|
||||
ptr += strlen(tmp[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
arrcnt = 0;
|
||||
while (tmp[arrcnt]) {
|
||||
strcpy(ptr, tmp[arrcnt]);
|
||||
ptr += strlen(tmp[arrcnt]) + 1;
|
||||
arrcnt++;
|
||||
}
|
||||
|
||||
free(tmp);
|
||||
return TRUE;
|
||||
free(tmp);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
typedef int bool_t;
|
||||
|
||||
#define E_SCALL 101
|
||||
#define E_IO 102
|
||||
#define E_NO_MEM 103
|
||||
#define E_FORK 104
|
||||
#define E_SCALL 101
|
||||
#define E_IO 102
|
||||
#define E_NO_MEM 103
|
||||
#define E_FORK 104
|
||||
|
||||
extern bool_t arr2envblk(char **arr, char **envblk_out);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -45,41 +45,41 @@ map_windows32_error_to_string (DWORD ercode) {
|
|||
* the corresponding GCC qualifier is '__thread'.)
|
||||
*/
|
||||
static char szMessageBuffer[128];
|
||||
/* Fill message buffer with a default message in
|
||||
* case FormatMessage fails
|
||||
*/
|
||||
/* Fill message buffer with a default message in
|
||||
* case FormatMessage fails
|
||||
*/
|
||||
wsprintf (szMessageBuffer, "Error %ld\n", ercode);
|
||||
|
||||
/*
|
||||
* Special code for winsock error handling.
|
||||
*/
|
||||
if (ercode > WSABASEERR) {
|
||||
/*
|
||||
* Special code for winsock error handling.
|
||||
*/
|
||||
if (ercode > WSABASEERR) {
|
||||
#if 0
|
||||
HMODULE hModule = GetModuleHandle("wsock32");
|
||||
if (hModule != NULL) {
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
|
||||
hModule,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
HMODULE hModule = GetModuleHandle("wsock32");
|
||||
if (hModule != NULL) {
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
|
||||
hModule,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
#else
|
||||
O (fatal, NILF, szMessageBuffer);
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* Default system message handling
|
||||
*/
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Default system message handling
|
||||
*/
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
ercode,
|
||||
LANG_NEUTRAL,
|
||||
szMessageBuffer,
|
||||
sizeof(szMessageBuffer),
|
||||
NULL);
|
||||
}
|
||||
return szMessageBuffer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue