From 7854435d8ef32c6998f97e681ba90fa6cf47cc15 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 7 Jan 2020 21:27:26 +0100 Subject: [PATCH] Switch pointer alignment to left Consistency with rest of boost --- .clang-format | 2 +- include/boost/nowide/args.hpp | 46 +++++------ include/boost/nowide/convert.hpp | 34 ++++---- include/boost/nowide/cstdio.hpp | 8 +- include/boost/nowide/cstdlib.hpp | 16 ++-- include/boost/nowide/detail/utf.hpp | 16 ++-- include/boost/nowide/filebuf.hpp | 28 +++---- include/boost/nowide/fstream.hpp | 36 ++++----- include/boost/nowide/iostream.hpp | 12 +-- include/boost/nowide/stackstring.hpp | 20 ++--- include/boost/nowide/utf8_codecvt.hpp | 92 ++++++++++----------- include/boost/nowide/windows.hpp | 14 ++-- src/iostream.cpp | 30 +++---- standalone/scoped_ptr.hpp | 24 +++--- test/benchmark_fstream.cpp | 20 ++--- test/exampleProject/example_main.cpp | 2 +- test/test.hpp | 2 +- test/test_codecvt.cpp | 110 +++++++++++++------------- test/test_convert.cpp | 10 +-- test/test_env.cpp | 4 +- test/test_fs.cpp | 2 +- test/test_fstream.cpp | 36 ++++----- test/test_iostream.cpp | 10 +-- test/test_sets.hpp | 12 +-- test/test_stackstring.cpp | 8 +- test/test_stdio.cpp | 22 +++--- test/test_system.cpp | 10 +-- 27 files changed, 313 insertions(+), 313 deletions(-) diff --git a/.clang-format b/.clang-format index 4ee2ef3..2aff157 100644 --- a/.clang-format +++ b/.clang-format @@ -100,7 +100,7 @@ PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 10000 PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right +PointerAlignment: Left ReflowComments: true SortIncludes: true SortUsingDeclarations: false diff --git a/include/boost/nowide/args.hpp b/include/boost/nowide/args.hpp index e1dce17..9673f98 100644 --- a/include/boost/nowide/args.hpp +++ b/include/boost/nowide/args.hpp @@ -22,9 +22,9 @@ namespace nowide { class args { public: - args(int &, char **&) + args(int&, char**&) {} - args(int &, char **&, char **&) + args(int&, char**&, char**&) {} ~args() {} @@ -53,7 +53,7 @@ namespace nowide { /// /// Fix command line arguments /// - args(int &argc, char **&argv) : + args(int& argc, char**& argv) : old_argc_(argc), old_argv_(argv), old_env_(0), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(0) { fix_args(argc, argv); @@ -61,7 +61,7 @@ namespace nowide { /// /// Fix command line arguments and environment /// - args(int &argc, char **&argv, char **&env) : + args(int& argc, char**& argv, char**& env) : old_argc_(argc), old_argv_(argv), old_env_(env), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(&env) { fix_args(argc, argv); @@ -83,11 +83,11 @@ namespace nowide { private: class wargv_ptr { - wchar_t **p; + wchar_t** p; int argc; // Non-copyable - wargv_ptr(const wargv_ptr &); - wargv_ptr &operator=(const wargv_ptr &); + wargv_ptr(const wargv_ptr&); + wargv_ptr& operator=(const wargv_ptr&); public: wargv_ptr() : p(CommandLineToArgvW(GetCommandLineW(), &argc)) @@ -105,17 +105,17 @@ namespace nowide { { return p != NULL; } - const wchar_t *operator[](size_t i) const + const wchar_t* operator[](size_t i) const { return p[i]; } }; class wenv_ptr { - wchar_t *p; + wchar_t* p; // Non-copyable - wenv_ptr(const wenv_ptr &); - wenv_ptr &operator=(const wenv_ptr &); + wenv_ptr(const wenv_ptr&); + wenv_ptr& operator=(const wenv_ptr&); public: wenv_ptr() : p(GetEnvironmentStringsW()) @@ -125,13 +125,13 @@ namespace nowide { if(p) FreeEnvironmentStringsW(p); } - operator const wchar_t *() const + operator const wchar_t*() const { return p; } }; - void fix_args(int &argc, char **&argv) + void fix_args(int& argc, char**& argv) { const wargv_ptr wargv; if(!wargv) @@ -143,18 +143,18 @@ namespace nowide { argc = wargv.size(); argv = &args_[0]; } - void fix_env(char **&env) + void fix_env(char**& env) { const wenv_ptr wstrings; if(!wstrings) throw std::runtime_error("Could not get environment strings!"); - const wchar_t *wstrings_end = 0; + const wchar_t* wstrings_end = 0; int count = 0; for(wstrings_end = wstrings; *wstrings_end; wstrings_end += wcslen(wstrings_end) + 1) count++; env_.convert(wstrings, wstrings_end); envp_.resize(count + 1, 0); - char *p = env_.get(); + char* p = env_.get(); int pos = 0; for(int i = 0; i < count; i++) { @@ -165,18 +165,18 @@ namespace nowide { env = &envp_[0]; } - std::vector args_; + std::vector args_; std::vector arg_values_; stackstring env_; - std::vector envp_; + std::vector envp_; int old_argc_; - char **old_argv_; - char **old_env_; + char** old_argv_; + char** old_env_; - int *old_argc_ptr_; - char ***old_argv_ptr_; - char ***old_env_ptr_; + int* old_argc_ptr_; + char*** old_argv_ptr_; + char*** old_env_ptr_; }; #endif diff --git a/include/boost/nowide/convert.hpp b/include/boost/nowide/convert.hpp index 742f1fc..1855504 100644 --- a/include/boost/nowide/convert.hpp +++ b/include/boost/nowide/convert.hpp @@ -25,16 +25,16 @@ namespace nowide { /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// template - CharOut *basic_convert(CharOut *buffer, size_t buffer_size, const CharIn *source_begin, const CharIn *source_end) + CharOut* basic_convert(CharOut* buffer, size_t buffer_size, const CharIn* source_begin, const CharIn* source_end) { - CharOut *rv = buffer; + CharOut* rv = buffer; if(buffer_size == 0) return 0; buffer_size--; while(source_begin != source_end) { using namespace detail::utf; - code_point c = utf_traits::template decode(source_begin, source_end); + code_point c = utf_traits::template decode(source_begin, source_end); if(c == illegal || c == incomplete) { c = BOOST_NOWIDE_REPLACEMENT_CHARACTER; @@ -45,7 +45,7 @@ namespace nowide { rv = NULL; break; } - buffer = utf_traits::template encode(c, buffer); + buffer = utf_traits::template encode(c, buffer); buffer_size -= width; } *buffer++ = 0; @@ -59,7 +59,7 @@ namespace nowide { /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// template - std::basic_string basic_convert(const CharIn *begin, const CharIn *end) + std::basic_string basic_convert(const CharIn* begin, const CharIn* end) { std::basic_string result; result.reserve(end - begin); @@ -69,7 +69,7 @@ namespace nowide { code_point c; while(begin != end) { - c = utf_traits::template decode(begin, end); + c = utf_traits::template decode(begin, end); if(c == illegal || c == incomplete) { c = BOOST_NOWIDE_REPLACEMENT_CHARACTER; @@ -85,7 +85,7 @@ namespace nowide { // wcslen defined only in C99... So we will not use it // template - const Char *basic_strend(const Char *s) + const Char* basic_strend(const Char* s) { while(*s) s++; @@ -101,7 +101,7 @@ namespace nowide { /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// template - std::basic_string basic_convert(std::basic_string const &s) + std::basic_string basic_convert(std::basic_string const& s) { return basic_convert(s.c_str(), s.c_str() + s.size()); } @@ -112,7 +112,7 @@ namespace nowide { /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// template - std::basic_string basic_convert(const CharIn *s) + std::basic_string basic_convert(const CharIn* s) { return basic_convert(s, detail::basic_strend(s)); } @@ -124,7 +124,7 @@ namespace nowide { /// In case of success output is returned, if there is not enough room NULL is returned. /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline char *narrow(char *output, size_t output_size, const wchar_t *source) + inline char* narrow(char* output, size_t output_size, const wchar_t* source) { return basic_convert(output, output_size, source, detail::basic_strend(source)); } @@ -135,7 +135,7 @@ namespace nowide { /// In case of success output is returned, if there is not enough room NULL is returned. /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline char *narrow(char *output, size_t output_size, const wchar_t *begin, const wchar_t *end) + inline char* narrow(char* output, size_t output_size, const wchar_t* begin, const wchar_t* end) { return basic_convert(output, output_size, begin, end); } @@ -146,7 +146,7 @@ namespace nowide { /// In case of success output is returned, if there is not enough room NULL is returned. /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline wchar_t *widen(wchar_t *output, size_t output_size, const char *source) + inline wchar_t* widen(wchar_t* output, size_t output_size, const char* source) { return basic_convert(output, output_size, source, detail::basic_strend(source)); } @@ -157,7 +157,7 @@ namespace nowide { /// In case of success output is returned, if there is not enough room NULL is returned. /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline wchar_t *widen(wchar_t *output, size_t output_size, const char *begin, const char *end) + inline wchar_t* widen(wchar_t* output, size_t output_size, const char* begin, const char* end) { return basic_convert(output, output_size, begin, end); } @@ -167,7 +167,7 @@ namespace nowide { /// /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline std::string narrow(const wchar_t *s) + inline std::string narrow(const wchar_t* s) { return basic_convert(s); } @@ -176,7 +176,7 @@ namespace nowide { /// /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline std::wstring widen(const char *s) + inline std::wstring widen(const char* s) { return basic_convert(s); } @@ -185,7 +185,7 @@ namespace nowide { /// /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline std::string narrow(const std::wstring &s) + inline std::string narrow(const std::wstring& s) { return basic_convert(s); } @@ -194,7 +194,7 @@ namespace nowide { /// /// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER /// - inline std::wstring widen(const std::string &s) + inline std::wstring widen(const std::string& s) { return basic_convert(s); } diff --git a/include/boost/nowide/cstdio.hpp b/include/boost/nowide/cstdio.hpp index 394d035..7a313ad 100644 --- a/include/boost/nowide/cstdio.hpp +++ b/include/boost/nowide/cstdio.hpp @@ -32,7 +32,7 @@ namespace nowide { /// /// \brief Same as freopen but file_name and mode are UTF-8 strings /// - inline FILE *freopen(const char *file_name, const char *mode, FILE *stream) + inline FILE* freopen(const char* file_name, const char* mode, FILE* stream) { const wstackstring wname(file_name); const wshort_stackstring wmode(mode); @@ -41,7 +41,7 @@ namespace nowide { /// /// \brief Same as fopen but file_name and mode are UTF-8 strings /// - inline FILE *fopen(const char *file_name, const char *mode) + inline FILE* fopen(const char* file_name, const char* mode) { const wstackstring wname(file_name); const wshort_stackstring wmode(mode); @@ -50,7 +50,7 @@ namespace nowide { /// /// \brief Same as rename but old_name and new_name are UTF-8 strings /// - inline int rename(const char *old_name, const char *new_name) + inline int rename(const char* old_name, const char* new_name) { const wstackstring wold(old_name), wnew(new_name); return _wrename(wold.get(), wnew.get()); @@ -58,7 +58,7 @@ namespace nowide { /// /// \brief Same as rename but name is UTF-8 string /// - inline int remove(const char *name) + inline int remove(const char* name) { const wstackstring wname(name); return _wremove(wname.get()); diff --git a/include/boost/nowide/cstdlib.hpp b/include/boost/nowide/cstdlib.hpp index 7996a56..9fb226e 100644 --- a/include/boost/nowide/cstdlib.hpp +++ b/include/boost/nowide/cstdlib.hpp @@ -31,7 +31,7 @@ namespace nowide { /// /// This function is not thread safe or reenterable as defined by the standard library /// - inline char *getenv(const char *key) + inline char* getenv(const char* key) { static stackstring value; @@ -40,7 +40,7 @@ namespace nowide { static const size_t buf_size = 64; wchar_t buf[buf_size]; std::vector tmp; - wchar_t *ptr = buf; + wchar_t* ptr = buf; size_t n = GetEnvironmentVariableW(name.get(), buf, buf_size); if(n == 0 && GetLastError() == 203) // ERROR_ENVVAR_NOT_FOUND return 0; @@ -62,7 +62,7 @@ namespace nowide { /// if overwrite is not 0, that the old value is always overwritten, otherwise, /// if the variable exists it remains unchanged /// - inline int setenv(const char *key, const char *value, int overwrite) + inline int setenv(const char* key, const char* value, int overwrite) { const wshort_stackstring name(key); if(!overwrite) @@ -79,7 +79,7 @@ namespace nowide { /// /// \brief Remove environment variable \a key /// - inline int unsetenv(const char *key) + inline int unsetenv(const char* key) { const wshort_stackstring name(key); if(SetEnvironmentVariableW(name.get(), 0)) @@ -89,10 +89,10 @@ namespace nowide { /// /// \brief UTF-8 aware putenv implementation, expects string in format KEY=VALUE /// - inline int putenv(char *string) + inline int putenv(char* string) { - const char *key = string; - const char *key_end = string; + const char* key = string; + const char* key_end = string; while(*key_end != '=' && *key_end != '\0') key_end++; if(*key_end == '\0') @@ -108,7 +108,7 @@ namespace nowide { /// /// Same as std::system but cmd is UTF-8. /// - inline int system(const char *cmd) + inline int system(const char* cmd) { if(!cmd) return _wsystem(0); diff --git a/include/boost/nowide/detail/utf.hpp b/include/boost/nowide/detail/utf.hpp index ed43980..cd24522 100644 --- a/include/boost/nowide/detail/utf.hpp +++ b/include/boost/nowide/detail/utf.hpp @@ -75,7 +75,7 @@ namespace nowide { /// - p points to the last consumed character /// template - static code_point decode(Iterator &p, Iterator e); + static code_point decode(Iterator& p, Iterator e); /// /// Maximal width of valid sequence in the code units: @@ -126,7 +126,7 @@ namespace nowide { /// If the sequence is invalid or points to end the behavior is undefined /// template - static code_point decode_valid(Iterator &p); + static code_point decode_valid(Iterator& p); }; #else @@ -186,7 +186,7 @@ namespace nowide { } template - static code_point decode(Iterator &p, Iterator e) + static code_point decode(Iterator& p, Iterator e) { if(BOOST_UNLIKELY(p == e)) return incomplete; @@ -250,7 +250,7 @@ namespace nowide { } template - static code_point decode_valid(Iterator &p) + static code_point decode_valid(Iterator& p) { unsigned char lead = *p++; if(lead < 192) @@ -345,7 +345,7 @@ namespace nowide { } template - static code_point decode(It ¤t, It last) + static code_point decode(It& current, It last) { if(BOOST_UNLIKELY(current == last)) return incomplete; @@ -364,7 +364,7 @@ namespace nowide { return combine_surrogate(w1, w2); } template - static code_point decode_valid(It ¤t) + static code_point decode_valid(It& current) { uint16_t w1 = *current++; if(BOOST_LIKELY(w1 < 0xD800 || 0xDFFF < w1)) @@ -416,13 +416,13 @@ namespace nowide { } template - static code_point decode_valid(It ¤t) + static code_point decode_valid(It& current) { return *current++; } template - static code_point decode(It ¤t, It last) + static code_point decode(It& current, It last) { if(BOOST_UNLIKELY(current == last)) return incomplete; diff --git a/include/boost/nowide/filebuf.hpp b/include/boost/nowide/filebuf.hpp index a2a51a8..fafc863 100644 --- a/include/boost/nowide/filebuf.hpp +++ b/include/boost/nowide/filebuf.hpp @@ -54,8 +54,8 @@ namespace nowide { class basic_filebuf : public std::basic_streambuf { // Non-copyable - basic_filebuf(const basic_filebuf &); - basic_filebuf &operator=(const basic_filebuf &); + basic_filebuf(const basic_filebuf&); + basic_filebuf& operator=(const basic_filebuf&); typedef std::char_traits Traits; @@ -77,14 +77,14 @@ namespace nowide { /// /// Same as std::filebuf::open but s is UTF-8 string /// - basic_filebuf *open(const std::string &s, std::ios_base::openmode mode) + basic_filebuf* open(const std::string& s, std::ios_base::openmode mode) { return open(s.c_str(), mode); } /// /// Same as std::filebuf::open but s is UTF-8 string /// - basic_filebuf *open(const char *s, std::ios_base::openmode mode) + basic_filebuf* open(const char* s, std::ios_base::openmode mode) { if(is_open()) return NULL; @@ -92,7 +92,7 @@ namespace nowide { const bool ate = bool(mode & std::ios_base::ate); if(ate) mode = mode ^ std::ios_base::ate; - const wchar_t *smode = get_mode(mode); + const wchar_t* smode = get_mode(mode); if(!smode) return 0; #ifdef BOOST_WINDOWS @@ -116,7 +116,7 @@ namespace nowide { /// /// Same as std::filebuf::close() /// - basic_filebuf *close() + basic_filebuf* close() { if(!is_open()) return NULL; @@ -152,14 +152,14 @@ namespace nowide { owns_buffer_ = true; } } - void validate_cvt(const std::locale &loc) + void validate_cvt(const std::locale& loc) { if(!std::use_facet >(loc).always_noconv()) throw std::runtime_error("Converting codecvts are not supported"); } protected: - virtual std::streambuf *setbuf(char *s, std::streamsize n) + virtual std::streambuf* setbuf(char* s, std::streamsize n) { assert(n >= 0); // Maximum compatibility: Discard all local buffers and use user-provided values @@ -305,7 +305,7 @@ namespace nowide { // Standard mandates "as-if fsetpos", but assume the effect is the same as fseek return seekoff(pos, std::ios_base::beg, m); } - virtual void imbue(const std::locale &loc) + virtual void imbue(const std::locale& loc) { validate_cvt(loc); } @@ -332,7 +332,7 @@ namespace nowide { { if(pptr()) { - const char *const base = pbase(); + const char* const base = pbase(); const size_t n = pptr() - base; setp(0, 0); if(n && std::fwrite(base, 1, n, file_) != n) @@ -341,7 +341,7 @@ namespace nowide { return true; } - void reset(FILE *f = 0) + void reset(FILE* f = 0) { sync(); if(file_) @@ -352,7 +352,7 @@ namespace nowide { file_ = f; } - static const wchar_t *get_mode(std::ios_base::openmode mode) + static const wchar_t* get_mode(std::ios_base::openmode mode) { // // done according to n2914 table 106 27.9.1.4 @@ -400,8 +400,8 @@ namespace nowide { } size_t buffer_size_; - char *buffer_; - FILE *file_; + char* buffer_; + FILE* file_; bool owns_buffer_; char last_char_; std::ios::openmode mode_; diff --git a/include/boost/nowide/fstream.hpp b/include/boost/nowide/fstream.hpp index 44fa57b..679a91b 100644 --- a/include/boost/nowide/fstream.hpp +++ b/include/boost/nowide/fstream.hpp @@ -49,23 +49,23 @@ namespace nowide { this->init(&buf_); } - explicit basic_ifstream(const char *file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL) + explicit basic_ifstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - explicit basic_ifstream(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL) + explicit basic_ifstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - void open(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::in) + void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in) { open(file_name.c_str(), mode); } - void open(const char *file_name, std::ios_base::openmode mode = std::ios_base::in) + void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::in) { if(!buf_.open(file_name, mode | std::ios_base::in)) this->setstate(std::ios_base::failbit); @@ -86,9 +86,9 @@ namespace nowide { this->setstate(std::ios_base::failbit); } - internal_buffer_type *rdbuf() const + internal_buffer_type* rdbuf() const { - return const_cast(&buf_); + return const_cast(&buf_); } private: @@ -110,22 +110,22 @@ namespace nowide { { this->init(&buf_); } - explicit basic_ofstream(const char *file_name, std::ios_base::openmode mode = std::ios_base::out) : internal_stream_type(NULL) + explicit basic_ofstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::out) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - explicit basic_ofstream(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::out) : + explicit basic_ofstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::out) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - void open(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::out) + void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::out) { open(file_name.c_str(), mode); } - void open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out) + void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::out) { if(!buf_.open(file_name, mode | std::ios_base::out)) this->setstate(std::ios_base::failbit); @@ -146,9 +146,9 @@ namespace nowide { this->setstate(std::ios_base::failbit); } - internal_buffer_type *rdbuf() const + internal_buffer_type* rdbuf() const { - return const_cast(&buf_); + return const_cast(&buf_); } private: @@ -173,23 +173,23 @@ namespace nowide { { this->init(&buf_); } - explicit basic_fstream(const char *file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : + explicit basic_fstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - explicit basic_fstream(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : + explicit basic_fstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : internal_stream_type(NULL) { this->init(&buf_); open(file_name, mode); } - void open(const std::string &file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { open(file_name.c_str(), mode); } - void open(const char *file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { if(!buf_.open(file_name, mode)) this->setstate(std::ios_base::failbit); @@ -210,9 +210,9 @@ namespace nowide { this->setstate(std::ios_base::failbit); } - internal_buffer_type *rdbuf() const + internal_buffer_type* rdbuf() const { - return const_cast(&buf_); + return const_cast(&buf_); } private: diff --git a/include/boost/nowide/iostream.hpp b/include/boost/nowide/iostream.hpp index 61e9f20..135d9a0 100644 --- a/include/boost/nowide/iostream.hpp +++ b/include/boost/nowide/iostream.hpp @@ -40,11 +40,11 @@ namespace nowide { class BOOST_NOWIDE_DECL winconsole_ostream : public std::ostream { - winconsole_ostream(const winconsole_ostream &); - void operator=(const winconsole_ostream &); + winconsole_ostream(const winconsole_ostream&); + void operator=(const winconsole_ostream&); public: - winconsole_ostream(int fd, winconsole_ostream *tieStream); + winconsole_ostream(int fd, winconsole_ostream* tieStream); ~winconsole_ostream(); private: @@ -53,11 +53,11 @@ namespace nowide { class BOOST_NOWIDE_DECL winconsole_istream : public std::istream { - winconsole_istream(const winconsole_istream &); - void operator=(const winconsole_istream &); + winconsole_istream(const winconsole_istream&); + void operator=(const winconsole_istream&); public: - explicit winconsole_istream(winconsole_ostream *tieStream); + explicit winconsole_istream(winconsole_ostream* tieStream); ~winconsole_istream(); private: diff --git a/include/boost/nowide/stackstring.hpp b/include/boost/nowide/stackstring.hpp index a5fca54..9fcfed9 100644 --- a/include/boost/nowide/stackstring.hpp +++ b/include/boost/nowide/stackstring.hpp @@ -34,12 +34,12 @@ namespace nowide { typedef CharOut output_char; typedef CharIn input_char; - basic_stackstring(const basic_stackstring &other) : data_(NULL) + basic_stackstring(const basic_stackstring& other) : data_(NULL) { *this = other; } - friend void swap(basic_stackstring &lhs, basic_stackstring &rhs) + friend void swap(basic_stackstring& lhs, basic_stackstring& rhs) { if(lhs.uses_stack_memory()) { @@ -63,7 +63,7 @@ namespace nowide { } else std::swap(lhs.data_, rhs.data_); } - basic_stackstring &operator=(const basic_stackstring &other) + basic_stackstring& operator=(const basic_stackstring& other) { if(this != &other) { @@ -82,22 +82,22 @@ namespace nowide { { buffer_[0] = 0; } - explicit basic_stackstring(const input_char *input) : data_(NULL) + explicit basic_stackstring(const input_char* input) : data_(NULL) { convert(input); } - basic_stackstring(const input_char *begin, const input_char *end) : data_(NULL) + basic_stackstring(const input_char* begin, const input_char* end) : data_(NULL) { convert(begin, end); } - output_char *convert(const input_char *input) + output_char* convert(const input_char* input) { if(input) return convert(input, detail::basic_strend(input)); clear(); return get(); } - output_char *convert(const input_char *begin, const input_char *end) + output_char* convert(const input_char* begin, const input_char* end) { clear(); @@ -117,12 +117,12 @@ namespace nowide { return get(); } /// Return the converted, NULL-terminated string or NULL if no string was converted - output_char *get() + output_char* get() { return data_; } /// Return the converted, NULL-terminated string or NULL if no string was converted - const output_char *get() const + const output_char* get() const { return data_; } @@ -164,7 +164,7 @@ namespace nowide { return 2 * in; } output_char buffer_[buffer_size]; - output_char *data_; + output_char* data_; }; // basic_stackstring /// diff --git a/include/boost/nowide/utf8_codecvt.hpp b/include/boost/nowide/utf8_codecvt.hpp index be19063..f5af170 100644 --- a/include/boost/nowide/utf8_codecvt.hpp +++ b/include/boost/nowide/utf8_codecvt.hpp @@ -42,9 +42,9 @@ namespace nowide { protected: typedef CharType uchar; - virtual std::codecvt_base::result do_unshift(std::mbstate_t &s, char *from, char * /*to*/, char *&next) const + virtual std::codecvt_base::result do_unshift(std::mbstate_t& s, char* from, char* /*to*/, char*& next) const { - boost::uint16_t &state = *reinterpret_cast(&s); + boost::uint16_t& state = *reinterpret_cast(&s); if(state != 0) return std::codecvt_base::error; next = from; @@ -67,21 +67,21 @@ namespace nowide { #ifdef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST const #endif - &std_state, - const char *from, - const char *from_end, + & std_state, + const char* from, + const char* from_end, size_t max) const { #ifndef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST - const char *save_from = from; - boost::uint16_t &state = *reinterpret_cast(&std_state); + const char* save_from = from; + boost::uint16_t& state = *reinterpret_cast(&std_state); #else size_t save_max = max; - boost::uint16_t state = *reinterpret_cast(&std_state); + boost::uint16_t state = *reinterpret_cast(&std_state); #endif while(max > 0 && from < from_end) { - const char *prev_from = from; + const char* prev_from = from; boost::uint32_t ch = detail::utf::utf_traits::decode(from, from_end); if(ch == detail::utf::illegal) { @@ -111,13 +111,13 @@ namespace nowide { #endif } - virtual std::codecvt_base::result do_in(std::mbstate_t &std_state, - const char *from, - const char *from_end, - const char *&from_next, - uchar *to, - uchar *to_end, - uchar *&to_next) const + virtual std::codecvt_base::result do_in(std::mbstate_t& std_state, + const char* from, + const char* from_end, + const char*& from_next, + uchar* to, + uchar* to_end, + uchar*& to_next) const { std::codecvt_base::result r = std::codecvt_base::ok; @@ -126,10 +126,10 @@ namespace nowide { // // if 0 no code above >0xFFFF observed, of 1 a code above 0xFFFF observed // and first pair is written, but no input consumed - boost::uint16_t &state = *reinterpret_cast(&std_state); + boost::uint16_t& state = *reinterpret_cast(&std_state); while(to < to_end && from < from_end) { - const char *from_saved = from; + const char* from_saved = from; uint32_t ch = detail::utf::utf_traits::decode(from, from_end); @@ -181,13 +181,13 @@ namespace nowide { return r; } - virtual std::codecvt_base::result do_out(std::mbstate_t &std_state, - const uchar *from, - const uchar *from_end, - const uchar *&from_next, - char *to, - char *to_end, - char *&to_next) const + virtual std::codecvt_base::result do_out(std::mbstate_t& std_state, + const uchar* from, + const uchar* from_end, + const uchar*& from_next, + char* to, + char* to_end, + char*& to_next) const { std::codecvt_base::result r = std::codecvt_base::ok; // mbstate_t is POD type and should be initialized to 0 (i.a. state = stateT()) @@ -197,7 +197,7 @@ namespace nowide { // State: state!=0 - a first surrogate pair was observed (state = first pair), // we expect the second one to come and then zero the state /// - boost::uint16_t &state = *reinterpret_cast(&std_state); + boost::uint16_t& state = *reinterpret_cast(&std_state); while(to < to_end && from < from_end) { boost::uint32_t ch = 0; @@ -272,7 +272,7 @@ namespace nowide { protected: typedef CharType uchar; - virtual std::codecvt_base::result do_unshift(std::mbstate_t & /*s*/, char *from, char * /*to*/, char *&next) const + virtual std::codecvt_base::result do_unshift(std::mbstate_t& /*s*/, char* from, char* /*to*/, char*& next) const { next = from; return std::codecvt_base::ok; @@ -295,19 +295,19 @@ namespace nowide { const #endif & /*state*/, - const char *from, - const char *from_end, + const char* from, + const char* from_end, size_t max) const { #ifndef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST - const char *start_from = from; + const char* start_from = from; #else size_t save_max = max; #endif while(max > 0 && from < from_end) { - const char *save_from = from; + const char* save_from = from; boost::uint32_t ch = detail::utf::utf_traits::decode(from, from_end); if(ch == detail::utf::incomplete) { @@ -326,13 +326,13 @@ namespace nowide { #endif } - virtual std::codecvt_base::result do_in(std::mbstate_t & /*state*/, - const char *from, - const char *from_end, - const char *&from_next, - uchar *to, - uchar *to_end, - uchar *&to_next) const + virtual std::codecvt_base::result do_in(std::mbstate_t& /*state*/, + const char* from, + const char* from_end, + const char*& from_next, + uchar* to, + uchar* to_end, + uchar*& to_next) const { std::codecvt_base::result r = std::codecvt_base::ok; @@ -343,7 +343,7 @@ namespace nowide { // and first pair is written, but no input consumed while(to < to_end && from < from_end) { - const char *from_saved = from; + const char* from_saved = from; uint32_t ch = detail::utf::utf_traits::decode(from, from_end); @@ -365,13 +365,13 @@ namespace nowide { return r; } - virtual std::codecvt_base::result do_out(std::mbstate_t & /*std_state*/, - const uchar *from, - const uchar *from_end, - const uchar *&from_next, - char *to, - char *to_end, - char *&to_next) const + virtual std::codecvt_base::result do_out(std::mbstate_t& /*std_state*/, + const uchar* from, + const uchar* from_end, + const uchar*& from_next, + char* to, + char* to_end, + char*& to_next) const { std::codecvt_base::result r = std::codecvt_base::ok; while(to < to_end && from < from_end) diff --git a/include/boost/nowide/windows.hpp b/include/boost/nowide/windows.hpp index f89bf7e..63fad3f 100644 --- a/include/boost/nowide/windows.hpp +++ b/include/boost/nowide/windows.hpp @@ -17,14 +17,14 @@ // extern "C" { -__declspec(dllimport) wchar_t *__stdcall GetEnvironmentStringsW(void); -__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t *); -__declspec(dllimport) wchar_t *__stdcall GetCommandLineW(void); -__declspec(dllimport) wchar_t **__stdcall CommandLineToArgvW(const wchar_t *, int *); +__declspec(dllimport) wchar_t* __stdcall GetEnvironmentStringsW(void); +__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t*); +__declspec(dllimport) wchar_t* __stdcall GetCommandLineW(void); +__declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(const wchar_t*, int*); __declspec(dllimport) unsigned long __stdcall GetLastError(); -__declspec(dllimport) void *__stdcall LocalFree(void *); -__declspec(dllimport) int __stdcall SetEnvironmentVariableW(const wchar_t *, const wchar_t *); -__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(const wchar_t *, wchar_t *, unsigned long); +__declspec(dllimport) void* __stdcall LocalFree(void*); +__declspec(dllimport) int __stdcall SetEnvironmentVariableW(const wchar_t*, const wchar_t*); +__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(const wchar_t*, wchar_t*, unsigned long); } #endif diff --git a/src/iostream.cpp b/src/iostream.cpp index 3667353..a46bc4a 100644 --- a/src/iostream.cpp +++ b/src/iostream.cpp @@ -78,15 +78,15 @@ namespace nowide { } private: - int write(const char *p, int n) + int write(const char* p, int n) { namespace uf = detail::utf; - const char *b = p; - const char *e = p + n; + const char* b = p; + const char* e = p + n; DWORD size = 0; if(n > buffer_size) return -1; - wchar_t *out = wbuffer_; + wchar_t* out = wbuffer_; uf::code_point c; size_t decoded = 0; while(p < e && (c = uf::utf_traits::decode(p, e)) != uf::incomplete) @@ -129,8 +129,8 @@ namespace nowide { if(pback_buffer_.empty()) { pback_buffer_.resize(4); - char *b = &pback_buffer_[0]; - char *e = b + pback_buffer_.size(); + char* b = &pback_buffer_[0]; + char* e = b + pback_buffer_.size(); setg(b, e - 1, e); *gptr() = traits_type::to_char_type(c); } else @@ -140,9 +140,9 @@ namespace nowide { tmp.resize(n * 2); memcpy(&tmp[n], &pback_buffer_[0], n); tmp.swap(pback_buffer_); - char *b = &pback_buffer_[0]; - char *e = b + n * 2; - char *p = b + n - 1; + char* b = &pback_buffer_[0]; + char* e = b + n * 2; + char* p = b + n - 1; *p = traits_type::to_char_type(c); setg(b, p, e); } @@ -173,10 +173,10 @@ namespace nowide { if(!ReadConsoleW(handle_, wbuffer_, static_cast(n), &read_wchars, 0)) return 0; wsize_ += read_wchars; - char *out = buffer_; - wchar_t *b = wbuffer_; - wchar_t *e = b + wsize_; - wchar_t *p = b; + char* out = buffer_; + wchar_t* b = wbuffer_; + wchar_t* e = b + wsize_; + wchar_t* p = b; uf::code_point c = 0; wsize_ = e - p; while(p < e && (c = uf::utf_traits::decode(p, e)) != uf::illegal && c != uf::incomplete) @@ -205,7 +205,7 @@ namespace nowide { std::vector pback_buffer_; }; - winconsole_ostream::winconsole_ostream(int fd, winconsole_ostream *tieStream) : std::ostream(0) + winconsole_ostream::winconsole_ostream(int fd, winconsole_ostream* tieStream) : std::ostream(0) { HANDLE h = 0; switch(fd) @@ -233,7 +233,7 @@ namespace nowide { {} } - winconsole_istream::winconsole_istream(winconsole_ostream *tieStream) : std::istream(0) + winconsole_istream::winconsole_istream(winconsole_ostream* tieStream) : std::istream(0) { HANDLE h = GetStdHandle(STD_INPUT_HANDLE); if(is_atty_handle(h)) diff --git a/standalone/scoped_ptr.hpp b/standalone/scoped_ptr.hpp index b16d043..37761a9 100644 --- a/standalone/scoped_ptr.hpp +++ b/standalone/scoped_ptr.hpp @@ -25,20 +25,20 @@ template class scoped_ptr // noncopyable { private: - T *px; + T* px; - scoped_ptr(scoped_ptr const &); - scoped_ptr &operator=(scoped_ptr const &); + scoped_ptr(scoped_ptr const&); + scoped_ptr& operator=(scoped_ptr const&); typedef scoped_ptr this_type; - void operator==(scoped_ptr const &) const; - void operator!=(scoped_ptr const &) const; + void operator==(scoped_ptr const&) const; + void operator!=(scoped_ptr const&) const; public: typedef T element_type; - explicit scoped_ptr(T *p = 0) : px(p) // never throws + explicit scoped_ptr(T* p = 0) : px(p) // never throws {} ~scoped_ptr() // never throws @@ -46,25 +46,25 @@ public: delete px; } - void reset(T *p = 0) // never throws + void reset(T* p = 0) // never throws { assert(p == 0 || p != px); // catch self-reset errors this_type(p).swap(*this); } - T &operator*() const // never throws + T& operator*() const // never throws { assert(px != 0); return *px; } - T *operator->() const // never throws + T* operator->() const // never throws { assert(px != 0); return px; } - T *get() const // never throws + T* get() const // never throws { return px; } @@ -74,9 +74,9 @@ public: return px != 0; } - void swap(scoped_ptr &b) // never throws + void swap(scoped_ptr& b) // never throws { - T *tmp = b.px; + T* tmp = b.px; b.px = px; px = tmp; } diff --git a/test/benchmark_fstream.cpp b/test/benchmark_fstream.cpp index 0e7a26b..4ddd0f7 100644 --- a/test/benchmark_fstream.cpp +++ b/test/benchmark_fstream.cpp @@ -27,16 +27,16 @@ template class io_fstream { public: - void open(const char *file) + void open(const char* file) { f_.open(file, std::fstream::out | std::fstream::in | std::fstream::trunc); TEST(f_); } - void write(char *buf, int size) + void write(char* buf, int size) { f_.write(buf, size); } - void read(char *buf, int size) + void read(char* buf, int size) { f_.read(buf, size); } @@ -61,16 +61,16 @@ private: class io_stdio { public: - void open(const char *file) + void open(const char* file) { f_ = fopen(file, "w+"); TEST(f_); } - void write(char *buf, int size) + void write(char* buf, int size) { fwrite(buf, 1, size, f_); } - void read(char *buf, int size) + void read(char* buf, int size) { size_t res = fread(buf, 1, size, f_); (void)res; @@ -90,11 +90,11 @@ public: } private: - FILE *f_; + FILE* f_; }; template -void test_io(const char *file, const char *type) +void test_io(const char* file, const char* type) { std::cout << "Testing I/O performance " << type << std::endl; FStream tmp; @@ -139,14 +139,14 @@ void test_io(const char *file, const char *type) std::remove(file); } -void test_perf(const char *file) +void test_perf(const char* file) { test_io(file, "stdio"); test_io >(file, "std::fstream"); test_io >(file, "nowide::fstream"); } -int main(int argc, char **argv) +int main(int argc, char** argv) { std::string filename = "perf_test_file.dat"; if(argc == 2) diff --git a/test/exampleProject/example_main.cpp b/test/exampleProject/example_main.cpp index 1c246c7..9124598 100644 --- a/test/exampleProject/example_main.cpp +++ b/test/exampleProject/example_main.cpp @@ -9,7 +9,7 @@ #include #include -int main(int argc, char **argv, char **env) +int main(int argc, char** argv, char** env) { boost::nowide::args _(argc, argv, env); if(argc < 1) diff --git a/test/test.hpp b/test/test.hpp index e5f6fae..c7faeea 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -13,7 +13,7 @@ #include /// Function called when a test failed to be able set a breakpoint for debugging -inline void test_failed(const std::string &msg) +inline void test_failed(const std::string& msg) { throw std::runtime_error(msg); } diff --git a/test/test_codecvt.cpp b/test/test_codecvt.cpp index 0ae978c..29f48fa 100644 --- a/test/test_codecvt.cpp +++ b/test/test_codecvt.cpp @@ -16,11 +16,11 @@ #include #include -static const char *utf8_name = "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt"; +static const char* utf8_name = "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt"; static const std::wstring wide_name_str = boost::nowide::widen(utf8_name); -static const wchar_t *wide_name = wide_name_str.c_str(); +static const wchar_t* wide_name = wide_name_str.c_str(); -const char *res(std::codecvt_base::result r) +const char* res(std::codecvt_base::result r) { switch(r) { @@ -34,15 +34,15 @@ const char *res(std::codecvt_base::result r) typedef std::codecvt cvt_type; -void test_codecvt_in_n_m(const cvt_type &cvt, int n, int m) +void test_codecvt_in_n_m(const cvt_type& cvt, int n, int m) { - const wchar_t *wptr = wide_name; + const wchar_t* wptr = wide_name; size_t wlen = std::wcslen(wide_name); size_t u8len = std::strlen(utf8_name); - const char *from = utf8_name; - const char *end = from; - const char *real_end = utf8_name + u8len; - const char *from_next = from; + const char* from = utf8_name; + const char* end = from; + const char* real_end = utf8_name + u8len; + const char* from_next = from; std::mbstate_t mb = std::mbstate_t(); while(from_next < real_end) { @@ -54,9 +54,9 @@ void test_codecvt_in_n_m(const cvt_type &cvt, int n, int m) } wchar_t buf[128]; - wchar_t *to = buf; - wchar_t *to_end = to + m; - wchar_t *to_next = to; + wchar_t* to = buf; + wchar_t* to_end = to + m; + wchar_t* to_next = to; std::mbstate_t mb2 = mb; std::codecvt_base::result r = cvt.in(mb, from, end, from_next, to, to_end, to_next); @@ -95,27 +95,27 @@ void test_codecvt_in_n_m(const cvt_type &cvt, int n, int m) TEST(from == real_end); } -void test_codecvt_out_n_m(const cvt_type &cvt, int n, int m) +void test_codecvt_out_n_m(const cvt_type& cvt, int n, int m) { - const char *nptr = utf8_name; + const char* nptr = utf8_name; size_t wlen = std::wcslen(wide_name); size_t u8len = std::strlen(utf8_name); std::mbstate_t mb = std::mbstate_t(); - const wchar_t *from_next = wide_name; - const wchar_t *real_from_end = wide_name + wlen; + const wchar_t* from_next = wide_name; + const wchar_t* real_from_end = wide_name + wlen; char buf[256]; - char *to = buf; - char *to_next = to; - char *to_end = to + n; - char *real_to_end = buf + sizeof(buf); + char* to = buf; + char* to_next = to; + char* to_end = to + n; + char* real_to_end = buf + sizeof(buf); while(from_next < real_from_end) { - const wchar_t *from = from_next; - const wchar_t *from_end = from + m; + const wchar_t* from = from_next; + const wchar_t* from_end = from + m; if(from_end > real_from_end) from_end = real_from_end; if(to_end == to) @@ -156,7 +156,7 @@ void test_codecvt_conv() std::cout << "Conversions " << std::endl; std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt()); - const cvt_type &cvt = std::use_facet(l); + const cvt_type& cvt = std::use_facet(l); for(int i = 1; i <= (int)std::strlen(utf8_name) + 1; i++) { @@ -180,20 +180,20 @@ void test_codecvt_err() std::cout << "Errors " << std::endl; std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt()); - const cvt_type &cvt = std::use_facet(l); + const cvt_type& cvt = std::use_facet(l); std::cout << "- UTF-8" << std::endl; { wchar_t buf[4]; - wchar_t *const to = buf; - wchar_t *const to_end = buf + 4; - const char *err_utf = "1\xFF\xFF\xd7\xa9"; + wchar_t* const to = buf; + wchar_t* const to_end = buf + 4; + const char* err_utf = "1\xFF\xFF\xd7\xa9"; { std::mbstate_t mb = std::mbstate_t(); - const char *from = err_utf; - const char *from_end = from + std::strlen(from); - const char *from_next = from; - wchar_t *to_next = to; + const char* from = err_utf; + const char* from_end = from + std::strlen(from); + const char* from_next = from; + wchar_t* to_next = to; TEST(cvt.in(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok); TEST(from_next == from + 5); TEST(to_next == to + 4); @@ -204,16 +204,16 @@ void test_codecvt_err() std::cout << "- UTF-16/32" << std::endl; { char buf[32]; - char *to = buf; - char *to_end = buf + 32; - char *to_next = to; + char* to = buf; + char* to_end = buf + 32; + char* to_next = to; wchar_t err_buf[3] = {'1', 0xDC9E, 0}; // second surrogate not works both for UTF-16 and 32 - const wchar_t *err_utf = err_buf; + const wchar_t* err_utf = err_buf; { std::mbstate_t mb = std::mbstate_t(); - const wchar_t *from = err_utf; - const wchar_t *from_end = from + std::wcslen(from); - const wchar_t *from_next = from; + const wchar_t* from = err_utf; + const wchar_t* from_end = from + std::wcslen(from); + const wchar_t* from_next = from; TEST(cvt.out(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok); TEST(from_next == from + 2); TEST(to_next == to + 4); @@ -222,21 +222,21 @@ void test_codecvt_err() } } -std::wstring codecvt_to_wide(const std::string &s) +std::wstring codecvt_to_wide(const std::string& s) { std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt()); - const cvt_type &cvt = std::use_facet(l); + const cvt_type& cvt = std::use_facet(l); std::mbstate_t mb = std::mbstate_t(); - const char *from = s.c_str(); - const char *from_end = from + s.size(); - const char *from_next = from; + const char* from = s.c_str(); + const char* from_end = from + s.size(); + const char* from_next = from; std::vector buf(s.size() + 1); - wchar_t *to = &buf[0]; - wchar_t *to_end = to + buf.size(); - wchar_t *to_next = to; + wchar_t* to = &buf[0]; + wchar_t* to_end = to + buf.size(); + wchar_t* to_next = to; TEST(cvt.in(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok); @@ -244,21 +244,21 @@ std::wstring codecvt_to_wide(const std::string &s) return res; } -std::string codecvt_to_narrow(const std::wstring &s) +std::string codecvt_to_narrow(const std::wstring& s) { std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt()); - const cvt_type &cvt = std::use_facet(l); + const cvt_type& cvt = std::use_facet(l); std::mbstate_t mb = std::mbstate_t(); - const wchar_t *from = s.c_str(); - const wchar_t *from_end = from + s.size(); - const wchar_t *from_next = from; + const wchar_t* from = s.c_str(); + const wchar_t* from_end = from + s.size(); + const wchar_t* from_next = from; std::vector buf(s.size() * 4 + 1); - char *to = &buf[0]; - char *to_end = to + buf.size(); - char *to_next = to; + char* to = &buf[0]; + char* to_end = to + buf.size(); + char* to_next = to; TEST(cvt.out(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok); @@ -280,7 +280,7 @@ int main() test_codecvt_err(); test_codecvt_subst(); - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed : " << e.what() << std::endl; return 1; diff --git a/test/test_convert.cpp b/test/test_convert.cpp index fb6bf8b..dcb3d10 100644 --- a/test/test_convert.cpp +++ b/test/test_convert.cpp @@ -29,8 +29,8 @@ int main() std::cout << "- boost::nowide::widen" << std::endl; { - const char *b = hello.c_str(); - const char *e = b + 8; + const char* b = hello.c_str(); + const char* e = b + 8; wchar_t buf[6] = {0, 0, 0, 0, 0, 1}; TEST(boost::nowide::widen(buf, 5, b, e) == buf); TEST(buf == whello); @@ -60,8 +60,8 @@ int main() } std::cout << "- boost::nowide::narrow" << std::endl; { - const wchar_t *b = whello.c_str(); - const wchar_t *e = b + 4; + const wchar_t* b = whello.c_str(); + const wchar_t* e = b + 4; char buf[10] = {0}; buf[9] = 1; TEST(boost::nowide::narrow(buf, 9, b, e) == buf); @@ -88,7 +88,7 @@ int main() } std::cout << "- Substitutions" << std::endl; run_all(boost::nowide::widen, boost::nowide::narrow); - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed :" << e.what() << std::endl; return 1; diff --git a/test/test_env.cpp b/test/test_env.cpp index 6f379c3..1fa9629 100644 --- a/test/test_env.cpp +++ b/test/test_env.cpp @@ -41,7 +41,7 @@ int main() // Passing a variable without an equals sign (before \0) is an error // But GLIBC has an extension that unsets the env var instead char penv2[256] = {0}; - const char *sPenv2 = "BOOST_TEST1SOMEGARBAGE="; + const char* sPenv2 = "BOOST_TEST1SOMEGARBAGE="; strncpy(penv2, sPenv2, sizeof(penv2) - 1); // End the string before the equals sign -> Expect fail penv2[strlen("BOOST_TEST1")] = '\0'; @@ -49,7 +49,7 @@ int main() TEST(boost::nowide::getenv("BOOST_TEST1")); TEST(boost::nowide::getenv("BOOST_TEST1") == example); #endif - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed " << e.what() << std::endl; return 1; diff --git a/test/test_fs.cpp b/test/test_fs.cpp index 09f245e..ea801a9 100644 --- a/test/test_fs.cpp +++ b/test/test_fs.cpp @@ -37,7 +37,7 @@ int main() TEST(!boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name))); TEST(!boost::filesystem::is_regular_file(utf8_name)); - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed : " << e.what() << std::endl; return 1; diff --git a/test/test_fstream.cpp b/test/test_fstream.cpp index d3c755f..7b4c8a1 100644 --- a/test/test_fstream.cpp +++ b/test/test_fstream.cpp @@ -16,15 +16,15 @@ namespace nw = boost::nowide; -void make_empty_file(const char *filepath) +void make_empty_file(const char* filepath) { nw::ofstream f(filepath, std::ios_base::out | std::ios::trunc); TEST(f); } -bool file_exists(const char *filepath) +bool file_exists(const char* filepath) { - FILE *f = nw::fopen(filepath, "r"); + FILE* f = nw::fopen(filepath, "r"); if(f) { std::fclose(f); @@ -34,9 +34,9 @@ bool file_exists(const char *filepath) } template -bool file_contents_equal(const char *filepath, const char (&contents)[N], bool binary_mode = false) +bool file_contents_equal(const char* filepath, const char (&contents)[N], bool binary_mode = false) { - FILE *f = nw::fopen(filepath, binary_mode ? "rb" : "r"); + FILE* f = nw::fopen(filepath, binary_mode ? "rb" : "r"); if(!f) return false; for(size_t i = 0; i + 1 < N; i++) @@ -51,7 +51,7 @@ bool file_contents_equal(const char *filepath, const char (&contents)[N], bool b } template -void test_with_different_buffer_sizes(const char *filepath) +void test_with_different_buffer_sizes(const char* filepath) { /* Important part of the standard for mixing input with output: However, output shall not be directly followed by input without an intervening call to the fflush function @@ -131,7 +131,7 @@ void test_with_different_buffer_sizes(const char *filepath) } template -void test_close(const char *filepath) +void test_close(const char* filepath) { const std::string filepath2 = std::string(filepath) + ".2"; // Make sure file does not exist yet @@ -156,7 +156,7 @@ void test_close(const char *filepath) } template -void test_flush(const char *filepath) +void test_flush(const char* filepath) { OFStream fo(filepath, std::ios_base::out | std::ios::trunc); TEST(fo); @@ -179,7 +179,7 @@ void test_flush(const char *filepath) } } -void test_ofstream_creates_file(const char *filename) +void test_ofstream_creates_file(const char* filename) { nw::remove(filename); TEST(!file_exists(filename)); @@ -203,7 +203,7 @@ void test_ofstream_creates_file(const char *filename) } // Create filename file with content "test\n" -void test_ofstream_write(const char *filename) +void test_ofstream_write(const char* filename) { // char* ctor { @@ -259,7 +259,7 @@ void test_ofstream_write(const char *filename) TEST(nw::remove(filename) == 0); } -void test_ifstream_open_read(const char *filename) +void test_ifstream_open_read(const char* filename) { // Create test file { @@ -336,7 +336,7 @@ void test_ifstream_open_read(const char *filename) } } -void test_fstream(const char *filename) +void test_fstream(const char* filename) { nw::remove(filename); TEST(!file_exists(filename)); @@ -436,16 +436,16 @@ void test_fstream(const char *filename) } template -bool is_open(T &stream) +bool is_open(T& stream) { // There const are and const non versions of is_open // Test both - TEST(stream.is_open() == const_cast(stream).is_open()); + TEST(stream.is_open() == const_cast(stream).is_open()); return stream.is_open(); } template -void do_test_is_open(const char *filename) +void do_test_is_open(const char* filename) { T f; TEST(!is_open(f)); @@ -457,7 +457,7 @@ void do_test_is_open(const char *filename) TEST(!is_open(f)); } -void test_is_open(const char *filename) +void test_is_open(const char* filename) { // Note the order: Output before input so file exists do_test_is_open(filename); @@ -466,7 +466,7 @@ void test_is_open(const char *filename) TEST(nw::remove(filename) == 0); } -int main(int, char **argv) +int main(int, char** argv) { const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt"; try @@ -494,7 +494,7 @@ int main(int, char **argv) test_flush(exampleFilename.c_str()); std::cout << "Flush - Test" << std::endl; test_flush(exampleFilename.c_str()); - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << e.what() << std::endl; return 1; diff --git a/test/test_iostream.cpp b/test/test_iostream.cpp index 05ea69e..d241184 100644 --- a/test/test_iostream.cpp +++ b/test/test_iostream.cpp @@ -13,7 +13,7 @@ #include "test.hpp" -bool isValidUTF8(const std::string &s) +bool isValidUTF8(const std::string& s) { using namespace boost::nowide::detail::utf; for(std::string::const_iterator it = s.begin(); it != s.end();) @@ -25,9 +25,9 @@ bool isValidUTF8(const std::string &s) return true; } -int main(int argc, char **argv) +int main(int argc, char** argv) { - const char *example = "Basic letters: \xd7\xa9-\xd0\xbc-\xce\xbd\n" + const char* example = "Basic letters: \xd7\xa9-\xd0\xbc-\xce\xbd\n" "East Asian Letters: \xe5\x92\x8c\xe5\xb9\xb3\n" "Non-BMP letters: \xf0\x9d\x84\x9e\n" "Invalid UTF-8: `\xFF' `\xd7\xFF' `\xe5\xFF\x8c' `\xf0\x9d\x84\xFF' \n" @@ -67,7 +67,7 @@ int main(int argc, char **argv) boost::nowide::cout << "Flushing each character:" << std::endl; - for(const char *s = example; *s; s++) + for(const char* s = example; *s; s++) { boost::nowide::cout << *s << std::flush; TEST(boost::nowide::cout); @@ -86,7 +86,7 @@ int main(int argc, char **argv) boost::nowide::cout << "Second: " << v2 << std::endl; TEST(boost::nowide::cout); } - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Fail: " << e.what() << std::endl; return 1; diff --git a/test/test_sets.hpp b/test/test_sets.hpp index 41878db..74b0632 100644 --- a/test/test_sets.hpp +++ b/test/test_sets.hpp @@ -14,14 +14,14 @@ struct utf8_to_wide { - const char *utf8; - const wchar_t *wide; + const char* utf8; + const wchar_t* wide; }; struct wide_to_utf8 { - const wchar_t *wide; - const char *utf8; + const wchar_t* wide; + const char* utf8; }; #if defined(BOOST_MSVC) && BOOST_MSVC < 1700 @@ -75,7 +75,7 @@ wide_to_utf8 w2n_tests_utf32[] = { #pragma warning(disable : 4127) // Constant expression detected #endif -void run_all(std::wstring (*to_wide)(const std::string &), std::string (*to_narrow)(const std::wstring &)) +void run_all(std::wstring (*to_wide)(const std::string&), std::string (*to_narrow)(const std::wstring&)) { for(size_t i = 0; i < sizeof(n2w_tests) / sizeof(n2w_tests[0]); i++) { @@ -83,7 +83,7 @@ void run_all(std::wstring (*to_wide)(const std::string &), std::string (*to_narr TEST(to_wide(n2w_tests[i].utf8) == n2w_tests[i].wide); } int total = 0; - const wide_to_utf8 *ptr = 0; + const wide_to_utf8* ptr = 0; if(sizeof(wchar_t) == 2) { ptr = w2n_tests_utf16; diff --git a/test/test_stackstring.cpp b/test/test_stackstring.cpp index 465f1fa..6d1c4ee 100644 --- a/test/test_stackstring.cpp +++ b/test/test_stackstring.cpp @@ -15,13 +15,13 @@ #pragma warning(disable : 4428) // universal-character-name encountered in source #endif -std::wstring stackstring_to_wide(const std::string &s) +std::wstring stackstring_to_wide(const std::string& s) { const boost::nowide::wstackstring ss(s.c_str()); return ss.get(); } -std::string stackstring_to_narrow(const std::wstring &s) +std::string stackstring_to_narrow(const std::wstring& s) { const boost::nowide::stackstring ss(s.c_str()); return ss.get(); @@ -33,7 +33,7 @@ int main() { std::string hello = "\xd7\xa9\xd7\x9c\xd7\x95\xd7\x9d"; std::wstring whello = L"\u05e9\u05dc\u05d5\u05dd"; - const wchar_t *wempty = L""; + const wchar_t* wempty = L""; { // Default constructed string is NULL @@ -170,7 +170,7 @@ int main() } std::cout << "- Substitutions" << std::endl; run_all(stackstring_to_wide, stackstring_to_narrow); - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed :" << e.what() << std::endl; return 1; diff --git a/test/test_stdio.cpp b/test/test_stdio.cpp index 053d66b..92c6efa 100644 --- a/test/test_stdio.cpp +++ b/test/test_stdio.cpp @@ -17,12 +17,12 @@ #pragma warning(disable : 4996) // function unsafe/deprecated #endif -bool file_exists(const std::string &filename) +bool file_exists(const std::string& filename) { #ifdef BOOST_WINDOWS - FILE *f = _wfopen(boost::nowide::widen(filename).c_str(), L"r"); + FILE* f = _wfopen(boost::nowide::widen(filename).c_str(), L"r"); #else - FILE *f = std::fopen(filename.c_str(), "r"); + FILE* f = std::fopen(filename.c_str(), "r"); #endif bool result = false; if(f) @@ -33,19 +33,19 @@ bool file_exists(const std::string &filename) return result; } -void create_test_file(const std::string &filename) +void create_test_file(const std::string& filename) { #ifdef BOOST_WINDOWS - FILE *f = _wfopen(boost::nowide::widen(filename).c_str(), L"w"); + FILE* f = _wfopen(boost::nowide::widen(filename).c_str(), L"w"); #else - FILE *f = std::fopen(filename.c_str(), "w"); + FILE* f = std::fopen(filename.c_str(), "w"); #endif TEST(f); TEST(std::fputs("test\n", f) >= 0); std::fclose(f); } -int main(int, char **argv) +int main(int, char** argv) { const std::string prefix = argv[0]; const std::string filename = prefix + "\xd7\xa9-\xd0\xbc-\xce\xbd.txt"; @@ -55,7 +55,7 @@ int main(int, char **argv) // fopen - existing file { create_test_file(filename); - FILE *f = boost::nowide::fopen(filename.c_str(), "r"); + FILE* f = boost::nowide::fopen(filename.c_str(), "r"); TEST(f); char buf[16]; TEST(std::fgets(buf, 16, f) != 0); @@ -79,7 +79,7 @@ int main(int, char **argv) // freopen { create_test_file(filename); - FILE *f = boost::nowide::fopen(filename.c_str(), "r+"); + FILE* f = boost::nowide::fopen(filename.c_str(), "r+"); TEST(f); // Can read & write { @@ -92,7 +92,7 @@ int main(int, char **argv) // Reopen in read mode // Note that changing the mode is not possibly on all implementations // E.g. MSVC disallows NULL completely as the file parameter - FILE *f2 = boost::nowide::freopen(NULL, "r", f); + FILE* f2 = boost::nowide::freopen(NULL, "r", f); if(!f2) f2 = boost::nowide::freopen(filename.c_str(), "r", f); // no write possible @@ -134,7 +134,7 @@ int main(int, char **argv) TEST(boost::nowide::remove(filename.c_str()) < 0); TEST(boost::nowide::remove(filename2.c_str()) == 0); } - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed " << e.what() << std::endl; return 1; diff --git a/test/test_system.cpp b/test/test_system.cpp index c544164..76aecec 100644 --- a/test/test_system.cpp +++ b/test/test_system.cpp @@ -12,7 +12,7 @@ #include #include -int main(int argc, char **argv, char **env) +int main(int argc, char** argv, char** env) { try { @@ -27,11 +27,11 @@ int main(int argc, char **argv, char **env) TEST(boost::nowide::getenv("BOOST_NOWIDE_TEST") == example); std::string sample = "BOOST_NOWIDE_TEST=" + example; bool found = false; - for(char **e = env; *e != 0; e++) + for(char** e = env; *e != 0; e++) { - char *eptr = *e; + char* eptr = *e; // printf("%s\n",eptr); - char *key_end = strchr(eptr, '='); + char* key_end = strchr(eptr, '='); TEST(key_end); std::string key = std::string(eptr, key_end); std::string value = key_end + 1; @@ -62,7 +62,7 @@ int main(int argc, char **argv, char **env) std::cout << "Wide Parent ok" << std::endl; #endif } - } catch(const std::exception &e) + } catch(const std::exception& e) { std::cerr << "Failed " << e.what() << std::endl; return 1;