diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /intern/utfconv/utf_winfunc.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'intern/utfconv/utf_winfunc.c')
-rw-r--r-- | intern/utfconv/utf_winfunc.c | 233 |
1 files changed, 116 insertions, 117 deletions
diff --git a/intern/utfconv/utf_winfunc.c b/intern/utfconv/utf_winfunc.c index 6a46807e148..4dc290a0146 100644 --- a/intern/utfconv/utf_winfunc.c +++ b/intern/utfconv/utf_winfunc.c @@ -18,7 +18,7 @@ */ #ifndef _WIN32_IE -#define _WIN32_IE 0x0501 +# define _WIN32_IE 0x0501 #endif #include "utf_winfunc.h" @@ -27,157 +27,156 @@ #include <windows.h> #include <wchar.h> - FILE *ufopen(const char *filename, const char *mode) { - FILE *f = NULL; - UTF16_ENCODE(filename); - UTF16_ENCODE(mode); - - if (filename_16 && mode_16) { - f = _wfopen(filename_16, mode_16); - } - - UTF16_UN_ENCODE(mode); - UTF16_UN_ENCODE(filename); - - if (!f) { - if ((f = fopen(filename, mode))) { - printf("WARNING: %s is not utf path. Please update it.\n",filename); - } - } - - return f; + FILE *f = NULL; + UTF16_ENCODE(filename); + UTF16_ENCODE(mode); + + if (filename_16 && mode_16) { + f = _wfopen(filename_16, mode_16); + } + + UTF16_UN_ENCODE(mode); + UTF16_UN_ENCODE(filename); + + if (!f) { + if ((f = fopen(filename, mode))) { + printf("WARNING: %s is not utf path. Please update it.\n", filename); + } + } + + return f; } int uopen(const char *filename, int oflag, int pmode) { - int f = -1; - UTF16_ENCODE(filename); - - if (filename_16) { - f = _wopen(filename_16, oflag, pmode); - } - - UTF16_UN_ENCODE(filename); - - if (f == -1) { - if ((f = open(filename,oflag, pmode)) != -1) { - printf("WARNING: %s is not utf path. Please update it.\n",filename); - } - } - - return f; + int f = -1; + UTF16_ENCODE(filename); + + if (filename_16) { + f = _wopen(filename_16, oflag, pmode); + } + + UTF16_UN_ENCODE(filename); + + if (f == -1) { + if ((f = open(filename, oflag, pmode)) != -1) { + printf("WARNING: %s is not utf path. Please update it.\n", filename); + } + } + + return f; } int uaccess(const char *filename, int mode) { - int r = -1; - UTF16_ENCODE(filename); + int r = -1; + UTF16_ENCODE(filename); - if (filename_16) { - r = _waccess(filename_16, mode); - } + if (filename_16) { + r = _waccess(filename_16, mode); + } - UTF16_UN_ENCODE(filename); + UTF16_UN_ENCODE(filename); - return r; + return r; } -int urename(const char *oldname, const char *newname ) +int urename(const char *oldname, const char *newname) { - int r = -1; - UTF16_ENCODE(oldname); - UTF16_ENCODE(newname); - - if (oldname_16 && newname_16) { - r = _wrename(oldname_16, newname_16); - } - - UTF16_UN_ENCODE(newname); - UTF16_UN_ENCODE(oldname); - return r; + int r = -1; + UTF16_ENCODE(oldname); + UTF16_ENCODE(newname); + + if (oldname_16 && newname_16) { + r = _wrename(oldname_16, newname_16); + } + + UTF16_UN_ENCODE(newname); + UTF16_UN_ENCODE(oldname); + return r; } int umkdir(const char *pathname) { - BOOL r = 0; - UTF16_ENCODE(pathname); - - if (pathname_16) { - r = CreateDirectoryW(pathname_16, NULL); - } + BOOL r = 0; + UTF16_ENCODE(pathname); + + if (pathname_16) { + r = CreateDirectoryW(pathname_16, NULL); + } - UTF16_UN_ENCODE(pathname); + UTF16_UN_ENCODE(pathname); - return r ? 0 : -1; + return r ? 0 : -1; } char *u_alloc_getenv(const char *varname) { - char * r = 0; - wchar_t * str; - UTF16_ENCODE(varname); - if (varname_16) { - str = _wgetenv(varname_16); - r = alloc_utf_8_from_16(str, 0); - } - UTF16_UN_ENCODE(varname); - - return r; + char *r = 0; + wchar_t *str; + UTF16_ENCODE(varname); + if (varname_16) { + str = _wgetenv(varname_16); + r = alloc_utf_8_from_16(str, 0); + } + UTF16_UN_ENCODE(varname); + + return r; } -void u_free_getenv(char *val) +void u_free_getenv(char *val) { - free(val); + free(val); } int uput_getenv(const char *varname, char *value, size_t buffsize) { - int r = 0; - wchar_t * str; - - if (!buffsize) { - return r; - } - - UTF16_ENCODE(varname); - if (varname_16) { - str = _wgetenv(varname_16); - conv_utf_16_to_8(str, value, buffsize); - r = 1; - } - UTF16_UN_ENCODE(varname); - - if (!r) { - value[0] = 0; - } - - return r; + int r = 0; + wchar_t *str; + + if (!buffsize) { + return r; + } + + UTF16_ENCODE(varname); + if (varname_16) { + str = _wgetenv(varname_16); + conv_utf_16_to_8(str, value, buffsize); + r = 1; + } + UTF16_UN_ENCODE(varname); + + if (!r) { + value[0] = 0; + } + + return r; } int uputenv(const char *name, const char *value) { - int r = -1; - UTF16_ENCODE(name); - - if (value) { - /* set */ - UTF16_ENCODE(value); - - if (name_16 && value_16) { - r = (SetEnvironmentVariableW(name_16,value_16)!= 0) ? 0 : -1; - } - UTF16_UN_ENCODE(value); - } - else { - /* clear */ - if (name_16) { - r = (SetEnvironmentVariableW(name_16,NULL)!= 0) ? 0 : -1; - } - } - - UTF16_UN_ENCODE(name); - - return r; + int r = -1; + UTF16_ENCODE(name); + + if (value) { + /* set */ + UTF16_ENCODE(value); + + if (name_16 && value_16) { + r = (SetEnvironmentVariableW(name_16, value_16) != 0) ? 0 : -1; + } + UTF16_UN_ENCODE(value); + } + else { + /* clear */ + if (name_16) { + r = (SetEnvironmentVariableW(name_16, NULL) != 0) ? 0 : -1; + } + } + + UTF16_UN_ENCODE(name); + + return r; } |