From 7b5409010af104a97c2767b8ce81d779b7c0e93c Mon Sep 17 00:00:00 2001 From: mturk Date: Thu, 2 Dec 2021 23:53:57 +0000 Subject: TAB police ... get rid of missmatch of TAB and spaces through the code git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895516 13f79535-47bb-0310-9956-ffa450edef68 --- file_io/win32/dir.c | 2 +- file_io/win32/filepath.c | 4 +- file_io/win32/filestat.c | 130 ++++++++++++++++++------------------- file_io/win32/filesys.c | 100 ++++++++++++++--------------- file_io/win32/open.c | 164 +++++++++++++++++++++++------------------------ 5 files changed, 200 insertions(+), 200 deletions(-) diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c index f44bceb97..6eb65eeaf 100644 --- a/file_io/win32/dir.c +++ b/file_io/win32/dir.c @@ -58,7 +58,7 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, (*new)->dirname = apr_palloc(pool, len + 3); memcpy((*new)->dirname, dirname, len); if (len && (*new)->dirname[len - 1] != '/') { - (*new)->dirname[len++] = '/'; + (*new)->dirname[len++] = '/'; } (*new)->dirname[len++] = '\0'; (*new)->dirname[len] = '\0'; diff --git a/file_io/win32/filepath.c b/file_io/win32/filepath.c index 56e69a153..3f1e6eadf 100644 --- a/file_io/win32/filepath.c +++ b/file_io/win32/filepath.c @@ -977,6 +977,6 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p) { - *style = APR_FILEPATH_ENCODING_UTF8; - return APR_SUCCESS; + *style = APR_FILEPATH_ENCODING_UTF8; + return APR_SUCCESS; } diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c index e8e52fdd4..ce32cf91d 100644 --- a/file_io/win32/filestat.c +++ b/file_io/win32/filestat.c @@ -229,26 +229,26 @@ static int reparse_point_is_link(WIN32_FILE_ATTRIBUTE_DATA *wininfo, } else { - apr_wchar_t wfname[APR_PATH_MAX]; - HANDLE hFind; - WIN32_FIND_DATAW fd; + apr_wchar_t wfname[APR_PATH_MAX]; + HANDLE hFind; + WIN32_FIND_DATAW fd; if (test_safe_name(fname) != APR_SUCCESS) { return 0; } - if (utf8_to_unicode_path(wfname, APR_PATH_MAX, fname) != APR_SUCCESS) { - return 0; - } + if (utf8_to_unicode_path(wfname, APR_PATH_MAX, fname) != APR_SUCCESS) { + return 0; + } - hFind = FindFirstFileW(wfname, &fd); - if (hFind == INVALID_HANDLE_VALUE) { - return 0; - } + hFind = FindFirstFileW(wfname, &fd); + if (hFind == INVALID_HANDLE_VALUE) { + return 0; + } - FindClose(hFind); + FindClose(hFind); - tag = fd.dwReserved0; + tag = fd.dwReserved0; } // Test "Name surrogate bit" to detect any kind of symbolic link @@ -567,59 +567,59 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, return APR_ENAMETOOLONG; } - if ((wanted & (APR_FINFO_IDENT | APR_FINFO_NLINK)) - || (~wanted & APR_FINFO_LINK)) { - /* FindFirstFile and GetFileAttributesEx can't figure the inode, - * device or number of links, so we need to resolve with an open - * file handle. If the user has asked for these fields, fall over - * to the get file info by handle method. If we fail, or the user - * also asks for the file name, continue by our usual means. - * - * We also must use this method for a 'true' stat, that resolves - * a symlink (NTFS Junction) target. This is because all fileinfo - * on a Junction always returns the junction, opening the target - * is the only way to resolve the target's attributes. - */ - if ((ident_rv = resolve_ident(finfo, fname, wanted, pool)) - == APR_SUCCESS) - return ident_rv; - else if (ident_rv == APR_INCOMPLETE) - wanted &= ~finfo->valid; - } - - if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname))) - return rv; - if (!(wanted & (APR_FINFO_NAME | APR_FINFO_LINK))) { - if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, - &FileInfo.i)) - return apr_get_os_error(); - } - else { - /* Guard against bogus wildcards and retrieve by name - * since we want the true name, and set aside a long - * enough string to handle the longest file name. - */ - HANDLE hFind; - if ((rv = test_safe_name(fname)) != APR_SUCCESS) { - return rv; - } - hFind = FindFirstFileW(wfname, &FileInfo.w); - if (hFind == INVALID_HANDLE_VALUE) - return apr_get_os_error(); - FindClose(hFind); - finddata = 1; - - if (wanted & APR_FINFO_NAME) - { - char tmpname[APR_FILE_MAX * 3 + 1]; - if (unicode_to_utf8_path(tmpname, sizeof(tmpname), - FileInfo.w.cFileName)) { - return APR_ENAMETOOLONG; - } - filename = apr_pstrdup(pool, tmpname); - } - } + if ((wanted & (APR_FINFO_IDENT | APR_FINFO_NLINK)) + || (~wanted & APR_FINFO_LINK)) { + /* FindFirstFile and GetFileAttributesEx can't figure the inode, + * device or number of links, so we need to resolve with an open + * file handle. If the user has asked for these fields, fall over + * to the get file info by handle method. If we fail, or the user + * also asks for the file name, continue by our usual means. + * + * We also must use this method for a 'true' stat, that resolves + * a symlink (NTFS Junction) target. This is because all fileinfo + * on a Junction always returns the junction, opening the target + * is the only way to resolve the target's attributes. + */ + if ((ident_rv = resolve_ident(finfo, fname, wanted, pool)) + == APR_SUCCESS) + return ident_rv; + else if (ident_rv == APR_INCOMPLETE) + wanted &= ~finfo->valid; + } + + if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) + / sizeof(apr_wchar_t), fname))) + return rv; + if (!(wanted & (APR_FINFO_NAME | APR_FINFO_LINK))) { + if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, + &FileInfo.i)) + return apr_get_os_error(); + } + else { + /* Guard against bogus wildcards and retrieve by name + * since we want the true name, and set aside a long + * enough string to handle the longest file name. + */ + HANDLE hFind; + if ((rv = test_safe_name(fname)) != APR_SUCCESS) { + return rv; + } + hFind = FindFirstFileW(wfname, &FileInfo.w); + if (hFind == INVALID_HANDLE_VALUE) + return apr_get_os_error(); + FindClose(hFind); + finddata = 1; + + if (wanted & APR_FINFO_NAME) + { + char tmpname[APR_FILE_MAX * 3 + 1]; + if (unicode_to_utf8_path(tmpname, sizeof(tmpname), + FileInfo.w.cFileName)) { + return APR_ENAMETOOLONG; + } + filename = apr_pstrdup(pool, tmpname); + } + } if (ident_rv != APR_INCOMPLETE) { if (fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, diff --git a/file_io/win32/filesys.c b/file_io/win32/filesys.c index 2a23c8f68..bf1a7c2bc 100644 --- a/file_io/win32/filesys.c +++ b/file_io/win32/filesys.c @@ -66,12 +66,12 @@ const char apr_c_is_fnchar[256] = apr_status_t filepath_root_test(char *path, apr_pool_t *p) { apr_status_t rv; - apr_wchar_t wpath[APR_PATH_MAX]; + apr_wchar_t wpath[APR_PATH_MAX]; - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path))) - return rv; - rv = GetDriveTypeW(wpath); + if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) + / sizeof(apr_wchar_t), path))) + return rv; + rv = GetDriveTypeW(wpath); if (rv == DRIVE_UNKNOWN || rv == DRIVE_NO_ROOT_DIR) return APR_EBADPATH; @@ -83,19 +83,19 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, apr_int32_t flags, apr_pool_t *p) { char path[APR_PATH_MAX]; - apr_wchar_t *ignored; - apr_wchar_t wdrive[8]; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" - * as if that is useful for anything. - */ - wcscpy(wdrive, L"D:."); - wdrive[0] = (apr_wchar_t)(unsigned char)drive; - if (!GetFullPathNameW(wdrive, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); - if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) - return rv; + apr_wchar_t *ignored; + apr_wchar_t wdrive[8]; + apr_wchar_t wpath[APR_PATH_MAX]; + apr_status_t rv; + /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" + * as if that is useful for anything. + */ + wcscpy(wdrive, L"D:."); + wdrive[0] = (apr_wchar_t)(unsigned char)drive; + if (!GetFullPathNameW(wdrive, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) + return apr_get_os_error(); + if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) + return rv; if (!(flags & APR_FILEPATH_NATIVE)) { for (*rootpath = path; **rootpath; ++*rootpath) { if (**rootpath == '\\') @@ -109,24 +109,24 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) { - apr_wchar_t *ignored; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - apr_wchar_t wroot[APR_PATH_MAX]; - /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" - * as if that is useful for anything. - */ - if ((rv = utf8_to_unicode_path(wroot, sizeof(wroot) - / sizeof(apr_wchar_t), root))) - return rv; - if (!GetFullPathNameW(wroot, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); - - /* Borrow wroot as a char buffer (twice as big as necessary) - */ - if ((rv = unicode_to_utf8_path((char*)wroot, sizeof(wroot), wpath))) - return rv; - *rootpath = apr_pstrdup(p, (char*)wroot); + apr_wchar_t *ignored; + apr_wchar_t wpath[APR_PATH_MAX]; + apr_status_t rv; + apr_wchar_t wroot[APR_PATH_MAX]; + /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" + * as if that is useful for anything. + */ + if ((rv = utf8_to_unicode_path(wroot, sizeof(wroot) + / sizeof(apr_wchar_t), root))) + return rv; + if (!GetFullPathNameW(wroot, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) + return apr_get_os_error(); + + /* Borrow wroot as a char buffer (twice as big as necessary) + */ + if ((rv = unicode_to_utf8_path((char*)wroot, sizeof(wroot), wpath))) + return rv; + *rootpath = apr_pstrdup(p, (char*)wroot); return APR_SUCCESS; } @@ -135,13 +135,13 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, apr_pool_t *p) { char path[APR_PATH_MAX]; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + apr_wchar_t wpath[APR_PATH_MAX]; + apr_status_t rv; - if (!GetCurrentDirectoryW(sizeof(wpath) / sizeof(apr_wchar_t), wpath)) - return apr_get_os_error(); - if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) - return rv; + if (!GetCurrentDirectoryW(sizeof(wpath) / sizeof(apr_wchar_t), wpath)) + return apr_get_os_error(); + if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) + return rv; if (!(flags & APR_FILEPATH_NATIVE)) { for (*rootpath = path; **rootpath; ++*rootpath) { if (**rootpath == '\\') @@ -156,13 +156,13 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, apr_pool_t *p) { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), rootpath))) - return rv; - if (!SetCurrentDirectoryW(wpath)) - return apr_get_os_error(); + apr_wchar_t wpath[APR_PATH_MAX]; + apr_status_t rv; + + if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) + / sizeof(apr_wchar_t), rootpath))) + return rv; + if (!SetCurrentDirectoryW(wpath)) + return apr_get_os_error(); return APR_SUCCESS; } diff --git a/file_io/win32/open.c b/file_io/win32/open.c index 18d01e064..f36fa5ddf 100644 --- a/file_io/win32/open.c +++ b/file_io/win32/open.c @@ -137,36 +137,36 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) { - apr_wchar_t *wpre, *wfile, *ch; - apr_size_t n = strlen(file) + 1; - apr_size_t r, d; - - if (global) - wpre = L"Global\\"; - else - wpre = L"Local\\"; - r = wcslen(wpre); - - if (n > 256 - r) { - file += n - 256 - r; - n = 256; - /* skip utf8 continuation bytes */ - while ((*file & 0xC0) == 0x80) { - ++file; - --n; - } - } - wfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); - wcscpy(wfile, wpre); - d = n; - if (apr_conv_utf8_to_utf16(file, &n, wfile + r, &d)) { - return NULL; - } - for (ch = wfile + r; *ch; ++ch) { - if (*ch == ':' || *ch == '/' || *ch == '\\') - *ch = '_'; - } - return wfile; + apr_wchar_t *wpre, *wfile, *ch; + apr_size_t n = strlen(file) + 1; + apr_size_t r, d; + + if (global) + wpre = L"Global\\"; + else + wpre = L"Local\\"; + r = wcslen(wpre); + + if (n > 256 - r) { + file += n - 256 - r; + n = 256; + /* skip utf8 continuation bytes */ + while ((*file & 0xC0) == 0x80) { + ++file; + --n; + } + } + wfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); + wcscpy(wfile, wpre); + d = n; + if (apr_conv_utf8_to_utf16(file, &n, wfile + r, &d)) { + return NULL; + } + for (ch = wfile + r; *ch; ++ch) { + if (*ch == ':' || *ch == '/' || *ch == '\\') + *ch = '_'; + } + return wfile; } static apr_status_t make_sparse_file(apr_file_t *file) @@ -270,7 +270,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, DWORD attributes = 0; DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE; apr_status_t rv; - apr_wchar_t wfname[APR_PATH_MAX]; + apr_wchar_t wfname[APR_PATH_MAX]; if (flag & APR_FOPEN_NONBLOCK) { @@ -347,19 +347,19 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, attributes |= FILE_FLAG_OVERLAPPED; } - if (flag & APR_FOPEN_SENDFILE_ENABLED) { - /* This feature is required to enable sendfile operations - * against the file on Win32. Also implies APR_FOPEN_XTHREAD. - */ - flag |= APR_FOPEN_XTHREAD; - attributes |= FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED; - } + if (flag & APR_FOPEN_SENDFILE_ENABLED) { + /* This feature is required to enable sendfile operations + * against the file on Win32. Also implies APR_FOPEN_XTHREAD. + */ + flag |= APR_FOPEN_XTHREAD; + attributes |= FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED; + } - if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname))) - return rv; - handle = CreateFileW(wfname, oflags, sharemode, - NULL, createflags, attributes, 0); + if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) + / sizeof(apr_wchar_t), fname))) + return rv; + handle = CreateFileW(wfname, oflags, sharemode, + NULL, createflags, attributes, 0); if (handle == INVALID_HANDLE_VALUE) { return apr_get_os_error(); } @@ -433,15 +433,15 @@ APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path))) { - return rv; - } - if (DeleteFileW(wpath)) - return APR_SUCCESS; + apr_wchar_t wpath[APR_PATH_MAX]; + apr_status_t rv; + + if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) + / sizeof(apr_wchar_t), path))) { + return rv; + } + if (DeleteFileW(wpath)) + return APR_SUCCESS; return apr_get_os_error(); } @@ -449,22 +449,22 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, const char *topath, apr_pool_t *pool) { - apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; - apr_status_t rv; - - if ((rv = utf8_to_unicode_path(wfrompath, - sizeof(wfrompath) / sizeof(apr_wchar_t), - frompath))) { - return rv; - } - if ((rv = utf8_to_unicode_path(wtopath, - sizeof(wtopath) / sizeof(apr_wchar_t), - topath))) { - return rv; - } - if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING | - MOVEFILE_COPY_ALLOWED)) - return APR_SUCCESS; + apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; + apr_status_t rv; + + if ((rv = utf8_to_unicode_path(wfrompath, + sizeof(wfrompath) / sizeof(apr_wchar_t), + frompath))) { + return rv; + } + if ((rv = utf8_to_unicode_path(wtopath, + sizeof(wtopath) / sizeof(apr_wchar_t), + topath))) { + return rv; + } + if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING | + MOVEFILE_COPY_ALLOWED)) + return APR_SUCCESS; return apr_get_os_error(); } @@ -472,20 +472,20 @@ APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, const char *to_path) { apr_status_t rv = APR_SUCCESS; - apr_wchar_t wfrom_path[APR_PATH_MAX]; - apr_wchar_t wto_path[APR_PATH_MAX]; - - if ((rv = utf8_to_unicode_path(wfrom_path, - sizeof(wfrom_path) / sizeof(apr_wchar_t), - from_path))) - return rv; - if ((rv = utf8_to_unicode_path(wto_path, - sizeof(wto_path) / sizeof(apr_wchar_t), - to_path))) - return rv; - - if (!CreateHardLinkW(wto_path, wfrom_path, NULL)) - return apr_get_os_error(); + apr_wchar_t wfrom_path[APR_PATH_MAX]; + apr_wchar_t wto_path[APR_PATH_MAX]; + + if ((rv = utf8_to_unicode_path(wfrom_path, + sizeof(wfrom_path) / sizeof(apr_wchar_t), + from_path))) + return rv; + if ((rv = utf8_to_unicode_path(wto_path, + sizeof(wto_path) / sizeof(apr_wchar_t), + to_path))) + return rv; + + if (!CreateHardLinkW(wto_path, wfrom_path, NULL)) + return apr_get_os_error(); return rv; } -- cgit v1.2.1