diff options
author | Andy Polyakov <appro@openssl.org> | 2004-07-25 16:48:28 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2004-07-25 16:48:28 +0000 |
commit | da2ee71de577fd9fb34bb8a8d253c3b8a9733842 (patch) | |
tree | 52546d4e76f01a0c04781a0f58005fe43d2563ca /crypto/LPdir_win.c | |
parent | 8611934352da42fa5a3c5ddc366086eaa6f666ac (diff) |
Typos and due casts. As for the latter. It's "safe" to cast as below,
because "wrong" casts will either be optimized away or never performed.
Diffstat (limited to 'crypto/LPdir_win.c')
-rw-r--r-- | crypto/LPdir_win.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/crypto/LPdir_win.c b/crypto/LPdir_win.c index 3bcc11982d..ec0d798e96 100644 --- a/crypto/LPdir_win.c +++ b/crypto/LPdir_win.c @@ -41,6 +41,10 @@ # define FindNextFile FindNextFileW #endif +#ifndef NAME_MAX +#define NAME_MAX 255 +#endif + struct LP_dir_context_st { WIN32_FIND_DATA ctx; @@ -73,7 +77,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) { TCHAR *wdir = NULL; /* len_0 denotes string length *with* trailing 0 */ - size_t index = 0,len_0 = strlen(direcory) + 1; + size_t index = 0,len_0 = strlen(directory) + 1; wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR)); if (wdir == NULL) @@ -85,7 +89,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) } #ifdef LP_MULTIBYTE_AVAILABLE - if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, wdir, len_0)) + if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0)) #endif for (index = 0; index < len_0; index++) wdir[index] = (TCHAR)directory[index]; @@ -95,7 +99,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) free(wdir); } else - (*ctx)->handle = FindFirstFile(directory, &(*ctx)->ctx); + (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx); if ((*ctx)->handle == INVALID_HANDLE_VALUE) { @@ -107,7 +111,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) } else { - if (FindNextFile((*ctx)->handle, (*ctx)->ctx) == FALSE) + if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE) { return 0; } @@ -118,18 +122,18 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) TCHAR *wdir = (*ctx)->ctx.cFileName; size_t index, len_0 = 0; - while (wdir[len] && len < (sizeof((*ctx)->entry_name) - 1)) len_0++; + while (wdir[len_0] && len_0 < (sizeof((*ctx)->entry_name) - 1)) len_0++; len_0++; #ifdef LP_MULTIBYTE_AVAILABLE - if (!WideCharToMultiByte(CP_ACP, 0, wdir, len_0, (*ctx)->entry_name, + if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR *)wdir, len_0, (*ctx)->entry_name, sizeof((*ctx)->entry_name), NULL, 0)) #endif for (index = 0; index < len_0; index++) (*ctx)->entry_name[index] = (char)wdir[index]; } else - strncpy((*ctx)->entry_name, (*ctx)->ctx.cFileName, + strncpy((*ctx)->entry_name, (const char *)(*ctx)->ctx.cFileName, sizeof((*ctx)->entry_name)-1); (*ctx)->entry_name[sizeof((*ctx)->entry_name)-1] = '\0'; |