clang-format everything
Change-Id: I37d07b604fe89b9a893503514ef9dc51347a23c6
Reviewed-on: https://gn-review.googlesource.com/1625
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/base/bind.h b/base/bind.h
index aab6828..71df0fe 100644
--- a/base/bind.h
+++ b/base/bind.h
@@ -175,8 +175,9 @@
// Bind as OnceCallback.
template <typename Functor, typename... Args>
-inline OnceCallback<MakeUnboundRunType<Functor, Args...>>
-BindOnce(Functor&& functor, Args&&... args) {
+inline OnceCallback<MakeUnboundRunType<Functor, Args...>> BindOnce(
+ Functor&& functor,
+ Args&&... args) {
static_assert(!internal::IsOnceCallback<std::decay_t<Functor>>() ||
(std::is_rvalue_reference<Functor&&>() &&
!std::is_const<std::remove_reference_t<Functor>>()),
@@ -212,14 +213,14 @@
using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
return CallbackType(new BindState(
reinterpret_cast<InvokeFuncStorage>(invoke_func),
- std::forward<Functor>(functor),
- std::forward<Args>(args)...));
+ std::forward<Functor>(functor), std::forward<Args>(args)...));
}
// Bind as RepeatingCallback.
template <typename Functor, typename... Args>
-inline RepeatingCallback<MakeUnboundRunType<Functor, Args...>>
-BindRepeating(Functor&& functor, Args&&... args) {
+inline RepeatingCallback<MakeUnboundRunType<Functor, Args...>> BindRepeating(
+ Functor&& functor,
+ Args&&... args) {
static_assert(
!internal::IsOnceCallback<std::decay_t<Functor>>(),
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
@@ -253,16 +254,15 @@
using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
return CallbackType(new BindState(
reinterpret_cast<InvokeFuncStorage>(invoke_func),
- std::forward<Functor>(functor),
- std::forward<Args>(args)...));
+ std::forward<Functor>(functor), std::forward<Args>(args)...));
}
// Unannotated Bind.
// TODO(tzik): Deprecate this and migrate to OnceCallback and
// RepeatingCallback, once they get ready.
template <typename Functor, typename... Args>
-inline Callback<MakeUnboundRunType<Functor, Args...>>
-Bind(Functor&& functor, Args&&... args) {
+inline Callback<MakeUnboundRunType<Functor, Args...>> Bind(Functor&& functor,
+ Args&&... args) {
return base::BindRepeating(std::forward<Functor>(functor),
std::forward<Args>(args)...);
}
diff --git a/base/callback_internal.cc b/base/callback_internal.cc
index 6cef841..c52d8af 100644
--- a/base/callback_internal.cc
+++ b/base/callback_internal.cc
@@ -23,8 +23,7 @@
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
void (*destructor)(const BindStateBase*))
- : BindStateBase(polymorphic_invoke, destructor, &ReturnFalse) {
-}
+ : BindStateBase(polymorphic_invoke, destructor, &ReturnFalse) {}
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
void (*destructor)(const BindStateBase*),
diff --git a/base/callback_internal.h b/base/callback_internal.h
index 5139e6b..7e5180f 100644
--- a/base/callback_internal.h
+++ b/base/callback_internal.h
@@ -62,7 +62,7 @@
public:
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
- using InvokeFuncStorage = void(*)();
+ using InvokeFuncStorage = void (*)();
private:
BindStateBase(InvokeFuncStorage polymorphic_invoke,
@@ -84,9 +84,7 @@
friend struct BindState;
friend struct ::base::FakeBindState;
- bool IsCancelled() const {
- return is_cancelled_(this);
- }
+ bool IsCancelled() const { return is_cancelled_(this); }
// In C++, it is safe to cast function pointers to function pointers of
// another type. It is not okay to use void*. We create a InvokeFuncStorage
diff --git a/base/callback_list.h b/base/callback_list.h
index f455c65..cced145 100644
--- a/base/callback_list.h
+++ b/base/callback_list.h
@@ -76,9 +76,7 @@
public:
Subscription(CallbackListBase<CallbackType>* list,
typename std::list<CallbackType>::iterator iter)
- : list_(list),
- iter_(iter) {
- }
+ : list_(list), iter_(iter) {}
~Subscription() {
if (list_->active_iterator_count_) {
@@ -123,14 +121,12 @@
class Iterator {
public:
explicit Iterator(CallbackListBase<CallbackType>* list)
- : list_(list),
- list_iter_(list_->callbacks_.begin()) {
+ : list_(list), list_iter_(list_->callbacks_.begin()) {
++list_->active_iterator_count_;
}
Iterator(const Iterator& iter)
- : list_(iter.list_),
- list_iter_(iter.list_iter_) {
+ : list_(iter.list_), list_iter_(iter.list_iter_) {
++list_->active_iterator_count_;
}
@@ -166,9 +162,7 @@
// Returns an instance of a CallbackListBase::Iterator which can be used
// to run callbacks.
- Iterator GetIterator() {
- return Iterator(this);
- }
+ Iterator GetIterator() { return Iterator(this); }
// Compact the list: remove any entries which were nulled out during
// iteration.
@@ -198,7 +192,8 @@
} // namespace internal
-template <typename Sig> class CallbackList;
+template <typename Sig>
+class CallbackList;
template <typename... Args>
class CallbackList<void(Args...)>
diff --git a/base/command_line.cc b/base/command_line.cc
index 134ffb8..a49ca71 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -19,6 +19,7 @@
#if defined(OS_WIN)
#include <windows.h>
+
#include <shellapi.h>
#endif
@@ -123,7 +124,8 @@
if (arg[i] == '\\') {
// Find the extent of this run of backslashes.
size_t start = i, end = start + 1;
- for (; end < arg.size() && arg[end] == '\\'; ++end) {}
+ for (; end < arg.size() && arg[end] == '\\'; ++end) {
+ }
size_t backslash_count = end - start;
// Backslashes are escapes only if the run is followed by a double quote.
@@ -153,26 +155,18 @@
} // namespace
-CommandLine::CommandLine(NoProgram no_program)
- : argv_(1),
- begin_args_(1) {
-}
+CommandLine::CommandLine(NoProgram no_program) : argv_(1), begin_args_(1) {}
-CommandLine::CommandLine(const FilePath& program)
- : argv_(1),
- begin_args_(1) {
+CommandLine::CommandLine(const FilePath& program) : argv_(1), begin_args_(1) {
SetProgram(program);
}
CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
- : argv_(1),
- begin_args_(1) {
+ : argv_(1), begin_args_(1) {
InitFromArgv(argc, argv);
}
-CommandLine::CommandLine(const StringVector& argv)
- : argv_(1),
- begin_args_(1) {
+CommandLine::CommandLine(const StringVector& argv) : argv_(1), begin_args_(1) {
InitFromArgv(argv);
}
diff --git a/base/command_line.h b/base/command_line.h
index c8394ee..7530d66 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -174,8 +174,7 @@
// Append a switch [with optional value] to the command line.
// Note: Switches will precede arguments regardless of appending order.
void AppendSwitch(const std::string& switch_string);
- void AppendSwitchPath(const std::string& switch_string,
- const FilePath& path);
+ void AppendSwitchPath(const std::string& switch_string, const FilePath& path);
void AppendSwitchNative(const std::string& switch_string,
const StringType& value);
void AppendSwitchASCII(const std::string& switch_string,
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index c27c7bc..b548aa6 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -25,12 +25,12 @@
// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and
// for the next line of the source file.
-#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n))
+#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress : n))
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
// The warning remains disabled until popped by MSVC_POP_WARNING.
-#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
- __pragma(warning(disable:n))
+#define MSVC_PUSH_DISABLE_WARNING(n) \
+ __pragma(warning(push)) __pragma(warning(disable : n))
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
@@ -136,7 +136,7 @@
// (This is undocumented but matches what the system C headers do.)
#if defined(COMPILER_GCC) || defined(__clang__)
#define PRINTF_FORMAT(format_param, dots_param) \
- __attribute__((format(printf, format_param, dots_param)))
+ __attribute__((format(printf, format_param, dots_param)))
#else
#define PRINTF_FORMAT(format_param, dots_param)
#endif
@@ -165,14 +165,14 @@
// Mark a memory region fully initialized.
// Use this to annotate code that deliberately reads uninitialized data, for
// example a GC scavenging root set pointers from the stack.
-#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
+#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
// Check a memory region for initializedness, as if it was being used here.
// If any bits are uninitialized, crash with an MSan report.
// Use this to sanitize data which MSan won't be able to track, e.g. before
// passing data to another process via shared memory.
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \
- __msan_check_mem_is_initialized(p, size)
+ __msan_check_mem_is_initialized(p, size)
#else // MEMORY_SANITIZER
#define MSAN_UNPOISON(p, size)
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size)
diff --git a/base/containers/span.h b/base/containers/span.h
index f1e0000..c971861 100644
--- a/base/containers/span.h
+++ b/base/containers/span.h
@@ -267,9 +267,9 @@
template <size_t Offset, size_t Count = dynamic_extent>
constexpr span<T,
(Count != dynamic_extent
- ? Count
- : (Extent != dynamic_extent ? Extent - Offset
- : dynamic_extent))>
+ ? Count
+ : (Extent != dynamic_extent ? Extent - Offset
+ : dynamic_extent))>
subspan() const noexcept {
static_assert(Extent == dynamic_extent || Offset <= Extent,
"Offset must not exceed Extent");
diff --git a/base/environment.cc b/base/environment.cc
index fed01d0..19bc20e 100644
--- a/base/environment.cc
+++ b/base/environment.cc
@@ -143,8 +143,7 @@
#if defined(OS_WIN)
-string16 AlterEnvironment(const wchar_t* env,
- const EnvironmentMap& changes) {
+string16 AlterEnvironment(const wchar_t* env, const EnvironmentMap& changes) {
string16 result;
// First copy all unmodified values to the output.
@@ -163,8 +162,8 @@
}
// Now append all modified and new values.
- for (EnvironmentMap::const_iterator i = changes.begin();
- i != changes.end(); ++i) {
+ for (EnvironmentMap::const_iterator i = changes.begin(); i != changes.end();
+ ++i) {
if (!i->second.empty()) {
result.append(i->first);
result.push_back('=');
@@ -203,8 +202,8 @@
}
// Now append all modified and new values.
- for (EnvironmentMap::const_iterator i = changes.begin();
- i != changes.end(); ++i) {
+ for (EnvironmentMap::const_iterator i = changes.begin(); i != changes.end();
+ ++i) {
if (!i->second.empty()) {
result_indices.push_back(value_storage.size());
value_storage.append(i->first);
@@ -220,8 +219,8 @@
std::unique_ptr<char* []> result(new char*[pointer_count_required]);
// The string storage goes after the array of pointers.
- char* storage_data = reinterpret_cast<char*>(
- &result.get()[result_indices.size() + 1]);
+ char* storage_data =
+ reinterpret_cast<char*>(&result.get()[result_indices.size() + 1]);
if (!value_storage.empty())
memcpy(storage_data, value_storage.data(), value_storage.size());
diff --git a/base/environment.h b/base/environment.h
index 2d5976d..135e3c8 100644
--- a/base/environment.h
+++ b/base/environment.h
@@ -45,7 +45,6 @@
virtual bool UnSetVar(StringPiece variable_name) = 0;
};
-
#if defined(OS_WIN)
typedef string16 NativeEnvironmentString;
@@ -62,8 +61,7 @@
// which is a concatenated list of null-terminated 16-bit strings. The end is
// marked by a double-null terminator. The size of the returned string will
// include the terminators.
-string16 AlterEnvironment(const wchar_t* env,
- const EnvironmentMap& changes);
+string16 AlterEnvironment(const wchar_t* env, const EnvironmentMap& changes);
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
@@ -78,9 +76,8 @@
// returned array will have appended to it the storage for the array itself so
// there is only one pointer to manage, but this means that you can't copy the
// array without keeping the original around.
-std::unique_ptr<char* []> AlterEnvironment(
- const char* const* env,
- const EnvironmentMap& changes);
+std::unique_ptr<char* []> AlterEnvironment(const char* const* env,
+ const EnvironmentMap& changes);
#endif
diff --git a/base/files/file.cc b/base/files/file.cc
index 7485b1a..8f779d5 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -13,19 +13,12 @@
namespace base {
-File::Info::Info()
- : size(0),
- is_directory(false),
- is_symbolic_link(false) {
-}
+File::Info::Info() : size(0), is_directory(false), is_symbolic_link(false) {}
File::Info::~Info() = default;
File::File()
- : error_details_(FILE_ERROR_FAILED),
- created_(false),
- async_(false) {
-}
+ : error_details_(FILE_ERROR_FAILED), created_(false), async_(false) {}
#if !defined(OS_NACL)
File::File(const FilePath& path, uint32_t flags)
@@ -45,10 +38,7 @@
}
File::File(Error error_details)
- : error_details_(error_details),
- created_(false),
- async_(false) {
-}
+ : error_details_(error_details), created_(false), async_(false) {}
File::File(File&& other)
: file_(other.TakePlatformFile()),
diff --git a/base/files/file.h b/base/files/file.h
index c554249..49a2cb4 100644
--- a/base/files/file.h
+++ b/base/files/file.h
@@ -106,11 +106,7 @@
};
// This explicit mapping matches both FILE_ on Windows and SEEK_ on Linux.
- enum Whence {
- FROM_BEGIN = 0,
- FROM_CURRENT = 1,
- FROM_END = 2
- };
+ enum Whence { FROM_BEGIN = 0, FROM_CURRENT = 1, FROM_END = 2 };
// Used to hold information about a given file.
// If you add more fields to this structure (platform-specific fields are OK),
@@ -361,4 +357,3 @@
} // namespace base
#endif // BASE_FILES_FILE_H_
-
diff --git a/base/files/file_enumerator.h b/base/files/file_enumerator.h
index 45ce88b..905871d 100644
--- a/base/files/file_enumerator.h
+++ b/base/files/file_enumerator.h
@@ -111,9 +111,7 @@
// since the underlying code uses OS-specific matching routines. In general,
// Windows matching is less featureful than others, so test there first.
// If unspecified, this will match all files.
- FileEnumerator(const FilePath& root_path,
- bool recursive,
- int file_type);
+ FileEnumerator(const FilePath& root_path, bool recursive, int file_type);
FileEnumerator(const FilePath& root_path,
bool recursive,
int file_type,
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 969a977..325b9b2 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -33,8 +33,8 @@
namespace {
-const char* const kCommonDoubleExtensionSuffixes[] = { "gz", "z", "bz2", "bz" };
-const char* const kCommonDoubleExtensions[] = { "user.js" };
+const char* const kCommonDoubleExtensionSuffixes[] = {"gz", "z", "bz2", "bz"};
+const char* const kCommonDoubleExtensions[] = {"user.js"};
const FilePath::CharType kStringTerminator = FILE_PATH_LITERAL('\0');
@@ -81,20 +81,19 @@
if (letter != StringType::npos) {
// Look for a separator right after the drive specification.
return path.length() > letter + 1 &&
- FilePath::IsSeparator(path[letter + 1]);
+ FilePath::IsSeparator(path[letter + 1]);
}
// Look for a pair of leading separators.
- return path.length() > 1 &&
- FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]);
-#else // FILE_PATH_USES_DRIVE_LETTERS
+ return path.length() > 1 && FilePath::IsSeparator(path[0]) &&
+ FilePath::IsSeparator(path[1]);
+#else // FILE_PATH_USES_DRIVE_LETTERS
// Look for a separator in the first position.
return path.length() > 0 && FilePath::IsSeparator(path[0]);
#endif // FILE_PATH_USES_DRIVE_LETTERS
}
bool AreAllSeparators(const StringType& input) {
- for (StringType::const_iterator it = input.begin();
- it != input.end(); ++it) {
+ for (StringType::const_iterator it = input.begin(); it != input.end(); ++it) {
if (!FilePath::IsSeparator(*it))
return false;
}
@@ -126,9 +125,8 @@
const StringType::size_type penultimate_dot =
path.rfind(FilePath::kExtensionSeparator, last_dot - 1);
- const StringType::size_type last_separator =
- path.find_last_of(FilePath::kSeparators, last_dot - 1,
- FilePath::kSeparatorsLength - 1);
+ const StringType::size_type last_separator = path.find_last_of(
+ FilePath::kSeparators, last_dot - 1, FilePath::kSeparatorsLength - 1);
if (penultimate_dot == StringType::npos ||
(last_separator != StringType::npos &&
@@ -189,7 +187,7 @@
bool FilePath::operator==(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return EqualDriveLetterCaseInsensitive(this->path_, that.path_);
-#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
+#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ == that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}
@@ -197,7 +195,7 @@
bool FilePath::operator!=(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return !EqualDriveLetterCaseInsensitive(this->path_, that.path_);
-#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
+#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ != that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}
@@ -256,8 +254,7 @@
return AppendRelativePath(child, nullptr);
}
-bool FilePath::AppendRelativePath(const FilePath& child,
- FilePath* path) const {
+bool FilePath::AppendRelativePath(const FilePath& child, FilePath* path) const {
std::vector<StringType> parent_components;
std::vector<StringType> child_components;
GetComponents(&parent_components);
@@ -269,8 +266,7 @@
std::vector<StringType>::const_iterator parent_comp =
parent_components.begin();
- std::vector<StringType>::const_iterator child_comp =
- child_components.begin();
+ std::vector<StringType>::const_iterator child_comp = child_components.begin();
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
// Windows can access case sensitive filesystems, so component
@@ -314,9 +310,8 @@
// resizes below using letter will still be valid.
StringType::size_type letter = FindDriveLetter(new_path.path_);
- StringType::size_type last_separator =
- new_path.path_.find_last_of(kSeparators, StringType::npos,
- kSeparatorsLength - 1);
+ StringType::size_type last_separator = new_path.path_.find_last_of(
+ kSeparators, StringType::npos, kSeparatorsLength - 1);
if (last_separator == StringType::npos) {
// path_ is in the current directory.
new_path.path_.resize(letter + 1);
@@ -352,9 +347,8 @@
// Keep everything after the final separator, but if the pathname is only
// one character and it's a separator, leave it alone.
- StringType::size_type last_separator =
- new_path.path_.find_last_of(kSeparators, StringType::npos,
- kSeparatorsLength - 1);
+ StringType::size_type last_separator = new_path.path_.find_last_of(
+ kSeparators, StringType::npos, kSeparatorsLength - 1);
if (last_separator != StringType::npos &&
last_separator < new_path.path_.length() - 1) {
new_path.path_.erase(0, last_separator + 1);
@@ -417,8 +411,7 @@
return FilePath(ret);
}
-FilePath FilePath::InsertBeforeExtensionASCII(StringPiece suffix)
- const {
+FilePath FilePath::InsertBeforeExtensionASCII(StringPiece suffix) const {
DCHECK(IsStringASCII(suffix));
#if defined(OS_WIN)
return InsertBeforeExtension(ASCIIToUTF16(suffix));
@@ -682,7 +675,7 @@
StringPieceType::const_iterator i2 = string2.begin();
StringPieceType::const_iterator string1end = string1.end();
StringPieceType::const_iterator string2end = string2.end();
- for ( ; i1 != string1end && i2 != string2end; ++i1, ++i2) {
+ for (; i1 != string1end && i2 != string2end; ++i1, ++i2) {
wchar_t c1 =
(wchar_t)LOWORD(char_upper_api((LPWSTR)(DWORD_PTR)MAKELONG(*i1, 0)));
wchar_t c2 =
@@ -702,7 +695,8 @@
#elif defined(OS_MACOSX)
// Mac OS X specific implementation of file string comparisons.
-// cf. http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties
+// cf.
+// http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties
//
// "When using CreateTextEncoding to create a text encoding, you should set
// the TextEncodingBase to kTextEncodingUnicodeV2_0, set the
@@ -713,7 +707,8 @@
//
// Another technical article for X 10.4 updates this: one should use
// the new (unambiguous) kUnicodeHFSPlusDecompVariant.
-// cf. http://developer.apple.com/mac/library/releasenotes/TextFonts/RN-TEC/index.html
+// cf.
+// http://developer.apple.com/mac/library/releasenotes/TextFonts/RN-TEC/index.html
//
// This implementation uses CFStringGetFileSystemRepresentation() to get the
// decomposed form, and an adapted version of the FastUnicodeCompare as
@@ -733,390 +728,390 @@
namespace {
const UInt16 lower_case_table[] = {
- // High-byte indices ( == 0 iff no case mapping and no ignorables )
+ // High-byte indices ( == 0 iff no case mapping and no ignorables )
- /* 0 */ 0x0100, 0x0200, 0x0000, 0x0300, 0x0400, 0x0500, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 1 */ 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 2 */ 0x0700, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 3 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 4 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 5 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 6 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 7 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 9 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* A */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* B */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* C */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* D */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* E */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* F */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0900, 0x0A00,
+ /* 0 */ 0x0100, 0x0200, 0x0000, 0x0300, 0x0400, 0x0500, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 1 */ 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 2 */ 0x0700, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 3 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 4 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 5 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 6 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 7 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 9 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* A */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* B */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* C */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* D */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* E */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* F */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0900, 0x0A00,
- // Table 1 (for high byte 0x00)
+ // Table 1 (for high byte 0x00)
- /* 0 */ 0xFFFF, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
- 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
- /* 1 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
- 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
- /* 2 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
- /* 3 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
- 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
- /* 4 */ 0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
- /* 5 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
- /* 6 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
- /* 7 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
- /* 8 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
- /* 9 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
- /* A */ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
- 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
- /* B */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
- 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
- /* C */ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00E6, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- /* D */ 0x00F0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
- 0x00F8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00FE, 0x00DF,
- /* E */ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- /* F */ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
- 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF,
+ /* 0 */ 0xFFFF, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ /* 1 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ /* 2 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ /* 3 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ /* 4 */ 0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ /* 5 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ /* 6 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ /* 7 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ /* 8 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ /* 9 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ /* A */ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ /* B */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ /* C */ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00E6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ /* D */ 0x00F0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00F8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00FE, 0x00DF,
+ /* E */ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ /* F */ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF,
- // Table 2 (for high byte 0x01)
+ // Table 2 (for high byte 0x01)
- /* 0 */ 0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107,
- 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F,
- /* 1 */ 0x0111, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117,
- 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F,
- /* 2 */ 0x0120, 0x0121, 0x0122, 0x0123, 0x0124, 0x0125, 0x0127, 0x0127,
- 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F,
- /* 3 */ 0x0130, 0x0131, 0x0133, 0x0133, 0x0134, 0x0135, 0x0136, 0x0137,
- 0x0138, 0x0139, 0x013A, 0x013B, 0x013C, 0x013D, 0x013E, 0x0140,
- /* 4 */ 0x0140, 0x0142, 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0147,
- 0x0148, 0x0149, 0x014B, 0x014B, 0x014C, 0x014D, 0x014E, 0x014F,
- /* 5 */ 0x0150, 0x0151, 0x0153, 0x0153, 0x0154, 0x0155, 0x0156, 0x0157,
- 0x0158, 0x0159, 0x015A, 0x015B, 0x015C, 0x015D, 0x015E, 0x015F,
- /* 6 */ 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0167, 0x0167,
- 0x0168, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F,
- /* 7 */ 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x0175, 0x0176, 0x0177,
- 0x0178, 0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E, 0x017F,
- /* 8 */ 0x0180, 0x0253, 0x0183, 0x0183, 0x0185, 0x0185, 0x0254, 0x0188,
- 0x0188, 0x0256, 0x0257, 0x018C, 0x018C, 0x018D, 0x01DD, 0x0259,
- /* 9 */ 0x025B, 0x0192, 0x0192, 0x0260, 0x0263, 0x0195, 0x0269, 0x0268,
- 0x0199, 0x0199, 0x019A, 0x019B, 0x026F, 0x0272, 0x019E, 0x0275,
- /* A */ 0x01A0, 0x01A1, 0x01A3, 0x01A3, 0x01A5, 0x01A5, 0x01A6, 0x01A8,
- 0x01A8, 0x0283, 0x01AA, 0x01AB, 0x01AD, 0x01AD, 0x0288, 0x01AF,
- /* B */ 0x01B0, 0x028A, 0x028B, 0x01B4, 0x01B4, 0x01B6, 0x01B6, 0x0292,
- 0x01B9, 0x01B9, 0x01BA, 0x01BB, 0x01BD, 0x01BD, 0x01BE, 0x01BF,
- /* C */ 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C6, 0x01C6, 0x01C6, 0x01C9,
- 0x01C9, 0x01C9, 0x01CC, 0x01CC, 0x01CC, 0x01CD, 0x01CE, 0x01CF,
- /* D */ 0x01D0, 0x01D1, 0x01D2, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7,
- 0x01D8, 0x01D9, 0x01DA, 0x01DB, 0x01DC, 0x01DD, 0x01DE, 0x01DF,
- /* E */ 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E5, 0x01E5, 0x01E6, 0x01E7,
- 0x01E8, 0x01E9, 0x01EA, 0x01EB, 0x01EC, 0x01ED, 0x01EE, 0x01EF,
- /* F */ 0x01F0, 0x01F3, 0x01F3, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7,
- 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
+ /* 0 */ 0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107,
+ 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F,
+ /* 1 */ 0x0111, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117,
+ 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F,
+ /* 2 */ 0x0120, 0x0121, 0x0122, 0x0123, 0x0124, 0x0125, 0x0127, 0x0127,
+ 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F,
+ /* 3 */ 0x0130, 0x0131, 0x0133, 0x0133, 0x0134, 0x0135, 0x0136, 0x0137,
+ 0x0138, 0x0139, 0x013A, 0x013B, 0x013C, 0x013D, 0x013E, 0x0140,
+ /* 4 */ 0x0140, 0x0142, 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0147,
+ 0x0148, 0x0149, 0x014B, 0x014B, 0x014C, 0x014D, 0x014E, 0x014F,
+ /* 5 */ 0x0150, 0x0151, 0x0153, 0x0153, 0x0154, 0x0155, 0x0156, 0x0157,
+ 0x0158, 0x0159, 0x015A, 0x015B, 0x015C, 0x015D, 0x015E, 0x015F,
+ /* 6 */ 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0167, 0x0167,
+ 0x0168, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F,
+ /* 7 */ 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x0175, 0x0176, 0x0177,
+ 0x0178, 0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E, 0x017F,
+ /* 8 */ 0x0180, 0x0253, 0x0183, 0x0183, 0x0185, 0x0185, 0x0254, 0x0188,
+ 0x0188, 0x0256, 0x0257, 0x018C, 0x018C, 0x018D, 0x01DD, 0x0259,
+ /* 9 */ 0x025B, 0x0192, 0x0192, 0x0260, 0x0263, 0x0195, 0x0269, 0x0268,
+ 0x0199, 0x0199, 0x019A, 0x019B, 0x026F, 0x0272, 0x019E, 0x0275,
+ /* A */ 0x01A0, 0x01A1, 0x01A3, 0x01A3, 0x01A5, 0x01A5, 0x01A6, 0x01A8,
+ 0x01A8, 0x0283, 0x01AA, 0x01AB, 0x01AD, 0x01AD, 0x0288, 0x01AF,
+ /* B */ 0x01B0, 0x028A, 0x028B, 0x01B4, 0x01B4, 0x01B6, 0x01B6, 0x0292,
+ 0x01B9, 0x01B9, 0x01BA, 0x01BB, 0x01BD, 0x01BD, 0x01BE, 0x01BF,
+ /* C */ 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C6, 0x01C6, 0x01C6, 0x01C9,
+ 0x01C9, 0x01C9, 0x01CC, 0x01CC, 0x01CC, 0x01CD, 0x01CE, 0x01CF,
+ /* D */ 0x01D0, 0x01D1, 0x01D2, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7,
+ 0x01D8, 0x01D9, 0x01DA, 0x01DB, 0x01DC, 0x01DD, 0x01DE, 0x01DF,
+ /* E */ 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E5, 0x01E5, 0x01E6, 0x01E7,
+ 0x01E8, 0x01E9, 0x01EA, 0x01EB, 0x01EC, 0x01ED, 0x01EE, 0x01EF,
+ /* F */ 0x01F0, 0x01F3, 0x01F3, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7,
+ 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
- // Table 3 (for high byte 0x03)
+ // Table 3 (for high byte 0x03)
- /* 0 */ 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307,
- 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x030F,
- /* 1 */ 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, 0x0317,
- 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F,
- /* 2 */ 0x0320, 0x0321, 0x0322, 0x0323, 0x0324, 0x0325, 0x0326, 0x0327,
- 0x0328, 0x0329, 0x032A, 0x032B, 0x032C, 0x032D, 0x032E, 0x032F,
- /* 3 */ 0x0330, 0x0331, 0x0332, 0x0333, 0x0334, 0x0335, 0x0336, 0x0337,
- 0x0338, 0x0339, 0x033A, 0x033B, 0x033C, 0x033D, 0x033E, 0x033F,
- /* 4 */ 0x0340, 0x0341, 0x0342, 0x0343, 0x0344, 0x0345, 0x0346, 0x0347,
- 0x0348, 0x0349, 0x034A, 0x034B, 0x034C, 0x034D, 0x034E, 0x034F,
- /* 5 */ 0x0350, 0x0351, 0x0352, 0x0353, 0x0354, 0x0355, 0x0356, 0x0357,
- 0x0358, 0x0359, 0x035A, 0x035B, 0x035C, 0x035D, 0x035E, 0x035F,
- /* 6 */ 0x0360, 0x0361, 0x0362, 0x0363, 0x0364, 0x0365, 0x0366, 0x0367,
- 0x0368, 0x0369, 0x036A, 0x036B, 0x036C, 0x036D, 0x036E, 0x036F,
- /* 7 */ 0x0370, 0x0371, 0x0372, 0x0373, 0x0374, 0x0375, 0x0376, 0x0377,
- 0x0378, 0x0379, 0x037A, 0x037B, 0x037C, 0x037D, 0x037E, 0x037F,
- /* 8 */ 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0386, 0x0387,
- 0x0388, 0x0389, 0x038A, 0x038B, 0x038C, 0x038D, 0x038E, 0x038F,
- /* 9 */ 0x0390, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
- 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- /* A */ 0x03C0, 0x03C1, 0x03A2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
- 0x03C8, 0x03C9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
- /* B */ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
- 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- /* C */ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
- 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x03CF,
- /* D */ 0x03D0, 0x03D1, 0x03D2, 0x03D3, 0x03D4, 0x03D5, 0x03D6, 0x03D7,
- 0x03D8, 0x03D9, 0x03DA, 0x03DB, 0x03DC, 0x03DD, 0x03DE, 0x03DF,
- /* E */ 0x03E0, 0x03E1, 0x03E3, 0x03E3, 0x03E5, 0x03E5, 0x03E7, 0x03E7,
- 0x03E9, 0x03E9, 0x03EB, 0x03EB, 0x03ED, 0x03ED, 0x03EF, 0x03EF,
- /* F */ 0x03F0, 0x03F1, 0x03F2, 0x03F3, 0x03F4, 0x03F5, 0x03F6, 0x03F7,
- 0x03F8, 0x03F9, 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
+ /* 0 */ 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307,
+ 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x030F,
+ /* 1 */ 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, 0x0317,
+ 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F,
+ /* 2 */ 0x0320, 0x0321, 0x0322, 0x0323, 0x0324, 0x0325, 0x0326, 0x0327,
+ 0x0328, 0x0329, 0x032A, 0x032B, 0x032C, 0x032D, 0x032E, 0x032F,
+ /* 3 */ 0x0330, 0x0331, 0x0332, 0x0333, 0x0334, 0x0335, 0x0336, 0x0337,
+ 0x0338, 0x0339, 0x033A, 0x033B, 0x033C, 0x033D, 0x033E, 0x033F,
+ /* 4 */ 0x0340, 0x0341, 0x0342, 0x0343, 0x0344, 0x0345, 0x0346, 0x0347,
+ 0x0348, 0x0349, 0x034A, 0x034B, 0x034C, 0x034D, 0x034E, 0x034F,
+ /* 5 */ 0x0350, 0x0351, 0x0352, 0x0353, 0x0354, 0x0355, 0x0356, 0x0357,
+ 0x0358, 0x0359, 0x035A, 0x035B, 0x035C, 0x035D, 0x035E, 0x035F,
+ /* 6 */ 0x0360, 0x0361, 0x0362, 0x0363, 0x0364, 0x0365, 0x0366, 0x0367,
+ 0x0368, 0x0369, 0x036A, 0x036B, 0x036C, 0x036D, 0x036E, 0x036F,
+ /* 7 */ 0x0370, 0x0371, 0x0372, 0x0373, 0x0374, 0x0375, 0x0376, 0x0377,
+ 0x0378, 0x0379, 0x037A, 0x037B, 0x037C, 0x037D, 0x037E, 0x037F,
+ /* 8 */ 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0386, 0x0387,
+ 0x0388, 0x0389, 0x038A, 0x038B, 0x038C, 0x038D, 0x038E, 0x038F,
+ /* 9 */ 0x0390, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ /* A */ 0x03C0, 0x03C1, 0x03A2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
+ /* B */ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ /* C */ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x03CF,
+ /* D */ 0x03D0, 0x03D1, 0x03D2, 0x03D3, 0x03D4, 0x03D5, 0x03D6, 0x03D7,
+ 0x03D8, 0x03D9, 0x03DA, 0x03DB, 0x03DC, 0x03DD, 0x03DE, 0x03DF,
+ /* E */ 0x03E0, 0x03E1, 0x03E3, 0x03E3, 0x03E5, 0x03E5, 0x03E7, 0x03E7,
+ 0x03E9, 0x03E9, 0x03EB, 0x03EB, 0x03ED, 0x03ED, 0x03EF, 0x03EF,
+ /* F */ 0x03F0, 0x03F1, 0x03F2, 0x03F3, 0x03F4, 0x03F5, 0x03F6, 0x03F7,
+ 0x03F8, 0x03F9, 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
- // Table 4 (for high byte 0x04)
+ // Table 4 (for high byte 0x04)
- /* 0 */ 0x0400, 0x0401, 0x0452, 0x0403, 0x0454, 0x0455, 0x0456, 0x0407,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x040C, 0x040D, 0x040E, 0x045F,
- /* 1 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
- 0x0438, 0x0419, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
- /* 2 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
- 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
- /* 3 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
- 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
- /* 4 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
- 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
- /* 5 */ 0x0450, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x045D, 0x045E, 0x045F,
- /* 6 */ 0x0461, 0x0461, 0x0463, 0x0463, 0x0465, 0x0465, 0x0467, 0x0467,
- 0x0469, 0x0469, 0x046B, 0x046B, 0x046D, 0x046D, 0x046F, 0x046F,
- /* 7 */ 0x0471, 0x0471, 0x0473, 0x0473, 0x0475, 0x0475, 0x0476, 0x0477,
- 0x0479, 0x0479, 0x047B, 0x047B, 0x047D, 0x047D, 0x047F, 0x047F,
- /* 8 */ 0x0481, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487,
- 0x0488, 0x0489, 0x048A, 0x048B, 0x048C, 0x048D, 0x048E, 0x048F,
- /* 9 */ 0x0491, 0x0491, 0x0493, 0x0493, 0x0495, 0x0495, 0x0497, 0x0497,
- 0x0499, 0x0499, 0x049B, 0x049B, 0x049D, 0x049D, 0x049F, 0x049F,
- /* A */ 0x04A1, 0x04A1, 0x04A3, 0x04A3, 0x04A5, 0x04A5, 0x04A7, 0x04A7,
- 0x04A9, 0x04A9, 0x04AB, 0x04AB, 0x04AD, 0x04AD, 0x04AF, 0x04AF,
- /* B */ 0x04B1, 0x04B1, 0x04B3, 0x04B3, 0x04B5, 0x04B5, 0x04B7, 0x04B7,
- 0x04B9, 0x04B9, 0x04BB, 0x04BB, 0x04BD, 0x04BD, 0x04BF, 0x04BF,
- /* C */ 0x04C0, 0x04C1, 0x04C2, 0x04C4, 0x04C4, 0x04C5, 0x04C6, 0x04C8,
- 0x04C8, 0x04C9, 0x04CA, 0x04CC, 0x04CC, 0x04CD, 0x04CE, 0x04CF,
- /* D */ 0x04D0, 0x04D1, 0x04D2, 0x04D3, 0x04D4, 0x04D5, 0x04D6, 0x04D7,
- 0x04D8, 0x04D9, 0x04DA, 0x04DB, 0x04DC, 0x04DD, 0x04DE, 0x04DF,
- /* E */ 0x04E0, 0x04E1, 0x04E2, 0x04E3, 0x04E4, 0x04E5, 0x04E6, 0x04E7,
- 0x04E8, 0x04E9, 0x04EA, 0x04EB, 0x04EC, 0x04ED, 0x04EE, 0x04EF,
- /* F */ 0x04F0, 0x04F1, 0x04F2, 0x04F3, 0x04F4, 0x04F5, 0x04F6, 0x04F7,
- 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC, 0x04FD, 0x04FE, 0x04FF,
+ /* 0 */ 0x0400, 0x0401, 0x0452, 0x0403, 0x0454, 0x0455, 0x0456, 0x0407,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x040C, 0x040D, 0x040E, 0x045F,
+ /* 1 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0419, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ /* 2 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ /* 3 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ /* 4 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ /* 5 */ 0x0450, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x045D, 0x045E, 0x045F,
+ /* 6 */ 0x0461, 0x0461, 0x0463, 0x0463, 0x0465, 0x0465, 0x0467, 0x0467,
+ 0x0469, 0x0469, 0x046B, 0x046B, 0x046D, 0x046D, 0x046F, 0x046F,
+ /* 7 */ 0x0471, 0x0471, 0x0473, 0x0473, 0x0475, 0x0475, 0x0476, 0x0477,
+ 0x0479, 0x0479, 0x047B, 0x047B, 0x047D, 0x047D, 0x047F, 0x047F,
+ /* 8 */ 0x0481, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487,
+ 0x0488, 0x0489, 0x048A, 0x048B, 0x048C, 0x048D, 0x048E, 0x048F,
+ /* 9 */ 0x0491, 0x0491, 0x0493, 0x0493, 0x0495, 0x0495, 0x0497, 0x0497,
+ 0x0499, 0x0499, 0x049B, 0x049B, 0x049D, 0x049D, 0x049F, 0x049F,
+ /* A */ 0x04A1, 0x04A1, 0x04A3, 0x04A3, 0x04A5, 0x04A5, 0x04A7, 0x04A7,
+ 0x04A9, 0x04A9, 0x04AB, 0x04AB, 0x04AD, 0x04AD, 0x04AF, 0x04AF,
+ /* B */ 0x04B1, 0x04B1, 0x04B3, 0x04B3, 0x04B5, 0x04B5, 0x04B7, 0x04B7,
+ 0x04B9, 0x04B9, 0x04BB, 0x04BB, 0x04BD, 0x04BD, 0x04BF, 0x04BF,
+ /* C */ 0x04C0, 0x04C1, 0x04C2, 0x04C4, 0x04C4, 0x04C5, 0x04C6, 0x04C8,
+ 0x04C8, 0x04C9, 0x04CA, 0x04CC, 0x04CC, 0x04CD, 0x04CE, 0x04CF,
+ /* D */ 0x04D0, 0x04D1, 0x04D2, 0x04D3, 0x04D4, 0x04D5, 0x04D6, 0x04D7,
+ 0x04D8, 0x04D9, 0x04DA, 0x04DB, 0x04DC, 0x04DD, 0x04DE, 0x04DF,
+ /* E */ 0x04E0, 0x04E1, 0x04E2, 0x04E3, 0x04E4, 0x04E5, 0x04E6, 0x04E7,
+ 0x04E8, 0x04E9, 0x04EA, 0x04EB, 0x04EC, 0x04ED, 0x04EE, 0x04EF,
+ /* F */ 0x04F0, 0x04F1, 0x04F2, 0x04F3, 0x04F4, 0x04F5, 0x04F6, 0x04F7,
+ 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC, 0x04FD, 0x04FE, 0x04FF,
- // Table 5 (for high byte 0x05)
+ // Table 5 (for high byte 0x05)
- /* 0 */ 0x0500, 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506, 0x0507,
- 0x0508, 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x050E, 0x050F,
- /* 1 */ 0x0510, 0x0511, 0x0512, 0x0513, 0x0514, 0x0515, 0x0516, 0x0517,
- 0x0518, 0x0519, 0x051A, 0x051B, 0x051C, 0x051D, 0x051E, 0x051F,
- /* 2 */ 0x0520, 0x0521, 0x0522, 0x0523, 0x0524, 0x0525, 0x0526, 0x0527,
- 0x0528, 0x0529, 0x052A, 0x052B, 0x052C, 0x052D, 0x052E, 0x052F,
- /* 3 */ 0x0530, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567,
- 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F,
- /* 4 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577,
- 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F,
- /* 5 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0557,
- 0x0558, 0x0559, 0x055A, 0x055B, 0x055C, 0x055D, 0x055E, 0x055F,
- /* 6 */ 0x0560, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567,
- 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F,
- /* 7 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577,
- 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F,
- /* 8 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0587,
- 0x0588, 0x0589, 0x058A, 0x058B, 0x058C, 0x058D, 0x058E, 0x058F,
- /* 9 */ 0x0590, 0x0591, 0x0592, 0x0593, 0x0594, 0x0595, 0x0596, 0x0597,
- 0x0598, 0x0599, 0x059A, 0x059B, 0x059C, 0x059D, 0x059E, 0x059F,
- /* A */ 0x05A0, 0x05A1, 0x05A2, 0x05A3, 0x05A4, 0x05A5, 0x05A6, 0x05A7,
- 0x05A8, 0x05A9, 0x05AA, 0x05AB, 0x05AC, 0x05AD, 0x05AE, 0x05AF,
- /* B */ 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
- 0x05B8, 0x05B9, 0x05BA, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
- /* C */ 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05C4, 0x05C5, 0x05C6, 0x05C7,
- 0x05C8, 0x05C9, 0x05CA, 0x05CB, 0x05CC, 0x05CD, 0x05CE, 0x05CF,
- /* D */ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
- 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
- /* E */ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
- 0x05E8, 0x05E9, 0x05EA, 0x05EB, 0x05EC, 0x05ED, 0x05EE, 0x05EF,
- /* F */ 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F5, 0x05F6, 0x05F7,
- 0x05F8, 0x05F9, 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ /* 0 */ 0x0500, 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506, 0x0507,
+ 0x0508, 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x050E, 0x050F,
+ /* 1 */ 0x0510, 0x0511, 0x0512, 0x0513, 0x0514, 0x0515, 0x0516, 0x0517,
+ 0x0518, 0x0519, 0x051A, 0x051B, 0x051C, 0x051D, 0x051E, 0x051F,
+ /* 2 */ 0x0520, 0x0521, 0x0522, 0x0523, 0x0524, 0x0525, 0x0526, 0x0527,
+ 0x0528, 0x0529, 0x052A, 0x052B, 0x052C, 0x052D, 0x052E, 0x052F,
+ /* 3 */ 0x0530, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567,
+ 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F,
+ /* 4 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577,
+ 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F,
+ /* 5 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0557,
+ 0x0558, 0x0559, 0x055A, 0x055B, 0x055C, 0x055D, 0x055E, 0x055F,
+ /* 6 */ 0x0560, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567,
+ 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F,
+ /* 7 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577,
+ 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F,
+ /* 8 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0587,
+ 0x0588, 0x0589, 0x058A, 0x058B, 0x058C, 0x058D, 0x058E, 0x058F,
+ /* 9 */ 0x0590, 0x0591, 0x0592, 0x0593, 0x0594, 0x0595, 0x0596, 0x0597,
+ 0x0598, 0x0599, 0x059A, 0x059B, 0x059C, 0x059D, 0x059E, 0x059F,
+ /* A */ 0x05A0, 0x05A1, 0x05A2, 0x05A3, 0x05A4, 0x05A5, 0x05A6, 0x05A7,
+ 0x05A8, 0x05A9, 0x05AA, 0x05AB, 0x05AC, 0x05AD, 0x05AE, 0x05AF,
+ /* B */ 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
+ 0x05B8, 0x05B9, 0x05BA, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
+ /* C */ 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05C4, 0x05C5, 0x05C6, 0x05C7,
+ 0x05C8, 0x05C9, 0x05CA, 0x05CB, 0x05CC, 0x05CD, 0x05CE, 0x05CF,
+ /* D */ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+ 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+ /* E */ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+ 0x05E8, 0x05E9, 0x05EA, 0x05EB, 0x05EC, 0x05ED, 0x05EE, 0x05EF,
+ /* F */ 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F5, 0x05F6, 0x05F7,
+ 0x05F8, 0x05F9, 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
- // Table 6 (for high byte 0x10)
+ // Table 6 (for high byte 0x10)
- /* 0 */ 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007,
- 0x1008, 0x1009, 0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F,
- /* 1 */ 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017,
- 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F,
- /* 2 */ 0x1020, 0x1021, 0x1022, 0x1023, 0x1024, 0x1025, 0x1026, 0x1027,
- 0x1028, 0x1029, 0x102A, 0x102B, 0x102C, 0x102D, 0x102E, 0x102F,
- /* 3 */ 0x1030, 0x1031, 0x1032, 0x1033, 0x1034, 0x1035, 0x1036, 0x1037,
- 0x1038, 0x1039, 0x103A, 0x103B, 0x103C, 0x103D, 0x103E, 0x103F,
- /* 4 */ 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047,
- 0x1048, 0x1049, 0x104A, 0x104B, 0x104C, 0x104D, 0x104E, 0x104F,
- /* 5 */ 0x1050, 0x1051, 0x1052, 0x1053, 0x1054, 0x1055, 0x1056, 0x1057,
- 0x1058, 0x1059, 0x105A, 0x105B, 0x105C, 0x105D, 0x105E, 0x105F,
- /* 6 */ 0x1060, 0x1061, 0x1062, 0x1063, 0x1064, 0x1065, 0x1066, 0x1067,
- 0x1068, 0x1069, 0x106A, 0x106B, 0x106C, 0x106D, 0x106E, 0x106F,
- /* 7 */ 0x1070, 0x1071, 0x1072, 0x1073, 0x1074, 0x1075, 0x1076, 0x1077,
- 0x1078, 0x1079, 0x107A, 0x107B, 0x107C, 0x107D, 0x107E, 0x107F,
- /* 8 */ 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086, 0x1087,
- 0x1088, 0x1089, 0x108A, 0x108B, 0x108C, 0x108D, 0x108E, 0x108F,
- /* 9 */ 0x1090, 0x1091, 0x1092, 0x1093, 0x1094, 0x1095, 0x1096, 0x1097,
- 0x1098, 0x1099, 0x109A, 0x109B, 0x109C, 0x109D, 0x109E, 0x109F,
- /* A */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7,
- 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF,
- /* B */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7,
- 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF,
- /* C */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10C6, 0x10C7,
- 0x10C8, 0x10C9, 0x10CA, 0x10CB, 0x10CC, 0x10CD, 0x10CE, 0x10CF,
- /* D */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7,
- 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF,
- /* E */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7,
- 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF,
- /* F */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10F6, 0x10F7,
- 0x10F8, 0x10F9, 0x10FA, 0x10FB, 0x10FC, 0x10FD, 0x10FE, 0x10FF,
+ /* 0 */ 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007,
+ 0x1008, 0x1009, 0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F,
+ /* 1 */ 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017,
+ 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F,
+ /* 2 */ 0x1020, 0x1021, 0x1022, 0x1023, 0x1024, 0x1025, 0x1026, 0x1027,
+ 0x1028, 0x1029, 0x102A, 0x102B, 0x102C, 0x102D, 0x102E, 0x102F,
+ /* 3 */ 0x1030, 0x1031, 0x1032, 0x1033, 0x1034, 0x1035, 0x1036, 0x1037,
+ 0x1038, 0x1039, 0x103A, 0x103B, 0x103C, 0x103D, 0x103E, 0x103F,
+ /* 4 */ 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047,
+ 0x1048, 0x1049, 0x104A, 0x104B, 0x104C, 0x104D, 0x104E, 0x104F,
+ /* 5 */ 0x1050, 0x1051, 0x1052, 0x1053, 0x1054, 0x1055, 0x1056, 0x1057,
+ 0x1058, 0x1059, 0x105A, 0x105B, 0x105C, 0x105D, 0x105E, 0x105F,
+ /* 6 */ 0x1060, 0x1061, 0x1062, 0x1063, 0x1064, 0x1065, 0x1066, 0x1067,
+ 0x1068, 0x1069, 0x106A, 0x106B, 0x106C, 0x106D, 0x106E, 0x106F,
+ /* 7 */ 0x1070, 0x1071, 0x1072, 0x1073, 0x1074, 0x1075, 0x1076, 0x1077,
+ 0x1078, 0x1079, 0x107A, 0x107B, 0x107C, 0x107D, 0x107E, 0x107F,
+ /* 8 */ 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086, 0x1087,
+ 0x1088, 0x1089, 0x108A, 0x108B, 0x108C, 0x108D, 0x108E, 0x108F,
+ /* 9 */ 0x1090, 0x1091, 0x1092, 0x1093, 0x1094, 0x1095, 0x1096, 0x1097,
+ 0x1098, 0x1099, 0x109A, 0x109B, 0x109C, 0x109D, 0x109E, 0x109F,
+ /* A */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7,
+ 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF,
+ /* B */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7,
+ 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF,
+ /* C */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10C6, 0x10C7,
+ 0x10C8, 0x10C9, 0x10CA, 0x10CB, 0x10CC, 0x10CD, 0x10CE, 0x10CF,
+ /* D */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7,
+ 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF,
+ /* E */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7,
+ 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF,
+ /* F */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10F6, 0x10F7,
+ 0x10F8, 0x10F9, 0x10FA, 0x10FB, 0x10FC, 0x10FD, 0x10FE, 0x10FF,
- // Table 7 (for high byte 0x20)
+ // Table 7 (for high byte 0x20)
- /* 0 */ 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007,
- 0x2008, 0x2009, 0x200A, 0x200B, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 1 */ 0x2010, 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017,
- 0x2018, 0x2019, 0x201A, 0x201B, 0x201C, 0x201D, 0x201E, 0x201F,
- /* 2 */ 0x2020, 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027,
- 0x2028, 0x2029, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x202F,
- /* 3 */ 0x2030, 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037,
- 0x2038, 0x2039, 0x203A, 0x203B, 0x203C, 0x203D, 0x203E, 0x203F,
- /* 4 */ 0x2040, 0x2041, 0x2042, 0x2043, 0x2044, 0x2045, 0x2046, 0x2047,
- 0x2048, 0x2049, 0x204A, 0x204B, 0x204C, 0x204D, 0x204E, 0x204F,
- /* 5 */ 0x2050, 0x2051, 0x2052, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057,
- 0x2058, 0x2059, 0x205A, 0x205B, 0x205C, 0x205D, 0x205E, 0x205F,
- /* 6 */ 0x2060, 0x2061, 0x2062, 0x2063, 0x2064, 0x2065, 0x2066, 0x2067,
- 0x2068, 0x2069, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 7 */ 0x2070, 0x2071, 0x2072, 0x2073, 0x2074, 0x2075, 0x2076, 0x2077,
- 0x2078, 0x2079, 0x207A, 0x207B, 0x207C, 0x207D, 0x207E, 0x207F,
- /* 8 */ 0x2080, 0x2081, 0x2082, 0x2083, 0x2084, 0x2085, 0x2086, 0x2087,
- 0x2088, 0x2089, 0x208A, 0x208B, 0x208C, 0x208D, 0x208E, 0x208F,
- /* 9 */ 0x2090, 0x2091, 0x2092, 0x2093, 0x2094, 0x2095, 0x2096, 0x2097,
- 0x2098, 0x2099, 0x209A, 0x209B, 0x209C, 0x209D, 0x209E, 0x209F,
- /* A */ 0x20A0, 0x20A1, 0x20A2, 0x20A3, 0x20A4, 0x20A5, 0x20A6, 0x20A7,
- 0x20A8, 0x20A9, 0x20AA, 0x20AB, 0x20AC, 0x20AD, 0x20AE, 0x20AF,
- /* B */ 0x20B0, 0x20B1, 0x20B2, 0x20B3, 0x20B4, 0x20B5, 0x20B6, 0x20B7,
- 0x20B8, 0x20B9, 0x20BA, 0x20BB, 0x20BC, 0x20BD, 0x20BE, 0x20BF,
- /* C */ 0x20C0, 0x20C1, 0x20C2, 0x20C3, 0x20C4, 0x20C5, 0x20C6, 0x20C7,
- 0x20C8, 0x20C9, 0x20CA, 0x20CB, 0x20CC, 0x20CD, 0x20CE, 0x20CF,
- /* D */ 0x20D0, 0x20D1, 0x20D2, 0x20D3, 0x20D4, 0x20D5, 0x20D6, 0x20D7,
- 0x20D8, 0x20D9, 0x20DA, 0x20DB, 0x20DC, 0x20DD, 0x20DE, 0x20DF,
- /* E */ 0x20E0, 0x20E1, 0x20E2, 0x20E3, 0x20E4, 0x20E5, 0x20E6, 0x20E7,
- 0x20E8, 0x20E9, 0x20EA, 0x20EB, 0x20EC, 0x20ED, 0x20EE, 0x20EF,
- /* F */ 0x20F0, 0x20F1, 0x20F2, 0x20F3, 0x20F4, 0x20F5, 0x20F6, 0x20F7,
- 0x20F8, 0x20F9, 0x20FA, 0x20FB, 0x20FC, 0x20FD, 0x20FE, 0x20FF,
+ /* 0 */ 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007,
+ 0x2008, 0x2009, 0x200A, 0x200B, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 1 */ 0x2010, 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017,
+ 0x2018, 0x2019, 0x201A, 0x201B, 0x201C, 0x201D, 0x201E, 0x201F,
+ /* 2 */ 0x2020, 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027,
+ 0x2028, 0x2029, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x202F,
+ /* 3 */ 0x2030, 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037,
+ 0x2038, 0x2039, 0x203A, 0x203B, 0x203C, 0x203D, 0x203E, 0x203F,
+ /* 4 */ 0x2040, 0x2041, 0x2042, 0x2043, 0x2044, 0x2045, 0x2046, 0x2047,
+ 0x2048, 0x2049, 0x204A, 0x204B, 0x204C, 0x204D, 0x204E, 0x204F,
+ /* 5 */ 0x2050, 0x2051, 0x2052, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057,
+ 0x2058, 0x2059, 0x205A, 0x205B, 0x205C, 0x205D, 0x205E, 0x205F,
+ /* 6 */ 0x2060, 0x2061, 0x2062, 0x2063, 0x2064, 0x2065, 0x2066, 0x2067,
+ 0x2068, 0x2069, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ /* 7 */ 0x2070, 0x2071, 0x2072, 0x2073, 0x2074, 0x2075, 0x2076, 0x2077,
+ 0x2078, 0x2079, 0x207A, 0x207B, 0x207C, 0x207D, 0x207E, 0x207F,
+ /* 8 */ 0x2080, 0x2081, 0x2082, 0x2083, 0x2084, 0x2085, 0x2086, 0x2087,
+ 0x2088, 0x2089, 0x208A, 0x208B, 0x208C, 0x208D, 0x208E, 0x208F,
+ /* 9 */ 0x2090, 0x2091, 0x2092, 0x2093, 0x2094, 0x2095, 0x2096, 0x2097,
+ 0x2098, 0x2099, 0x209A, 0x209B, 0x209C, 0x209D, 0x209E, 0x209F,
+ /* A */ 0x20A0, 0x20A1, 0x20A2, 0x20A3, 0x20A4, 0x20A5, 0x20A6, 0x20A7,
+ 0x20A8, 0x20A9, 0x20AA, 0x20AB, 0x20AC, 0x20AD, 0x20AE, 0x20AF,
+ /* B */ 0x20B0, 0x20B1, 0x20B2, 0x20B3, 0x20B4, 0x20B5, 0x20B6, 0x20B7,
+ 0x20B8, 0x20B9, 0x20BA, 0x20BB, 0x20BC, 0x20BD, 0x20BE, 0x20BF,
+ /* C */ 0x20C0, 0x20C1, 0x20C2, 0x20C3, 0x20C4, 0x20C5, 0x20C6, 0x20C7,
+ 0x20C8, 0x20C9, 0x20CA, 0x20CB, 0x20CC, 0x20CD, 0x20CE, 0x20CF,
+ /* D */ 0x20D0, 0x20D1, 0x20D2, 0x20D3, 0x20D4, 0x20D5, 0x20D6, 0x20D7,
+ 0x20D8, 0x20D9, 0x20DA, 0x20DB, 0x20DC, 0x20DD, 0x20DE, 0x20DF,
+ /* E */ 0x20E0, 0x20E1, 0x20E2, 0x20E3, 0x20E4, 0x20E5, 0x20E6, 0x20E7,
+ 0x20E8, 0x20E9, 0x20EA, 0x20EB, 0x20EC, 0x20ED, 0x20EE, 0x20EF,
+ /* F */ 0x20F0, 0x20F1, 0x20F2, 0x20F3, 0x20F4, 0x20F5, 0x20F6, 0x20F7,
+ 0x20F8, 0x20F9, 0x20FA, 0x20FB, 0x20FC, 0x20FD, 0x20FE, 0x20FF,
- // Table 8 (for high byte 0x21)
+ // Table 8 (for high byte 0x21)
- /* 0 */ 0x2100, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107,
- 0x2108, 0x2109, 0x210A, 0x210B, 0x210C, 0x210D, 0x210E, 0x210F,
- /* 1 */ 0x2110, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117,
- 0x2118, 0x2119, 0x211A, 0x211B, 0x211C, 0x211D, 0x211E, 0x211F,
- /* 2 */ 0x2120, 0x2121, 0x2122, 0x2123, 0x2124, 0x2125, 0x2126, 0x2127,
- 0x2128, 0x2129, 0x212A, 0x212B, 0x212C, 0x212D, 0x212E, 0x212F,
- /* 3 */ 0x2130, 0x2131, 0x2132, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137,
- 0x2138, 0x2139, 0x213A, 0x213B, 0x213C, 0x213D, 0x213E, 0x213F,
- /* 4 */ 0x2140, 0x2141, 0x2142, 0x2143, 0x2144, 0x2145, 0x2146, 0x2147,
- 0x2148, 0x2149, 0x214A, 0x214B, 0x214C, 0x214D, 0x214E, 0x214F,
- /* 5 */ 0x2150, 0x2151, 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157,
- 0x2158, 0x2159, 0x215A, 0x215B, 0x215C, 0x215D, 0x215E, 0x215F,
- /* 6 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177,
- 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F,
- /* 7 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177,
- 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F,
- /* 8 */ 0x2180, 0x2181, 0x2182, 0x2183, 0x2184, 0x2185, 0x2186, 0x2187,
- 0x2188, 0x2189, 0x218A, 0x218B, 0x218C, 0x218D, 0x218E, 0x218F,
- /* 9 */ 0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x2196, 0x2197,
- 0x2198, 0x2199, 0x219A, 0x219B, 0x219C, 0x219D, 0x219E, 0x219F,
- /* A */ 0x21A0, 0x21A1, 0x21A2, 0x21A3, 0x21A4, 0x21A5, 0x21A6, 0x21A7,
- 0x21A8, 0x21A9, 0x21AA, 0x21AB, 0x21AC, 0x21AD, 0x21AE, 0x21AF,
- /* B */ 0x21B0, 0x21B1, 0x21B2, 0x21B3, 0x21B4, 0x21B5, 0x21B6, 0x21B7,
- 0x21B8, 0x21B9, 0x21BA, 0x21BB, 0x21BC, 0x21BD, 0x21BE, 0x21BF,
- /* C */ 0x21C0, 0x21C1, 0x21C2, 0x21C3, 0x21C4, 0x21C5, 0x21C6, 0x21C7,
- 0x21C8, 0x21C9, 0x21CA, 0x21CB, 0x21CC, 0x21CD, 0x21CE, 0x21CF,
- /* D */ 0x21D0, 0x21D1, 0x21D2, 0x21D3, 0x21D4, 0x21D5, 0x21D6, 0x21D7,
- 0x21D8, 0x21D9, 0x21DA, 0x21DB, 0x21DC, 0x21DD, 0x21DE, 0x21DF,
- /* E */ 0x21E0, 0x21E1, 0x21E2, 0x21E3, 0x21E4, 0x21E5, 0x21E6, 0x21E7,
- 0x21E8, 0x21E9, 0x21EA, 0x21EB, 0x21EC, 0x21ED, 0x21EE, 0x21EF,
- /* F */ 0x21F0, 0x21F1, 0x21F2, 0x21F3, 0x21F4, 0x21F5, 0x21F6, 0x21F7,
- 0x21F8, 0x21F9, 0x21FA, 0x21FB, 0x21FC, 0x21FD, 0x21FE, 0x21FF,
+ /* 0 */ 0x2100, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107,
+ 0x2108, 0x2109, 0x210A, 0x210B, 0x210C, 0x210D, 0x210E, 0x210F,
+ /* 1 */ 0x2110, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117,
+ 0x2118, 0x2119, 0x211A, 0x211B, 0x211C, 0x211D, 0x211E, 0x211F,
+ /* 2 */ 0x2120, 0x2121, 0x2122, 0x2123, 0x2124, 0x2125, 0x2126, 0x2127,
+ 0x2128, 0x2129, 0x212A, 0x212B, 0x212C, 0x212D, 0x212E, 0x212F,
+ /* 3 */ 0x2130, 0x2131, 0x2132, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137,
+ 0x2138, 0x2139, 0x213A, 0x213B, 0x213C, 0x213D, 0x213E, 0x213F,
+ /* 4 */ 0x2140, 0x2141, 0x2142, 0x2143, 0x2144, 0x2145, 0x2146, 0x2147,
+ 0x2148, 0x2149, 0x214A, 0x214B, 0x214C, 0x214D, 0x214E, 0x214F,
+ /* 5 */ 0x2150, 0x2151, 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157,
+ 0x2158, 0x2159, 0x215A, 0x215B, 0x215C, 0x215D, 0x215E, 0x215F,
+ /* 6 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177,
+ 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F,
+ /* 7 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177,
+ 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F,
+ /* 8 */ 0x2180, 0x2181, 0x2182, 0x2183, 0x2184, 0x2185, 0x2186, 0x2187,
+ 0x2188, 0x2189, 0x218A, 0x218B, 0x218C, 0x218D, 0x218E, 0x218F,
+ /* 9 */ 0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x2196, 0x2197,
+ 0x2198, 0x2199, 0x219A, 0x219B, 0x219C, 0x219D, 0x219E, 0x219F,
+ /* A */ 0x21A0, 0x21A1, 0x21A2, 0x21A3, 0x21A4, 0x21A5, 0x21A6, 0x21A7,
+ 0x21A8, 0x21A9, 0x21AA, 0x21AB, 0x21AC, 0x21AD, 0x21AE, 0x21AF,
+ /* B */ 0x21B0, 0x21B1, 0x21B2, 0x21B3, 0x21B4, 0x21B5, 0x21B6, 0x21B7,
+ 0x21B8, 0x21B9, 0x21BA, 0x21BB, 0x21BC, 0x21BD, 0x21BE, 0x21BF,
+ /* C */ 0x21C0, 0x21C1, 0x21C2, 0x21C3, 0x21C4, 0x21C5, 0x21C6, 0x21C7,
+ 0x21C8, 0x21C9, 0x21CA, 0x21CB, 0x21CC, 0x21CD, 0x21CE, 0x21CF,
+ /* D */ 0x21D0, 0x21D1, 0x21D2, 0x21D3, 0x21D4, 0x21D5, 0x21D6, 0x21D7,
+ 0x21D8, 0x21D9, 0x21DA, 0x21DB, 0x21DC, 0x21DD, 0x21DE, 0x21DF,
+ /* E */ 0x21E0, 0x21E1, 0x21E2, 0x21E3, 0x21E4, 0x21E5, 0x21E6, 0x21E7,
+ 0x21E8, 0x21E9, 0x21EA, 0x21EB, 0x21EC, 0x21ED, 0x21EE, 0x21EF,
+ /* F */ 0x21F0, 0x21F1, 0x21F2, 0x21F3, 0x21F4, 0x21F5, 0x21F6, 0x21F7,
+ 0x21F8, 0x21F9, 0x21FA, 0x21FB, 0x21FC, 0x21FD, 0x21FE, 0x21FF,
- // Table 9 (for high byte 0xFE)
+ // Table 9 (for high byte 0xFE)
- /* 0 */ 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07,
- 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F,
- /* 1 */ 0xFE10, 0xFE11, 0xFE12, 0xFE13, 0xFE14, 0xFE15, 0xFE16, 0xFE17,
- 0xFE18, 0xFE19, 0xFE1A, 0xFE1B, 0xFE1C, 0xFE1D, 0xFE1E, 0xFE1F,
- /* 2 */ 0xFE20, 0xFE21, 0xFE22, 0xFE23, 0xFE24, 0xFE25, 0xFE26, 0xFE27,
- 0xFE28, 0xFE29, 0xFE2A, 0xFE2B, 0xFE2C, 0xFE2D, 0xFE2E, 0xFE2F,
- /* 3 */ 0xFE30, 0xFE31, 0xFE32, 0xFE33, 0xFE34, 0xFE35, 0xFE36, 0xFE37,
- 0xFE38, 0xFE39, 0xFE3A, 0xFE3B, 0xFE3C, 0xFE3D, 0xFE3E, 0xFE3F,
- /* 4 */ 0xFE40, 0xFE41, 0xFE42, 0xFE43, 0xFE44, 0xFE45, 0xFE46, 0xFE47,
- 0xFE48, 0xFE49, 0xFE4A, 0xFE4B, 0xFE4C, 0xFE4D, 0xFE4E, 0xFE4F,
- /* 5 */ 0xFE50, 0xFE51, 0xFE52, 0xFE53, 0xFE54, 0xFE55, 0xFE56, 0xFE57,
- 0xFE58, 0xFE59, 0xFE5A, 0xFE5B, 0xFE5C, 0xFE5D, 0xFE5E, 0xFE5F,
- /* 6 */ 0xFE60, 0xFE61, 0xFE62, 0xFE63, 0xFE64, 0xFE65, 0xFE66, 0xFE67,
- 0xFE68, 0xFE69, 0xFE6A, 0xFE6B, 0xFE6C, 0xFE6D, 0xFE6E, 0xFE6F,
- /* 7 */ 0xFE70, 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE75, 0xFE76, 0xFE77,
- 0xFE78, 0xFE79, 0xFE7A, 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F,
- /* 8 */ 0xFE80, 0xFE81, 0xFE82, 0xFE83, 0xFE84, 0xFE85, 0xFE86, 0xFE87,
- 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C, 0xFE8D, 0xFE8E, 0xFE8F,
- /* 9 */ 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95, 0xFE96, 0xFE97,
- 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E, 0xFE9F,
- /* A */ 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
- 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF,
- /* B */ 0xFEB0, 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7,
- 0xFEB8, 0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF,
- /* C */ 0xFEC0, 0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7,
- 0xFEC8, 0xFEC9, 0xFECA, 0xFECB, 0xFECC, 0xFECD, 0xFECE, 0xFECF,
- /* D */ 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4, 0xFED5, 0xFED6, 0xFED7,
- 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD, 0xFEDE, 0xFEDF,
- /* E */ 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6, 0xFEE7,
- 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
- /* F */ 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7,
- 0xFEF8, 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0x0000,
+ /* 0 */ 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07,
+ 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F,
+ /* 1 */ 0xFE10, 0xFE11, 0xFE12, 0xFE13, 0xFE14, 0xFE15, 0xFE16, 0xFE17,
+ 0xFE18, 0xFE19, 0xFE1A, 0xFE1B, 0xFE1C, 0xFE1D, 0xFE1E, 0xFE1F,
+ /* 2 */ 0xFE20, 0xFE21, 0xFE22, 0xFE23, 0xFE24, 0xFE25, 0xFE26, 0xFE27,
+ 0xFE28, 0xFE29, 0xFE2A, 0xFE2B, 0xFE2C, 0xFE2D, 0xFE2E, 0xFE2F,
+ /* 3 */ 0xFE30, 0xFE31, 0xFE32, 0xFE33, 0xFE34, 0xFE35, 0xFE36, 0xFE37,
+ 0xFE38, 0xFE39, 0xFE3A, 0xFE3B, 0xFE3C, 0xFE3D, 0xFE3E, 0xFE3F,
+ /* 4 */ 0xFE40, 0xFE41, 0xFE42, 0xFE43, 0xFE44, 0xFE45, 0xFE46, 0xFE47,
+ 0xFE48, 0xFE49, 0xFE4A, 0xFE4B, 0xFE4C, 0xFE4D, 0xFE4E, 0xFE4F,
+ /* 5 */ 0xFE50, 0xFE51, 0xFE52, 0xFE53, 0xFE54, 0xFE55, 0xFE56, 0xFE57,
+ 0xFE58, 0xFE59, 0xFE5A, 0xFE5B, 0xFE5C, 0xFE5D, 0xFE5E, 0xFE5F,
+ /* 6 */ 0xFE60, 0xFE61, 0xFE62, 0xFE63, 0xFE64, 0xFE65, 0xFE66, 0xFE67,
+ 0xFE68, 0xFE69, 0xFE6A, 0xFE6B, 0xFE6C, 0xFE6D, 0xFE6E, 0xFE6F,
+ /* 7 */ 0xFE70, 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE75, 0xFE76, 0xFE77,
+ 0xFE78, 0xFE79, 0xFE7A, 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F,
+ /* 8 */ 0xFE80, 0xFE81, 0xFE82, 0xFE83, 0xFE84, 0xFE85, 0xFE86, 0xFE87,
+ 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C, 0xFE8D, 0xFE8E, 0xFE8F,
+ /* 9 */ 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95, 0xFE96, 0xFE97,
+ 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E, 0xFE9F,
+ /* A */ 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
+ 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF,
+ /* B */ 0xFEB0, 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7,
+ 0xFEB8, 0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF,
+ /* C */ 0xFEC0, 0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7,
+ 0xFEC8, 0xFEC9, 0xFECA, 0xFECB, 0xFECC, 0xFECD, 0xFECE, 0xFECF,
+ /* D */ 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4, 0xFED5, 0xFED6, 0xFED7,
+ 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD, 0xFEDE, 0xFEDF,
+ /* E */ 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6, 0xFEE7,
+ 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
+ /* F */ 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7,
+ 0xFEF8, 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0x0000,
- // Table 10 (for high byte 0xFF)
+ // Table 10 (for high byte 0xFF)
- /* 0 */ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05, 0xFF06, 0xFF07,
- 0xFF08, 0xFF09, 0xFF0A, 0xFF0B, 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F,
- /* 1 */ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
- 0xFF18, 0xFF19, 0xFF1A, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0xFF1F,
- /* 2 */ 0xFF20, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
- 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
- /* 3 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
- 0xFF58, 0xFF59, 0xFF5A, 0xFF3B, 0xFF3C, 0xFF3D, 0xFF3E, 0xFF3F,
- /* 4 */ 0xFF40, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
- 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
- /* 5 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
- 0xFF58, 0xFF59, 0xFF5A, 0xFF5B, 0xFF5C, 0xFF5D, 0xFF5E, 0xFF5F,
- /* 6 */ 0xFF60, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
- 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
- /* 7 */ 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
- 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
- /* 8 */ 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
- 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
- /* 9 */ 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
- 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
- /* A */ 0xFFA0, 0xFFA1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0xFFA6, 0xFFA7,
- 0xFFA8, 0xFFA9, 0xFFAA, 0xFFAB, 0xFFAC, 0xFFAD, 0xFFAE, 0xFFAF,
- /* B */ 0xFFB0, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0xFFB6, 0xFFB7,
- 0xFFB8, 0xFFB9, 0xFFBA, 0xFFBB, 0xFFBC, 0xFFBD, 0xFFBE, 0xFFBF,
- /* C */ 0xFFC0, 0xFFC1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0xFFC7,
- 0xFFC8, 0xFFC9, 0xFFCA, 0xFFCB, 0xFFCC, 0xFFCD, 0xFFCE, 0xFFCF,
- /* D */ 0xFFD0, 0xFFD1, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7,
- 0xFFD8, 0xFFD9, 0xFFDA, 0xFFDB, 0xFFDC, 0xFFDD, 0xFFDE, 0xFFDF,
- /* E */ 0xFFE0, 0xFFE1, 0xFFE2, 0xFFE3, 0xFFE4, 0xFFE5, 0xFFE6, 0xFFE7,
- 0xFFE8, 0xFFE9, 0xFFEA, 0xFFEB, 0xFFEC, 0xFFED, 0xFFEE, 0xFFEF,
- /* F */ 0xFFF0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6, 0xFFF7,
- 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF,
+ /* 0 */ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05, 0xFF06, 0xFF07,
+ 0xFF08, 0xFF09, 0xFF0A, 0xFF0B, 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F,
+ /* 1 */ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
+ 0xFF18, 0xFF19, 0xFF1A, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0xFF1F,
+ /* 2 */ 0xFF20, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
+ 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
+ /* 3 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
+ 0xFF58, 0xFF59, 0xFF5A, 0xFF3B, 0xFF3C, 0xFF3D, 0xFF3E, 0xFF3F,
+ /* 4 */ 0xFF40, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
+ 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
+ /* 5 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
+ 0xFF58, 0xFF59, 0xFF5A, 0xFF5B, 0xFF5C, 0xFF5D, 0xFF5E, 0xFF5F,
+ /* 6 */ 0xFF60, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
+ 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
+ /* 7 */ 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
+ 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
+ /* 8 */ 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
+ 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
+ /* 9 */ 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
+ 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
+ /* A */ 0xFFA0, 0xFFA1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0xFFA6, 0xFFA7,
+ 0xFFA8, 0xFFA9, 0xFFAA, 0xFFAB, 0xFFAC, 0xFFAD, 0xFFAE, 0xFFAF,
+ /* B */ 0xFFB0, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0xFFB6, 0xFFB7,
+ 0xFFB8, 0xFFB9, 0xFFBA, 0xFFBB, 0xFFBC, 0xFFBD, 0xFFBE, 0xFFBF,
+ /* C */ 0xFFC0, 0xFFC1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0xFFC7,
+ 0xFFC8, 0xFFC9, 0xFFCA, 0xFFCB, 0xFFCC, 0xFFCD, 0xFFCE, 0xFFCF,
+ /* D */ 0xFFD0, 0xFFD1, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7,
+ 0xFFD8, 0xFFD9, 0xFFDA, 0xFFDB, 0xFFDC, 0xFFDD, 0xFFDE, 0xFFDF,
+ /* E */ 0xFFE0, 0xFFE1, 0xFFE2, 0xFFE3, 0xFFE4, 0xFFE5, 0xFFE6, 0xFFE7,
+ 0xFFE8, 0xFFE9, 0xFFEA, 0xFFEB, 0xFFEC, 0xFFED, 0xFFEE, 0xFFEF,
+ /* F */ 0xFFF0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6, 0xFFF7,
+ 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF,
};
// Returns the next non-ignorable codepoint within string starting from the
@@ -1157,12 +1152,10 @@
int index2 = 0;
for (;;) {
- int codepoint1 = HFSReadNextNonIgnorableCodepoint(string1.data(),
- length1,
- &index1);
- int codepoint2 = HFSReadNextNonIgnorableCodepoint(string2.data(),
- length2,
- &index2);
+ int codepoint1 =
+ HFSReadNextNonIgnorableCodepoint(string1.data(), length1, &index1);
+ int codepoint2 =
+ HFSReadNextNonIgnorableCodepoint(string2.data(), length2, &index2);
if (codepoint1 != codepoint2)
return (codepoint1 < codepoint2) ? -1 : 1;
if (codepoint1 == 0) {
@@ -1175,14 +1168,9 @@
StringType FilePath::GetHFSDecomposedForm(StringPieceType string) {
StringType result;
- ScopedCFTypeRef<CFStringRef> cfstring(
- CFStringCreateWithBytesNoCopy(
- NULL,
- reinterpret_cast<const UInt8*>(string.data()),
- string.length(),
- kCFStringEncodingUTF8,
- false,
- kCFAllocatorNull));
+ ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
+ NULL, reinterpret_cast<const UInt8*>(string.data()), string.length(),
+ kCFStringEncodingUTF8, false, kCFAllocatorNull));
if (cfstring) {
// Query the maximum length needed to store the result. In most cases this
// will overestimate the required space. The return value also already
@@ -1194,9 +1182,8 @@
// (Increasing rather than decreasing it would clobber the string contents!)
result.reserve(length);
result.resize(length - 1);
- Boolean success = CFStringGetFileSystemRepresentation(cfstring,
- &result[0],
- length);
+ Boolean success =
+ CFStringGetFileSystemRepresentation(cfstring, &result[0], length);
if (success) {
// Reduce result.length() to actual string length.
result.resize(strlen(result.c_str()));
@@ -1223,25 +1210,13 @@
// GetHFSDecomposedForm() returns an empty string in an error case.
if (hfs1.empty() || hfs2.empty()) {
NOTREACHED();
- ScopedCFTypeRef<CFStringRef> cfstring1(
- CFStringCreateWithBytesNoCopy(
- NULL,
- reinterpret_cast<const UInt8*>(string1.data()),
- string1.length(),
- kCFStringEncodingUTF8,
- false,
- kCFAllocatorNull));
- ScopedCFTypeRef<CFStringRef> cfstring2(
- CFStringCreateWithBytesNoCopy(
- NULL,
- reinterpret_cast<const UInt8*>(string2.data()),
- string2.length(),
- kCFStringEncodingUTF8,
- false,
- kCFAllocatorNull));
- return CFStringCompare(cfstring1,
- cfstring2,
- kCFCompareCaseInsensitive);
+ ScopedCFTypeRef<CFStringRef> cfstring1(CFStringCreateWithBytesNoCopy(
+ NULL, reinterpret_cast<const UInt8*>(string1.data()), string1.length(),
+ kCFStringEncodingUTF8, false, kCFAllocatorNull));
+ ScopedCFTypeRef<CFStringRef> cfstring2(CFStringCreateWithBytesNoCopy(
+ NULL, reinterpret_cast<const UInt8*>(string2.data()), string2.length(),
+ kCFStringEncodingUTF8, false, kCFAllocatorNull));
+ return CFStringCompare(cfstring1, cfstring2, kCFCompareCaseInsensitive);
}
return HFSFastUnicodeCompare(hfs1, hfs2);
@@ -1253,8 +1228,8 @@
int FilePath::CompareIgnoreCase(StringPieceType string1,
StringPieceType string2) {
// Specifically need null termianted strings for this API call.
- int comparison = strcasecmp(string1.as_string().c_str(),
- string2.as_string().c_str());
+ int comparison =
+ strcasecmp(string1.as_string().c_str(), string2.as_string().c_str());
if (comparison < 0)
return -1;
if (comparison > 0)
@@ -1264,7 +1239,6 @@
#endif // OS versions of CompareIgnoreCase()
-
void FilePath::StripTrailingSeparatorsInternal() {
// If there is no drive letter, start will be 1, which will prevent stripping
// the leading separator if there is only one separator. If there is a drive
@@ -1275,8 +1249,7 @@
StringType::size_type last_stripped = StringType::npos;
for (StringType::size_type pos = path_.length();
- pos > start && IsSeparator(path_[pos - 1]);
- --pos) {
+ pos > start && IsSeparator(path_[pos - 1]); --pos) {
// If the string only has two separators and they're at the beginning,
// don't strip them, unless the string began with more than two separators.
if (pos != start + 1 || last_stripped == start + 2 ||
diff --git a/base/files/file_path.h b/base/files/file_path.h
index 8c153b4..63b21e8 100644
--- a/base/files/file_path.h
+++ b/base/files/file_path.h
@@ -191,9 +191,7 @@
bool operator!=(const FilePath& that) const;
// Required for some STL containers and operations
- bool operator<(const FilePath& that) const {
- return path_ < that.path_;
- }
+ bool operator<(const FilePath& that) const { return path_ < that.path_; }
const StringType& value() const { return path_; }
@@ -284,10 +282,10 @@
// path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg"
// path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)"
// path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
- FilePath InsertBeforeExtension(
- StringPieceType suffix) const WARN_UNUSED_RESULT;
- FilePath InsertBeforeExtensionASCII(
- StringPiece suffix) const WARN_UNUSED_RESULT;
+ FilePath InsertBeforeExtension(StringPieceType suffix) const
+ WARN_UNUSED_RESULT;
+ FilePath InsertBeforeExtensionASCII(StringPiece suffix) const
+ WARN_UNUSED_RESULT;
// Adds |extension| to |file_name|. Returns the current FilePath if
// |extension| is empty. Returns "" if BaseName() == "." or "..".
@@ -437,15 +435,14 @@
StringType path_;
};
-std::ostream& operator<<(std::ostream& out,
- const FilePath& file_path);
+std::ostream& operator<<(std::ostream& out, const FilePath& file_path);
} // namespace base
// Macros for string literal initialization of FilePath::CharType[], and for
// using a FilePath::CharType[] in a printf-style format string.
#if defined(OS_WIN)
-#define FILE_PATH_LITERAL(x) L ## x
+#define FILE_PATH_LITERAL(x) L##x
#define PRFilePath "ls"
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#define FILE_PATH_LITERAL(x) x
diff --git a/base/files/file_path_constants.cc b/base/files/file_path_constants.cc
index 0b74846..fc7d663 100644
--- a/base/files/file_path_constants.cc
+++ b/base/files/file_path_constants.cc
@@ -11,7 +11,7 @@
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/");
-#else // FILE_PATH_USES_WIN_SEPARATORS
+#else // FILE_PATH_USES_WIN_SEPARATORS
const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/");
#endif // FILE_PATH_USES_WIN_SEPARATORS
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 344621f..fcc10c6 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -26,11 +26,11 @@
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
defined(OS_ANDROID) && __ANDROID_API__ < 21
-int CallFstat(int fd, stat_wrapper_t *sb) {
+int CallFstat(int fd, stat_wrapper_t* sb) {
return fstat(fd, sb);
}
#else
-int CallFstat(int fd, stat_wrapper_t *sb) {
+int CallFstat(int fd, stat_wrapper_t* sb) {
return fstat64(fd, sb);
}
#endif
@@ -52,9 +52,9 @@
// http://pubs.opengroup.org/onlinepubs/9699919799/
timespec ts_times[2];
- ts_times[0].tv_sec = times[0].tv_sec;
+ ts_times[0].tv_sec = times[0].tv_sec;
ts_times[0].tv_nsec = times[0].tv_usec * 1000;
- ts_times[1].tv_sec = times[1].tv_sec;
+ ts_times[1].tv_sec = times[1].tv_sec;
ts_times[1].tv_nsec = times[1].tv_usec * 1000;
return futimens(file, ts_times);
@@ -126,20 +126,17 @@
#error
#endif
- last_modified =
- Time::FromTimeT(last_modified_sec) +
- TimeDelta::FromMicroseconds(last_modified_nsec /
- Time::kNanosecondsPerMicrosecond);
+ last_modified = Time::FromTimeT(last_modified_sec) +
+ TimeDelta::FromMicroseconds(last_modified_nsec /
+ Time::kNanosecondsPerMicrosecond);
- last_accessed =
- Time::FromTimeT(last_accessed_sec) +
- TimeDelta::FromMicroseconds(last_accessed_nsec /
- Time::kNanosecondsPerMicrosecond);
+ last_accessed = Time::FromTimeT(last_accessed_sec) +
+ TimeDelta::FromMicroseconds(last_accessed_nsec /
+ Time::kNanosecondsPerMicrosecond);
- creation_time =
- Time::FromTimeT(creation_time_sec) +
- TimeDelta::FromMicroseconds(creation_time_nsec /
- Time::kNanosecondsPerMicrosecond);
+ creation_time = Time::FromTimeT(creation_time_sec) +
+ TimeDelta::FromMicroseconds(creation_time_nsec /
+ Time::kNanosecondsPerMicrosecond);
}
bool File::IsValid() const {
@@ -177,8 +174,8 @@
int bytes_read = 0;
int rv;
do {
- rv = HANDLE_EINTR(pread(file_.get(), data + bytes_read,
- size - bytes_read, offset + bytes_read));
+ rv = HANDLE_EINTR(pread(file_.get(), data + bytes_read, size - bytes_read,
+ offset + bytes_read));
if (rv <= 0)
break;
@@ -249,8 +246,8 @@
int bytes_written = 0;
int rv;
do {
- rv = HANDLE_EINTR(write(file_.get(), data + bytes_written,
- size - bytes_written));
+ rv = HANDLE_EINTR(
+ write(file_.get(), data + bytes_written, size - bytes_written));
if (rv <= 0)
break;
@@ -399,10 +396,8 @@
open_flags |= O_RDWR;
} else if (flags & FLAG_WRITE) {
open_flags |= O_WRONLY;
- } else if (!(flags & FLAG_READ) &&
- !(flags & FLAG_WRITE_ATTRIBUTES) &&
- !(flags & FLAG_APPEND) &&
- !(flags & FLAG_OPEN_ALWAYS)) {
+ } else if (!(flags & FLAG_READ) && !(flags & FLAG_WRITE_ATTRIBUTES) &&
+ !(flags & FLAG_APPEND) && !(flags & FLAG_OPEN_ALWAYS)) {
NOTREACHED();
}
@@ -423,7 +418,7 @@
if (descriptor < 0) {
open_flags |= O_CREAT;
if (flags & FLAG_EXCLUSIVE_READ || flags & FLAG_EXCLUSIVE_WRITE)
- open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW
+ open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW
descriptor = HANDLE_EINTR(open(path.value().c_str(), open_flags, mode));
if (descriptor >= 0)
diff --git a/base/files/file_util.cc b/base/files/file_util.cc
index 887139b..b30057e 100644
--- a/base/files/file_util.cc
+++ b/base/files/file_util.cc
@@ -69,8 +69,7 @@
file1.read(buffer1, BUFFER_SIZE);
file2.read(buffer2, BUFFER_SIZE);
- if ((file1.eof() != file2.eof()) ||
- (file1.gcount() != file2.gcount()) ||
+ if ((file1.eof() != file2.eof()) || (file1.gcount() != file2.gcount()) ||
(memcmp(buffer1, buffer2, static_cast<size_t>(file1.gcount())))) {
file1.close();
file2.close();
@@ -98,8 +97,7 @@
getline(file2, line2);
// Check for mismatched EOF states, or any error state.
- if ((file1.eof() != file2.eof()) ||
- file1.bad() || file2.bad()) {
+ if ((file1.eof() != file2.eof()) || file1.bad() || file2.bad()) {
return false;
}
@@ -194,7 +192,7 @@
#if !defined(OS_NACL_NONSFI)
bool IsDirectoryEmpty(const FilePath& dir_path) {
FileEnumerator files(dir_path, false,
- FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
+ FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
if (files.Next().empty())
return true;
return false;
diff --git a/base/files/file_util.h b/base/files/file_util.h
index 1401108..6176073 100644
--- a/base/files/file_util.h
+++ b/base/files/file_util.h
@@ -90,8 +90,8 @@
// Returns true on success, leaving *error unchanged.
// Returns false on failure and sets *error appropriately, if it is non-NULL.
bool ReplaceFile(const FilePath& from_path,
- const FilePath& to_path,
- File::Error* error);
+ const FilePath& to_path,
+ File::Error* error);
// Copies a single file. Use CopyDirectory() to copy directories.
// This function fails if either path contains traversal components ('..').
@@ -125,14 +125,14 @@
//
// If you only need to copy a file use CopyFile, it's faster.
bool CopyDirectory(const FilePath& from_path,
- const FilePath& to_path,
- bool recursive);
+ const FilePath& to_path,
+ bool recursive);
// Like CopyDirectory() except trying to overwrite an existing file will not
// work and will return false.
bool CopyDirectoryExcl(const FilePath& from_path,
- const FilePath& to_path,
- bool recursive);
+ const FilePath& to_path,
+ bool recursive);
// Returns true if the given path exists on the local filesystem,
// false otherwise.
@@ -146,13 +146,11 @@
// Returns true if the contents of the two files given are equal, false
// otherwise. If either file can't be read, returns false.
-bool ContentsEqual(const FilePath& filename1,
- const FilePath& filename2);
+bool ContentsEqual(const FilePath& filename1, const FilePath& filename2);
// Returns true if the contents of the two text files given are equal, false
// otherwise. This routine treats "\r\n" and "\n" as equivalent.
-bool TextContentsEqual(const FilePath& filename1,
- const FilePath& filename2);
+bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2);
// Reads the file at |path| into |contents| and returns true on success and
// false on error. For security reasons, a |path| containing path traversal
@@ -173,8 +171,8 @@
// |contents| may be NULL, in which case this function is useful for its side
// effect of priming the disk cache (could be used for unit tests).
bool ReadFileToStringWithMaxSize(const FilePath& path,
- std::string* contents,
- size_t max_size);
+ std::string* contents,
+ size_t max_size);
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
@@ -186,8 +184,7 @@
// Performs the same function as CreateAndOpenTemporaryFileInDir(), but returns
// the file-descriptor directly, rather than wrapping it into a FILE. Returns
// -1 on failure.
-int CreateAndOpenFdForTemporaryFileInDir(const FilePath& dir,
- FilePath* path);
+int CreateAndOpenFdForTemporaryFileInDir(const FilePath& dir, FilePath* path);
#endif // OS_POSIX || OS_FUCHSIA
@@ -195,8 +192,7 @@
// Creates a symbolic link at |symlink| pointing to |target|. Returns
// false on failure.
-bool CreateSymbolicLink(const FilePath& target,
- const FilePath& symlink);
+bool CreateSymbolicLink(const FilePath& target, const FilePath& symlink);
// Reads the given |symlink| and returns where it points to in |target|.
// Returns false upon failure.
@@ -204,19 +200,19 @@
// Bits and masks of the file permission.
enum FilePermissionBits {
- FILE_PERMISSION_MASK = S_IRWXU | S_IRWXG | S_IRWXO,
- FILE_PERMISSION_USER_MASK = S_IRWXU,
- FILE_PERMISSION_GROUP_MASK = S_IRWXG,
- FILE_PERMISSION_OTHERS_MASK = S_IRWXO,
+ FILE_PERMISSION_MASK = S_IRWXU | S_IRWXG | S_IRWXO,
+ FILE_PERMISSION_USER_MASK = S_IRWXU,
+ FILE_PERMISSION_GROUP_MASK = S_IRWXG,
+ FILE_PERMISSION_OTHERS_MASK = S_IRWXO,
- FILE_PERMISSION_READ_BY_USER = S_IRUSR,
- FILE_PERMISSION_WRITE_BY_USER = S_IWUSR,
- FILE_PERMISSION_EXECUTE_BY_USER = S_IXUSR,
- FILE_PERMISSION_READ_BY_GROUP = S_IRGRP,
- FILE_PERMISSION_WRITE_BY_GROUP = S_IWGRP,
- FILE_PERMISSION_EXECUTE_BY_GROUP = S_IXGRP,
- FILE_PERMISSION_READ_BY_OTHERS = S_IROTH,
- FILE_PERMISSION_WRITE_BY_OTHERS = S_IWOTH,
+ FILE_PERMISSION_READ_BY_USER = S_IRUSR,
+ FILE_PERMISSION_WRITE_BY_USER = S_IWUSR,
+ FILE_PERMISSION_EXECUTE_BY_USER = S_IXUSR,
+ FILE_PERMISSION_READ_BY_GROUP = S_IRGRP,
+ FILE_PERMISSION_WRITE_BY_GROUP = S_IWGRP,
+ FILE_PERMISSION_EXECUTE_BY_GROUP = S_IXGRP,
+ FILE_PERMISSION_READ_BY_OTHERS = S_IROTH,
+ FILE_PERMISSION_WRITE_BY_OTHERS = S_IWOTH,
FILE_PERMISSION_EXECUTE_BY_OTHERS = S_IXOTH,
};
@@ -231,7 +227,7 @@
// Returns true iff |executable| can be found in any directory specified by the
// environment variable in |env|.
bool ExecutableExistsInPath(Environment* env,
- const FilePath::StringType& executable);
+ const FilePath::StringType& executable);
#endif // OS_POSIX
@@ -260,8 +256,7 @@
bool CreateTemporaryFile(FilePath* path);
// Same as CreateTemporaryFile but the file is created in |dir|.
-bool CreateTemporaryFileInDir(const FilePath& dir,
- FilePath* temp_file);
+bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file);
// Create and open a temporary file. File is opened for read/write.
// The full path is placed in |path|.
@@ -269,30 +264,28 @@
FILE* CreateAndOpenTemporaryFile(FilePath* path);
// Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|.
-FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir,
- FilePath* path);
+FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path);
// Create a new directory. If prefix is provided, the new directory name is in
// the format of prefixyyyy.
// NOTE: prefix is ignored in the POSIX implementation.
// If success, return true and output the full path of the directory created.
bool CreateNewTempDirectory(const FilePath::StringType& prefix,
- FilePath* new_temp_path);
+ FilePath* new_temp_path);
// Create a directory within another directory.
// Extra characters will be appended to |prefix| to ensure that the
// new directory does not have the same name as an existing directory.
bool CreateTemporaryDirInDir(const FilePath& base_dir,
- const FilePath::StringType& prefix,
- FilePath* new_dir);
+ const FilePath::StringType& prefix,
+ FilePath* new_dir);
// Creates a directory, as well as creating any parent directories, if they
// don't exist. Returns 'true' on successful creation, or if the directory
// already exists. The directory is only readable by the current user.
// Returns true on success, leaving *error unchanged.
// Returns false on failure and sets *error appropriately, if it is non-NULL.
-bool CreateDirectoryAndGetError(const FilePath& full_path,
- File::Error* error);
+bool CreateDirectoryAndGetError(const FilePath& full_path, File::Error* error);
// Backward-compatible convenience method for the above.
bool CreateDirectory(const FilePath& full_path);
@@ -314,14 +307,13 @@
// return in |drive_letter_path| the equivalent path that starts with
// a drive letter ("C:\..."). Return false if no such path exists.
bool DevicePathToDriveLetterPath(const FilePath& device_path,
- FilePath* drive_letter_path);
+ FilePath* drive_letter_path);
// Given an existing file in |path|, set |real_path| to the path
// in native NT format, of the form "\Device\HarddiskVolumeXX\..".
// Returns false if the path can not be found. Empty files cannot
// be resolved with this function.
-bool NormalizeToNativeFilePath(const FilePath& path,
- FilePath* nt_path);
+bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path);
#endif
// This function will return if the given file is a symlink or not.
@@ -332,8 +324,8 @@
// Sets the time of the last access and the time of the last modification.
bool TouchFile(const FilePath& path,
- const Time& last_accessed,
- const Time& last_modified);
+ const Time& last_accessed,
+ const Time& last_modified);
// Wrapper for fopen-like calls. Returns non-NULL FILE* on success. The
// underlying file descriptor (POSIX) or handle (Windows) is unconditionally
@@ -357,8 +349,7 @@
// Writes the given buffer into the file, overwriting any data that was
// previously there. Returns the number of bytes written, or -1 on error.
-int WriteFile(const FilePath& filename, const char* data,
- int size);
+int WriteFile(const FilePath& filename, const char* data, int size);
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
// Appends |data| to |fd|. Does not close |fd| when done. Returns true iff
@@ -368,9 +359,7 @@
// Appends |data| to |filename|. Returns true iff |size| bytes of |data| were
// written to |filename|.
-bool AppendToFile(const FilePath& filename,
- const char* data,
- int size);
+bool AppendToFile(const FilePath& filename, const char* data, int size);
// Gets the current working directory for the process.
bool GetCurrentDirectory(FilePath* path);
@@ -383,7 +372,7 @@
// a number, -1 is returned. If |suffix| is not empty, also checks the
// existence of it with the given suffix.
int GetUniquePathNumber(const FilePath& path,
- const FilePath::StringType& suffix);
+ const FilePath::StringType& suffix);
// Sets the given |fd| to non-blocking mode.
// Returns true if it was able to set it in the non-blocking mode, otherwise
@@ -414,9 +403,9 @@
// This is useful for checking that a config file is administrator-controlled.
// |base| must contain |path|.
bool VerifyPathControlledByUser(const base::FilePath& base,
- const base::FilePath& path,
- uid_t owner_uid,
- const std::set<gid_t>& group_gids);
+ const base::FilePath& path,
+ uid_t owner_uid,
+ const std::set<gid_t>& group_gids);
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
#if defined(OS_MACOSX) && !defined(OS_IOS)
@@ -437,15 +426,15 @@
#if defined(OS_LINUX) || defined(OS_AIX)
// Broad categories of file systems as returned by statfs() on Linux.
enum FileSystemType {
- FILE_SYSTEM_UNKNOWN, // statfs failed.
- FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS.
- FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2
+ FILE_SYSTEM_UNKNOWN, // statfs failed.
+ FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS.
+ FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2
FILE_SYSTEM_NFS,
FILE_SYSTEM_SMB,
FILE_SYSTEM_CODA,
- FILE_SYSTEM_MEMORY, // in-memory file system
- FILE_SYSTEM_CGROUP, // cgroup control.
- FILE_SYSTEM_OTHER, // any other value.
+ FILE_SYSTEM_MEMORY, // in-memory file system
+ FILE_SYSTEM_CGROUP, // cgroup control.
+ FILE_SYSTEM_OTHER, // any other value.
FILE_SYSTEM_TYPE_COUNT
};
@@ -469,16 +458,14 @@
// Same as Move but allows paths with traversal components.
// Use only with extreme care.
-bool MoveUnsafe(const FilePath& from_path,
- const FilePath& to_path);
+bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path);
#if defined(OS_WIN)
// Copy from_path to to_path recursively and then delete from_path recursively.
// Returns true if all operations succeed.
// This function simulates Move(), but unlike Move() it works across volumes.
// This function is not transactional.
-bool CopyAndDeleteDirectory(const FilePath& from_path,
- const FilePath& to_path);
+bool CopyAndDeleteDirectory(const FilePath& from_path, const FilePath& to_path);
#endif // defined(OS_WIN)
} // namespace internal
diff --git a/base/files/file_util_mac.mm b/base/files/file_util_mac.mm
index 0b2e2a0..35fd27a 100644
--- a/base/files/file_util_mac.mm
+++ b/base/files/file_util_mac.mm
@@ -19,8 +19,8 @@
bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
if (from_path.ReferencesParent() || to_path.ReferencesParent())
return false;
- return (copyfile(from_path.value().c_str(),
- to_path.value().c_str(), NULL, COPYFILE_DATA) == 0);
+ return (copyfile(from_path.value().c_str(), to_path.value().c_str(), NULL,
+ COPYFILE_DATA) == 0);
}
bool GetTempDir(base::FilePath* path) {
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index 6fb43bd..83cace9 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -76,8 +76,7 @@
const std::set<gid_t>& group_gids) {
stat_wrapper_t stat_info;
if (CallLstat(path.value().c_str(), &stat_info) != 0) {
- DPLOG(ERROR) << "Failed to get information on path "
- << path.value();
+ DPLOG(ERROR) << "Failed to get information on path " << path.value();
return false;
}
@@ -297,11 +296,11 @@
open_flags |= O_EXCL;
else
open_flags |= O_TRUNC | O_NONBLOCK;
- // Each platform has different default file opening modes for CopyFile which
- // we want to replicate here. On OS X, we use copyfile(3) which takes the
- // source file's permissions into account. On the other platforms, we just
- // use the base::File constructor. On Chrome OS, base::File uses a different
- // set of permissions than it does on other POSIX platforms.
+// Each platform has different default file opening modes for CopyFile which
+// we want to replicate here. On OS X, we use copyfile(3) which takes the
+// source file's permissions into account. On the other platforms, we just
+// use the base::File constructor. On Chrome OS, base::File uses a different
+// set of permissions than it does on other POSIX platforms.
#if defined(OS_MACOSX)
int mode = 0600 | (stat_at_use.st_mode & 0177);
#else
@@ -367,8 +366,8 @@
stack<std::string> directories;
directories.push(path.value());
FileEnumerator traversal(path, true,
- FileEnumerator::FILES | FileEnumerator::DIRECTORIES |
- FileEnumerator::SHOW_SYM_LINKS);
+ FileEnumerator::FILES | FileEnumerator::DIRECTORIES |
+ FileEnumerator::SHOW_SYM_LINKS);
for (FilePath current = traversal.Next(); !current.empty();
current = traversal.Next()) {
if (traversal.GetInfo().IsDirectory())
@@ -503,8 +502,8 @@
const FilePath& symlink_path) {
DCHECK(!symlink_path.empty());
DCHECK(!target_path.empty());
- return ::symlink(target_path.value().c_str(),
- symlink_path.value().c_str()) != -1;
+ return ::symlink(target_path.value().c_str(), symlink_path.value().c_str()) !=
+ -1;
}
bool ReadSymbolicLink(const FilePath& symlink_path, FilePath* target_path) {
@@ -535,8 +534,7 @@
return true;
}
-bool SetPosixFilePermissions(const FilePath& path,
- int mode) {
+bool SetPosixFilePermissions(const FilePath& path, int mode) {
DCHECK_EQ(mode & ~FILE_PERMISSION_MASK, 0);
// Calls stat() so that we can preserve the higher bits like S_ISGID.
@@ -668,15 +666,14 @@
return CreateTemporaryDirInDirImpl(tmpdir, TempFileName(), new_temp_path);
}
-bool CreateDirectoryAndGetError(const FilePath& full_path,
- File::Error* error) {
+bool CreateDirectoryAndGetError(const FilePath& full_path, File::Error* error) {
std::vector<FilePath> subpaths;
// Collect a list of all parent directories.
FilePath last_path = full_path;
subpaths.push_back(full_path);
- for (FilePath path = full_path.DirName();
- path.value() != last_path.value(); path = path.DirName()) {
+ for (FilePath path = full_path.DirName(); path.value() != last_path.value();
+ path = path.DirName()) {
subpaths.push_back(path);
last_path = path;
}
@@ -800,9 +797,8 @@
ssize_t bytes_written_total = 0;
for (ssize_t bytes_written_partial = 0; bytes_written_total < size;
bytes_written_total += bytes_written_partial) {
- bytes_written_partial =
- HANDLE_EINTR(write(fd, data + bytes_written_total,
- size - bytes_written_total));
+ bytes_written_partial = HANDLE_EINTR(
+ write(fd, data + bytes_written_total, size - bytes_written_total));
if (bytes_written_partial < 0)
return false;
}
@@ -850,9 +846,9 @@
uid_t owner_uid,
const std::set<gid_t>& group_gids) {
if (base != path && !base.IsParent(path)) {
- DLOG(ERROR) << "|base| must be a subdirectory of |path|. base = \""
- << base.value() << "\", path = \"" << path.value() << "\"";
- return false;
+ DLOG(ERROR) << "|base| must be a subdirectory of |path|. base = \""
+ << base.value() << "\", path = \"" << path.value() << "\"";
+ return false;
}
std::vector<FilePath::StringType> base_components;
@@ -877,8 +873,8 @@
for (; ip != path_components.end(); ++ip) {
current_path = current_path.Append(*ip);
- if (!VerifySpecificPathControlledByUser(
- current_path, owner_uid, group_gids))
+ if (!VerifySpecificPathControlledByUser(current_path, owner_uid,
+ group_gids))
return false;
}
return true;
@@ -890,14 +886,11 @@
const FilePath kFileSystemRoot("/");
// The name of the administrator group on mac os.
- const char* const kAdminGroupNames[] = {
- "admin",
- "wheel"
- };
+ const char* const kAdminGroupNames[] = {"admin", "wheel"};
std::set<gid_t> allowed_group_ids;
for (int i = 0, ie = arraysize(kAdminGroupNames); i < ie; ++i) {
- struct group *group_record = getgrnam(kAdminGroupNames[i]);
+ struct group* group_record = getgrnam(kAdminGroupNames[i]);
if (!group_record) {
DPLOG(ERROR) << "Could not get the group ID of group \""
<< kAdminGroupNames[i] << "\".";
@@ -907,8 +900,8 @@
allowed_group_ids.insert(group_record->gr_gid);
}
- return VerifyPathControlledByUser(
- kFileSystemRoot, path, kRootUid, allowed_group_ids);
+ return VerifyPathControlledByUser(kFileSystemRoot, path, kRootUid,
+ allowed_group_ids);
}
#endif // defined(OS_MACOSX) && !defined(OS_IOS)
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
index d59b7e4..48190ad 100644
--- a/base/files/file_util_win.cc
+++ b/base/files/file_util_win.cc
@@ -5,6 +5,7 @@
#include "base/files/file_util.h"
#include <windows.h>
+
#include <io.h>
#include <psapi.h>
#include <shellapi.h>
@@ -326,8 +327,8 @@
return false;
return MoveFileEx(path.value().c_str(), NULL,
- MOVEFILE_DELAY_UNTIL_REBOOT |
- MOVEFILE_REPLACE_EXISTING) != FALSE;
+ MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING) !=
+ FALSE;
}
bool ReplaceFile(const FilePath& from_path,
@@ -376,8 +377,8 @@
bool PathIsWritable(const FilePath& path) {
HANDLE dir =
- CreateFile(path.value().c_str(), FILE_ADD_FILE, kFileShareAll,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ CreateFile(path.value().c_str(), FILE_ADD_FILE, kFileShareAll, NULL,
+ OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (dir == INVALID_HANDLE_VALUE)
return false;
@@ -528,8 +529,7 @@
return CreateTemporaryDirInDir(system_temp_dir, prefix, new_temp_path);
}
-bool CreateDirectoryAndGetError(const FilePath& full_path,
- File::Error* error) {
+bool CreateDirectoryAndGetError(const FilePath& full_path, File::Error* error) {
// If the path exists, we've succeeded if it's a directory, failed otherwise.
const wchar_t* full_path_str = full_path.value().c_str();
DWORD fileattr = ::GetFileAttributes(full_path_str);
@@ -622,14 +622,16 @@
FilePath device_path(device_path_as_string);
if (device_path == nt_device_path ||
device_path.IsParent(nt_device_path)) {
- *out_drive_letter_path = FilePath(drive +
- nt_device_path.value().substr(wcslen(device_path_as_string)));
+ *out_drive_letter_path =
+ FilePath(drive + nt_device_path.value().substr(
+ wcslen(device_path_as_string)));
return true;
}
}
// Move to the next drive letter string, which starts one
// increment after the '\0' that terminates the current string.
- while (*drive_map_ptr++) {}
+ while (*drive_map_ptr++) {
+ }
}
// No drive matched. The path does not start with a device junction
@@ -644,14 +646,9 @@
// code below to a call to GetFinalPathNameByHandle(). The method this
// function uses is explained in the following msdn article:
// http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx
- win::ScopedHandle file_handle(
- ::CreateFile(path.value().c_str(),
- GENERIC_READ,
- kFileShareAll,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL));
+ win::ScopedHandle file_handle(::CreateFile(path.value().c_str(), GENERIC_READ,
+ kFileShareAll, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL));
if (!file_handle.IsValid())
return false;
@@ -659,18 +656,15 @@
// we only map the first byte, and need direct access to the handle. You can
// not map an empty file, this call fails in that case.
win::ScopedHandle file_map_handle(
- ::CreateFileMapping(file_handle.Get(),
- NULL,
- PAGE_READONLY,
- 0,
+ ::CreateFileMapping(file_handle.Get(), NULL, PAGE_READONLY, 0,
1, // Just one byte. No need to look at the data.
NULL));
if (!file_map_handle.IsValid())
return false;
// Use a view of the file to get the path to the file.
- void* file_view = MapViewOfFile(file_map_handle.Get(),
- FILE_MAP_READ, 0, 0, 1);
+ void* file_view =
+ MapViewOfFile(file_map_handle.Get(), FILE_MAP_READ, 0, 0, 1);
if (!file_view)
return false;
@@ -700,8 +694,8 @@
bool GetFileInfo(const FilePath& file_path, File::Info* results) {
WIN32_FILE_ATTRIBUTE_DATA attr;
- if (!GetFileAttributesEx(file_path.value().c_str(),
- GetFileExInfoStandard, &attr)) {
+ if (!GetFileAttributesEx(file_path.value().c_str(), GetFileExInfoStandard,
+ &attr)) {
return false;
}
@@ -745,12 +739,9 @@
}
int ReadFile(const FilePath& filename, char* data, int max_size) {
- win::ScopedHandle file(CreateFile(filename.value().c_str(),
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_SEQUENTIAL_SCAN,
+ win::ScopedHandle file(CreateFile(filename.value().c_str(), GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN,
NULL));
if (!file.IsValid())
return -1;
@@ -790,13 +781,8 @@
}
bool AppendToFile(const FilePath& filename, const char* data, int size) {
- win::ScopedHandle file(CreateFile(filename.value().c_str(),
- FILE_APPEND_DATA,
- 0,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL));
+ win::ScopedHandle file(CreateFile(filename.value().c_str(), FILE_APPEND_DATA,
+ 0, NULL, OPEN_EXISTING, 0, NULL));
if (!file.IsValid()) {
return false;
}
@@ -830,8 +816,7 @@
int GetMaximumPathComponentLength(const FilePath& path) {
wchar_t volume_path[MAX_PATH];
if (!GetVolumePathNameW(path.NormalizePathSeparators().value().c_str(),
- volume_path,
- arraysize(volume_path))) {
+ volume_path, arraysize(volume_path))) {
return -1;
}
diff --git a/base/files/file_win.cc b/base/files/file_win.cc
index e922ad8..401ac33 100644
--- a/base/files/file_win.cc
+++ b/base/files/file_win.cc
@@ -226,7 +226,7 @@
GetPlatformFile(),
GetCurrentProcess(), // hTargetProcessHandle
&other_handle,
- 0, // dwDesiredAccess ignored due to SAME_ACCESS
+ 0, // dwDesiredAccess ignored due to SAME_ACCESS
FALSE, // !bInheritHandle
DUPLICATE_SAME_ACCESS)) {
return File(GetLastFileError());
@@ -355,8 +355,8 @@
if (flags & FLAG_SEQUENTIAL_SCAN)
create_flags |= FILE_FLAG_SEQUENTIAL_SCAN;
- file_.Set(CreateFile(path.value().c_str(), access, sharing, NULL,
- disposition, create_flags, NULL));
+ file_.Set(CreateFile(path.value().c_str(), access, sharing, NULL, disposition,
+ create_flags, NULL));
if (file_.IsValid()) {
error_details_ = FILE_OK;
diff --git a/base/files/scoped_file.h b/base/files/scoped_file.h
index c1a2988..f262f18 100644
--- a/base/files/scoped_file.h
+++ b/base/files/scoped_file.h
@@ -19,9 +19,7 @@
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
struct ScopedFDCloseTraits {
- static int InvalidValue() {
- return -1;
- }
+ static int InvalidValue() { return -1; }
static void Free(int fd);
};
#endif
diff --git a/base/gtest_prod_util.h b/base/gtest_prod_util.h
index 6df62e2..664dded 100644
--- a/base/gtest_prod_util.h
+++ b/base/gtest_prod_util.h
@@ -6,11 +6,11 @@
#define BASE_GTEST_PROD_UTIL_H_
// TODO: Remove me.
-#define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \
+#define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \
friend class test_case_name##test_name
// TODO: Remove me.
-#define FORWARD_DECLARE_TEST(test_case_name, test_name) \
+#define FORWARD_DECLARE_TEST(test_case_name, test_name) \
class test_case_name##test_name
#endif // BASE_GTEST_PROD_UTIL_H_
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc
index b0974c0..ac3ba7b 100644
--- a/base/json/json_file_value_serializer.cc
+++ b/base/json/json_file_value_serializer.cc
@@ -18,8 +18,7 @@
JSONFileValueSerializer::JSONFileValueSerializer(
const base::FilePath& json_file_path)
- : json_file_path_(json_file_path) {
-}
+ : json_file_path_(json_file_path) {}
JSONFileValueSerializer::~JSONFileValueSerializer() = default;
@@ -37,9 +36,9 @@
std::string json_string;
JSONStringValueSerializer serializer(&json_string);
serializer.set_pretty_print(true);
- bool result = omit_binary_values ?
- serializer.SerializeAndOmitBinaryValues(root) :
- serializer.Serialize(root);
+ bool result = omit_binary_values
+ ? serializer.SerializeAndOmitBinaryValues(root)
+ : serializer.Serialize(root);
if (!result)
return false;
diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h
index db243b7..b260543 100644
--- a/base/json/json_file_value_serializer.h
+++ b/base/json/json_file_value_serializer.h
@@ -99,4 +99,3 @@
};
#endif // BASE_JSON_JSON_FILE_VALUE_SERIALIZER_H_
-
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc
index e6483ee..713f692 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -35,9 +35,7 @@
++(*depth_);
DCHECK_LE(*depth_, max_depth_);
}
- ~StackMarker() {
- --(*depth_);
- }
+ ~StackMarker() { --(*depth_); }
bool IsTooDeep() const { return *depth_ >= max_depth_; }
@@ -112,7 +110,7 @@
std::string JSONParser::GetErrorMessage() const {
return FormatErrorMessage(error_line_, error_column_,
- JSONReader::ErrorCodeToString(error_code_));
+ JSONReader::ErrorCodeToString(error_code_));
}
int JSONParser::error_line() const {
@@ -454,8 +452,7 @@
while (PeekChar()) {
uint32_t next_char = 0;
if (!ReadUnicodeCharacter(input_.data(),
- static_cast<int32_t>(input_.length()),
- &index_,
+ static_cast<int32_t>(input_.length()), &index_,
&next_char) ||
!IsValidCharacter(next_char)) {
if ((options_ & JSON_REPLACE_INVALID_CHARACTERS) == 0) {
@@ -736,11 +733,12 @@
}
// static
-std::string JSONParser::FormatErrorMessage(int line, int column,
+std::string JSONParser::FormatErrorMessage(int line,
+ int column,
const std::string& description) {
if (line || column) {
- return StringPrintf("Line: %i, column: %i, %s",
- line, column, description.c_str());
+ return StringPrintf("Line: %i, column: %i, %s", line, column,
+ description.c_str());
}
return description;
}
diff --git a/base/json/json_parser.h b/base/json/json_parser.h
index b14a8d7..1289560 100644
--- a/base/json/json_parser.h
+++ b/base/json/json_parser.h
@@ -67,10 +67,10 @@
private:
enum Token {
- T_OBJECT_BEGIN, // {
- T_OBJECT_END, // }
- T_ARRAY_BEGIN, // [
- T_ARRAY_END, // ]
+ T_OBJECT_BEGIN, // {
+ T_OBJECT_END, // }
+ T_ARRAY_BEGIN, // [
+ T_ARRAY_END, // ]
T_STRING,
T_NUMBER,
T_BOOL_TRUE, // true
@@ -207,7 +207,8 @@
// Given the line and column number of an error, formats one of the error
// message contants from json_reader.h for human display.
- static std::string FormatErrorMessage(int line, int column,
+ static std::string FormatErrorMessage(int line,
+ int column,
const std::string& description);
// base::JSONParserOptions that control parsing.
diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc
index bf2a18a..3d5475e 100644
--- a/base/json/json_reader.cc
+++ b/base/json/json_reader.cc
@@ -22,24 +22,18 @@
static_assert(JSONReader::JSON_PARSE_ERROR_COUNT < 1000,
"JSONReader error out of bounds");
-const char JSONReader::kInvalidEscape[] =
- "Invalid escape sequence.";
-const char JSONReader::kSyntaxError[] =
- "Syntax error.";
-const char JSONReader::kUnexpectedToken[] =
- "Unexpected token.";
-const char JSONReader::kTrailingComma[] =
- "Trailing comma not allowed.";
-const char JSONReader::kTooMuchNesting[] =
- "Too much nesting.";
+const char JSONReader::kInvalidEscape[] = "Invalid escape sequence.";
+const char JSONReader::kSyntaxError[] = "Syntax error.";
+const char JSONReader::kUnexpectedToken[] = "Unexpected token.";
+const char JSONReader::kTrailingComma[] = "Trailing comma not allowed.";
+const char JSONReader::kTooMuchNesting[] = "Too much nesting.";
const char JSONReader::kUnexpectedDataAfterRoot[] =
"Unexpected data after root element.";
const char JSONReader::kUnsupportedEncoding[] =
"Unsupported encoding. JSON must be UTF-8.";
const char JSONReader::kUnquotedDictionaryKey[] =
"Dictionary keys must be quoted.";
-const char JSONReader::kInputTooLarge[] =
- "Input string is too large (>2GB).";
+const char JSONReader::kInputTooLarge[] = "Input string is too large (>2GB).";
JSONReader::JSONReader(int options, int max_depth)
: parser_(new internal::JSONParser(options, max_depth)) {}
@@ -55,7 +49,6 @@
return root ? std::make_unique<Value>(std::move(*root)) : nullptr;
}
-
// static
std::unique_ptr<Value> JSONReader::ReadAndReturnError(
StringPiece json,
diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc
index f9c45a4..0c979b7 100644
--- a/base/json/json_string_value_serializer.cc
+++ b/base/json/json_string_value_serializer.cc
@@ -11,9 +11,7 @@
using base::Value;
JSONStringValueSerializer::JSONStringValueSerializer(std::string* json_string)
- : json_string_(json_string),
- pretty_print_(false) {
-}
+ : json_string_(json_string), pretty_print_(false) {}
JSONStringValueSerializer::~JSONStringValueSerializer() = default;
diff --git a/base/json/json_value_converter.cc b/base/json/json_value_converter.cc
index 6f772f3..55506e6 100644
--- a/base/json/json_value_converter.cc
+++ b/base/json/json_value_converter.cc
@@ -7,31 +7,30 @@
namespace base {
namespace internal {
-bool BasicValueConverter<int>::Convert(
- const base::Value& value, int* field) const {
+bool BasicValueConverter<int>::Convert(const base::Value& value,
+ int* field) const {
return value.GetAsInteger(field);
}
-bool BasicValueConverter<std::string>::Convert(
- const base::Value& value, std::string* field) const {
+bool BasicValueConverter<std::string>::Convert(const base::Value& value,
+ std::string* field) const {
return value.GetAsString(field);
}
-bool BasicValueConverter<string16>::Convert(
- const base::Value& value, string16* field) const {
+bool BasicValueConverter<string16>::Convert(const base::Value& value,
+ string16* field) const {
return value.GetAsString(field);
}
-bool BasicValueConverter<double>::Convert(
- const base::Value& value, double* field) const {
+bool BasicValueConverter<double>::Convert(const base::Value& value,
+ double* field) const {
return value.GetAsDouble(field);
}
-bool BasicValueConverter<bool>::Convert(
- const base::Value& value, bool* field) const {
+bool BasicValueConverter<bool>::Convert(const base::Value& value,
+ bool* field) const {
return value.GetAsBoolean(field);
}
} // namespace internal
} // namespace base
-
diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h
index 115e47a..d91bead 100644
--- a/base/json/json_value_converter.h
+++ b/base/json/json_value_converter.h
@@ -91,13 +91,13 @@
namespace internal {
-template<typename StructType>
+template <typename StructType>
class FieldConverterBase {
public:
explicit FieldConverterBase(const std::string& path) : field_path_(path) {}
virtual ~FieldConverterBase() = default;
- virtual bool ConvertField(const base::Value& value, StructType* obj)
- const = 0;
+ virtual bool ConvertField(const base::Value& value,
+ StructType* obj) const = 0;
const std::string& field_path() const { return field_path_; }
private:
@@ -116,19 +116,18 @@
class FieldConverter : public FieldConverterBase<StructType> {
public:
explicit FieldConverter(const std::string& path,
- FieldType StructType::* field,
+ FieldType StructType::*field,
ValueConverter<FieldType>* converter)
: FieldConverterBase<StructType>(path),
field_pointer_(field),
- value_converter_(converter) {
- }
+ value_converter_(converter) {}
bool ConvertField(const base::Value& value, StructType* dst) const override {
return value_converter_->Convert(value, &(dst->*field_pointer_));
}
private:
- FieldType StructType::* field_pointer_;
+ FieldType StructType::*field_pointer_;
std::unique_ptr<ValueConverter<FieldType>> value_converter_;
DISALLOW_COPY_AND_ASSIGN(FieldConverter);
};
@@ -148,8 +147,7 @@
};
template <>
-class BasicValueConverter<std::string>
- : public ValueConverter<std::string> {
+class BasicValueConverter<std::string> : public ValueConverter<std::string> {
public:
BasicValueConverter() = default;
@@ -160,8 +158,7 @@
};
template <>
-class BasicValueConverter<string16>
- : public ValueConverter<string16> {
+class BasicValueConverter<string16> : public ValueConverter<string16> {
public:
BasicValueConverter() = default;
@@ -196,7 +193,7 @@
template <typename FieldType>
class ValueFieldConverter : public ValueConverter<FieldType> {
public:
- typedef bool(*ConvertFunc)(const base::Value* value, FieldType* field);
+ typedef bool (*ConvertFunc)(const base::Value* value, FieldType* field);
explicit ValueFieldConverter(ConvertFunc convert_func)
: convert_func_(convert_func) {}
@@ -222,7 +219,7 @@
bool Convert(const base::Value& value, FieldType* field) const override {
std::string string_value;
return value.GetAsString(&string_value) &&
- convert_func_(string_value, field);
+ convert_func_(string_value, field);
}
private:
@@ -317,7 +314,7 @@
class RepeatedCustomValueConverter
: public ValueConverter<std::vector<std::unique_ptr<NestedType>>> {
public:
- typedef bool(*ConvertFunc)(const base::Value* value, NestedType* field);
+ typedef bool (*ConvertFunc)(const base::Value* value, NestedType* field);
explicit RepeatedCustomValueConverter(ConvertFunc convert_func)
: convert_func_(convert_func) {}
@@ -349,54 +346,50 @@
DISALLOW_COPY_AND_ASSIGN(RepeatedCustomValueConverter);
};
-
} // namespace internal
template <class StructType>
class JSONValueConverter {
public:
- JSONValueConverter() {
- StructType::RegisterJSONConverter(this);
- }
+ JSONValueConverter() { StructType::RegisterJSONConverter(this); }
- void RegisterIntField(const std::string& field_name,
- int StructType::* field) {
+ void RegisterIntField(const std::string& field_name, int StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, int>>(
field_name, field, new internal::BasicValueConverter<int>));
}
void RegisterStringField(const std::string& field_name,
- std::string StructType::* field) {
+ std::string StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, std::string>>(
field_name, field, new internal::BasicValueConverter<std::string>));
}
void RegisterStringField(const std::string& field_name,
- string16 StructType::* field) {
+ string16 StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, string16>>(
field_name, field, new internal::BasicValueConverter<string16>));
}
void RegisterBoolField(const std::string& field_name,
- bool StructType::* field) {
+ bool StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, bool>>(
field_name, field, new internal::BasicValueConverter<bool>));
}
void RegisterDoubleField(const std::string& field_name,
- double StructType::* field) {
+ double StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, double>>(
field_name, field, new internal::BasicValueConverter<double>));
}
template <class NestedType>
- void RegisterNestedField(
- const std::string& field_name, NestedType StructType::* field) {
+ void RegisterNestedField(const std::string& field_name,
+ NestedType StructType::*field) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, NestedType>>(
field_name, field, new internal::NestedValueConverter<NestedType>));
@@ -413,10 +406,10 @@
}
template <typename FieldType>
- void RegisterCustomValueField(
- const std::string& field_name,
- FieldType StructType::* field,
- bool (*convert_func)(const base::Value*, FieldType*)) {
+ void RegisterCustomValueField(const std::string& field_name,
+ FieldType StructType::*field,
+ bool (*convert_func)(const base::Value*,
+ FieldType*)) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, FieldType>>(
field_name, field,
diff --git a/base/json/string_escape.h b/base/json/string_escape.h
index 2f74836..d318b6a 100644
--- a/base/json/string_escape.h
+++ b/base/json/string_escape.h
@@ -25,16 +25,12 @@
//
// If |put_in_quotes| is true, then a leading and trailing double-quote mark
// will be appended to |dest| as well.
-bool EscapeJSONString(StringPiece str,
- bool put_in_quotes,
- std::string* dest);
+bool EscapeJSONString(StringPiece str, bool put_in_quotes, std::string* dest);
// Performs a similar function to the UTF-8 StringPiece version above,
// converting UTF-16 code units to UTF-8 code units and escaping non-printing
// control characters. On return, |dest| will contain a valid UTF-8 JSON string.
-bool EscapeJSONString(StringPiece16 str,
- bool put_in_quotes,
- std::string* dest);
+bool EscapeJSONString(StringPiece16 str, bool put_in_quotes, std::string* dest);
// Helper functions that wrap the above two functions but return the value
// instead of appending. |put_in_quotes| is always true.
@@ -52,8 +48,7 @@
//
// The output of this function takes the *appearance* of JSON but is not in
// fact valid according to RFC 4627.
-std::string EscapeBytesAsInvalidJSONString(StringPiece str,
- bool put_in_quotes);
+std::string EscapeBytesAsInvalidJSONString(StringPiece str, bool put_in_quotes);
} // namespace base
diff --git a/base/logging.cc b/base/logging.cc
index 915f2e0..f6de944 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -42,9 +42,9 @@
#endif
#include <CoreFoundation/CoreFoundation.h>
+#include <mach-o/dyld.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
-#include <mach-o/dyld.h>
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#include <time.h>
@@ -198,13 +198,9 @@
// LoggingLocks can not be nested.
class LoggingLock {
public:
- LoggingLock() {
- LockLogging();
- }
+ LoggingLock() { LockLogging(); }
- ~LoggingLock() {
- UnlockLogging();
- }
+ ~LoggingLock() { UnlockLogging(); }
static void Init(LogLockingState lock_log, const PathChar* new_log_file) {
if (initialized)
@@ -290,8 +286,8 @@
// try the current directory
wchar_t system_buffer[MAX_PATH];
system_buffer[0] = 0;
- DWORD len = ::GetCurrentDirectory(arraysize(system_buffer),
- system_buffer);
+ DWORD len =
+ ::GetCurrentDirectory(arraysize(system_buffer), system_buffer);
if (len == 0 || len > arraysize(system_buffer))
return false;
@@ -403,8 +399,10 @@
severity >= kAlwaysPrintErrorLevel;
}
-void SetLogItems(bool enable_process_id, bool enable_thread_id,
- bool enable_timestamp, bool enable_tickcount) {
+void SetLogItems(bool enable_process_id,
+ bool enable_thread_id,
+ bool enable_timestamp,
+ bool enable_tickcount) {
g_log_process_id = enable_process_id;
g_log_thread_id = enable_thread_id;
g_log_timestamp = enable_timestamp;
@@ -424,16 +422,25 @@
}
// Explicit instantiations for commonly used comparisons.
-template std::string* MakeCheckOpString<int, int>(
- const int&, const int&, const char* names);
+template std::string* MakeCheckOpString<int, int>(const int&,
+ const int&,
+ const char* names);
template std::string* MakeCheckOpString<unsigned long, unsigned long>(
- const unsigned long&, const unsigned long&, const char* names);
+ const unsigned long&,
+ const unsigned long&,
+ const char* names);
template std::string* MakeCheckOpString<unsigned long, unsigned int>(
- const unsigned long&, const unsigned int&, const char* names);
+ const unsigned long&,
+ const unsigned int&,
+ const char* names);
template std::string* MakeCheckOpString<unsigned int, unsigned long>(
- const unsigned int&, const unsigned long&, const char* names);
+ const unsigned int&,
+ const unsigned long&,
+ const char* names);
template std::string* MakeCheckOpString<std::string, std::string>(
- const std::string&, const std::string&, const char* name);
+ const std::string&,
+ const std::string&,
+ const char* name);
void MakeCheckOpValueString(std::ostream* os, std::nullptr_t p) {
(*os) << "nullptr";
@@ -462,8 +469,7 @@
#endif // !defined(NDEBUG)
#if defined(OS_WIN)
-LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {
-}
+LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {}
LogMessage::SaveLastError::~SaveLastError() {
::SetLastError(last_error_);
@@ -488,7 +494,9 @@
delete result;
}
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
+LogMessage::LogMessage(const char* file,
+ int line,
+ LogSeverity severity,
std::string* result)
: severity_(severity), file_(file), line_(line) {
Init(file, line);
@@ -507,9 +515,8 @@
std::string str_newline(stream_.str());
// Give any log message handler first dibs on the message.
- if (log_message_handler &&
- log_message_handler(severity_, file_, line_,
- message_start_, str_newline)) {
+ if (log_message_handler && log_message_handler(severity_, file_, line_,
+ message_start_, str_newline)) {
// The handler took care of it, no further processing.
return;
}
@@ -603,9 +610,9 @@
// Map Chrome log severities to ASL log levels.
const char* const asl_level_string = [](LogSeverity severity) {
- // ASL_LEVEL_* are ints, but ASL needs equivalent strings. This
- // non-obvious two-step macro trick achieves what's needed.
- // https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
+// ASL_LEVEL_* are ints, but ASL needs equivalent strings. This
+// non-obvious two-step macro trick achieves what's needed.
+// https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define ASL_LEVEL_STR(level) ASL_LEVEL_STR_X(level)
#define ASL_LEVEL_STR_X(level) #level
switch (severity) {
@@ -677,13 +684,13 @@
// write to log file
if ((g_logging_destination & LOG_TO_FILE) != 0) {
- // We can have multiple threads and/or processes, so try to prevent them
- // from clobbering each other's writes.
- // If the client app did not call InitLogging, and the lock has not
- // been created do it now. We do this on demand, but if two threads try
- // to do this at the same time, there will be a race condition to create
- // the lock. This is why InitLogging should be called from the main
- // thread at the beginning of execution.
+// We can have multiple threads and/or processes, so try to prevent them
+// from clobbering each other's writes.
+// If the client app did not call InitLogging, and the lock has not
+// been created do it now. We do this on demand, but if two threads try
+// to do this at the same time, there will be a race condition to create
+// the lock. This is why InitLogging should be called from the main
+// thread at the beginning of execution.
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
LoggingLock::Init(LOCK_LOG_FILE, nullptr);
LoggingLock logging_lock;
@@ -691,14 +698,12 @@
if (InitializeLogFileHandle()) {
#if defined(OS_WIN)
DWORD num_written;
- WriteFile(g_log_file,
- static_cast<const void*>(str_newline.c_str()),
- static_cast<DWORD>(str_newline.length()),
- &num_written,
+ WriteFile(g_log_file, static_cast<const void*>(str_newline.c_str()),
+ static_cast<DWORD>(str_newline.length()), &num_written,
nullptr);
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
- ignore_result(fwrite(
- str_newline.data(), str_newline.size(), 1, g_log_file));
+ ignore_result(
+ fwrite(str_newline.data(), str_newline.size(), 1, g_log_file));
fflush(g_log_file);
#else
#error Unsupported platform
@@ -731,7 +736,7 @@
// TODO(darin): It might be nice if the columns were fixed width.
- stream_ << '[';
+ stream_ << '[';
if (g_log_process_id)
stream_ << CurrentProcessId() << ':';
if (g_log_thread_id)
@@ -740,17 +745,11 @@
#if defined(OS_WIN)
SYSTEMTIME local_time;
GetLocalTime(&local_time);
- stream_ << std::setfill('0')
- << std::setw(2) << local_time.wMonth
- << std::setw(2) << local_time.wDay
- << '/'
- << std::setw(2) << local_time.wHour
- << std::setw(2) << local_time.wMinute
- << std::setw(2) << local_time.wSecond
- << '.'
- << std::setw(3)
- << local_time.wMilliseconds
- << ':';
+ stream_ << std::setfill('0') << std::setw(2) << local_time.wMonth
+ << std::setw(2) << local_time.wDay << '/' << std::setw(2)
+ << local_time.wHour << std::setw(2) << local_time.wMinute
+ << std::setw(2) << local_time.wSecond << '.' << std::setw(3)
+ << local_time.wMilliseconds << ':';
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
timeval tv;
gettimeofday(&tv, nullptr);
@@ -758,16 +757,11 @@
struct tm local_time;
localtime_r(&t, &local_time);
struct tm* tm_time = &local_time;
- stream_ << std::setfill('0')
- << std::setw(2) << 1 + tm_time->tm_mon
- << std::setw(2) << tm_time->tm_mday
- << '/'
- << std::setw(2) << tm_time->tm_hour
- << std::setw(2) << tm_time->tm_min
- << std::setw(2) << tm_time->tm_sec
- << '.'
- << std::setw(6) << tv.tv_usec
- << ':';
+ stream_ << std::setfill('0') << std::setw(2) << 1 + tm_time->tm_mon
+ << std::setw(2) << tm_time->tm_mday << '/' << std::setw(2)
+ << tm_time->tm_hour << std::setw(2) << tm_time->tm_min
+ << std::setw(2) << tm_time->tm_sec << '.' << std::setw(6)
+ << tv.tv_usec << ':';
#else
#error Unsupported platform
#endif
@@ -819,15 +813,12 @@
#endif // defined(OS_WIN)
}
-
#if defined(OS_WIN)
Win32ErrorLogMessage::Win32ErrorLogMessage(const char* file,
int line,
LogSeverity severity,
SystemErrorCode err)
- : err_(err),
- log_message_(file, line, severity) {
-}
+ : err_(err), log_message_(file, line, severity) {}
Win32ErrorLogMessage::~Win32ErrorLogMessage() {
stream() << ": " << SystemErrorCodeToString(err_);
@@ -837,9 +828,7 @@
int line,
LogSeverity severity,
SystemErrorCode err)
- : err_(err),
- log_message_(file, line, severity) {
-}
+ : err_(err), log_message_(file, line, severity) {}
ErrnoLogMessage::~ErrnoLogMessage() {
stream() << ": " << SystemErrorCodeToString(err_);
@@ -859,9 +848,8 @@
const size_t message_len = strlen(message);
int rv;
while (bytes_written < message_len) {
- rv = HANDLE_EINTR(
- write(STDERR_FILENO, message + bytes_written,
- message_len - bytes_written));
+ rv = HANDLE_EINTR(write(STDERR_FILENO, message + bytes_written,
+ message_len - bytes_written));
if (rv < 0) {
// Give up, nothing we can do now.
break;
@@ -900,8 +888,7 @@
#endif
void LogErrorNotReached(const char* file, int line) {
- LogMessage(file, line, LOG_ERROR).stream()
- << "NOTREACHED() hit.";
+ LogMessage(file, line, LOG_ERROR).stream() << "NOTREACHED() hit.";
}
} // namespace logging
diff --git a/base/logging.h b/base/logging.h
index 36eb271..3fb3778 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -45,7 +45,6 @@
// If DebugMessage.exe is not found, the logging code will use a normal
// MessageBox, potentially causing the problems discussed above.
-
// Instructions
// ------------
//
@@ -114,15 +113,15 @@
// Where to record logging output? A flat file and/or system debug log
// via OutputDebugString.
enum LoggingDestination {
- LOG_NONE = 0,
- LOG_TO_FILE = 1 << 0,
+ LOG_NONE = 0,
+ LOG_TO_FILE = 1 << 0,
LOG_TO_SYSTEM_DEBUG_LOG = 1 << 1,
LOG_TO_ALL = LOG_TO_FILE | LOG_TO_SYSTEM_DEBUG_LOG,
- // On Windows, use a file next to the exe; on POSIX platforms, where
- // it may not even be possible to locate the executable on disk, use
- // stderr.
+// On Windows, use a file next to the exe; on POSIX platforms, where
+// it may not even be possible to locate the executable on disk, use
+// stderr.
#if defined(OS_WIN)
LOG_DEFAULT = LOG_TO_FILE,
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
@@ -210,8 +209,10 @@
// process and thread IDs default to off, the timestamp defaults to on.
// If this function is not called, logging defaults to writing the timestamp
// only.
-void SetLogItems(bool enable_process_id, bool enable_thread_id,
- bool enable_timestamp, bool enable_tickcount);
+void SetLogItems(bool enable_process_id,
+ bool enable_thread_id,
+ bool enable_timestamp,
+ bool enable_tickcount);
// Sets whether or not you'd like to see fatal debug messages popped up in
// a dialog box or not.
@@ -223,7 +224,10 @@
// Returns true to signal that it handled the message and the message
// should not be sent to other log destinations.
typedef bool (*LogMessageHandlerFunction)(int severity,
- const char* file, int line, size_t message_start, const std::string& str);
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str);
void SetLogMessageHandler(LogMessageHandlerFunction handler);
LogMessageHandlerFunction GetLogMessageHandler();
@@ -308,7 +312,7 @@
// the Windows SDK does for consistency.
#define ERROR 0
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
- COMPACT_GOOGLE_LOG_EX_ERROR(ClassName , ##__VA_ARGS__)
+ COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
// Needed for LOG_IS_ON(ERROR).
const LogSeverity LOG_0 = LOG_ERROR;
@@ -322,8 +326,8 @@
// Helper macro which avoids evaluating the arguments to a stream if
// the condition doesn't hold. Condition is evaluated once and only once.
-#define LAZY_STREAM(stream, condition) \
- !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream)
+#define LAZY_STREAM(stream, condition) \
+ !(condition) ? (void)0 : ::logging::LogMessageVoidify() & (stream)
// We use the preprocessor's merging operator, "##", so that, e.g.,
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
@@ -333,7 +337,7 @@
// impossible to stream something like a string directly to an unnamed
// ostream. We employ a neat hack by calling the stream() member
// function of LogMessage which seems to avoid the problem.
-#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
+#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream()
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
#define LOG_IF(severity, condition) \
@@ -344,17 +348,18 @@
<< "Assert failed: " #condition ". "
#if defined(OS_WIN)
-#define PLOG_STREAM(severity) \
- COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \
- ::logging::GetLastSystemErrorCode()).stream()
+#define PLOG_STREAM(severity) \
+ COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \
+ ::logging::GetLastSystemErrorCode()) \
+ .stream()
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
-#define PLOG_STREAM(severity) \
- COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
- ::logging::GetLastSystemErrorCode()).stream()
+#define PLOG_STREAM(severity) \
+ COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \
+ ::logging::GetLastSystemErrorCode()) \
+ .stream()
#endif
-#define PLOG(severity) \
- LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
+#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
#define PLOG_IF(severity, condition) \
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
@@ -517,7 +522,7 @@
LAZY_STREAM(PLOG_STREAM(FATAL), UNLIKELY(!(condition))); \
EAT_STREAM_PARAMETERS
-#define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2))
+#define CHECK_OP(name, op, val1, val2) CHECK((val1)op(val2))
#else // !(OFFICIAL_BUILD && NDEBUG)
@@ -529,15 +534,13 @@
// __analysis_assume gets confused on some conditions:
// http://randomascii.wordpress.com/2011/09/13/analyze-for-visual-studio-the-ugly-part-5/
-#define CHECK(condition) \
- __analysis_assume(!!(condition)), \
- LAZY_STREAM(LOG_STREAM(FATAL), false) \
- << "Check failed: " #condition ". "
+#define CHECK(condition) \
+ __analysis_assume(!!(condition)), LAZY_STREAM(LOG_STREAM(FATAL), false) \
+ << "Check failed: " #condition ". "
-#define PCHECK(condition) \
- __analysis_assume(!!(condition)), \
- LAZY_STREAM(PLOG_STREAM(FATAL), false) \
- << "Check failed: " #condition ". "
+#define PCHECK(condition) \
+ __analysis_assume(!!(condition)), LAZY_STREAM(PLOG_STREAM(FATAL), false) \
+ << "Check failed: " #condition ". "
#else // _PREFAST_
@@ -558,14 +561,17 @@
// macro is used in an 'if' clause such as:
// if (a == 1)
// CHECK_EQ(2, a);
-#define CHECK_OP(name, op, val1, val2) \
- switch (0) case 0: default: \
- if (::logging::CheckOpResult true_if_passed = \
- ::logging::Check##name##Impl((val1), (val2), \
- #val1 " " #op " " #val2)) \
- ; \
- else \
- ::logging::LogMessage(__FILE__, __LINE__, true_if_passed.message()).stream()
+#define CHECK_OP(name, op, val1, val2) \
+ switch (0) \
+ case 0: \
+ default: \
+ if (::logging::CheckOpResult true_if_passed = \
+ ::logging::Check##name##Impl((val1), (val2), \
+ #val1 " " #op " " #val2)) \
+ ; \
+ else \
+ ::logging::LogMessage(__FILE__, __LINE__, true_if_passed.message()) \
+ .stream()
#endif // !(OFFICIAL_BUILD && NDEBUG)
@@ -611,7 +617,7 @@
// function template because it is not performance critical and so can
// be out of line, while the "Impl" code should be inline. Caller
// takes ownership of the returned string.
-template<class t1, class t2>
+template <class t1, class t2>
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
std::ostringstream ss;
ss << names << " (";
@@ -625,20 +631,25 @@
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
// in logging.cc.
-extern template std::string* MakeCheckOpString<int, int>(
- const int&, const int&, const char* names);
-extern template
-std::string* MakeCheckOpString<unsigned long, unsigned long>(
- const unsigned long&, const unsigned long&, const char* names);
-extern template
-std::string* MakeCheckOpString<unsigned long, unsigned int>(
- const unsigned long&, const unsigned int&, const char* names);
-extern template
-std::string* MakeCheckOpString<unsigned int, unsigned long>(
- const unsigned int&, const unsigned long&, const char* names);
-extern template
-std::string* MakeCheckOpString<std::string, std::string>(
- const std::string&, const std::string&, const char* name);
+extern template std::string* MakeCheckOpString<int, int>(const int&,
+ const int&,
+ const char* names);
+extern template std::string* MakeCheckOpString<unsigned long, unsigned long>(
+ const unsigned long&,
+ const unsigned long&,
+ const char* names);
+extern template std::string* MakeCheckOpString<unsigned long, unsigned int>(
+ const unsigned long&,
+ const unsigned int&,
+ const char* names);
+extern template std::string* MakeCheckOpString<unsigned int, unsigned long>(
+ const unsigned int&,
+ const unsigned long&,
+ const char* names);
+extern template std::string* MakeCheckOpString<std::string, std::string>(
+ const std::string&,
+ const std::string&,
+ const char* name);
// Helper functions for CHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
@@ -666,17 +677,17 @@
DEFINE_CHECK_OP_IMPL(EQ, ==)
DEFINE_CHECK_OP_IMPL(NE, !=)
DEFINE_CHECK_OP_IMPL(LE, <=)
-DEFINE_CHECK_OP_IMPL(LT, < )
+DEFINE_CHECK_OP_IMPL(LT, <)
DEFINE_CHECK_OP_IMPL(GE, >=)
-DEFINE_CHECK_OP_IMPL(GT, > )
+DEFINE_CHECK_OP_IMPL(GT, >)
#undef DEFINE_CHECK_OP_IMPL
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
+#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2)
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
+#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2)
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
#define DCHECK_IS_ON() 0
@@ -706,11 +717,9 @@
#endif // DCHECK_IS_ON()
-#define DLOG(severity) \
- LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
+#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
-#define DPLOG(severity) \
- LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
+#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
// Definitions for DCHECK et al.
@@ -742,15 +751,13 @@
#if defined(_PREFAST_) && defined(OS_WIN)
// See comments on the previous use of __analysis_assume.
-#define DCHECK(condition) \
- __analysis_assume(!!(condition)), \
- LAZY_STREAM(LOG_STREAM(DCHECK), false) \
- << "Check failed: " #condition ". "
+#define DCHECK(condition) \
+ __analysis_assume(!!(condition)), LAZY_STREAM(LOG_STREAM(DCHECK), false) \
+ << "Check failed: " #condition ". "
-#define DPCHECK(condition) \
- __analysis_assume(!!(condition)), \
- LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
- << "Check failed: " #condition ". "
+#define DPCHECK(condition) \
+ __analysis_assume(!!(condition)), LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
+ << "Check failed: " #condition ". "
#else // !(defined(_PREFAST_) && defined(OS_WIN))
@@ -780,16 +787,19 @@
// DCHECK_EQ(2, a);
#if DCHECK_IS_ON()
-#define DCHECK_OP(name, op, val1, val2) \
- switch (0) case 0: default: \
- if (::logging::CheckOpResult true_if_passed = \
- DCHECK_IS_ON() ? \
- ::logging::Check##name##Impl((val1), (val2), \
- #val1 " " #op " " #val2) : nullptr) \
- ; \
- else \
- ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
- true_if_passed.message()).stream()
+#define DCHECK_OP(name, op, val1, val2) \
+ switch (0) \
+ case 0: \
+ default: \
+ if (::logging::CheckOpResult true_if_passed = \
+ DCHECK_IS_ON() ? ::logging::Check##name##Impl( \
+ (val1), (val2), #val1 " " #op " " #val2) \
+ : nullptr) \
+ ; \
+ else \
+ ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
+ true_if_passed.message()) \
+ .stream()
#else // DCHECK_IS_ON()
@@ -833,9 +843,9 @@
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
-#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
+#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2)
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
-#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
+#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
#if !DCHECK_IS_ON() && defined(OS_CHROMEOS)
// Implement logging of NOTREACHED() as a dedicated function to get function
@@ -873,7 +883,9 @@
LogMessage(const char* file, int line, std::string* result);
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
- LogMessage(const char* file, int line, LogSeverity severity,
+ LogMessage(const char* file,
+ int line,
+ LogSeverity severity,
std::string* result);
~LogMessage();
@@ -925,7 +937,7 @@
LogMessageVoidify() = default;
// This has to be an operator with a precedence lower than << but
// higher than ?:
- void operator&(std::ostream&) { }
+ void operator&(std::ostream&) {}
};
#if defined(OS_WIN)
diff --git a/base/mac/bind_objc_block.h b/base/mac/bind_objc_block.h
index 9a481ed..87d38bf 100644
--- a/base/mac/bind_objc_block.h
+++ b/base/mac/bind_objc_block.h
@@ -41,9 +41,9 @@
namespace internal {
// Helper function to run the block contained in the parameter.
-template<typename R, typename... Args>
-R RunBlock(base::mac::ScopedBlock<R(^)(Args...)> block, Args... args) {
- R(^extracted_block)(Args...) = block.get();
+template <typename R, typename... Args>
+R RunBlock(base::mac::ScopedBlock<R (^)(Args...)> block, Args... args) {
+ R (^extracted_block)(Args...) = block.get();
return extracted_block(args...);
}
@@ -53,8 +53,8 @@
// Construct a callback from an objective-C block with up to six arguments (see
// note above).
-template<typename R, typename... Args>
-base::Callback<R(Args...)> BindBlock(R(^block)(Args...)) {
+template <typename R, typename... Args>
+base::Callback<R(Args...)> BindBlock(R (^block)(Args...)) {
return base::Bind(
&base::internal::RunBlock<R, Args...>,
base::mac::ScopedBlock<R (^)(Args...)>(
diff --git a/base/mac/bundle_locations.h b/base/mac/bundle_locations.h
index 86ff1a4..2bda76e 100644
--- a/base/mac/bundle_locations.h
+++ b/base/mac/bundle_locations.h
@@ -9,7 +9,7 @@
#if defined(__OBJC__)
#import <Foundation/Foundation.h>
-#else // __OBJC__
+#else // __OBJC__
class NSBundle;
#endif // __OBJC__
diff --git a/base/mac/dispatch_source_mach.cc b/base/mac/dispatch_source_mach.cc
index 0858f30..50da7e4 100644
--- a/base/mac/dispatch_source_mach.cc
+++ b/base/mac/dispatch_source_mach.cc
@@ -24,11 +24,13 @@
void (^event_handler)())
: queue_(queue, base::scoped_policy::RETAIN),
source_(dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV,
- port, 0, queue_)),
+ port,
+ 0,
+ queue_)),
source_canceled_(dispatch_semaphore_create(0)) {
dispatch_source_set_event_handler(source_, event_handler);
dispatch_source_set_cancel_handler(source_, ^{
- dispatch_semaphore_signal(source_canceled_);
+ dispatch_semaphore_signal(source_canceled_);
});
}
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h
index 29f281b..c5cead4 100644
--- a/base/mac/foundation_util.h
+++ b/base/mac/foundation_util.h
@@ -35,8 +35,9 @@
// Adapted from NSObjCRuntime.h NS_ENUM definition (used in Foundation starting
// with the OS X 10.8 SDK and the iOS 6.0 SDK).
#if __has_extension(cxx_strong_enums) && \
- (defined(OS_IOS) || (defined(MAC_OS_X_VERSION_10_8) && \
- MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8))
+ (defined(OS_IOS) || \
+ (defined(MAC_OS_X_VERSION_10_8) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8))
#define CR_FORWARD_ENUM(_type, _name) enum _name : _type _name
#else
#define CR_FORWARD_ENUM(_type, _name) _type _name
@@ -102,20 +103,18 @@
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
bool GetSearchPathDirectory(NSSearchPathDirectory directory,
- NSSearchPathDomainMask domain_mask,
- FilePath* result);
+ NSSearchPathDomainMask domain_mask,
+ FilePath* result);
// Searches for directories for the given key in only the local domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
-bool GetLocalDirectory(NSSearchPathDirectory directory,
- FilePath* result);
+bool GetLocalDirectory(NSSearchPathDirectory directory, FilePath* result);
// Searches for directories for the given key in only the user domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
-bool GetUserDirectory(NSSearchPathDirectory directory,
- FilePath* result);
+bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result);
// Returns the ~/Library directory.
FilePath GetUserLibraryPath();
@@ -128,7 +127,7 @@
FilePath GetAppBundlePath(const FilePath& exec_name);
#define TYPE_NAME_FOR_CF_TYPE_DECL(TypeCF) \
-std::string TypeNameForCFType(TypeCF##Ref);
+ std::string TypeNameForCFType(TypeCF##Ref);
TYPE_NAME_FOR_CF_TYPE_DECL(CFArray);
TYPE_NAME_FOR_CF_TYPE_DECL(CFBag);
@@ -208,25 +207,25 @@
// of macros and function overloading is used instead.
#define CF_TO_NS_CAST_DECL(TypeCF, TypeNS) \
-OBJC_CPP_CLASS_DECL(TypeNS) \
-\
-namespace base { \
-namespace mac { \
-TypeNS* CFToNSCast(TypeCF##Ref cf_val); \
-TypeCF##Ref NSToCFCast(TypeNS* ns_val); \
-} \
-}
+ OBJC_CPP_CLASS_DECL(TypeNS) \
+ \
+ namespace base { \
+ namespace mac { \
+ TypeNS* CFToNSCast(TypeCF##Ref cf_val); \
+ TypeCF##Ref NSToCFCast(TypeNS* ns_val); \
+ } \
+ }
-#define CF_TO_NS_MUTABLE_CAST_DECL(name) \
-CF_TO_NS_CAST_DECL(CF##name, NS##name) \
-OBJC_CPP_CLASS_DECL(NSMutable##name) \
-\
-namespace base { \
-namespace mac { \
-NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val); \
-CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val); \
-} \
-}
+#define CF_TO_NS_MUTABLE_CAST_DECL(name) \
+ CF_TO_NS_CAST_DECL(CF##name, NS##name) \
+ OBJC_CPP_CLASS_DECL(NSMutable##name) \
+ \
+ namespace base { \
+ namespace mac { \
+ NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val); \
+ CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val); \
+ } \
+ }
// List of toll-free bridged types taken from:
// http://www.cocoadev.com/index.pl?TollFreeBridged
@@ -278,18 +277,18 @@
// CFTypeRef hello = CFSTR("hello world");
// CFStringRef some_string = base::mac::CFCastStrict<CFStringRef>(hello);
-template<typename T>
+template <typename T>
T CFCast(const CFTypeRef& cf_val);
-template<typename T>
+template <typename T>
T CFCastStrict(const CFTypeRef& cf_val);
-#define CF_CAST_DECL(TypeCF) \
-template<> TypeCF##Ref \
-CFCast<TypeCF##Ref>(const CFTypeRef& cf_val);\
-\
-template<> TypeCF##Ref \
-CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val);
+#define CF_CAST_DECL(TypeCF) \
+ template <> \
+ TypeCF##Ref CFCast<TypeCF##Ref>(const CFTypeRef& cf_val); \
+ \
+ template <> \
+ TypeCF##Ref CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val);
CF_CAST_DECL(CFArray);
CF_CAST_DECL(CFBag);
@@ -341,7 +340,7 @@
//
// NSString* str = base::mac::ObjCCastStrict<NSString>(
// [ns_arr_of_ns_strs objectAtIndex:0]);
-template<typename T>
+template <typename T>
T* ObjCCast(id objc_val) {
if ([objc_val isKindOfClass:[T class]]) {
return reinterpret_cast<T*>(objc_val);
@@ -349,7 +348,7 @@
return nil;
}
-template<typename T>
+template <typename T>
T* ObjCCastStrict(id objc_val) {
T* rv = ObjCCast<T>(objc_val);
DCHECK(objc_val == nil || rv);
@@ -360,20 +359,20 @@
// Helper function for GetValueFromDictionary to create the error message
// that appears when a type mismatch is encountered.
-std::string GetValueFromDictionaryErrorMessage(
- CFStringRef key, const std::string& expected_type, CFTypeRef value);
+std::string GetValueFromDictionaryErrorMessage(CFStringRef key,
+ const std::string& expected_type,
+ CFTypeRef value);
// Utility function to pull out a value from a dictionary, check its type, and
// return it. Returns NULL if the key is not present or of the wrong type.
-template<typename T>
+template <typename T>
T GetValueFromDictionary(CFDictionaryRef dict, CFStringRef key) {
CFTypeRef value = CFDictionaryGetValue(dict, key);
T value_specific = CFCast<T>(value);
if (value && !value_specific) {
std::string expected_type = TypeNameForCFType(value_specific);
- DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key,
- expected_type,
+ DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key, expected_type,
value);
}
@@ -390,8 +389,7 @@
// Converts |range| to an NSRange, returning the new range in |range_out|.
// Returns true if conversion was successful, false if the values of |range|
// could not be converted to NSUIntegers.
-bool CFRangeToNSRange(CFRange range,
- NSRange* range_out) WARN_UNUSED_RESULT;
+bool CFRangeToNSRange(CFRange range, NSRange* range_out) WARN_UNUSED_RESULT;
#endif // defined(__OBJC__)
} // namespace mac
@@ -402,9 +400,7 @@
// e.g. LOG(INFO) << base::mac::NSToCFCast(@"foo");
// Operator << can not be overloaded for ObjectiveC types as the compiler
// can not distinguish between overloads for id with overloads for void*.
-extern std::ostream& operator<<(std::ostream& o,
- const CFErrorRef err);
-extern std::ostream& operator<<(std::ostream& o,
- const CFStringRef str);
+extern std::ostream& operator<<(std::ostream& o, const CFErrorRef err);
+extern std::ostream& operator<<(std::ostream& o, const CFStringRef str);
#endif // BASE_MAC_FOUNDATION_UTIL_H_
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index a0c5cec..1fb91a9 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -94,8 +94,8 @@
FilePath PathForFrameworkBundleResource(CFStringRef resourceName) {
NSBundle* bundle = base::mac::FrameworkBundle();
- NSString* resourcePath = [bundle pathForResource:(NSString*)resourceName
- ofType:nil];
+ NSString* resourcePath =
+ [bundle pathForResource:(NSString*)resourceName ofType:nil];
return NSStringToFilePath(resourcePath);
}
@@ -192,9 +192,7 @@
}
#define TYPE_NAME_FOR_CF_TYPE_DEFN(TypeCF) \
-std::string TypeNameForCFType(TypeCF##Ref) { \
- return #TypeCF; \
-}
+ std::string TypeNameForCFType(TypeCF##Ref) { return #TypeCF; }
TYPE_NAME_FOR_CF_TYPE_DEFN(CFArray);
TYPE_NAME_FOR_CF_TYPE_DEFN(CFBag);
@@ -222,12 +220,12 @@
#undef TYPE_NAME_FOR_CF_TYPE_DEFN
void NSObjectRetain(void* obj) {
- id<NSObject> nsobj = static_cast<id<NSObject> >(obj);
+ id<NSObject> nsobj = static_cast<id<NSObject>>(obj);
[nsobj retain];
}
void NSObjectRelease(void* obj) {
- id<NSObject> nsobj = static_cast<id<NSObject> >(obj);
+ id<NSObject> nsobj = static_cast<id<NSObject>>(obj);
[nsobj release];
}
@@ -265,36 +263,36 @@
// Definitions for the corresponding CF_TO_NS_CAST_DECL macros in
// foundation_util.h.
-#define CF_TO_NS_CAST_DEFN(TypeCF, TypeNS) \
-\
-TypeNS* CFToNSCast(TypeCF##Ref cf_val) { \
- DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \
- TypeNS* ns_val = \
- const_cast<TypeNS*>(reinterpret_cast<const TypeNS*>(cf_val)); \
- return ns_val; \
-} \
-\
-TypeCF##Ref NSToCFCast(TypeNS* ns_val) { \
- TypeCF##Ref cf_val = reinterpret_cast<TypeCF##Ref>(ns_val); \
- DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \
- return cf_val; \
-}
+#define CF_TO_NS_CAST_DEFN(TypeCF, TypeNS) \
+ \
+ TypeNS* CFToNSCast(TypeCF##Ref cf_val) { \
+ DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \
+ TypeNS* ns_val = \
+ const_cast<TypeNS*>(reinterpret_cast<const TypeNS*>(cf_val)); \
+ return ns_val; \
+ } \
+ \
+ TypeCF##Ref NSToCFCast(TypeNS* ns_val) { \
+ TypeCF##Ref cf_val = reinterpret_cast<TypeCF##Ref>(ns_val); \
+ DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \
+ return cf_val; \
+ }
-#define CF_TO_NS_MUTABLE_CAST_DEFN(name) \
-CF_TO_NS_CAST_DEFN(CF##name, NS##name) \
-\
-NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val) { \
- DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \
- NSMutable##name* ns_val = reinterpret_cast<NSMutable##name*>(cf_val); \
- return ns_val; \
-} \
-\
-CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val) { \
- CFMutable##name##Ref cf_val = \
- reinterpret_cast<CFMutable##name##Ref>(ns_val); \
- DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \
- return cf_val; \
-}
+#define CF_TO_NS_MUTABLE_CAST_DEFN(name) \
+ CF_TO_NS_CAST_DEFN(CF##name, NS##name) \
+ \
+ NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val) { \
+ DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \
+ NSMutable##name* ns_val = reinterpret_cast<NSMutable##name*>(cf_val); \
+ return ns_val; \
+ } \
+ \
+ CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val) { \
+ CFMutable##name##Ref cf_val = \
+ reinterpret_cast<CFMutable##name##Ref>(ns_val); \
+ DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \
+ return cf_val; \
+ }
CF_TO_NS_MUTABLE_CAST_DEFN(Array);
CF_TO_NS_MUTABLE_CAST_DEFN(AttributedString);
@@ -321,10 +319,8 @@
// checking, so do some special-casing.
// http://www.openradar.me/15341349 rdar://15341349
NSFont* CFToNSCast(CTFontRef cf_val) {
- NSFont* ns_val =
- const_cast<NSFont*>(reinterpret_cast<const NSFont*>(cf_val));
- DCHECK(!cf_val ||
- CTFontGetTypeID() == CFGetTypeID(cf_val) ||
+ NSFont* ns_val = const_cast<NSFont*>(reinterpret_cast<const NSFont*>(cf_val));
+ DCHECK(!cf_val || CTFontGetTypeID() == CFGetTypeID(cf_val) ||
(_CFIsObjC(CTFontGetTypeID(), cf_val) &&
[ns_val isKindOfClass:[NSFont class]]));
return ns_val;
@@ -332,8 +328,7 @@
CTFontRef NSToCFCast(NSFont* ns_val) {
CTFontRef cf_val = reinterpret_cast<CTFontRef>(ns_val);
- DCHECK(!cf_val ||
- CTFontGetTypeID() == CFGetTypeID(cf_val) ||
+ DCHECK(!cf_val || CTFontGetTypeID() == CFGetTypeID(cf_val) ||
[ns_val isKindOfClass:[NSFont class]]);
return cf_val;
}
@@ -342,24 +337,24 @@
#undef CF_TO_NS_CAST_DEFN
#undef CF_TO_NS_MUTABLE_CAST_DEFN
-#define CF_CAST_DEFN(TypeCF) \
-template<> TypeCF##Ref \
-CFCast<TypeCF##Ref>(const CFTypeRef& cf_val) { \
- if (cf_val == NULL) { \
- return NULL; \
- } \
- if (CFGetTypeID(cf_val) == TypeCF##GetTypeID()) { \
- return (TypeCF##Ref)(cf_val); \
- } \
- return NULL; \
-} \
-\
-template<> TypeCF##Ref \
-CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val) { \
- TypeCF##Ref rv = CFCast<TypeCF##Ref>(cf_val); \
- DCHECK(cf_val == NULL || rv); \
- return rv; \
-}
+#define CF_CAST_DEFN(TypeCF) \
+ template <> \
+ TypeCF##Ref CFCast<TypeCF##Ref>(const CFTypeRef& cf_val) { \
+ if (cf_val == NULL) { \
+ return NULL; \
+ } \
+ if (CFGetTypeID(cf_val) == TypeCF##GetTypeID()) { \
+ return (TypeCF##Ref)(cf_val); \
+ } \
+ return NULL; \
+ } \
+ \
+ template <> \
+ TypeCF##Ref CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val) { \
+ TypeCF##Ref rv = CFCast<TypeCF##Ref>(cf_val); \
+ DCHECK(cf_val == NULL || rv); \
+ return rv; \
+ }
CF_CAST_DEFN(CFArray);
CF_CAST_DEFN(CFBag);
@@ -385,8 +380,8 @@
// The NSFont/CTFont toll-free bridging is broken when it comes to type
// checking, so do some special-casing.
// http://www.openradar.me/15341349 rdar://15341349
-template<> CTFontRef
-CFCast<CTFontRef>(const CFTypeRef& cf_val) {
+template <>
+CTFontRef CFCast<CTFontRef>(const CFTypeRef& cf_val) {
if (cf_val == NULL) {
return NULL;
}
@@ -404,8 +399,8 @@
return NULL;
}
-template<> CTFontRef
-CFCastStrict<CTFontRef>(const CFTypeRef& cf_val) {
+template <>
+CTFontRef CFCastStrict<CTFontRef>(const CFTypeRef& cf_val) {
CTFontRef rv = CFCast<CTFontRef>(cf_val);
DCHECK(cf_val == NULL || rv);
return rv;
@@ -421,17 +416,14 @@
#undef CF_CAST_DEFN
-std::string GetValueFromDictionaryErrorMessage(
- CFStringRef key, const std::string& expected_type, CFTypeRef value) {
+std::string GetValueFromDictionaryErrorMessage(CFStringRef key,
+ const std::string& expected_type,
+ CFTypeRef value) {
ScopedCFTypeRef<CFStringRef> actual_type_ref(
CFCopyTypeIDDescription(CFGetTypeID(value)));
- return "Expected value for key " +
- base::SysCFStringRefToUTF8(key) +
- " to be " +
- expected_type +
- " but it was " +
- base::SysCFStringRefToUTF8(actual_type_ref) +
- " instead";
+ return "Expected value for key " + base::SysCFStringRefToUTF8(key) +
+ " to be " + expected_type + " but it was " +
+ base::SysCFStringRefToUTF8(actual_type_ref) + " instead";
}
NSString* FilePathToNSString(const FilePath& path) {
@@ -474,10 +466,9 @@
errorDesc = reinterpret_cast<CFStringRef>(
CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey));
}
- o << "Code: " << CFErrorGetCode(err)
- << " Domain: " << CFErrorGetDomain(err)
+ o << "Code: " << CFErrorGetCode(err) << " Domain: " << CFErrorGetDomain(err)
<< " Desc: " << desc.get();
- if(errorDesc) {
+ if (errorDesc) {
o << "(" << errorDesc << ")";
}
return o;
diff --git a/base/mac/mac_logging.h b/base/mac/mac_logging.h
index 148b383..9891d69 100644
--- a/base/mac/mac_logging.h
+++ b/base/mac/mac_logging.h
@@ -48,23 +48,23 @@
} // namespace logging
#define OSSTATUS_LOG_STREAM(severity, status) \
- COMPACT_GOOGLE_LOG_EX_ ## severity(OSStatusLogMessage, status).stream()
+ COMPACT_GOOGLE_LOG_EX_##severity(OSStatusLogMessage, status).stream()
#define OSSTATUS_LOG(severity, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), LOG_IS_ON(severity))
+ LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), LOG_IS_ON(severity))
#define OSSTATUS_LOG_IF(severity, condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
- LOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
+ LOG_IS_ON(severity) && (condition))
-#define OSSTATUS_CHECK(condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(FATAL, status), !(condition)) \
- << "Check failed: " # condition << ". "
+#define OSSTATUS_CHECK(condition, status) \
+ LAZY_STREAM(OSSTATUS_LOG_STREAM(FATAL, status), !(condition)) \
+ << "Check failed: " #condition << ". "
#define OSSTATUS_DLOG(severity, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), DLOG_IS_ON(severity))
+ LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), DLOG_IS_ON(severity))
#define OSSTATUS_DLOG_IF(severity, condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
- DLOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
+ DLOG_IS_ON(severity) && (condition))
#define OSSTATUS_DCHECK(condition, status) \
LAZY_STREAM(OSSTATUS_LOG_STREAM(FATAL, status), \
diff --git a/base/mac/mac_logging.mm b/base/mac/mac_logging.mm
index 1f9682d..ff311e3 100644
--- a/base/mac/mac_logging.mm
+++ b/base/mac/mac_logging.mm
@@ -26,9 +26,7 @@
int line,
LogSeverity severity,
OSStatus status)
- : LogMessage(file_path, line, severity),
- status_(status) {
-}
+ : LogMessage(file_path, line, severity), status_(status) {}
OSStatusLogMessage::~OSStatusLogMessage() {
#if defined(OS_IOS)
@@ -36,10 +34,7 @@
// to try to get a description of the failure.
stream() << ": " << status_;
#else
- stream() << ": "
- << DescriptionFromOSStatus(status_)
- << " ("
- << status_
+ stream() << ": " << DescriptionFromOSStatus(status_) << " (" << status_
<< ")";
#endif
}
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h
index 96dda1d..c4fcd33 100644
--- a/base/mac/mac_util.h
+++ b/base/mac/mac_util.h
@@ -10,7 +10,6 @@
#import <CoreGraphics/CoreGraphics.h>
-
namespace base {
class FilePath;
@@ -59,8 +58,7 @@
// Convenience method to switch the current fullscreen mode. This has the same
// net effect as a ReleaseFullScreen(from_mode) call followed immediately by a
// RequestFullScreen(to_mode). Must be called on the main thread.
-void SwitchFullScreenModes(FullScreenMode from_mode,
- FullScreenMode to_mode);
+void SwitchFullScreenModes(FullScreenMode from_mode, FullScreenMode to_mode);
// Excludes the file given by |file_path| from being backed up by Time Machine.
bool SetFileBackupExclusion(const FilePath& file_path);
@@ -171,9 +169,9 @@
// Parse a model identifier string; for example, into ("MacBookPro", 6, 1).
// If any error occurs, none of the input pointers are touched.
bool ParseModelIdentifier(const std::string& ident,
- std::string* type,
- int32_t* major,
- int32_t* minor);
+ std::string* type,
+ int32_t* major,
+ int32_t* minor);
} // namespace mac
} // namespace base
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index a8308be..bb8797d 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -32,7 +32,7 @@
// The current count of outstanding requests for full screen mode from browser
// windows, plugins, etc.
-int g_full_screen_requests[kNumFullScreenModes] = { 0 };
+int g_full_screen_requests[kNumFullScreenModes] = {0};
// Sets the appropriate application presentation option based on the current
// full screen requests. Since only one presentation option can be active at a
@@ -82,8 +82,8 @@
// representing the current application. If such an item is found, returns a
// retained reference to it. Caller is responsible for releasing the reference.
LSSharedFileListItemRef GetLoginItemForApp() {
- ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate(
- NULL, kLSSharedFileListSessionLoginItems, NULL));
+ ScopedCFTypeRef<LSSharedFileListRef> login_items(
+ LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
if (!login_items.get()) {
DLOG(ERROR) << "Couldn't get a Login Items list.";
@@ -95,7 +95,7 @@
NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
- for(NSUInteger i = 0; i < [login_items_array count]; ++i) {
+ for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
CFURLRef item_url_ref = NULL;
@@ -117,8 +117,9 @@
}
bool IsHiddenLoginItem(LSSharedFileListItemRef item) {
- ScopedCFTypeRef<CFBooleanRef> hidden(reinterpret_cast<CFBooleanRef>(
- LSSharedFileListItemCopyProperty(item,
+ ScopedCFTypeRef<CFBooleanRef> hidden(
+ reinterpret_cast<CFBooleanRef>(LSSharedFileListItemCopyProperty(
+ item,
reinterpret_cast<CFStringRef>(kLSSharedFileListLoginItemHidden))));
return hidden && hidden == kCFBooleanTrue;
@@ -130,8 +131,8 @@
// Leaked. That's OK, it's scoped to the lifetime of the application.
static CGColorSpaceRef g_color_space_generic_rgb(
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
- DLOG_IF(ERROR, !g_color_space_generic_rgb) <<
- "Couldn't get the generic RGB color space";
+ DLOG_IF(ERROR, !g_color_space_generic_rgb)
+ << "Couldn't get the generic RGB color space";
return g_color_space_generic_rgb;
}
@@ -154,8 +155,8 @@
g_system_color_space = CGColorSpaceCreateDeviceRGB();
if (g_system_color_space) {
- DLOG(WARNING) <<
- "Couldn't get the main display's color space, using generic";
+ DLOG(WARNING)
+ << "Couldn't get the main display's color space, using generic";
} else {
DLOG(ERROR) << "Couldn't get any color space";
}
@@ -247,8 +248,8 @@
return; // Already is a login item with required hide flag.
}
- ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate(
- NULL, kLSSharedFileListSessionLoginItems, NULL));
+ ScopedCFTypeRef<LSSharedFileListRef> login_items(
+ LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
if (!login_items.get()) {
DLOG(ERROR) << "Couldn't get a Login Items list.";
@@ -263,10 +264,9 @@
NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
BOOL hide = hide_on_startup ? YES : NO;
- NSDictionary* properties =
- [NSDictionary
- dictionaryWithObject:[NSNumber numberWithBool:hide]
- forKey:(NSString*)kLSSharedFileListLoginItemHidden];
+ NSDictionary* properties = [NSDictionary
+ dictionaryWithObject:[NSNumber numberWithBool:hide]
+ forKey:(NSString*)kLSSharedFileListLoginItemHidden];
ScopedCFTypeRef<LSSharedFileListItemRef> new_item;
new_item.reset(LSSharedFileListInsertItemURL(
@@ -284,8 +284,8 @@
if (!item.get())
return;
- ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate(
- NULL, kLSSharedFileListSessionLoginItems, NULL));
+ ScopedCFTypeRef<LSSharedFileListRef> login_items(
+ LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
if (!login_items.get()) {
DLOG(ERROR) << "Couldn't get a Login Items list.";
@@ -296,7 +296,7 @@
}
bool WasLaunchedAsLoginOrResumeItem() {
- ProcessSerialNumber psn = { 0, kCurrentProcess };
+ ProcessSerialNumber psn = {0, kCurrentProcess};
ProcessInfoRec info = {};
info.processInfoLength = sizeof(info);
@@ -393,9 +393,9 @@
int darwin_major_version = 0;
char* dot = strchr(uname_info.release, '.');
if (dot) {
- if (!base::StringToInt(base::StringPiece(uname_info.release,
- dot - uname_info.release),
- &darwin_major_version)) {
+ if (!base::StringToInt(
+ base::StringPiece(uname_info.release, dot - uname_info.release),
+ &darwin_major_version)) {
dot = NULL;
}
}
@@ -440,16 +440,12 @@
std::string GetModelIdentifier() {
std::string return_string;
- ScopedIOObject<io_service_t> platform_expert(
- IOServiceGetMatchingService(kIOMasterPortDefault,
- IOServiceMatching("IOPlatformExpertDevice")));
+ ScopedIOObject<io_service_t> platform_expert(IOServiceGetMatchingService(
+ kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")));
if (platform_expert) {
ScopedCFTypeRef<CFDataRef> model_data(
static_cast<CFDataRef>(IORegistryEntryCreateCFProperty(
- platform_expert,
- CFSTR("model"),
- kCFAllocatorDefault,
- 0)));
+ platform_expert, CFSTR("model"), kCFAllocatorDefault, 0)));
if (model_data) {
return_string =
reinterpret_cast<const char*>(CFDataGetBytePtr(model_data));
@@ -470,10 +466,9 @@
return false;
int32_t major_tmp, minor_tmp;
std::string::const_iterator begin = ident.begin();
- if (!StringToInt(
- StringPiece(begin + number_loc, begin + comma_loc), &major_tmp) ||
- !StringToInt(
- StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
+ if (!StringToInt(StringPiece(begin + number_loc, begin + comma_loc),
+ &major_tmp) ||
+ !StringToInt(StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
return false;
*type = ident.substr(0, number_loc);
*major = major_tmp;
diff --git a/base/mac/mach_logging.cc b/base/mac/mach_logging.cc
index fbd0134..b708ded 100644
--- a/base/mac/mach_logging.cc
+++ b/base/mac/mach_logging.cc
@@ -34,13 +34,10 @@
int line,
LogSeverity severity,
mach_error_t mach_err)
- : LogMessage(file_path, line, severity),
- mach_err_(mach_err) {
-}
+ : LogMessage(file_path, line, severity), mach_err_(mach_err) {}
MachLogMessage::~MachLogMessage() {
- stream() << ": "
- << mach_error_string(mach_err_)
+ stream() << ": " << mach_error_string(mach_err_)
<< FormatMachErrorNumber(mach_err_);
}
@@ -50,13 +47,10 @@
int line,
LogSeverity severity,
kern_return_t bootstrap_err)
- : LogMessage(file_path, line, severity),
- bootstrap_err_(bootstrap_err) {
-}
+ : LogMessage(file_path, line, severity), bootstrap_err_(bootstrap_err) {}
BootstrapLogMessage::~BootstrapLogMessage() {
- stream() << ": "
- << bootstrap_strerror(bootstrap_err_);
+ stream() << ": " << bootstrap_strerror(bootstrap_err_);
switch (bootstrap_err_) {
case BOOTSTRAP_SUCCESS:
diff --git a/base/mac/mach_logging.h b/base/mac/mach_logging.h
index e32e1db..1f20b85 100644
--- a/base/mac/mach_logging.h
+++ b/base/mac/mach_logging.h
@@ -49,23 +49,23 @@
} // namespace logging
#define MACH_LOG_STREAM(severity, mach_err) \
- COMPACT_GOOGLE_LOG_EX_ ## severity(MachLogMessage, mach_err).stream()
+ COMPACT_GOOGLE_LOG_EX_##severity(MachLogMessage, mach_err).stream()
#define MACH_LOG(severity, mach_err) \
- LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), LOG_IS_ON(severity))
+ LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), LOG_IS_ON(severity))
#define MACH_LOG_IF(severity, condition, mach_err) \
- LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), \
- LOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), \
+ LOG_IS_ON(severity) && (condition))
-#define MACH_CHECK(condition, mach_err) \
- LAZY_STREAM(MACH_LOG_STREAM(FATAL, mach_err), !(condition)) \
- << "Check failed: " # condition << ". "
+#define MACH_CHECK(condition, mach_err) \
+ LAZY_STREAM(MACH_LOG_STREAM(FATAL, mach_err), !(condition)) \
+ << "Check failed: " #condition << ". "
#define MACH_DLOG(severity, mach_err) \
- LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), DLOG_IS_ON(severity))
+ LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), DLOG_IS_ON(severity))
#define MACH_DLOG_IF(severity, condition, mach_err) \
- LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), \
- DLOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(MACH_LOG_STREAM(severity, mach_err), \
+ DLOG_IS_ON(severity) && (condition))
#define MACH_DCHECK(condition, mach_err) \
LAZY_STREAM(MACH_LOG_STREAM(FATAL, mach_err), \
@@ -93,25 +93,24 @@
} // namespace logging
#define BOOTSTRAP_LOG_STREAM(severity, bootstrap_err) \
- COMPACT_GOOGLE_LOG_EX_ ## severity(BootstrapLogMessage, \
- bootstrap_err).stream()
-#define BOOTSTRAP_LOG(severity, bootstrap_err) \
- LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, \
- bootstrap_err), LOG_IS_ON(severity))
+ COMPACT_GOOGLE_LOG_EX_##severity(BootstrapLogMessage, bootstrap_err).stream()
+#define BOOTSTRAP_LOG(severity, bootstrap_err) \
+ LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
+ LOG_IS_ON(severity))
#define BOOTSTRAP_LOG_IF(severity, condition, bootstrap_err) \
- LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
- LOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
+ LOG_IS_ON(severity) && (condition))
-#define BOOTSTRAP_CHECK(condition, bootstrap_err) \
- LAZY_STREAM(BOOTSTRAP_LOG_STREAM(FATAL, bootstrap_err), !(condition)) \
- << "Check failed: " # condition << ". "
+#define BOOTSTRAP_CHECK(condition, bootstrap_err) \
+ LAZY_STREAM(BOOTSTRAP_LOG_STREAM(FATAL, bootstrap_err), !(condition)) \
+ << "Check failed: " #condition << ". "
-#define BOOTSTRAP_DLOG(severity, bootstrap_err) \
- LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
- DLOG_IS_ON(severity))
+#define BOOTSTRAP_DLOG(severity, bootstrap_err) \
+ LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
+ DLOG_IS_ON(severity))
#define BOOTSTRAP_DLOG_IF(severity, condition, bootstrap_err) \
- LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
- DLOG_IS_ON(severity) && (condition))
+ LAZY_STREAM(BOOTSTRAP_LOG_STREAM(severity, bootstrap_err), \
+ DLOG_IS_ON(severity) && (condition))
#define BOOTSTRAP_DCHECK(condition, bootstrap_err) \
LAZY_STREAM(BOOTSTRAP_LOG_STREAM(FATAL, bootstrap_err), \
diff --git a/base/mac/scoped_cftyperef.h b/base/mac/scoped_cftyperef.h
index ccbc5cf..a602fd9 100644
--- a/base/mac/scoped_cftyperef.h
+++ b/base/mac/scoped_cftyperef.h
@@ -27,21 +27,19 @@
namespace internal {
-template<typename CFT>
+template <typename CFT>
struct ScopedCFTypeRefTraits {
static CFT InvalidValue() { return nullptr; }
static CFT Retain(CFT object) {
CFRetain(object);
return object;
}
- static void Release(CFT object) {
- CFRelease(object);
- }
+ static void Release(CFT object) { CFRelease(object); }
};
} // namespace internal
-template<typename CFT>
+template <typename CFT>
using ScopedCFTypeRef =
ScopedTypeRef<CFT, internal::ScopedCFTypeRefTraits<CFT>>;
diff --git a/base/mac/scoped_dispatch_object.h b/base/mac/scoped_dispatch_object.h
index cd2daf2..43d057b 100644
--- a/base/mac/scoped_dispatch_object.h
+++ b/base/mac/scoped_dispatch_object.h
@@ -20,12 +20,10 @@
dispatch_retain(object);
return object;
}
- static void Release(T object) {
- dispatch_release(object);
- }
+ static void Release(T object) { dispatch_release(object); }
};
-} // namepsace internal
+} // namespace internal
template <typename T>
using ScopedDispatchObject =
diff --git a/base/mac/scoped_ioobject.h b/base/mac/scoped_ioobject.h
index c948cb5..d656175 100644
--- a/base/mac/scoped_ioobject.h
+++ b/base/mac/scoped_ioobject.h
@@ -24,7 +24,7 @@
static void Release(IOT iot) { IOObjectRelease(iot); }
};
-} // namespce internal
+} // namespace internal
// Just like ScopedCFTypeRef but for io_object_t and subclasses.
template <typename IOT>
diff --git a/base/mac/scoped_mach_port.h b/base/mac/scoped_mach_port.h
index 9b4470d..64d6765 100644
--- a/base/mac/scoped_mach_port.h
+++ b/base/mac/scoped_mach_port.h
@@ -15,25 +15,19 @@
namespace internal {
struct SendRightTraits {
- static mach_port_t InvalidValue() {
- return MACH_PORT_NULL;
- }
+ static mach_port_t InvalidValue() { return MACH_PORT_NULL; }
static void Free(mach_port_t port);
};
struct ReceiveRightTraits {
- static mach_port_t InvalidValue() {
- return MACH_PORT_NULL;
- }
+ static mach_port_t InvalidValue() { return MACH_PORT_NULL; }
static void Free(mach_port_t port);
};
struct PortSetTraits {
- static mach_port_t InvalidValue() {
- return MACH_PORT_NULL;
- }
+ static mach_port_t InvalidValue() { return MACH_PORT_NULL; }
static void Free(mach_port_t port);
};
diff --git a/base/mac/scoped_nsautorelease_pool.h b/base/mac/scoped_nsautorelease_pool.h
index 017f1c0..fd4ae66 100644
--- a/base/mac/scoped_nsautorelease_pool.h
+++ b/base/mac/scoped_nsautorelease_pool.h
@@ -9,7 +9,7 @@
#if defined(__OBJC__)
@class NSAutoreleasePool;
-#else // __OBJC__
+#else // __OBJC__
class NSAutoreleasePool;
#endif // __OBJC__
@@ -31,6 +31,7 @@
// Only use then when you're certain the items currently in the pool are
// no longer needed.
void Recycle();
+
private:
NSAutoreleasePool* autorelease_pool_;
diff --git a/base/mac/scoped_nsobject.h b/base/mac/scoped_nsobject.h
index 45ab325..a5da218 100644
--- a/base/mac/scoped_nsobject.h
+++ b/base/mac/scoped_nsobject.h
@@ -191,7 +191,7 @@
};
// Specialization to make scoped_nsobject<id> work.
-template<>
+template <>
class scoped_nsobject<id> : public scoped_nsprotocol<id> {
public:
using Traits = typename scoped_nsprotocol<id>::Traits;
diff --git a/base/mac/scoped_typeref.h b/base/mac/scoped_typeref.h
index dd9841d..659ee34 100644
--- a/base/mac/scoped_typeref.h
+++ b/base/mac/scoped_typeref.h
@@ -45,10 +45,10 @@
// with |ASSUME| for the former and |RETAIN| for the latter. The default policy
// is to |ASSUME|.
-template<typename T>
+template <typename T>
struct ScopedTypeRefTraits;
-template<typename T, typename Traits = ScopedTypeRefTraits<T>>
+template <typename T, typename Traits = ScopedTypeRefTraits<T>>
class ScopedTypeRef {
public:
typedef T element_type;
@@ -61,8 +61,7 @@
object_ = Traits::Retain(object_);
}
- ScopedTypeRef(const ScopedTypeRef<T, Traits>& that)
- : object_(that.object_) {
+ ScopedTypeRef(const ScopedTypeRef<T, Traits>& that) : object_(that.object_) {
if (object_)
object_ = Traits::Retain(object_);
}
diff --git a/base/macros.h b/base/macros.h
index 3064a1b..f59fa6c 100644
--- a/base/macros.h
+++ b/base/macros.h
@@ -23,8 +23,7 @@
#endif
// Put this in the declarations for a class to be uncopyable.
-#define DISALLOW_COPY(TypeName) \
- TypeName(const TypeName&) = delete
+#define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete
// Put this in the declarations for a class to be unassignable.
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
@@ -53,7 +52,8 @@
//
// DEPRECATED, please use base::size(array) instead.
// TODO(https://crbug.com/837308): Replace existing arraysize usages.
-template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N];
+template <typename T, size_t N>
+char (&ArraySizeHelper(T (&array)[N]))[N];
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
// Used to explicitly mark the return value of a function as unused. If you are
@@ -64,9 +64,8 @@
// if (TakeOwnership(my_var.get()) == SUCCESS)
// ignore_result(my_var.release());
//
-template<typename T>
-inline void ignore_result(const T&) {
-}
+template <typename T>
+inline void ignore_result(const T&) {}
namespace base {
diff --git a/base/md5.cc b/base/md5.cc
index 72c774d..c66f7b2 100644
--- a/base/md5.cc
+++ b/base/md5.cc
@@ -38,9 +38,9 @@
*/
void byteReverse(uint8_t* buf, unsigned longs) {
do {
- uint32_t temp = static_cast<uint32_t>(
- static_cast<unsigned>(buf[3]) << 8 |
- buf[2]) << 16 |
+ uint32_t temp =
+ static_cast<uint32_t>(static_cast<unsigned>(buf[3]) << 8 | buf[2])
+ << 16 |
(static_cast<unsigned>(buf[1]) << 8 | buf[0]);
*reinterpret_cast<uint32_t*>(buf) = temp;
buf += 4;
diff --git a/base/md5.h b/base/md5.h
index e6345b1..16a0a6f 100644
--- a/base/md5.h
+++ b/base/md5.h
@@ -59,8 +59,7 @@
// MD5IntermediateFinal() generates a digest without finalizing the MD5
// operation. Can be used to generate digests for the input seen thus far,
// without affecting the digest generated for the entire input.
-void MD5IntermediateFinal(MD5Digest* digest,
- const MD5Context* context);
+void MD5IntermediateFinal(MD5Digest* digest, const MD5Context* context);
// Converts a digest into human-readable hexadecimal.
std::string MD5DigestToBase16(const MD5Digest& digest);
diff --git a/base/memory/free_deleter.h b/base/memory/free_deleter.h
index 5604118..e12795c 100644
--- a/base/memory/free_deleter.h
+++ b/base/memory/free_deleter.h
@@ -15,9 +15,7 @@
// std::unique_ptr<int, base::FreeDeleter> foo_ptr(
// static_cast<int*>(malloc(sizeof(int))));
struct FreeDeleter {
- inline void operator()(void* ptr) const {
- free(ptr);
- }
+ inline void operator()(void* ptr) const { free(ptr); }
};
} // namespace base
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 9447d51..a897171 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -24,18 +24,13 @@
bool HasOneRef() const { return ref_count_ == 1; }
protected:
- explicit RefCountedBase(StartRefCountFromZeroTag) {
- }
+ explicit RefCountedBase(StartRefCountFromZeroTag) {}
- explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {
- }
+ explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {}
- ~RefCountedBase() {
- }
+ ~RefCountedBase() {}
- void AddRef() const {
- AddRefImpl();
- }
+ void AddRef() const { AddRefImpl(); }
// Returns true if the object should self-delete.
bool Release() const {
@@ -62,16 +57,13 @@
// the sending thread), but will trap if the sending thread holds onto a
// reference, or if the object is accessed from multiple threads
// simultaneously.
- bool IsOnValidSequence() const {
- return true;
- }
+ bool IsOnValidSequence() const { return true; }
private:
template <typename U>
friend scoped_refptr<U> base::AdoptRef(U*);
- void Adopted() const {
- }
+ void Adopted() const {}
#if defined(ARCH_CPU_64_BIT)
void AddRefImpl() const;
@@ -91,8 +83,7 @@
protected:
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromZeroTag) {}
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromOneTag)
- : ref_count_(1) {
- }
+ : ref_count_(1) {}
~RefCountedThreadSafeBase() = default;
@@ -113,12 +104,9 @@
template <typename U>
friend scoped_refptr<U> base::AdoptRef(U*);
- void Adopted() const {
- }
+ void Adopted() const {}
- ALWAYS_INLINE void AddRefImpl() const {
- ref_count_.Increment();
- }
+ ALWAYS_INLINE void AddRefImpl() const { ref_count_.Increment(); }
ALWAYS_INLINE bool ReleaseImpl() const {
if (!ref_count_.Decrement()) {
@@ -216,9 +204,7 @@
RefCounted() : subtle::RefCountedBase(T::kRefCountPreference) {}
- void AddRef() const {
- subtle::RefCountedBase::AddRef();
- }
+ void AddRef() const { subtle::RefCountedBase::AddRef(); }
void Release() const {
if (subtle::RefCountedBase::Release()) {
@@ -245,18 +231,19 @@
};
// Forward declaration.
-template <class T, typename Traits> class RefCountedThreadSafe;
+template <class T, typename Traits>
+class RefCountedThreadSafe;
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
// count reaches 0. Overload to delete it on a different thread etc.
-template<typename T>
+template <typename T>
struct DefaultRefCountedThreadSafeTraits {
static void Destruct(const T* x) {
// Delete through RefCountedThreadSafe to make child classes only need to be
// friend with RefCountedThreadSafe instead of this struct, which is an
// implementation detail.
- RefCountedThreadSafe<T,
- DefaultRefCountedThreadSafeTraits>::DeleteInternal(x);
+ RefCountedThreadSafe<T, DefaultRefCountedThreadSafeTraits>::DeleteInternal(
+ x);
}
};
@@ -275,7 +262,7 @@
//
// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
// too. See the comment above the RefCounted definition for details.
-template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> >
+template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
public:
static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference =
@@ -284,9 +271,7 @@
explicit RefCountedThreadSafe()
: subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
- void AddRef() const {
- subtle::RefCountedThreadSafeBase::AddRef();
- }
+ void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); }
void Release() const {
if (subtle::RefCountedThreadSafeBase::Release()) {
@@ -312,9 +297,9 @@
// A thread-safe wrapper for some piece of data so we can place other
// things in scoped_refptrs<>.
//
-template<typename T>
+template <typename T>
class RefCountedData
- : public base::RefCountedThreadSafe< base::RefCountedData<T> > {
+ : public base::RefCountedThreadSafe<base::RefCountedData<T>> {
public:
RefCountedData() : data() {}
RefCountedData(const T& in_value) : data(in_value) {}
@@ -323,7 +308,7 @@
T data;
private:
- friend class base::RefCountedThreadSafe<base::RefCountedData<T> >;
+ friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
~RefCountedData() = default;
};
diff --git a/base/memory/weak_ptr.cc b/base/memory/weak_ptr.cc
index 1186829..4abeb7f 100644
--- a/base/memory/weak_ptr.cc
+++ b/base/memory/weak_ptr.cc
@@ -7,8 +7,7 @@
namespace base {
namespace internal {
-WeakReference::Flag::Flag() : is_valid_(true) {
-}
+WeakReference::Flag::Flag() : is_valid_(true) {}
void WeakReference::Flag::Invalidate() {
is_valid_ = false;
diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h
index 2a42692..3b2a0af 100644
--- a/base/memory/weak_ptr.h
+++ b/base/memory/weak_ptr.h
@@ -79,8 +79,10 @@
namespace base {
-template <typename T> class SupportsWeakPtr;
-template <typename T> class WeakPtr;
+template <typename T>
+class SupportsWeakPtr;
+template <typename T>
+class WeakPtr;
namespace internal {
// These classes are part of the WeakPtr implementation.
@@ -175,7 +177,7 @@
// function that makes calling this easier.
//
// Precondition: t != nullptr
- template<typename Derived>
+ template <typename Derived>
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
static_assert(
std::is_base_of<internal::SupportsWeakPtrBase, Derived>::value,
@@ -197,7 +199,8 @@
} // namespace internal
-template <typename T> class WeakPtrFactory;
+template <typename T>
+class WeakPtrFactory;
// The WeakPtr class holds a weak reference to |T*|.
//
@@ -254,7 +257,8 @@
private:
friend class internal::SupportsWeakPtrBase;
- template <typename U> friend class WeakPtr;
+ template <typename U>
+ friend class WeakPtr;
friend class SupportsWeakPtr<T>;
friend class WeakPtrFactory<T>;
diff --git a/base/numerics/safe_conversions_impl.h b/base/numerics/safe_conversions_impl.h
index 2516204..3355b34 100644
--- a/base/numerics/safe_conversions_impl.h
+++ b/base/numerics/safe_conversions_impl.h
@@ -691,9 +691,8 @@
const RangeCheck l_range,
const RangeCheck r_range) {
return l_range.IsUnderflow() || r_range.IsOverflow() ||
- (l_range == r_range &&
- static_cast<decltype(lhs + rhs)>(lhs) <
- static_cast<decltype(lhs + rhs)>(rhs));
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) <
+ static_cast<decltype(lhs + rhs)>(rhs));
}
template <typename L, typename R>
@@ -712,9 +711,8 @@
const RangeCheck l_range,
const RangeCheck r_range) {
return l_range.IsUnderflow() || r_range.IsOverflow() ||
- (l_range == r_range &&
- static_cast<decltype(lhs + rhs)>(lhs) <=
- static_cast<decltype(lhs + rhs)>(rhs));
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) <=
+ static_cast<decltype(lhs + rhs)>(rhs));
}
template <typename L, typename R>
@@ -733,9 +731,8 @@
const RangeCheck l_range,
const RangeCheck r_range) {
return l_range.IsOverflow() || r_range.IsUnderflow() ||
- (l_range == r_range &&
- static_cast<decltype(lhs + rhs)>(lhs) >
- static_cast<decltype(lhs + rhs)>(rhs));
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) >
+ static_cast<decltype(lhs + rhs)>(rhs));
}
template <typename L, typename R>
@@ -754,9 +751,8 @@
const RangeCheck l_range,
const RangeCheck r_range) {
return l_range.IsOverflow() || r_range.IsUnderflow() ||
- (l_range == r_range &&
- static_cast<decltype(lhs + rhs)>(lhs) >=
- static_cast<decltype(lhs + rhs)>(rhs));
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) >=
+ static_cast<decltype(lhs + rhs)>(rhs));
}
template <typename L, typename R>
diff --git a/base/optional.h b/base/optional.h
index c1d11ca..14aa4be 100644
--- a/base/optional.h
+++ b/base/optional.h
@@ -629,7 +629,7 @@
}
template <class U>
- constexpr T value_or(U&& default_value) const& {
+ constexpr T value_or(U&& default_value) const & {
// TODO(mlamouri): add the following assert when possible:
// static_assert(std::is_copy_constructible<T>::value,
// "T must be copy constructible");
diff --git a/base/posix/eintr_wrapper.h b/base/posix/eintr_wrapper.h
index c3565da..5c24e03 100644
--- a/base/posix/eintr_wrapper.h
+++ b/base/posix/eintr_wrapper.h
@@ -25,38 +25,41 @@
#if defined(NDEBUG)
-#define HANDLE_EINTR(x) ({ \
- decltype(x) eintr_wrapper_result; \
- do { \
- eintr_wrapper_result = (x); \
- } while (eintr_wrapper_result == -1 && errno == EINTR); \
- eintr_wrapper_result; \
-})
+#define HANDLE_EINTR(x) \
+ ({ \
+ decltype(x) eintr_wrapper_result; \
+ do { \
+ eintr_wrapper_result = (x); \
+ } while (eintr_wrapper_result == -1 && errno == EINTR); \
+ eintr_wrapper_result; \
+ })
#else
-#define HANDLE_EINTR(x) ({ \
- int eintr_wrapper_counter = 0; \
- decltype(x) eintr_wrapper_result; \
- do { \
- eintr_wrapper_result = (x); \
- } while (eintr_wrapper_result == -1 && errno == EINTR && \
- eintr_wrapper_counter++ < 100); \
- eintr_wrapper_result; \
-})
+#define HANDLE_EINTR(x) \
+ ({ \
+ int eintr_wrapper_counter = 0; \
+ decltype(x) eintr_wrapper_result; \
+ do { \
+ eintr_wrapper_result = (x); \
+ } while (eintr_wrapper_result == -1 && errno == EINTR && \
+ eintr_wrapper_counter++ < 100); \
+ eintr_wrapper_result; \
+ })
#endif // NDEBUG
-#define IGNORE_EINTR(x) ({ \
- decltype(x) eintr_wrapper_result; \
- do { \
- eintr_wrapper_result = (x); \
- if (eintr_wrapper_result == -1 && errno == EINTR) { \
- eintr_wrapper_result = 0; \
- } \
- } while (0); \
- eintr_wrapper_result; \
-})
+#define IGNORE_EINTR(x) \
+ ({ \
+ decltype(x) eintr_wrapper_result; \
+ do { \
+ eintr_wrapper_result = (x); \
+ if (eintr_wrapper_result == -1 && errno == EINTR) { \
+ eintr_wrapper_result = 0; \
+ } \
+ } while (0); \
+ eintr_wrapper_result; \
+ })
#else // !OS_POSIX || OS_FUCHSIA
diff --git a/base/posix/file_descriptor_shuffle.cc b/base/posix/file_descriptor_shuffle.cc
index d2fd39a..f628bec 100644
--- a/base/posix/file_descriptor_shuffle.cc
+++ b/base/posix/file_descriptor_shuffle.cc
@@ -4,17 +4,17 @@
#include "base/posix/file_descriptor_shuffle.h"
-#include <unistd.h>
#include <stddef.h>
+#include <unistd.h>
#include <ostream>
-#include "base/posix/eintr_wrapper.h"
#include "base/logging.h"
+#include "base/posix/eintr_wrapper.h"
namespace base {
-bool PerformInjectiveMultimapDestructive(
- InjectiveMultimap* m, InjectionDelegate* delegate) {
+bool PerformInjectiveMultimapDestructive(InjectiveMultimap* m,
+ InjectionDelegate* delegate) {
static const size_t kMaxExtraFDs = 16;
int extra_fds[kMaxExtraFDs];
unsigned next_extra_fd = 0;
@@ -29,8 +29,8 @@
// We DCHECK the injectiveness of the mapping.
for (size_t j_index = i_index + 1; j_index < m->size(); ++j_index) {
InjectiveMultimap::value_type* j = &(*m)[j_index];
- DCHECK(i->dest != j->dest) << "Both fd " << i->source
- << " and " << j->source << " map to " << i->dest;
+ DCHECK(i->dest != j->dest) << "Both fd " << i->source << " and "
+ << j->source << " map to " << i->dest;
}
const bool is_identity = i->source == i->dest;
@@ -44,8 +44,9 @@
if (next_extra_fd < kMaxExtraFDs) {
extra_fds[next_extra_fd++] = temp_fd;
} else {
- RAW_LOG(ERROR, "PerformInjectiveMultimapDestructive overflowed "
- "extra_fds. Leaking file descriptors!");
+ RAW_LOG(ERROR,
+ "PerformInjectiveMultimapDestructive overflowed "
+ "extra_fds. Leaking file descriptors!");
}
}
diff --git a/base/posix/file_descriptor_shuffle.h b/base/posix/file_descriptor_shuffle.h
index f2e8877..6843498 100644
--- a/base/posix/file_descriptor_shuffle.h
+++ b/base/posix/file_descriptor_shuffle.h
@@ -55,10 +55,7 @@
// A single arc of the directed graph which describes an injective multimapping.
struct InjectionArc {
InjectionArc(int in_source, int in_dest, bool in_close)
- : source(in_source),
- dest(in_dest),
- close(in_close) {
- }
+ : source(in_source), dest(in_dest), close(in_close) {}
int source;
int dest;
@@ -69,11 +66,10 @@
typedef std::vector<InjectionArc> InjectiveMultimap;
bool PerformInjectiveMultimap(const InjectiveMultimap& map,
- InjectionDelegate* delegate);
+ InjectionDelegate* delegate);
-bool PerformInjectiveMultimapDestructive(
- InjectiveMultimap* map,
- InjectionDelegate* delegate);
+bool PerformInjectiveMultimapDestructive(InjectiveMultimap* map,
+ InjectionDelegate* delegate);
// This function will not call malloc but will mutate |map|
static inline bool ShuffleFileDescriptors(InjectiveMultimap* map) {
diff --git a/base/posix/safe_strerror.cc b/base/posix/safe_strerror.cc
index aa18098..3ae684f 100644
--- a/base/posix/safe_strerror.cc
+++ b/base/posix/safe_strerror.cc
@@ -39,13 +39,13 @@
// glibc has two strerror_r functions: a historical GNU-specific one that
// returns type char *, and a POSIX.1-2001 compliant one available since 2.3.4
// that returns int. This wraps the GNU-specific one.
-static void POSSIBLY_UNUSED wrap_posix_strerror_r(
- char *(*strerror_r_ptr)(int, char *, size_t),
- int err,
- char *buf,
- size_t len) {
+static void POSSIBLY_UNUSED
+wrap_posix_strerror_r(char* (*strerror_r_ptr)(int, char*, size_t),
+ int err,
+ char* buf,
+ size_t len) {
// GNU version.
- char *rc = (*strerror_r_ptr)(err, buf, len);
+ char* rc = (*strerror_r_ptr)(err, buf, len);
if (rc != buf) {
// glibc did not use buf and returned a static string instead. Copy it
// into buf.
@@ -62,11 +62,12 @@
// guarantee that they are handled. This is compiled on all POSIX platforms, but
// it will only be used on Linux if the POSIX strerror_r implementation is
// being used (see below).
-static void POSSIBLY_UNUSED wrap_posix_strerror_r(
- int (*strerror_r_ptr)(int, char *, size_t),
- int err,
- char *buf,
- size_t len) {
+static void POSSIBLY_UNUSED wrap_posix_strerror_r(int (*strerror_r_ptr)(int,
+ char*,
+ size_t),
+ int err,
+ char* buf,
+ size_t len) {
int old_errno = errno;
// Have to cast since otherwise we get an error if this is the GNU version
// (but in such a scenario this function is never called). Sadly we can't use
@@ -98,16 +99,13 @@
strerror_error = result;
}
// snprintf truncates and always null-terminates.
- snprintf(buf,
- len,
- "Error %d while retrieving error %d",
- strerror_error,
+ snprintf(buf, len, "Error %d while retrieving error %d", strerror_error,
err);
}
errno = old_errno;
}
-void safe_strerror_r(int err, char *buf, size_t len) {
+void safe_strerror_r(int err, char* buf, size_t len) {
if (buf == nullptr || len <= 0) {
return;
}
diff --git a/base/posix/safe_strerror.h b/base/posix/safe_strerror.h
index 5a2f888..48e9db9 100644
--- a/base/posix/safe_strerror.h
+++ b/base/posix/safe_strerror.h
@@ -9,7 +9,6 @@
#include <string>
-
namespace base {
// BEFORE using anything from this file, first look at PLOG and friends in
@@ -28,7 +27,7 @@
// result is always null-terminated. The value of errno is never changed.
//
// Use this instead of strerror_r().
-void safe_strerror_r(int err, char *buf, size_t len);
+void safe_strerror_r(int err, char* buf, size_t len);
// Calls safe_strerror_r with a buffer of suitable size and returns the result
// in a C++ string.
diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc
index 69a1a5b..6c2cafa 100644
--- a/base/process/internal_linux.cc
+++ b/base/process/internal_linux.cc
@@ -89,14 +89,13 @@
// PID.
proc_stats->push_back(stats_data.substr(0, open_parens_idx));
// Process name without parentheses.
- proc_stats->push_back(
- stats_data.substr(open_parens_idx + 1,
- close_parens_idx - (open_parens_idx + 1)));
+ proc_stats->push_back(stats_data.substr(
+ open_parens_idx + 1, close_parens_idx - (open_parens_idx + 1)));
// Split the rest.
- std::vector<std::string> other_stats = SplitString(
- stats_data.substr(close_parens_idx + 2), " ",
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ std::vector<std::string> other_stats =
+ SplitString(stats_data.substr(close_parens_idx + 2), " ",
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (size_t i = 0; i < other_stats.size(); ++i)
proc_stats->push_back(other_stats[i]);
return true;
@@ -150,8 +149,7 @@
return ReadStatFileAndGetFieldAsInt64(stat_file, field_num);
}
-size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid,
- ProcStatsFields field_num) {
+size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, ProcStatsFields field_num) {
std::string stats_data;
if (!ReadProcStats(pid, &stats_data))
return 0;
@@ -214,8 +212,8 @@
// It may be the case that this value is always 100.
static const int kHertz = sysconf(_SC_CLK_TCK);
- return TimeDelta::FromMicroseconds(
- Time::kMicrosecondsPerSecond * clock_ticks / kHertz);
+ return TimeDelta::FromMicroseconds(Time::kMicrosecondsPerSecond *
+ clock_ticks / kHertz);
}
} // namespace internal
diff --git a/base/process/internal_linux.h b/base/process/internal_linux.h
index d8904fd..56c08e6 100644
--- a/base/process/internal_linux.h
+++ b/base/process/internal_linux.h
@@ -82,8 +82,7 @@
int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num);
// Same as ReadProcStatsAndGetFieldAsInt64() but for size_t values.
-size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid,
- ProcStatsFields field_num);
+size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, ProcStatsFields field_num);
// Returns the time that the OS started. Clock ticks are relative to this.
Time GetBootTime();
diff --git a/base/process/kill.h b/base/process/kill.h
index 4bed1e5..89ab97b 100644
--- a/base/process/kill.h
+++ b/base/process/kill.h
@@ -46,13 +46,13 @@
// exit code arguments to KillProcess*(), use platform/application
// specific values instead.
enum TerminationStatus {
- TERMINATION_STATUS_NORMAL_TERMINATION, // zero exit status
- TERMINATION_STATUS_ABNORMAL_TERMINATION, // non-zero exit status
- TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill
- TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault
- TERMINATION_STATUS_STILL_RUNNING, // child hasn't exited yet
- TERMINATION_STATUS_LAUNCH_FAILED, // child process never launched
- TERMINATION_STATUS_OOM, // Process died due to oom
+ TERMINATION_STATUS_NORMAL_TERMINATION, // zero exit status
+ TERMINATION_STATUS_ABNORMAL_TERMINATION, // non-zero exit status
+ TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill
+ TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault
+ TERMINATION_STATUS_STILL_RUNNING, // child hasn't exited yet
+ TERMINATION_STATUS_LAUNCH_FAILED, // child process never launched
+ TERMINATION_STATUS_OOM, // Process died due to oom
TERMINATION_STATUS_MAX_ENUM
};
@@ -62,8 +62,8 @@
// Returns true if all processes were able to be killed off, false if at least
// one couldn't be killed.
bool KillProcesses(const FilePath::StringType& executable_name,
- int exit_code,
- const ProcessFilter* filter);
+ int exit_code,
+ const ProcessFilter* filter);
#if defined(OS_POSIX)
// Attempts to kill the process group identified by |process_group_id|. Returns
@@ -78,8 +78,7 @@
// will only return a useful result the first time it is called after
// the child exits (because it will reap the child and the information
// will no longer be available).
-TerminationStatus GetTerminationStatus(ProcessHandle handle,
- int* exit_code);
+TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code);
#if defined(OS_POSIX) && !defined(OS_FUCHSIA)
// Send a kill signal to the process and then wait for the process to exit
@@ -97,8 +96,8 @@
// GetTerminationStatus as the child will be reaped when WaitForExitCode
// returns, and this information will be lost.
//
-TerminationStatus GetKnownDeadTerminationStatus(
- ProcessHandle handle, int* exit_code);
+TerminationStatus GetKnownDeadTerminationStatus(ProcessHandle handle,
+ int* exit_code);
#if defined(OS_LINUX)
// Spawns a thread to wait asynchronously for the child |process| to exit
@@ -114,10 +113,9 @@
// is non-null, then only processes selected by the filter are waited on.
// Returns after all processes have exited or wait_milliseconds have expired.
// Returns true if all the processes exited, false otherwise.
-bool WaitForProcessesToExit(
- const FilePath::StringType& executable_name,
- base::TimeDelta wait,
- const ProcessFilter* filter);
+bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
+ base::TimeDelta wait,
+ const ProcessFilter* filter);
// Waits a certain amount of time (can be 0) for all the processes with a given
// executable name to exit, then kills off any of them that are still around.
@@ -126,9 +124,9 @@
// any processes needed to be killed, true if they all exited cleanly within
// the wait_milliseconds delay.
bool CleanupProcesses(const FilePath::StringType& executable_name,
- base::TimeDelta wait,
- int exit_code,
- const ProcessFilter* filter);
+ base::TimeDelta wait,
+ int exit_code,
+ const ProcessFilter* filter);
#endif // !defined(OS_FUCHSIA)
} // namespace base
diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc
index e6d658c..0e4e84d 100644
--- a/base/process/kill_posix.cc
+++ b/base/process/kill_posix.cc
@@ -28,8 +28,8 @@
DCHECK(exit_code);
int status = 0;
- const pid_t result = HANDLE_EINTR(waitpid(handle, &status,
- can_block ? 0 : WNOHANG));
+ const pid_t result =
+ HANDLE_EINTR(waitpid(handle, &status, can_block ? 0 : WNOHANG));
if (result == -1) {
DPLOG(ERROR) << "waitpid(" << handle << ")";
*exit_code = 0;
diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc
index 7a66442..f598c13 100644
--- a/base/process/kill_win.cc
+++ b/base/process/kill_win.cc
@@ -6,9 +6,9 @@
#include <algorithm>
-#include <windows.h>
#include <io.h>
#include <stdint.h>
+#include <windows.h>
#include "base/logging.h"
#include "base/macros.h"
@@ -92,9 +92,7 @@
DWORD remaining_wait = static_cast<DWORD>(
std::max(static_cast<int64_t>(0),
wait.InMilliseconds() - (GetTickCount() - start_time)));
- HANDLE process = OpenProcess(SYNCHRONIZE,
- FALSE,
- entry->th32ProcessID);
+ HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, entry->th32ProcessID);
DWORD wait_result = WaitForSingleObject(process, remaining_wait);
CloseHandle(process);
result &= (wait_result == WAIT_OBJECT_0);
diff --git a/base/process/memory.cc b/base/process/memory.cc
index 84305e0..2e87fea 100644
--- a/base/process/memory.cc
+++ b/base/process/memory.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "base/process/memory.h"
+#include "base/logging.h"
#include "build_config.h"
namespace base {
diff --git a/base/process/memory.h b/base/process/memory.h
index 49dad5d..bbcff68 100644
--- a/base/process/memory.h
+++ b/base/process/memory.h
@@ -71,11 +71,10 @@
// specifically ASan and other sanitizers.
// Return value tells whether the allocation succeeded. If it fails |result| is
// set to NULL, otherwise it holds the memory address.
-WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size,
- void** result);
+WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size, void** result);
WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items,
- size_t size,
- void** result);
+ size_t size,
+ void** result);
} // namespace base
diff --git a/base/process/memory_stubs.cc b/base/process/memory_stubs.cc
index 787d9ae..df4657f 100644
--- a/base/process/memory_stubs.cc
+++ b/base/process/memory_stubs.cc
@@ -9,11 +9,9 @@
namespace base {
-void EnableTerminationOnOutOfMemory() {
-}
+void EnableTerminationOnOutOfMemory() {}
-void EnableTerminationOnHeapCorruption() {
-}
+void EnableTerminationOnHeapCorruption() {}
bool AdjustOOMScore(ProcessId process, int score) {
return false;
diff --git a/base/process/memory_win.cc b/base/process/memory_win.cc
index c3fe758..77a2398 100644
--- a/base/process/memory_win.cc
+++ b/base/process/memory_win.cc
@@ -40,7 +40,7 @@
namespace {
#pragma warning(push)
-#pragma warning(disable: 4702) // Unreachable code after the _exit.
+#pragma warning(disable : 4702) // Unreachable code after the _exit.
NOINLINE int OnNoMemory(size_t size) {
// Kill the process. This is important for security since most of code
diff --git a/base/process/process.h b/base/process/process.h
index bef0aef..857bd6d 100644
--- a/base/process/process.h
+++ b/base/process/process.h
@@ -81,10 +81,10 @@
// Close the process handle. This will not terminate the process.
void Close();
- // Returns true if this process is still running. This is only safe on Windows
- // (and maybe Fuchsia?), because the ProcessHandle will keep the zombie
- // process information available until itself has been released. But on Posix,
- // the OS may reuse the ProcessId.
+// Returns true if this process is still running. This is only safe on Windows
+// (and maybe Fuchsia?), because the ProcessHandle will keep the zombie
+// process information available until itself has been released. But on Posix,
+// the OS may reuse the ProcessId.
#if defined(OS_WIN)
bool IsRunning() const {
return !WaitForExitWithTimeout(base::TimeDelta(), nullptr);
diff --git a/base/process/process_handle.h b/base/process/process_handle.h
index f241391..0ec6bf4 100644
--- a/base/process/process_handle.h
+++ b/base/process/process_handle.h
@@ -61,8 +61,7 @@
// WARNING: To avoid inconsistent results from GetUniqueIdForProcess, this
// should only be called very early after process startup - ideally as soon
// after process creation as possible.
-void InitUniqueIdForProcessInPidNamespace(
- ProcessId pid_outside_of_namespace);
+void InitUniqueIdForProcessInPidNamespace(ProcessId pid_outside_of_namespace);
#endif
// Returns the ProcessHandle of the current process.
diff --git a/base/process/process_handle_freebsd.cc b/base/process/process_handle_freebsd.cc
index 192d72b..bbbf660 100644
--- a/base/process/process_handle_freebsd.cc
+++ b/base/process/process_handle_freebsd.cc
@@ -17,7 +17,7 @@
ProcessId GetParentProcessId(ProcessHandle process) {
struct kinfo_proc info;
size_t length;
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process};
if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0)
return -1;
@@ -28,7 +28,7 @@
FilePath GetProcessExecutablePath(ProcessHandle process) {
char pathname[PATH_MAX];
size_t length;
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, process };
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, process};
length = sizeof(pathname);
diff --git a/base/process/process_handle_mac.cc b/base/process/process_handle_mac.cc
index d9d22f7..6b62406 100644
--- a/base/process/process_handle_mac.cc
+++ b/base/process/process_handle_mac.cc
@@ -16,7 +16,7 @@
ProcessId GetParentProcessId(ProcessHandle process) {
struct kinfo_proc info;
size_t length = sizeof(struct kinfo_proc);
- int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process};
if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) {
DPLOG(ERROR) << "sysctl";
return -1;
diff --git a/base/process/process_handle_openbsd.cc b/base/process/process_handle_openbsd.cc
index 045e720..0e85770 100644
--- a/base/process/process_handle_openbsd.cc
+++ b/base/process/process_handle_openbsd.cc
@@ -15,8 +15,9 @@
ProcessId GetParentProcessId(ProcessHandle process) {
struct kinfo_proc info;
size_t length;
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process,
- sizeof(struct kinfo_proc), 0 };
+ int mib[] = {
+ CTL_KERN, KERN_PROC, KERN_PROC_PID, process, sizeof(struct kinfo_proc),
+ 0};
if (sysctl(mib, arraysize(mib), NULL, &length, NULL, 0) < 0)
return -1;
@@ -32,8 +33,9 @@
FilePath GetProcessExecutablePath(ProcessHandle process) {
struct kinfo_proc kp;
size_t len;
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process,
- sizeof(struct kinfo_proc), 0 };
+ int mib[] = {
+ CTL_KERN, KERN_PROC, KERN_PROC_PID, process, sizeof(struct kinfo_proc),
+ 0};
if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) == -1)
return FilePath();
diff --git a/base/process/process_handle_win.cc b/base/process/process_handle_win.cc
index 67986cd..cf7ab2c 100644
--- a/base/process/process_handle_win.cc
+++ b/base/process/process_handle_win.cc
@@ -5,6 +5,7 @@
#include "base/process/process_handle.h"
#include <windows.h>
+
#include <tlhelp32.h>
#include "base/win/scoped_handle.h"
@@ -28,7 +29,7 @@
ProcessId GetParentProcessId(ProcessHandle process) {
ProcessId child_pid = GetProcId(process);
PROCESSENTRY32 process_entry;
- process_entry.dwSize = sizeof(PROCESSENTRY32);
+ process_entry.dwSize = sizeof(PROCESSENTRY32);
win::ScopedHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0));
if (snapshot.IsValid() && Process32First(snapshot.Get(), &process_entry)) {
diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc
index 27b9623..3083e53 100644
--- a/base/process/process_info_mac.cc
+++ b/base/process/process_info_mac.cc
@@ -19,7 +19,7 @@
// static
const Time CurrentProcessInfo::CreationTime() {
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()};
size_t len = 0;
if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0)
return Time();
diff --git a/base/process/process_iterator.cc b/base/process/process_iterator.cc
index 792237b..e56b349 100644
--- a/base/process/process_iterator.cc
+++ b/base/process/process_iterator.cc
@@ -37,9 +37,8 @@
NamedProcessIterator::NamedProcessIterator(
const FilePath::StringType& executable_name,
- const ProcessFilter* filter) : ProcessIterator(filter),
- executable_name_(executable_name) {
-}
+ const ProcessFilter* filter)
+ : ProcessIterator(filter), executable_name_(executable_name) {}
NamedProcessIterator::~NamedProcessIterator() = default;
diff --git a/base/process/process_iterator.h b/base/process/process_iterator.h
index 532104a..b0d96e4 100644
--- a/base/process/process_iterator.h
+++ b/base/process/process_iterator.h
@@ -20,6 +20,7 @@
#if defined(OS_WIN)
#include <windows.h>
+
#include <tlhelp32.h>
#elif defined(OS_MACOSX) || defined(OS_OPENBSD)
#include <sys/sysctl.h>
@@ -141,7 +142,7 @@
// given executable name. If filter is non-null, then only processes selected
// by the filter will be counted.
int GetProcessCount(const FilePath::StringType& executable_name,
- const ProcessFilter* filter);
+ const ProcessFilter* filter);
} // namespace base
diff --git a/base/process/process_iterator_freebsd.cc b/base/process/process_iterator_freebsd.cc
index 4df0d90..a69b2f0 100644
--- a/base/process/process_iterator_freebsd.cc
+++ b/base/process/process_iterator_freebsd.cc
@@ -5,9 +5,9 @@
#include "base/process/process_iterator.h"
#include <errno.h>
-#include <sys/types.h>
#include <stddef.h>
#include <sys/sysctl.h>
+#include <sys/types.h>
#include <unistd.h>
#include "base/logging.h"
@@ -18,10 +18,8 @@
namespace base {
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
- : index_of_kinfo_proc_(),
- filter_(filter) {
-
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid() };
+ : index_of_kinfo_proc_(), filter_(filter) {
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid()};
bool done = false;
int try_num = 1;
@@ -40,7 +38,7 @@
num_of_kinfo_proc += 16;
kinfo_procs_.resize(num_of_kinfo_proc);
len = num_of_kinfo_proc * sizeof(struct kinfo_proc);
- if (sysctl(mib, arraysize(mib), &kinfo_procs_[0], &len, NULL, 0) <0) {
+ if (sysctl(mib, arraysize(mib), &kinfo_procs_[0], &len, NULL, 0) < 0) {
// If we get a mem error, it just means we need a bigger buffer, so
// loop around again. Anything else is a real error and give up.
if (errno != ENOMEM) {
@@ -63,8 +61,7 @@
}
}
-ProcessIterator::~ProcessIterator() {
-}
+ProcessIterator::~ProcessIterator() {}
bool ProcessIterator::CheckForNextProcess() {
std::string data;
@@ -72,7 +69,7 @@
for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++index_of_kinfo_proc_) {
size_t length;
struct kinfo_proc kinfo = kinfo_procs_[index_of_kinfo_proc_];
- int mib[] = { CTL_KERN, KERN_PROC_ARGS, kinfo.ki_pid };
+ int mib[] = {CTL_KERN, KERN_PROC_ARGS, kinfo.ki_pid};
if ((kinfo.ki_pid > 0) && (kinfo.ki_stat == SZOMB))
continue;
@@ -92,8 +89,8 @@
std::string delimiters;
delimiters.push_back('\0');
- entry_.cmd_line_args_ = SplitString(data, delimiters,
- KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
+ entry_.cmd_line_args_ =
+ SplitString(data, delimiters, KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
size_t exec_name_end = data.find('\0');
if (exec_name_end == std::string::npos) {
diff --git a/base/process/process_iterator_linux.cc b/base/process/process_iterator_linux.cc
index a7b0b05..9894052 100644
--- a/base/process/process_iterator_linux.cc
+++ b/base/process/process_iterator_linux.cc
@@ -47,8 +47,8 @@
return false;
std::string delimiters;
delimiters.push_back('\0');
- *proc_cmd_line_args = SplitString(cmd_line, delimiters, KEEP_WHITESPACE,
- SPLIT_WANT_NONEMPTY);
+ *proc_cmd_line_args =
+ SplitString(cmd_line, delimiters, KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
return true;
}
diff --git a/base/process/process_iterator_mac.cc b/base/process/process_iterator_mac.cc
index 90d2184..10d712b 100644
--- a/base/process/process_iterator_mac.cc
+++ b/base/process/process_iterator_mac.cc
@@ -18,14 +18,12 @@
namespace base {
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
- : index_of_kinfo_proc_(0),
- filter_(filter) {
+ : index_of_kinfo_proc_(0), filter_(filter) {
// Get a snapshot of all of my processes (yes, as we loop it can go stale, but
// but trying to find where we were in a constantly changing list is basically
// impossible.
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID,
- static_cast<int>(geteuid()) };
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, static_cast<int>(geteuid())};
// Since more processes could start between when we get the size and when
// we get the list, we do a loop to keep trying until we get it.
@@ -69,8 +67,7 @@
}
}
-ProcessIterator::~ProcessIterator() {
-}
+ProcessIterator::~ProcessIterator() {}
bool ProcessIterator::CheckForNextProcess() {
std::string data;
@@ -81,7 +78,7 @@
if ((kinfo.kp_proc.p_pid > 0) && (kinfo.kp_proc.p_stat == SZOMB))
continue;
- int mib[] = { CTL_KERN, KERN_PROCARGS, kinfo.kp_proc.p_pid };
+ int mib[] = {CTL_KERN, KERN_PROCARGS, kinfo.kp_proc.p_pid};
// Find out what size buffer we need.
size_t data_len = 0;
@@ -100,8 +97,8 @@
// |entry_.cmd_line_args_|.
std::string delimiters;
delimiters.push_back('\0');
- entry_.cmd_line_args_ = SplitString(data, delimiters,
- KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
+ entry_.cmd_line_args_ =
+ SplitString(data, delimiters, KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
// |data| starts with the full executable path followed by a null character.
// We search for the first instance of '\0' and extract everything before it
diff --git a/base/process/process_iterator_openbsd.cc b/base/process/process_iterator_openbsd.cc
index fa32df4..4362c9a 100644
--- a/base/process/process_iterator_openbsd.cc
+++ b/base/process/process_iterator_openbsd.cc
@@ -16,11 +16,10 @@
namespace base {
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
- : index_of_kinfo_proc_(),
- filter_(filter) {
-
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid(),
- sizeof(struct kinfo_proc), 0 };
+ : index_of_kinfo_proc_(), filter_(filter) {
+ int mib[] = {
+ CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc),
+ 0};
bool done = false;
int try_num = 1;
@@ -62,8 +61,7 @@
}
}
-ProcessIterator::~ProcessIterator() {
-}
+ProcessIterator::~ProcessIterator() {}
bool ProcessIterator::CheckForNextProcess() {
std::string data;
@@ -74,7 +72,7 @@
if ((kinfo.p_pid > 0) && (kinfo.p_stat == SZOMB))
continue;
- int mib[] = { CTL_KERN, KERN_PROC_ARGS, kinfo.p_pid };
+ int mib[] = {CTL_KERN, KERN_PROC_ARGS, kinfo.p_pid};
// Find out what size buffer we need.
size_t data_len = 0;
@@ -93,8 +91,8 @@
// |entry_.cmd_line_args_|.
std::string delimiters;
delimiters.push_back('\0');
- entry_.cmd_line_args_ = SplitString(data, delimiters, KEEP_WHITESPACE,
- SPLIT_WANT_NONEMPTY);
+ entry_.cmd_line_args_ =
+ SplitString(data, delimiters, KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
// |data| starts with the full executable path followed by a null character.
// We search for the first instance of '\0' and extract everything before it
diff --git a/base/process/process_iterator_win.cc b/base/process/process_iterator_win.cc
index 9d5a970..e1bf808 100644
--- a/base/process/process_iterator_win.cc
+++ b/base/process/process_iterator_win.cc
@@ -7,8 +7,7 @@
namespace base {
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
- : started_iteration_(false),
- filter_(filter) {
+ : started_iteration_(false), filter_(filter) {
snapshot_ = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
}
diff --git a/base/process/process_posix.cc b/base/process/process_posix.cc
index 3cc9182..5c9ce05 100644
--- a/base/process/process_posix.cc
+++ b/base/process/process_posix.cc
@@ -162,13 +162,11 @@
DCHECK_EQ(result, 1);
- if (event.filter != EVFILT_PROC ||
- (event.fflags & NOTE_EXIT) == 0 ||
+ if (event.filter != EVFILT_PROC || (event.fflags & NOTE_EXIT) == 0 ||
event.ident != static_cast<uintptr_t>(handle)) {
DLOG(ERROR) << "kevent (wait " << handle
<< "): unexpected event: filter=" << event.filter
- << ", fflags=" << event.fflags
- << ", ident=" << event.ident;
+ << ", fflags=" << event.fflags << ", ident=" << event.ident;
return false;
}
@@ -222,8 +220,7 @@
namespace base {
-Process::Process(ProcessHandle handle) : process_(handle) {
-}
+Process::Process(ProcessHandle handle) : process_(handle) {}
Process::~Process() = default;
diff --git a/base/process/process_win.cc b/base/process/process_win.cc
index f5bd59e..ce2b394 100644
--- a/base/process/process_win.cc
+++ b/base/process/process_win.cc
@@ -13,9 +13,9 @@
namespace {
DWORD kBasicProcessAccess =
- PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE;
+ PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE;
-} // namespace
+} // namespace
namespace base {
@@ -30,8 +30,7 @@
other.Close();
}
-Process::~Process() {
-}
+Process::~Process() {}
Process& Process::operator=(Process&& other) {
DCHECK_NE(this, &other);
@@ -85,13 +84,9 @@
return Current();
ProcessHandle out_handle;
- if (!IsValid() || !::DuplicateHandle(GetCurrentProcess(),
- Handle(),
- GetCurrentProcess(),
- &out_handle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS)) {
+ if (!IsValid() ||
+ !::DuplicateHandle(GetCurrentProcess(), Handle(), GetCurrentProcess(),
+ &out_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
return Process();
}
return Process(out_handle);
@@ -162,8 +157,7 @@
return true;
}
-void Process::Exited(int exit_code) const {
-}
+void Process::Exited(int exit_code) const {}
int Process::GetPriority() const {
DCHECK(IsValid());
diff --git a/base/scoped_clear_errno.h b/base/scoped_clear_errno.h
index 585f6f7..44a0c62 100644
--- a/base/scoped_clear_errno.h
+++ b/base/scoped_clear_errno.h
@@ -15,9 +15,7 @@
// destruction puts the old value back.
class ScopedClearErrno {
public:
- ScopedClearErrno() : old_errno_(errno) {
- errno = 0;
- }
+ ScopedClearErrno() : old_errno_(errno) { errno = 0; }
~ScopedClearErrno() {
if (errno == 0)
errno = old_errno_;
diff --git a/base/scoped_generic.h b/base/scoped_generic.h
index 25e6208..6a56f64 100644
--- a/base/scoped_generic.h
+++ b/base/scoped_generic.h
@@ -51,7 +51,7 @@
// };
//
// typedef ScopedGeneric<int, FooScopedTraits> ScopedFoo;
-template<typename T, typename Traits>
+template <typename T, typename Traits>
class ScopedGeneric {
private:
// This must be first since it's used inline below.
@@ -78,17 +78,13 @@
// Constructor. Allows initialization of a stateful traits object.
ScopedGeneric(const element_type& value, const traits_type& traits)
- : data_(value, traits) {
- }
+ : data_(value, traits) {}
// Move constructor. Allows initialization from a ScopedGeneric rvalue.
ScopedGeneric(ScopedGeneric<T, Traits>&& rvalue)
- : data_(rvalue.release(), rvalue.get_traits()) {
- }
+ : data_(rvalue.release(), rvalue.get_traits()) {}
- ~ScopedGeneric() {
- FreeIfNecessary();
- }
+ ~ScopedGeneric() { FreeIfNecessary(); }
// operator=. Allows assignment from a ScopedGeneric rvalue.
ScopedGeneric& operator=(ScopedGeneric<T, Traits>&& rvalue) {
@@ -158,28 +154,28 @@
// Forbid comparison. If U != T, it totally doesn't make sense, and if U ==
// T, it still doesn't make sense because you should never have the same
// object owned by two different ScopedGenerics.
- template <typename T2, typename Traits2> bool operator==(
- const ScopedGeneric<T2, Traits2>& p2) const;
- template <typename T2, typename Traits2> bool operator!=(
- const ScopedGeneric<T2, Traits2>& p2) const;
+ template <typename T2, typename Traits2>
+ bool operator==(const ScopedGeneric<T2, Traits2>& p2) const;
+ template <typename T2, typename Traits2>
+ bool operator!=(const ScopedGeneric<T2, Traits2>& p2) const;
Data data_;
DISALLOW_COPY_AND_ASSIGN(ScopedGeneric);
};
-template<class T, class Traits>
+template <class T, class Traits>
void swap(const ScopedGeneric<T, Traits>& a,
const ScopedGeneric<T, Traits>& b) {
a.swap(b);
}
-template<class T, class Traits>
+template <class T, class Traits>
bool operator==(const T& value, const ScopedGeneric<T, Traits>& scoped) {
return value == scoped.get();
}
-template<class T, class Traits>
+template <class T, class Traits>
bool operator!=(const T& value, const ScopedGeneric<T, Traits>& scoped) {
return value != scoped.get();
}
diff --git a/base/sha1.cc b/base/sha1.cc
index a710001..9c22be1 100644
--- a/base/sha1.cc
+++ b/base/sha1.cc
@@ -78,7 +78,7 @@
}
static inline uint32_t S(uint32_t n, uint32_t X) {
- return (X << n) | (X >> (32-n));
+ return (X << n) | (X >> (32 - n));
}
static inline uint32_t K(uint32_t t) {
@@ -131,7 +131,7 @@
void SecureHashAlgorithm::Pad() {
M[cursor++] = 0x80;
- if (cursor > 64-8) {
+ if (cursor > 64 - 8) {
// pad out to next block
while (cursor < 64)
M[cursor++] = 0;
@@ -139,7 +139,7 @@
Process();
}
- while (cursor < 64-8)
+ while (cursor < 64 - 8)
M[cursor++] = 0;
M[cursor++] = (l >> 56) & 0xff;
@@ -202,8 +202,7 @@
return std::string(hash, SecureHashAlgorithm::kDigestSizeBytes);
}
-void SHA1HashBytes(const unsigned char* data, size_t len,
- unsigned char* hash) {
+void SHA1HashBytes(const unsigned char* data, size_t len, unsigned char* hash) {
SecureHashAlgorithm sha;
sha.Update(data, len);
sha.Final();
diff --git a/base/sha1.h b/base/sha1.h
index 5394606..482ebe6 100644
--- a/base/sha1.h
+++ b/base/sha1.h
@@ -9,7 +9,6 @@
#include <string>
-
namespace base {
// These functions perform SHA-1 operations.
@@ -22,8 +21,7 @@
// Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash
// in |hash|. |hash| must be kSHA1Length bytes long.
-void SHA1HashBytes(const unsigned char* data, size_t len,
- unsigned char* hash);
+void SHA1HashBytes(const unsigned char* data, size_t len, unsigned char* hash);
} // namespace base
diff --git a/base/stl_util.h b/base/stl_util.h
index 6d521cc..d9e3484 100644
--- a/base/stl_util.h
+++ b/base/stl_util.h
@@ -117,7 +117,7 @@
// Clears internal memory of an STL object.
// STL clear()/reserve(0) does not always free internal memory allocated
// This function uses swap/destructor to ensure the internal memory is freed.
-template<class T>
+template <class T>
void STLClearObject(T* obj) {
T tmp;
tmp.swap(*obj);
@@ -175,8 +175,8 @@
// Note: Use reverse iterator on container to ensure we only require
// value_type to implement operator<.
return std::adjacent_find(cont.rbegin(), cont.rend(),
- std::less<typename Container::value_type>())
- == cont.rend();
+ std::less<typename Container::value_type>()) ==
+ cont.rend();
}
// Returns a new ResultType containing the difference of two sorted containers.
@@ -185,8 +185,7 @@
DCHECK(STLIsSorted(a1));
DCHECK(STLIsSorted(a2));
ResultType difference;
- std::set_difference(a1.begin(), a1.end(),
- a2.begin(), a2.end(),
+ std::set_difference(a1.begin(), a1.end(), a2.begin(), a2.end(),
std::inserter(difference, difference.end()));
return difference;
}
@@ -197,8 +196,7 @@
DCHECK(STLIsSorted(a1));
DCHECK(STLIsSorted(a2));
ResultType result;
- std::set_union(a1.begin(), a1.end(),
- a2.begin(), a2.end(),
+ std::set_union(a1.begin(), a1.end(), a2.begin(), a2.end(),
std::inserter(result, result.end()));
return result;
}
@@ -210,8 +208,7 @@
DCHECK(STLIsSorted(a1));
DCHECK(STLIsSorted(a2));
ResultType result;
- std::set_intersection(a1.begin(), a1.end(),
- a2.begin(), a2.end(),
+ std::set_intersection(a1.begin(), a1.end(), a2.begin(), a2.end(),
std::inserter(result, result.end()));
return result;
}
@@ -222,8 +219,7 @@
bool STLIncludes(const Arg1& a1, const Arg2& a2) {
DCHECK(STLIsSorted(a1));
DCHECK(STLIsSorted(a2));
- return std::includes(a1.begin(), a1.end(),
- a2.begin(), a2.end());
+ return std::includes(a1.begin(), a1.end(), a2.begin(), a2.end());
}
// Erase/EraseIf are based on library fundamentals ts v2 erase/erase_if
diff --git a/base/strings/string16.cc b/base/strings/string16.cc
index 2abb0e5..997ab20 100644
--- a/base/strings/string16.cc
+++ b/base/strings/string16.cc
@@ -33,7 +33,7 @@
}
size_t c16len(const char16* s) {
- const char16 *s_orig = s;
+ const char16* s_orig = s;
while (*s) {
++s;
}
@@ -59,7 +59,7 @@
}
char16* c16memset(char16* s, char16 c, size_t n) {
- char16 *s_orig = s;
+ char16* s_orig = s;
while (n-- > 0) {
*s = c;
++s;
diff --git a/base/strings/string16.h b/base/strings/string16.h
index b143375..e79aee8 100644
--- a/base/strings/string16.h
+++ b/base/strings/string16.h
@@ -80,26 +80,19 @@
typedef mbstate_t state_type;
typedef std::fpos<state_type> pos_type;
- static void assign(char_type& c1, const char_type& c2) {
- c1 = c2;
- }
+ static void assign(char_type& c1, const char_type& c2) { c1 = c2; }
- static bool eq(const char_type& c1, const char_type& c2) {
- return c1 == c2;
- }
- static bool lt(const char_type& c1, const char_type& c2) {
- return c1 < c2;
- }
+ static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; }
+ static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; }
static int compare(const char_type* s1, const char_type* s2, size_t n) {
return c16memcmp(s1, s2, n);
}
- static size_t length(const char_type* s) {
- return c16len(s);
- }
+ static size_t length(const char_type* s) { return c16len(s); }
- static const char_type* find(const char_type* s, size_t n,
+ static const char_type* find(const char_type* s,
+ size_t n,
const char_type& a) {
return c16memchr(s, a, n);
}
@@ -120,21 +113,15 @@
return eq_int_type(c, eof()) ? 0 : c;
}
- static char_type to_char_type(const int_type& c) {
- return char_type(c);
- }
+ static char_type to_char_type(const int_type& c) { return char_type(c); }
- static int_type to_int_type(const char_type& c) {
- return int_type(c);
- }
+ static int_type to_int_type(const char_type& c) { return int_type(c); }
static bool eq_int_type(const int_type& c1, const int_type& c2) {
return c1 == c2;
}
- static int_type eof() {
- return static_cast<int_type>(EOF);
- }
+ static int_type eof() { return static_cast<int_type>(EOF); }
};
} // namespace string16_internals
@@ -145,8 +132,7 @@
namespace string16_internals {
-extern std::ostream& operator<<(std::ostream& out,
- const string16& str);
+extern std::ostream& operator<<(std::ostream& out, const string16& str);
// This is required by googletest to print a readable output on test failures.
extern void PrintTo(const string16& str, std::ostream* out);
@@ -194,9 +180,8 @@
//
// TODO(mark): File this bug with Apple and update this note with a bug number.
-extern template class
- std::basic_string<base::char16,
- base::string16_internals::string16_char_traits>;
+extern template class std::
+ basic_string<base::char16, base::string16_internals::string16_char_traits>;
// Specialize std::hash for base::string16. Although the style guide forbids
// this in general, it is necessary for consistency with WCHAR_T_IS_UTF16
diff --git a/base/strings/string_number_conversions.cc b/base/strings/string_number_conversions.cc
index c2a606f..01375f5 100644
--- a/base/strings/string_number_conversions.cc
+++ b/base/strings/string_number_conversions.cc
@@ -57,11 +57,12 @@
};
// Utility to convert a character to a digit in a given base
-template<typename CHAR, int BASE, bool BASE_LTE_10> class BaseCharToDigit {
-};
+template <typename CHAR, int BASE, bool BASE_LTE_10>
+class BaseCharToDigit {};
// Faster specialization for bases <= 10
-template<typename CHAR, int BASE> class BaseCharToDigit<CHAR, BASE, true> {
+template <typename CHAR, int BASE>
+class BaseCharToDigit<CHAR, BASE, true> {
public:
static bool Convert(CHAR c, uint8_t* digit) {
if (c >= '0' && c < '0' + BASE) {
@@ -73,7 +74,8 @@
};
// Specialization for bases where 10 < base <= 36
-template<typename CHAR, int BASE> class BaseCharToDigit<CHAR, BASE, false> {
+template <typename CHAR, int BASE>
+class BaseCharToDigit<CHAR, BASE, false> {
public:
static bool Convert(CHAR c, uint8_t* digit) {
if (c >= '0' && c <= '9') {
@@ -98,24 +100,25 @@
// is locale independent, whereas the functions we are replacing were
// locale-dependent. TBD what is desired, but for the moment let's not
// introduce a change in behaviour.
-template<typename CHAR> class WhitespaceHelper {
-};
+template <typename CHAR>
+class WhitespaceHelper {};
-template<> class WhitespaceHelper<char> {
+template <>
+class WhitespaceHelper<char> {
public:
static bool Invoke(char c) {
return 0 != isspace(static_cast<unsigned char>(c));
}
};
-template<> class WhitespaceHelper<char16> {
+template <>
+class WhitespaceHelper<char16> {
public:
- static bool Invoke(char16 c) {
- return 0 != iswspace(c);
- }
+ static bool Invoke(char16 c) { return 0 != iswspace(c); }
};
-template<typename CHAR> bool LocalIsWhitespace(CHAR c) {
+template <typename CHAR>
+bool LocalIsWhitespace(CHAR c) {
return WhitespaceHelper<CHAR>::Invoke(c);
}
@@ -125,7 +128,7 @@
// - static functions min, max (returning the minimum and maximum permitted
// values)
// - constant kBase, the base in which to interpret the input
-template<typename IteratorRangeToNumberTraits>
+template <typename IteratorRangeToNumberTraits>
class IteratorRangeToNumber {
public:
typedef IteratorRangeToNumberTraits traits;
@@ -169,10 +172,11 @@
// causes an overflow/underflow
// - a static function, Increment, that appends the next digit appropriately
// according to the sign of the number being parsed.
- template<typename Sign>
+ template <typename Sign>
class Base {
public:
- static bool Invoke(const_iterator begin, const_iterator end,
+ static bool Invoke(const_iterator begin,
+ const_iterator end,
typename traits::value_type* output) {
*output = 0;
@@ -240,24 +244,19 @@
};
};
-template<typename ITERATOR, typename VALUE, int BASE>
+template <typename ITERATOR, typename VALUE, int BASE>
class BaseIteratorRangeToNumberTraits {
public:
typedef ITERATOR iterator_type;
typedef VALUE value_type;
- static value_type min() {
- return std::numeric_limits<value_type>::min();
- }
- static value_type max() {
- return std::numeric_limits<value_type>::max();
- }
+ static value_type min() { return std::numeric_limits<value_type>::min(); }
+ static value_type max() { return std::numeric_limits<value_type>::max(); }
static const int kBase = BASE;
};
-template<typename ITERATOR>
+template <typename ITERATOR>
class BaseHexIteratorRangeToIntTraits
- : public BaseIteratorRangeToNumberTraits<ITERATOR, int, 16> {
-};
+ : public BaseIteratorRangeToNumberTraits<ITERATOR, int, 16> {};
template <typename ITERATOR>
class BaseHexIteratorRangeToUIntTraits
@@ -287,12 +286,11 @@
class StringPieceToNumberTraits
: public BaseIteratorRangeToNumberTraits<StringPiece::const_iterator,
VALUE,
- BASE> {
-};
+ BASE> {};
template <typename VALUE>
bool StringToIntImpl(StringPiece input, VALUE* output) {
- return IteratorRangeToNumber<StringPieceToNumberTraits<VALUE, 10> >::Invoke(
+ return IteratorRangeToNumber<StringPieceToNumberTraits<VALUE, 10>>::Invoke(
input.begin(), input.end(), output);
}
@@ -300,12 +298,11 @@
class StringPiece16ToNumberTraits
: public BaseIteratorRangeToNumberTraits<StringPiece16::const_iterator,
VALUE,
- BASE> {
-};
+ BASE> {};
template <typename VALUE>
bool String16ToIntImpl(StringPiece16 input, VALUE* output) {
- return IteratorRangeToNumber<StringPiece16ToNumberTraits<VALUE, 10> >::Invoke(
+ return IteratorRangeToNumber<StringPiece16ToNumberTraits<VALUE, 10>>::Invoke(
input.begin(), input.end(), output);
}
@@ -423,7 +420,7 @@
bool HexStringToInt(StringPiece input, int* output) {
return IteratorRangeToNumber<HexIteratorRangeToIntTraits>::Invoke(
- input.begin(), input.end(), output);
+ input.begin(), input.end(), output);
}
bool HexStringToUInt(StringPiece input, uint32_t* output) {
@@ -433,7 +430,7 @@
bool HexStringToInt64(StringPiece input, int64_t* output) {
return IteratorRangeToNumber<HexIteratorRangeToInt64Traits>::Invoke(
- input.begin(), input.end(), output);
+ input.begin(), input.end(), output);
}
bool HexStringToUInt64(StringPiece input, uint64_t* output) {
diff --git a/base/strings/string_number_conversions.h b/base/strings/string_number_conversions.h
index d31f09b..e89e26b 100644
--- a/base/strings/string_number_conversions.h
+++ b/base/strings/string_number_conversions.h
@@ -145,8 +145,7 @@
// |*output| will contain as many bytes as were successfully parsed prior to the
// error. There is no overflow, but input.size() must be evenly divisible by 2.
// Leading 0x or +/- are not allowed.
-bool HexStringToBytes(StringPiece input,
- std::vector<uint8_t>* output);
+bool HexStringToBytes(StringPiece input, std::vector<uint8_t>* output);
} // namespace base
diff --git a/base/strings/string_piece.cc b/base/strings/string_piece.cc
index be22261..612298a 100644
--- a/base/strings/string_piece.cc
+++ b/base/strings/string_piece.cc
@@ -55,7 +55,7 @@
namespace internal {
-template<typename STR>
+template <typename STR>
void CopyToStringT(const BasicStringPiece<STR>& self, STR* target) {
if (self.empty())
target->clear();
@@ -71,7 +71,7 @@
CopyToStringT(self, target);
}
-template<typename STR>
+template <typename STR>
void AppendToStringT(const BasicStringPiece<STR>& self, STR* target) {
if (!self.empty())
target->append(self.data(), self.size());
@@ -85,7 +85,7 @@
AppendToStringT(self, target);
}
-template<typename STR>
+template <typename STR>
size_t copyT(const BasicStringPiece<STR>& self,
typename STR::value_type* buf,
size_t n,
@@ -103,7 +103,7 @@
return copyT(self, buf, n, pos);
}
-template<typename STR>
+template <typename STR>
size_t findT(const BasicStringPiece<STR>& self,
const BasicStringPiece<STR>& s,
size_t pos) {
@@ -112,8 +112,7 @@
typename BasicStringPiece<STR>::const_iterator result =
std::search(self.begin() + pos, self.end(), s.begin(), s.end());
- const size_t xpos =
- static_cast<size_t>(result - self.begin());
+ const size_t xpos = static_cast<size_t>(result - self.begin());
return xpos + s.size() <= self.size() ? xpos : BasicStringPiece<STR>::npos;
}
@@ -125,7 +124,7 @@
return findT(self, s, pos);
}
-template<typename STR>
+template <typename STR>
size_t findT(const BasicStringPiece<STR>& self,
typename STR::value_type c,
size_t pos) {
@@ -134,8 +133,8 @@
typename BasicStringPiece<STR>::const_iterator result =
std::find(self.begin() + pos, self.end(), c);
- return result != self.end() ?
- static_cast<size_t>(result - self.begin()) : BasicStringPiece<STR>::npos;
+ return result != self.end() ? static_cast<size_t>(result - self.begin())
+ : BasicStringPiece<STR>::npos;
}
size_t find(const StringPiece& self, char c, size_t pos) {
@@ -146,7 +145,7 @@
return findT(self, c, pos);
}
-template<typename STR>
+template <typename STR>
size_t rfindT(const BasicStringPiece<STR>& self,
const BasicStringPiece<STR>& s,
size_t pos) {
@@ -160,8 +159,8 @@
self.begin() + std::min(self.size() - s.size(), pos) + s.size();
typename BasicStringPiece<STR>::const_iterator result =
std::find_end(self.begin(), last, s.begin(), s.end());
- return result != last ?
- static_cast<size_t>(result - self.begin()) : BasicStringPiece<STR>::npos;
+ return result != last ? static_cast<size_t>(result - self.begin())
+ : BasicStringPiece<STR>::npos;
}
size_t rfind(const StringPiece& self, const StringPiece& s, size_t pos) {
@@ -172,15 +171,14 @@
return rfindT(self, s, pos);
}
-template<typename STR>
+template <typename STR>
size_t rfindT(const BasicStringPiece<STR>& self,
typename STR::value_type c,
size_t pos) {
if (self.size() == 0)
return BasicStringPiece<STR>::npos;
- for (size_t i = std::min(pos, self.size() - 1); ;
- --i) {
+ for (size_t i = std::min(pos, self.size() - 1);; --i) {
if (self.data()[i] == c)
return i;
if (i == 0)
@@ -208,7 +206,7 @@
if (s.size() == 1)
return find(self, s.data()[0], pos);
- bool lookup[UCHAR_MAX + 1] = { false };
+ bool lookup[UCHAR_MAX + 1] = {false};
BuildLookupTable(s, lookup);
for (size_t i = pos; i < self.size(); ++i) {
if (lookup[static_cast<unsigned char>(self.data()[i])]) {
@@ -243,7 +241,7 @@
if (s.size() == 1)
return find_first_not_of(self, s.data()[0], pos);
- bool lookup[UCHAR_MAX + 1] = { false };
+ bool lookup[UCHAR_MAX + 1] = {false};
BuildLookupTable(s, lookup);
for (size_t i = pos; i < self.size(); ++i) {
if (!lookup[static_cast<unsigned char>(self.data()[i])]) {
@@ -255,8 +253,8 @@
// 16-bit brute-force version.
size_t find_first_not_of(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos) {
+ const StringPiece16& s,
+ size_t pos) {
if (self.size() == 0)
return StringPiece16::npos;
@@ -274,7 +272,7 @@
return StringPiece16::npos;
}
-template<typename STR>
+template <typename STR>
size_t find_first_not_ofT(const BasicStringPiece<STR>& self,
typename STR::value_type c,
size_t pos) {
@@ -289,15 +287,11 @@
return BasicStringPiece<STR>::npos;
}
-size_t find_first_not_of(const StringPiece& self,
- char c,
- size_t pos) {
+size_t find_first_not_of(const StringPiece& self, char c, size_t pos) {
return find_first_not_ofT(self, c, pos);
}
-size_t find_first_not_of(const StringPiece16& self,
- char16 c,
- size_t pos) {
+size_t find_first_not_of(const StringPiece16& self, char16 c, size_t pos) {
return find_first_not_ofT(self, c, pos);
}
@@ -310,9 +304,9 @@
if (s.size() == 1)
return rfind(self, s.data()[0], pos);
- bool lookup[UCHAR_MAX + 1] = { false };
+ bool lookup[UCHAR_MAX + 1] = {false};
BuildLookupTable(s, lookup);
- for (size_t i = std::min(pos, self.size() - 1); ; --i) {
+ for (size_t i = std::min(pos, self.size() - 1);; --i) {
if (lookup[static_cast<unsigned char>(self.data()[i])])
return i;
if (i == 0)
@@ -328,8 +322,7 @@
if (self.size() == 0)
return StringPiece16::npos;
- for (size_t self_i = std::min(pos, self.size() - 1); ;
- --self_i) {
+ for (size_t self_i = std::min(pos, self.size() - 1);; --self_i) {
for (size_t s_i = 0; s_i < s.size(); s_i++) {
if (self.data()[self_i] == s[s_i])
return self_i;
@@ -355,9 +348,9 @@
if (s.size() == 1)
return find_last_not_of(self, s.data()[0], pos);
- bool lookup[UCHAR_MAX + 1] = { false };
+ bool lookup[UCHAR_MAX + 1] = {false};
BuildLookupTable(s, lookup);
- for (; ; --i) {
+ for (;; --i) {
if (!lookup[static_cast<unsigned char>(self.data()[i])])
return i;
if (i == 0)
@@ -373,7 +366,7 @@
if (self.size() == 0)
return StringPiece::npos;
- for (size_t self_i = std::min(pos, self.size() - 1); ; --self_i) {
+ for (size_t self_i = std::min(pos, self.size() - 1);; --self_i) {
bool found = false;
for (size_t s_i = 0; s_i < s.size(); s_i++) {
if (self.data()[self_i] == s[s_i]) {
@@ -389,14 +382,14 @@
return StringPiece16::npos;
}
-template<typename STR>
+template <typename STR>
size_t find_last_not_ofT(const BasicStringPiece<STR>& self,
typename STR::value_type c,
size_t pos) {
if (self.size() == 0)
return BasicStringPiece<STR>::npos;
- for (size_t i = std::min(pos, self.size() - 1); ; --i) {
+ for (size_t i = std::min(pos, self.size() - 1);; --i) {
if (self.data()[i] != c)
return i;
if (i == 0)
@@ -405,36 +398,30 @@
return BasicStringPiece<STR>::npos;
}
-size_t find_last_not_of(const StringPiece& self,
- char c,
- size_t pos) {
+size_t find_last_not_of(const StringPiece& self, char c, size_t pos) {
return find_last_not_ofT(self, c, pos);
}
-size_t find_last_not_of(const StringPiece16& self,
- char16 c,
- size_t pos) {
+size_t find_last_not_of(const StringPiece16& self, char16 c, size_t pos) {
return find_last_not_ofT(self, c, pos);
}
-template<typename STR>
+template <typename STR>
BasicStringPiece<STR> substrT(const BasicStringPiece<STR>& self,
size_t pos,
size_t n) {
- if (pos > self.size()) pos = self.size();
- if (n > self.size() - pos) n = self.size() - pos;
+ if (pos > self.size())
+ pos = self.size();
+ if (n > self.size() - pos)
+ n = self.size() - pos;
return BasicStringPiece<STR>(self.data() + pos, n);
}
-StringPiece substr(const StringPiece& self,
- size_t pos,
- size_t n) {
+StringPiece substr(const StringPiece& self, size_t pos, size_t n) {
return substrT(self, pos, n);
}
-StringPiece16 substr(const StringPiece16& self,
- size_t pos,
- size_t n) {
+StringPiece16 substr(const StringPiece16& self, size_t pos, size_t n) {
return substrT(self, pos, n);
}
diff --git a/base/strings/string_piece.h b/base/strings/string_piece.h
index 6b19b80..8e4deae 100644
--- a/base/strings/string_piece.h
+++ b/base/strings/string_piece.h
@@ -51,100 +51,58 @@
void AppendToString(const StringPiece& self, std::string* target);
void AppendToString(const StringPiece16& self, string16* target);
-size_t copy(const StringPiece& self,
- char* buf,
- size_t n,
- size_t pos);
-size_t copy(const StringPiece16& self,
- char16* buf,
- size_t n,
- size_t pos);
+size_t copy(const StringPiece& self, char* buf, size_t n, size_t pos);
+size_t copy(const StringPiece16& self, char16* buf, size_t n, size_t pos);
-size_t find(const StringPiece& self,
- const StringPiece& s,
- size_t pos);
-size_t find(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos);
-size_t find(const StringPiece& self,
- char c,
- size_t pos);
-size_t find(const StringPiece16& self,
- char16 c,
- size_t pos);
+size_t find(const StringPiece& self, const StringPiece& s, size_t pos);
+size_t find(const StringPiece16& self, const StringPiece16& s, size_t pos);
+size_t find(const StringPiece& self, char c, size_t pos);
+size_t find(const StringPiece16& self, char16 c, size_t pos);
-size_t rfind(const StringPiece& self,
+size_t rfind(const StringPiece& self, const StringPiece& s, size_t pos);
+size_t rfind(const StringPiece16& self, const StringPiece16& s, size_t pos);
+size_t rfind(const StringPiece& self, char c, size_t pos);
+size_t rfind(const StringPiece16& self, char16 c, size_t pos);
+
+size_t find_first_of(const StringPiece& self, const StringPiece& s, size_t pos);
+size_t find_first_of(const StringPiece16& self,
+ const StringPiece16& s,
+ size_t pos);
+
+size_t find_first_not_of(const StringPiece& self,
const StringPiece& s,
size_t pos);
-size_t rfind(const StringPiece16& self,
+size_t find_first_not_of(const StringPiece16& self,
const StringPiece16& s,
size_t pos);
-size_t rfind(const StringPiece& self,
- char c,
- size_t pos);
-size_t rfind(const StringPiece16& self,
- char16 c,
- size_t pos);
+size_t find_first_not_of(const StringPiece& self, char c, size_t pos);
+size_t find_first_not_of(const StringPiece16& self, char16 c, size_t pos);
-size_t find_first_of(const StringPiece& self,
- const StringPiece& s,
- size_t pos);
-size_t find_first_of(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos);
-
-size_t find_first_not_of(const StringPiece& self,
- const StringPiece& s,
- size_t pos);
-size_t find_first_not_of(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos);
-size_t find_first_not_of(const StringPiece& self,
- char c,
- size_t pos);
-size_t find_first_not_of(const StringPiece16& self,
- char16 c,
- size_t pos);
-
-size_t find_last_of(const StringPiece& self,
- const StringPiece& s,
- size_t pos);
+size_t find_last_of(const StringPiece& self, const StringPiece& s, size_t pos);
size_t find_last_of(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos);
-size_t find_last_of(const StringPiece& self,
- char c,
- size_t pos);
-size_t find_last_of(const StringPiece16& self,
- char16 c,
- size_t pos);
+ const StringPiece16& s,
+ size_t pos);
+size_t find_last_of(const StringPiece& self, char c, size_t pos);
+size_t find_last_of(const StringPiece16& self, char16 c, size_t pos);
size_t find_last_not_of(const StringPiece& self,
- const StringPiece& s,
- size_t pos);
+ const StringPiece& s,
+ size_t pos);
size_t find_last_not_of(const StringPiece16& self,
- const StringPiece16& s,
- size_t pos);
-size_t find_last_not_of(const StringPiece16& self,
- char16 c,
- size_t pos);
-size_t find_last_not_of(const StringPiece& self,
- char c,
- size_t pos);
+ const StringPiece16& s,
+ size_t pos);
+size_t find_last_not_of(const StringPiece16& self, char16 c, size_t pos);
+size_t find_last_not_of(const StringPiece& self, char c, size_t pos);
-StringPiece substr(const StringPiece& self,
- size_t pos,
- size_t n);
-StringPiece16 substr(const StringPiece16& self,
- size_t pos,
- size_t n);
+StringPiece substr(const StringPiece& self, size_t pos, size_t n);
+StringPiece16 substr(const StringPiece16& self, size_t pos, size_t n);
#if DCHECK_IS_ON()
// Asserts that begin <= end to catch some errors with iterator usage.
void AssertIteratorsInOrder(std::string::const_iterator begin,
- std::string::const_iterator end);
+ std::string::const_iterator end);
void AssertIteratorsInOrder(string16::const_iterator begin,
- string16::const_iterator end);
+ string16::const_iterator end);
#endif
} // namespace internal
@@ -157,7 +115,8 @@
//
// This is templatized by string class type rather than character type, so
// BasicStringPiece<std::string> or BasicStringPiece<base::string16>.
-template <typename STRING_TYPE> class BasicStringPiece {
+template <typename STRING_TYPE>
+class BasicStringPiece {
public:
// Standard STL container boilerplate.
typedef size_t size_type;
@@ -252,8 +211,10 @@
int r = CharTraits<value_type>::compare(
ptr_, x.ptr_, (length_ < x.length_ ? length_ : x.length_));
if (r == 0) {
- if (length_ < x.length_) r = -1;
- else if (length_ > x.length_) r = +1;
+ if (length_ < x.length_)
+ r = -1;
+ else if (length_ > x.length_)
+ r = +1;
}
return r;
}
@@ -271,9 +232,7 @@
const_reverse_iterator rbegin() const {
return const_reverse_iterator(ptr_ + length_);
}
- const_reverse_iterator rend() const {
- return const_reverse_iterator(ptr_);
- }
+ const_reverse_iterator rend() const { return const_reverse_iterator(ptr_); }
size_type max_size() const { return length_; }
size_type capacity() const { return length_; }
@@ -326,8 +285,7 @@
}
// find_first_of: Find the first occurence of one of a set of characters.
- size_type find_first_of(const BasicStringPiece& s,
- size_type pos = 0) const {
+ size_type find_first_of(const BasicStringPiece& s, size_type pos = 0) const {
return internal::find_first_of(*this, s, pos);
}
size_type find_first_of(value_type c, size_type pos = 0) const {
@@ -376,8 +334,8 @@
template <typename STRING_TYPE>
const typename BasicStringPiece<STRING_TYPE>::size_type
-BasicStringPiece<STRING_TYPE>::npos =
- typename BasicStringPiece<STRING_TYPE>::size_type(-1);
+ BasicStringPiece<STRING_TYPE>::npos =
+ typename BasicStringPiece<STRING_TYPE>::size_type(-1);
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
@@ -443,8 +401,7 @@
return !(x < y);
}
-std::ostream& operator<<(std::ostream& o,
- const StringPiece& piece);
+std::ostream& operator<<(std::ostream& o, const StringPiece& piece);
// Hashing ---------------------------------------------------------------------
diff --git a/base/strings/string_split.cc b/base/strings/string_split.cc
index 81e47a6..e9b5c96 100644
--- a/base/strings/string_split.cc
+++ b/base/strings/string_split.cc
@@ -20,25 +20,28 @@
//
// The default converter is a NOP, it works when the OutputType is the
// correct StringPiece.
-template<typename Str, typename OutputType>
+template <typename Str, typename OutputType>
OutputType PieceToOutputType(BasicStringPiece<Str> piece) {
return piece;
}
-template<> // Convert StringPiece to std::string
+template <> // Convert StringPiece to std::string
std::string PieceToOutputType<std::string, std::string>(StringPiece piece) {
return piece.as_string();
}
-template<> // Convert StringPiece16 to string16.
+template <> // Convert StringPiece16 to string16.
string16 PieceToOutputType<string16, string16>(StringPiece16 piece) {
return piece.as_string();
}
// Returns either the ASCII or UTF-16 whitespace.
-template<typename Str> BasicStringPiece<Str> WhitespaceForType();
-template<> StringPiece16 WhitespaceForType<string16>() {
+template <typename Str>
+BasicStringPiece<Str> WhitespaceForType();
+template <>
+StringPiece16 WhitespaceForType<string16>() {
return kWhitespaceUTF16;
}
-template<> StringPiece WhitespaceForType<std::string>() {
+template <>
+StringPiece WhitespaceForType<std::string>() {
return kWhitespaceASCII;
}
@@ -69,12 +72,11 @@
// multiple characters (BasicStringPiece<Str>). StringPiece has a version of
// find for both of these cases, and the single-character version is the most
// common and can be implemented faster, which is why this is a template.
-template<typename Str, typename OutputStringType, typename DelimiterType>
-static std::vector<OutputStringType> SplitStringT(
- BasicStringPiece<Str> str,
- DelimiterType delimiter,
- WhitespaceHandling whitespace,
- SplitResult result_type) {
+template <typename Str, typename OutputStringType, typename DelimiterType>
+static std::vector<OutputStringType> SplitStringT(BasicStringPiece<Str> str,
+ DelimiterType delimiter,
+ WhitespaceHandling whitespace,
+ SplitResult result_type) {
std::vector<OutputStringType> result;
if (str.empty())
return result;
@@ -112,7 +114,7 @@
// Find the delimiter.
size_t end_key_pos = input.find_first_of(delimiter);
if (end_key_pos == std::string::npos) {
- return false; // No delimiter.
+ return false; // No delimiter.
}
input.substr(0, end_key_pos).CopyToString(&result_pair.first);
@@ -120,7 +122,7 @@
StringPiece remains = input.substr(end_key_pos, input.size() - end_key_pos);
size_t begin_value_pos = remains.find_first_not_of(delimiter);
if (begin_value_pos == StringPiece::npos) {
- return false; // No value.
+ return false; // No value.
}
remains.substr(begin_value_pos, remains.size() - begin_value_pos)
.CopyToString(&result_pair.second);
@@ -172,8 +174,8 @@
WhitespaceHandling whitespace,
SplitResult result_type) {
if (separators.size() == 1) {
- return SplitStringT<string16, string16, char16>(
- input, separators[0], whitespace, result_type);
+ return SplitStringT<string16, string16, char16>(input, separators[0],
+ whitespace, result_type);
}
return SplitStringT<string16, string16, StringPiece16>(
input, separators, whitespace, result_type);
@@ -209,9 +211,9 @@
StringPairs* key_value_pairs) {
key_value_pairs->clear();
- std::vector<StringPiece> pairs = SplitStringPiece(
- input, std::string(1, key_value_pair_delimiter),
- TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
+ std::vector<StringPiece> pairs =
+ SplitStringPiece(input, std::string(1, key_value_pair_delimiter),
+ TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
key_value_pairs->reserve(pairs.size());
bool success = true;
diff --git a/base/strings/string_split.h b/base/strings/string_split.h
index 1a41d2e..6f8fc7c 100644
--- a/base/strings/string_split.h
+++ b/base/strings/string_split.h
@@ -42,16 +42,14 @@
//
// std::vector<std::string> tokens = base::SplitString(
// input, ",;", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
-std::vector<std::string> SplitString(
- StringPiece input,
- StringPiece separators,
- WhitespaceHandling whitespace,
- SplitResult result_type);
-std::vector<string16> SplitString(
- StringPiece16 input,
- StringPiece16 separators,
- WhitespaceHandling whitespace,
- SplitResult result_type);
+std::vector<std::string> SplitString(StringPiece input,
+ StringPiece separators,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
+std::vector<string16> SplitString(StringPiece16 input,
+ StringPiece16 separators,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
// Like SplitString above except it returns a vector of StringPieces which
// reference the original buffer without copying. Although you have to be
@@ -65,16 +63,14 @@
// base::KEEP_WHITESPACE,
// base::SPLIT_WANT_NONEMPTY)) {
// ...
-std::vector<StringPiece> SplitStringPiece(
- StringPiece input,
- StringPiece separators,
- WhitespaceHandling whitespace,
- SplitResult result_type);
-std::vector<StringPiece16> SplitStringPiece(
- StringPiece16 input,
- StringPiece16 separators,
- WhitespaceHandling whitespace,
- SplitResult result_type);
+std::vector<StringPiece> SplitStringPiece(StringPiece input,
+ StringPiece separators,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
+std::vector<StringPiece16> SplitStringPiece(StringPiece16 input,
+ StringPiece16 separators,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
using StringPairs = std::vector<std::pair<std::string, std::string>>;
@@ -83,22 +79,20 @@
// only if each pair has a non-empty key and value. |key_value_pairs| will
// include ("","") pairs for entries without |key_value_delimiter|.
bool SplitStringIntoKeyValuePairs(StringPiece input,
- char key_value_delimiter,
- char key_value_pair_delimiter,
- StringPairs* key_value_pairs);
+ char key_value_delimiter,
+ char key_value_pair_delimiter,
+ StringPairs* key_value_pairs);
// Similar to SplitString, but use a substring delimiter instead of a list of
// characters that are all possible delimiters.
-std::vector<string16> SplitStringUsingSubstr(
- StringPiece16 input,
- StringPiece16 delimiter,
- WhitespaceHandling whitespace,
- SplitResult result_type);
-std::vector<std::string> SplitStringUsingSubstr(
- StringPiece input,
- StringPiece delimiter,
- WhitespaceHandling whitespace,
- SplitResult result_type);
+std::vector<string16> SplitStringUsingSubstr(StringPiece16 input,
+ StringPiece16 delimiter,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
+std::vector<std::string> SplitStringUsingSubstr(StringPiece input,
+ StringPiece delimiter,
+ WhitespaceHandling whitespace,
+ SplitResult result_type);
// Like SplitStringUsingSubstr above except it returns a vector of StringPieces
// which reference the original buffer without copying. Although you have to be
diff --git a/base/strings/string_tokenizer.h b/base/strings/string_tokenizer.h
index 72fc016..451a011 100644
--- a/base/strings/string_tokenizer.h
+++ b/base/strings/string_tokenizer.h
@@ -95,8 +95,7 @@
// should not be constructed with a temporary. The deleted rvalue constructor
// blocks the most obvious instances of this (e.g. passing a string literal to
// the constructor), but caution must still be exercised.
- StringTokenizerT(const str& string,
- const str& delims) {
+ StringTokenizerT(const str& string, const str& delims) {
Init(string.begin(), string.end(), delims);
}
@@ -131,9 +130,7 @@
}
// Start iterating through tokens from the beginning of the string.
- void Reset() {
- token_end_ = start_pos_;
- }
+ void Reset() { token_end_ = start_pos_; }
// Returns true if token is a delimiter. When the tokenizer is constructed
// with the RETURN_DELIMS option, this method can be used to check if the
@@ -204,13 +201,9 @@
return true;
}
- bool IsDelim(char_type c) const {
- return delims_.find(c) != str::npos;
- }
+ bool IsDelim(char_type c) const { return delims_.find(c) != str::npos; }
- bool IsQuote(char_type c) const {
- return quotes_.find(c) != str::npos;
- }
+ bool IsQuote(char_type c) const { return quotes_.find(c) != str::npos; }
struct AdvanceState {
bool in_quote;
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index 82ce02c..a387586 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -35,8 +35,7 @@
// replaced parameters.
struct ReplacementOffset {
ReplacementOffset(uintptr_t parameter, size_t offset)
- : parameter(parameter),
- offset(offset) {}
+ : parameter(parameter), offset(offset) {}
// Index of the parameter.
uintptr_t parameter;
@@ -74,30 +73,38 @@
return !(reinterpret_cast<MachineWord>(pointer) & kMachineWordAlignmentMask);
}
-template<typename T> inline T* AlignToMachineWord(T* pointer) {
+template <typename T>
+inline T* AlignToMachineWord(T* pointer) {
return reinterpret_cast<T*>(reinterpret_cast<MachineWord>(pointer) &
~kMachineWordAlignmentMask);
}
-template<size_t size, typename CharacterType> struct NonASCIIMask;
-template<> struct NonASCIIMask<4, char16> {
- static inline uint32_t value() { return 0xFF80FF80U; }
+template <size_t size, typename CharacterType>
+struct NonASCIIMask;
+template <>
+struct NonASCIIMask<4, char16> {
+ static inline uint32_t value() { return 0xFF80FF80U; }
};
-template<> struct NonASCIIMask<4, char> {
- static inline uint32_t value() { return 0x80808080U; }
+template <>
+struct NonASCIIMask<4, char> {
+ static inline uint32_t value() { return 0x80808080U; }
};
-template<> struct NonASCIIMask<8, char16> {
- static inline uint64_t value() { return 0xFF80FF80FF80FF80ULL; }
+template <>
+struct NonASCIIMask<8, char16> {
+ static inline uint64_t value() { return 0xFF80FF80FF80FF80ULL; }
};
-template<> struct NonASCIIMask<8, char> {
- static inline uint64_t value() { return 0x8080808080808080ULL; }
+template <>
+struct NonASCIIMask<8, char> {
+ static inline uint64_t value() { return 0x8080808080808080ULL; }
};
#if defined(WCHAR_T_IS_UTF32)
-template<> struct NonASCIIMask<4, wchar_t> {
- static inline uint32_t value() { return 0xFFFFFF80U; }
+template <>
+struct NonASCIIMask<4, wchar_t> {
+ static inline uint32_t value() { return 0xFFFFFF80U; }
};
-template<> struct NonASCIIMask<8, wchar_t> {
- static inline uint64_t value() { return 0xFFFFFF80FFFFFF80ULL; }
+template <>
+struct NonASCIIMask<8, wchar_t> {
+ static inline uint64_t value() { return 0xFFFFFF80FFFFFF80ULL; }
};
#endif // WCHAR_T_IS_UTF32
@@ -140,7 +147,7 @@
namespace {
-template<typename StringType>
+template <typename StringType>
StringType ToLowerASCIIImpl(BasicStringPiece<StringType> str) {
StringType ret;
ret.reserve(str.size());
@@ -149,7 +156,7 @@
return ret;
}
-template<typename StringType>
+template <typename StringType>
StringType ToUpperASCIIImpl(BasicStringPiece<StringType> str) {
StringType ret;
ret.reserve(str.size());
@@ -176,7 +183,7 @@
return ToUpperASCIIImpl<string16>(str);
}
-template<class StringType>
+template <class StringType>
int CompareCaseInsensitiveASCIIT(BasicStringPiece<StringType> a,
BasicStringPiece<StringType> b) {
// Find the first characters that aren't equal and compare them. If the end
@@ -256,7 +263,7 @@
return ReplaceCharsT(input, remove_chars, StringPiece(), output);
}
-template<typename Str>
+template <typename Str>
TrimPositions TrimStringT(const Str& input,
BasicStringPiece<Str> trim_chars,
TrimPositions positions,
@@ -267,24 +274,25 @@
// constant so avoid making a copy).
BasicStringPiece<Str> input_piece(input);
const size_t last_char = input.length() - 1;
- const size_t first_good_char = (positions & TRIM_LEADING) ?
- input_piece.find_first_not_of(trim_chars) : 0;
- const size_t last_good_char = (positions & TRIM_TRAILING) ?
- input_piece.find_last_not_of(trim_chars) : last_char;
+ const size_t first_good_char = (positions & TRIM_LEADING)
+ ? input_piece.find_first_not_of(trim_chars)
+ : 0;
+ const size_t last_good_char = (positions & TRIM_TRAILING)
+ ? input_piece.find_last_not_of(trim_chars)
+ : last_char;
// When the string was all trimmed, report that we stripped off characters
// from whichever position the caller was interested in. For empty input, we
// stripped no characters, but we still need to clear |output|.
- if (input.empty() ||
- (first_good_char == Str::npos) || (last_good_char == Str::npos)) {
+ if (input.empty() || (first_good_char == Str::npos) ||
+ (last_good_char == Str::npos)) {
bool input_was_empty = input.empty(); // in case output == &input
output->clear();
return input_was_empty ? TRIM_NONE : positions;
}
// Trim.
- *output =
- input.substr(first_good_char, last_good_char - first_good_char + 1);
+ *output = input.substr(first_good_char, last_good_char - first_good_char + 1);
// Return where we trimmed from.
return static_cast<TrimPositions>(
@@ -304,14 +312,15 @@
return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE;
}
-template<typename Str>
+template <typename Str>
BasicStringPiece<Str> TrimStringPieceT(BasicStringPiece<Str> input,
BasicStringPiece<Str> trim_chars,
TrimPositions positions) {
- size_t begin = (positions & TRIM_LEADING) ?
- input.find_first_not_of(trim_chars) : 0;
- size_t end = (positions & TRIM_TRAILING) ?
- input.find_last_not_of(trim_chars) + 1 : input.size();
+ size_t begin =
+ (positions & TRIM_LEADING) ? input.find_first_not_of(trim_chars) : 0;
+ size_t end = (positions & TRIM_TRAILING)
+ ? input.find_last_not_of(trim_chars) + 1
+ : input.size();
return input.substr(begin, end - begin);
}
@@ -350,15 +359,14 @@
int32_t prev = char_index;
base_icu::UChar32 code_point = 0;
CBU8_NEXT(data, char_index, truncation_length, code_point);
- if (!IsValidCharacter(code_point) ||
- !IsValidCodepoint(code_point)) {
+ if (!IsValidCharacter(code_point) || !IsValidCodepoint(code_point)) {
char_index = prev - 1;
} else {
break;
}
}
- if (char_index >= 0 )
+ if (char_index >= 0)
*output = input.substr(0, char_index);
else
output->clear();
@@ -370,8 +378,7 @@
return TrimStringT(input, StringPiece16(kWhitespaceUTF16), positions, output);
}
-StringPiece16 TrimWhitespace(StringPiece16 input,
- TrimPositions positions) {
+StringPiece16 TrimWhitespace(StringPiece16 input, TrimPositions positions) {
return TrimStringPieceT(input, StringPiece16(kWhitespaceUTF16), positions);
}
@@ -385,9 +392,8 @@
return TrimStringPieceT(input, StringPiece(kWhitespaceASCII), positions);
}
-template<typename STR>
-STR CollapseWhitespaceT(const STR& text,
- bool trim_sequences_with_line_breaks) {
+template <typename STR>
+STR CollapseWhitespaceT(const STR& text, bool trim_sequences_with_line_breaks) {
STR result;
result.resize(text.size());
@@ -490,7 +496,7 @@
#endif
bool IsStringUTF8(StringPiece str) {
- const char *src = str.data();
+ const char* src = str.data();
int32_t src_len = static_cast<int32_t>(str.length());
int32_t char_index = 0;
@@ -518,7 +524,7 @@
// The hardcoded strings are typically very short so it doesn't matter, and the
// string piece gives additional flexibility for the caller (doesn't have to be
// null terminated) so we choose the StringPiece route.
-template<typename Str>
+template <typename Str>
static inline bool DoLowerCaseEqualsASCII(BasicStringPiece<Str> str,
StringPiece lowercase_ascii) {
if (str.size() != lowercase_ascii.size())
@@ -544,7 +550,7 @@
return std::equal(ascii.begin(), ascii.end(), str.begin());
}
-template<typename Str>
+template <typename Str>
bool StartsWithT(BasicStringPiece<Str> str,
BasicStringPiece<Str> search_for,
CompareCase case_sensitivity) {
@@ -559,8 +565,7 @@
case CompareCase::INSENSITIVE_ASCII:
return std::equal(
- search_for.begin(), search_for.end(),
- source.begin(),
+ search_for.begin(), search_for.end(), source.begin(),
CaseInsensitiveCompareASCII<typename Str::value_type>());
default:
@@ -588,8 +593,8 @@
if (search_for.size() > str.size())
return false;
- BasicStringPiece<Str> source = str.substr(str.size() - search_for.size(),
- search_for.size());
+ BasicStringPiece<Str> source =
+ str.substr(str.size() - search_for.size(), search_for.size());
switch (case_sensitivity) {
case CompareCase::SENSITIVE:
@@ -597,8 +602,7 @@
case CompareCase::INSENSITIVE_ASCII:
return std::equal(
- source.begin(), source.end(),
- search_for.begin(),
+ source.begin(), source.end(), search_for.begin(),
CaseInsensitiveCompareASCII<typename Str::value_type>());
default:
@@ -639,14 +643,8 @@
return false;
}
-static const char* const kByteStringsUnlocalized[] = {
- " B",
- " kB",
- " MB",
- " GB",
- " TB",
- " PB"
-};
+static const char* const kByteStringsUnlocalized[] = {" B", " kB", " MB",
+ " GB", " TB", " PB"};
string16 FormatBytesUnlocalized(int64_t bytes) {
double unit_amount = static_cast<double>(bytes);
@@ -987,7 +985,7 @@
return JoinStringT(parts, separator);
}
-template<class FormatStringType, class OutStringType>
+template <class FormatStringType, class OutStringType>
OutStringType DoReplaceStringPlaceholders(
const FormatStringType& format_string,
const std::vector<OutStringType>& subst,
@@ -1086,7 +1084,8 @@
dst[dst_size - 1] = 0;
// Count the rest of the |src|, and return it's length in characters.
- while (src[dst_size]) ++dst_size;
+ while (src[dst_size])
+ ++dst_size;
return dst_size;
}
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index 98197d6..5403ada 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -8,7 +8,7 @@
#define BASE_STRINGS_STRING_UTIL_H_
#include <ctype.h>
-#include <stdarg.h> // va_list
+#include <stdarg.h> // va_list
#include <stddef.h>
#include <stdint.h>
@@ -119,7 +119,8 @@
// context (combining accents), and require handling UTF-16. If you need
// proper Unicode support, use base::i18n::ToLower/FoldCase and then just
// use a normal operator== on the result.
-template<typename Char> struct CaseInsensitiveCompareASCII {
+template <typename Char>
+struct CaseInsensitiveCompareASCII {
public:
bool operator()(Char x, Char y) const {
return ToLowerASCII(x) == ToLowerASCII(y);
@@ -157,11 +158,11 @@
// if any characters were removed. |remove_chars| must be null-terminated.
// NOTE: Safe to use the same variable for both |input| and |output|.
bool RemoveChars(const string16& input,
- StringPiece16 remove_chars,
- string16* output);
+ StringPiece16 remove_chars,
+ string16* output);
bool RemoveChars(const std::string& input,
- StringPiece remove_chars,
- std::string* output);
+ StringPiece remove_chars,
+ std::string* output);
// Replaces characters in |replace_chars| from anywhere in |input| with
// |replace_with|. Each character in |replace_chars| will be replaced with
@@ -169,19 +170,19 @@
// |replace_chars| must be null-terminated.
// NOTE: Safe to use the same variable for both |input| and |output|.
bool ReplaceChars(const string16& input,
- StringPiece16 replace_chars,
- const string16& replace_with,
- string16* output);
+ StringPiece16 replace_chars,
+ const string16& replace_with,
+ string16* output);
bool ReplaceChars(const std::string& input,
- StringPiece replace_chars,
- const std::string& replace_with,
- std::string* output);
+ StringPiece replace_chars,
+ const std::string& replace_with,
+ std::string* output);
enum TrimPositions {
- TRIM_NONE = 0,
- TRIM_LEADING = 1 << 0,
+ TRIM_NONE = 0,
+ TRIM_LEADING = 1 << 0,
TRIM_TRAILING = 1 << 1,
- TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
+ TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
};
// Removes characters in |trim_chars| from the beginning and end of |input|.
@@ -191,26 +192,26 @@
// It is safe to use the same variable for both |input| and |output| (this is
// the normal usage to trim in-place).
bool TrimString(const string16& input,
- StringPiece16 trim_chars,
- string16* output);
+ StringPiece16 trim_chars,
+ string16* output);
bool TrimString(const std::string& input,
- StringPiece trim_chars,
- std::string* output);
+ StringPiece trim_chars,
+ std::string* output);
// StringPiece versions of the above. The returned pieces refer to the original
// buffer.
StringPiece16 TrimString(StringPiece16 input,
- StringPiece16 trim_chars,
- TrimPositions positions);
+ StringPiece16 trim_chars,
+ TrimPositions positions);
StringPiece TrimString(StringPiece input,
- StringPiece trim_chars,
- TrimPositions positions);
+ StringPiece trim_chars,
+ TrimPositions positions);
// Truncates a string to the nearest UTF-8 character that will leave
// the string less than or equal to the specified byte size.
void TruncateUTF8ToByteSize(const std::string& input,
- const size_t byte_size,
- std::string* output);
+ const size_t byte_size,
+ std::string* output);
// Trims any whitespace from either end of the input string.
//
@@ -220,15 +221,13 @@
// The std::string versions return where whitespace was found.
// NOTE: Safe to use the same variable for both input and output.
TrimPositions TrimWhitespace(const string16& input,
- TrimPositions positions,
- string16* output);
-StringPiece16 TrimWhitespace(StringPiece16 input,
- TrimPositions positions);
+ TrimPositions positions,
+ string16* output);
+StringPiece16 TrimWhitespace(StringPiece16 input, TrimPositions positions);
TrimPositions TrimWhitespaceASCII(const std::string& input,
- TrimPositions positions,
- std::string* output);
-StringPiece TrimWhitespaceASCII(StringPiece input,
- TrimPositions positions);
+ TrimPositions positions,
+ std::string* output);
+StringPiece TrimWhitespaceASCII(StringPiece input, TrimPositions positions);
// Searches for CR or LF characters. Removes all contiguous whitespace
// strings that contain them. This is useful when trying to deal with text
@@ -238,18 +237,15 @@
// (2) If |trim_sequences_with_line_breaks| is true, any other whitespace
// sequences containing a CR or LF are trimmed.
// (3) All other whitespace sequences are converted to single spaces.
-string16 CollapseWhitespace(
- const string16& text,
- bool trim_sequences_with_line_breaks);
-std::string CollapseWhitespaceASCII(
- const std::string& text,
- bool trim_sequences_with_line_breaks);
+string16 CollapseWhitespace(const string16& text,
+ bool trim_sequences_with_line_breaks);
+std::string CollapseWhitespaceASCII(const std::string& text,
+ bool trim_sequences_with_line_breaks);
// Returns true if |input| is empty or contains only characters found in
// |characters|.
bool ContainsOnlyChars(StringPiece input, StringPiece characters);
-bool ContainsOnlyChars(StringPiece16 input,
- StringPiece16 characters);
+bool ContainsOnlyChars(StringPiece16 input, StringPiece16 characters);
// Returns true if the specified string matches the criteria. How can a wide
// string be 8-bit or UTF8? It contains only characters that are < 256 (in the
@@ -274,10 +270,8 @@
// Compare the lower-case form of the given string against the given
// previously-lower-cased ASCII string (typically a constant).
-bool LowerCaseEqualsASCII(StringPiece str,
- StringPiece lowecase_ascii);
-bool LowerCaseEqualsASCII(StringPiece16 str,
- StringPiece lowecase_ascii);
+bool LowerCaseEqualsASCII(StringPiece str, StringPiece lowecase_ascii);
+bool LowerCaseEqualsASCII(StringPiece16 str, StringPiece lowecase_ascii);
// Performs a case-sensitive string compare of the given 16-bit string against
// the given 8-bit ASCII string (typically a constant). The behavior is
@@ -298,17 +292,17 @@
};
bool StartsWith(StringPiece str,
- StringPiece search_for,
- CompareCase case_sensitivity);
+ StringPiece search_for,
+ CompareCase case_sensitivity);
bool StartsWith(StringPiece16 str,
- StringPiece16 search_for,
- CompareCase case_sensitivity);
+ StringPiece16 search_for,
+ CompareCase case_sensitivity);
bool EndsWith(StringPiece str,
- StringPiece search_for,
- CompareCase case_sensitivity);
+ StringPiece search_for,
+ CompareCase case_sensitivity);
bool EndsWith(StringPiece16 str,
- StringPiece16 search_for,
- CompareCase case_sensitivity);
+ StringPiece16 search_for,
+ CompareCase case_sensitivity);
// Determines the type of ASCII character, independent of locale (the C
// library versions will change based on locale).
@@ -335,8 +329,7 @@
template <typename Char>
inline bool IsHexDigit(Char c) {
- return (c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'F') ||
+ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
(c >= 'a' && c <= 'f');
}
@@ -358,16 +351,14 @@
// Starting at |start_offset| (usually 0), replace the first instance of
// |find_this| with |replace_with|.
-void ReplaceFirstSubstringAfterOffset(
- base::string16* str,
- size_t start_offset,
- StringPiece16 find_this,
- StringPiece16 replace_with);
-void ReplaceFirstSubstringAfterOffset(
- std::string* str,
- size_t start_offset,
- StringPiece find_this,
- StringPiece replace_with);
+void ReplaceFirstSubstringAfterOffset(base::string16* str,
+ size_t start_offset,
+ StringPiece16 find_this,
+ StringPiece16 replace_with);
+void ReplaceFirstSubstringAfterOffset(std::string* str,
+ size_t start_offset,
+ StringPiece find_this,
+ StringPiece replace_with);
// Starting at |start_offset| (usually 0), look through |str| and replace all
// instances of |find_this| with |replace_with|.
@@ -375,16 +366,14 @@
// This does entire substrings; use std::replace in <algorithm> for single
// characters, for example:
// std::replace(str.begin(), str.end(), 'a', 'b');
-void ReplaceSubstringsAfterOffset(
- string16* str,
- size_t start_offset,
- StringPiece16 find_this,
- StringPiece16 replace_with);
-void ReplaceSubstringsAfterOffset(
- std::string* str,
- size_t start_offset,
- StringPiece find_this,
- StringPiece replace_with);
+void ReplaceSubstringsAfterOffset(string16* str,
+ size_t start_offset,
+ StringPiece16 find_this,
+ StringPiece16 replace_with);
+void ReplaceSubstringsAfterOffset(std::string* str,
+ size_t start_offset,
+ StringPiece find_this,
+ StringPiece replace_with);
// Reserves enough memory in |str| to accommodate |length_with_null| characters,
// sets the size of |str| to |length_with_null - 1| characters, and returns a
@@ -421,39 +410,37 @@
//
// Use StrCat (in base/strings/strcat.h) if you don't need a separator.
std::string JoinString(const std::vector<std::string>& parts,
- StringPiece separator);
+ StringPiece separator);
string16 JoinString(const std::vector<string16>& parts,
- StringPiece16 separator);
+ StringPiece16 separator);
std::string JoinString(const std::vector<StringPiece>& parts,
- StringPiece separator);
+ StringPiece separator);
string16 JoinString(const std::vector<StringPiece16>& parts,
- StringPiece16 separator);
+ StringPiece16 separator);
// Explicit initializer_list overloads are required to break ambiguity when used
// with a literal initializer list (otherwise the compiler would not be able to
// decide between the string and StringPiece overloads).
std::string JoinString(std::initializer_list<StringPiece> parts,
- StringPiece separator);
+ StringPiece separator);
string16 JoinString(std::initializer_list<StringPiece16> parts,
- StringPiece16 separator);
+ StringPiece16 separator);
// Replace $1-$2-$3..$9 in the format string with values from |subst|.
// Additionally, any number of consecutive '$' characters is replaced by that
// number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be
// NULL. This only allows you to use up to nine replacements.
-string16 ReplaceStringPlaceholders(
- const string16& format_string,
- const std::vector<string16>& subst,
- std::vector<size_t>* offsets);
+string16 ReplaceStringPlaceholders(const string16& format_string,
+ const std::vector<string16>& subst,
+ std::vector<size_t>* offsets);
-std::string ReplaceStringPlaceholders(
- StringPiece format_string,
- const std::vector<std::string>& subst,
- std::vector<size_t>* offsets);
+std::string ReplaceStringPlaceholders(StringPiece format_string,
+ const std::vector<std::string>& subst,
+ std::vector<size_t>* offsets);
// Single-string shortcut for ReplaceStringHolders. |offset| may be NULL.
string16 ReplaceStringPlaceholders(const string16& format_string,
- const string16& a,
- size_t* offset);
+ const string16& a,
+ size_t* offset);
} // namespace base
diff --git a/base/strings/string_util_constants.cc b/base/strings/string_util_constants.cc
index aba1b12..37ff95f 100644
--- a/base/strings/string_util_constants.cc
+++ b/base/strings/string_util_constants.cc
@@ -6,61 +6,53 @@
namespace base {
-#define WHITESPACE_UNICODE \
- 0x0009, /* CHARACTER TABULATION */ \
- 0x000A, /* LINE FEED (LF) */ \
- 0x000B, /* LINE TABULATION */ \
- 0x000C, /* FORM FEED (FF) */ \
- 0x000D, /* CARRIAGE RETURN (CR) */ \
- 0x0020, /* SPACE */ \
- 0x0085, /* NEXT LINE (NEL) */ \
- 0x00A0, /* NO-BREAK SPACE */ \
- 0x1680, /* OGHAM SPACE MARK */ \
- 0x2000, /* EN QUAD */ \
- 0x2001, /* EM QUAD */ \
- 0x2002, /* EN SPACE */ \
- 0x2003, /* EM SPACE */ \
- 0x2004, /* THREE-PER-EM SPACE */ \
- 0x2005, /* FOUR-PER-EM SPACE */ \
- 0x2006, /* SIX-PER-EM SPACE */ \
- 0x2007, /* FIGURE SPACE */ \
- 0x2008, /* PUNCTUATION SPACE */ \
- 0x2009, /* THIN SPACE */ \
- 0x200A, /* HAIR SPACE */ \
- 0x2028, /* LINE SEPARATOR */ \
- 0x2029, /* PARAGRAPH SEPARATOR */ \
- 0x202F, /* NARROW NO-BREAK SPACE */ \
- 0x205F, /* MEDIUM MATHEMATICAL SPACE */ \
- 0x3000, /* IDEOGRAPHIC SPACE */ \
- 0
+#define WHITESPACE_UNICODE \
+ 0x0009, /* CHARACTER TABULATION */ \
+ 0x000A, /* LINE FEED (LF) */ \
+ 0x000B, /* LINE TABULATION */ \
+ 0x000C, /* FORM FEED (FF) */ \
+ 0x000D, /* CARRIAGE RETURN (CR) */ \
+ 0x0020, /* SPACE */ \
+ 0x0085, /* NEXT LINE (NEL) */ \
+ 0x00A0, /* NO-BREAK SPACE */ \
+ 0x1680, /* OGHAM SPACE MARK */ \
+ 0x2000, /* EN QUAD */ \
+ 0x2001, /* EM QUAD */ \
+ 0x2002, /* EN SPACE */ \
+ 0x2003, /* EM SPACE */ \
+ 0x2004, /* THREE-PER-EM SPACE */ \
+ 0x2005, /* FOUR-PER-EM SPACE */ \
+ 0x2006, /* SIX-PER-EM SPACE */ \
+ 0x2007, /* FIGURE SPACE */ \
+ 0x2008, /* PUNCTUATION SPACE */ \
+ 0x2009, /* THIN SPACE */ \
+ 0x200A, /* HAIR SPACE */ \
+ 0x2028, /* LINE SEPARATOR */ \
+ 0x2029, /* PARAGRAPH SEPARATOR */ \
+ 0x202F, /* NARROW NO-BREAK SPACE */ \
+ 0x205F, /* MEDIUM MATHEMATICAL SPACE */ \
+ 0x3000, /* IDEOGRAPHIC SPACE */ \
+ 0
-const wchar_t kWhitespaceWide[] = {
- WHITESPACE_UNICODE
-};
+const wchar_t kWhitespaceWide[] = {WHITESPACE_UNICODE};
-const char16 kWhitespaceUTF16[] = {
- WHITESPACE_UNICODE
-};
+const char16 kWhitespaceUTF16[] = {WHITESPACE_UNICODE};
-const char kWhitespaceASCII[] = {
- 0x09, // CHARACTER TABULATION
- 0x0A, // LINE FEED (LF)
- 0x0B, // LINE TABULATION
- 0x0C, // FORM FEED (FF)
- 0x0D, // CARRIAGE RETURN (CR)
- 0x20, // SPACE
- 0
-};
+const char kWhitespaceASCII[] = {0x09, // CHARACTER TABULATION
+ 0x0A, // LINE FEED (LF)
+ 0x0B, // LINE TABULATION
+ 0x0C, // FORM FEED (FF)
+ 0x0D, // CARRIAGE RETURN (CR)
+ 0x20, // SPACE
+ 0};
-const char16 kWhitespaceASCIIAs16[] = {
- 0x09, // CHARACTER TABULATION
- 0x0A, // LINE FEED (LF)
- 0x0B, // LINE TABULATION
- 0x0C, // FORM FEED (FF)
- 0x0D, // CARRIAGE RETURN (CR)
- 0x20, // SPACE
- 0
-};
+const char16 kWhitespaceASCIIAs16[] = {0x09, // CHARACTER TABULATION
+ 0x0A, // LINE FEED (LF)
+ 0x0B, // LINE TABULATION
+ 0x0C, // FORM FEED (FF)
+ 0x0D, // CARRIAGE RETURN (CR)
+ 0x20, // SPACE
+ 0};
const char kUtf8ByteOrderMark[] = "\xEF\xBB\xBF";
diff --git a/base/strings/string_util_posix.h b/base/strings/string_util_posix.h
index 8299118..6868a65 100644
--- a/base/strings/string_util_posix.h
+++ b/base/strings/string_util_posix.h
@@ -21,13 +21,17 @@
return ::strdup(str);
}
-inline int vsnprintf(char* buffer, size_t size,
- const char* format, va_list arguments) {
+inline int vsnprintf(char* buffer,
+ size_t size,
+ const char* format,
+ va_list arguments) {
return ::vsnprintf(buffer, size, format, arguments);
}
-inline int vswprintf(wchar_t* buffer, size_t size,
- const wchar_t* format, va_list arguments) {
+inline int vswprintf(wchar_t* buffer,
+ size_t size,
+ const wchar_t* format,
+ va_list arguments) {
DCHECK(IsWprintfFormatPortable(format));
return ::vswprintf(buffer, size, format, arguments);
}
diff --git a/base/strings/string_util_win.h b/base/strings/string_util_win.h
index 7f260bf..8f9fa81 100644
--- a/base/strings/string_util_win.h
+++ b/base/strings/string_util_win.h
@@ -21,16 +21,20 @@
return _strdup(str);
}
-inline int vsnprintf(char* buffer, size_t size,
- const char* format, va_list arguments) {
+inline int vsnprintf(char* buffer,
+ size_t size,
+ const char* format,
+ va_list arguments) {
int length = vsnprintf_s(buffer, size, size - 1, format, arguments);
if (length < 0)
return _vscprintf(format, arguments);
return length;
}
-inline int vswprintf(wchar_t* buffer, size_t size,
- const wchar_t* format, va_list arguments) {
+inline int vswprintf(wchar_t* buffer,
+ size_t size,
+ const wchar_t* format,
+ va_list arguments) {
DCHECK(IsWprintfFormatPortable(format));
int length = _vsnwprintf_s(buffer, size, size - 1, format, arguments);
diff --git a/base/strings/stringprintf.cc b/base/strings/stringprintf.cc
index dba4318..a241ee6 100644
--- a/base/strings/stringprintf.cc
+++ b/base/strings/stringprintf.cc
@@ -150,7 +150,8 @@
#if defined(OS_WIN)
const std::wstring& SStringPrintf(std::wstring* dst,
- const wchar_t* format, ...) {
+ const wchar_t* format,
+ ...) {
va_list ap;
va_start(ap, format);
dst->clear();
diff --git a/base/strings/stringprintf.h b/base/strings/stringprintf.h
index e45bef3..9c07862 100644
--- a/base/strings/stringprintf.h
+++ b/base/strings/stringprintf.h
@@ -5,7 +5,7 @@
#ifndef BASE_STRINGS_STRINGPRINTF_H_
#define BASE_STRINGS_STRINGPRINTF_H_
-#include <stdarg.h> // va_list
+#include <stdarg.h> // va_list
#include <string>
@@ -15,13 +15,11 @@
namespace base {
// Return a C++ string given printf-like input.
-std::string StringPrintf(_Printf_format_string_ const char* format,
- ...)
+std::string StringPrintf(_Printf_format_string_ const char* format, ...)
PRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
#if defined(OS_WIN)
-std::wstring StringPrintf(
- _Printf_format_string_ const wchar_t* format,
- ...) WPRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
+std::wstring StringPrintf(_Printf_format_string_ const wchar_t* format, ...)
+ WPRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
#endif
// Return a C++ string given vprintf-like input.
@@ -29,25 +27,23 @@
PRINTF_FORMAT(1, 0) WARN_UNUSED_RESULT;
// Store result into a supplied string and return it.
-const std::string& SStringPrintf(
- std::string* dst,
- _Printf_format_string_ const char* format,
- ...) PRINTF_FORMAT(2, 3);
+const std::string& SStringPrintf(std::string* dst,
+ _Printf_format_string_ const char* format,
+ ...) PRINTF_FORMAT(2, 3);
#if defined(OS_WIN)
-const std::wstring& SStringPrintf(
- std::wstring* dst,
- _Printf_format_string_ const wchar_t* format,
- ...) WPRINTF_FORMAT(2, 3);
+const std::wstring& SStringPrintf(std::wstring* dst,
+ _Printf_format_string_ const wchar_t* format,
+ ...) WPRINTF_FORMAT(2, 3);
#endif
// Append result to a supplied string.
void StringAppendF(std::string* dst,
- _Printf_format_string_ const char* format,
- ...) PRINTF_FORMAT(2, 3);
+ _Printf_format_string_ const char* format,
+ ...) PRINTF_FORMAT(2, 3);
#if defined(OS_WIN)
void StringAppendF(std::wstring* dst,
- _Printf_format_string_ const wchar_t* format,
- ...) WPRINTF_FORMAT(2, 3);
+ _Printf_format_string_ const wchar_t* format,
+ ...) WPRINTF_FORMAT(2, 3);
#endif
// Lower-level routine that takes a va_list and appends to a specified
@@ -55,8 +51,7 @@
void StringAppendV(std::string* dst, const char* format, va_list ap)
PRINTF_FORMAT(2, 0);
#if defined(OS_WIN)
-void StringAppendV(std::wstring* dst,
- const wchar_t* format, va_list ap)
+void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap)
WPRINTF_FORMAT(2, 0);
#endif
diff --git a/base/strings/sys_string_conversions.h b/base/strings/sys_string_conversions.h
index 096840b..a13775c 100644
--- a/base/strings/sys_string_conversions.h
+++ b/base/strings/sys_string_conversions.h
@@ -47,8 +47,7 @@
// code page identifier is one accepted by the Windows function
// MultiByteToWideChar().
std::wstring SysMultiByteToWide(StringPiece mb, uint32_t code_page);
-std::string SysWideToMultiByte(const std::wstring& wide,
- uint32_t code_page);
+std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page);
#endif // defined(OS_WIN)
diff --git a/base/strings/sys_string_conversions_mac.mm b/base/strings/sys_string_conversions_mac.mm
index 637d941..3b78777 100644
--- a/base/strings/sys_string_conversions_mac.mm
+++ b/base/strings/sys_string_conversions_mac.mm
@@ -21,7 +21,7 @@
// an STL string of the template type. Returns an empty string on failure.
//
// Do not assert in this function since it is used by the asssertion code!
-template<typename StringType>
+template <typename StringType>
static StringType CFStringToSTLStringWithEncodingT(CFStringRef cfstring,
CFStringEncoding encoding) {
CFIndex length = CFStringGetLength(cfstring);
@@ -30,9 +30,7 @@
CFRange whole_string = CFRangeMake(0, length);
CFIndex out_size;
- CFIndex converted = CFStringGetBytes(cfstring,
- whole_string,
- encoding,
+ CFIndex converted = CFStringGetBytes(cfstring, whole_string, encoding,
0, // lossByte
false, // isExternalRepresentation
NULL, // buffer
@@ -50,14 +48,12 @@
out_size * sizeof(UInt8) / sizeof(typename StringType::value_type) + 1;
std::vector<typename StringType::value_type> out_buffer(elements);
- converted = CFStringGetBytes(cfstring,
- whole_string,
- encoding,
- 0, // lossByte
- false, // isExternalRepresentation
- reinterpret_cast<UInt8*>(&out_buffer[0]),
- out_size,
- NULL); // usedBufLen
+ converted =
+ CFStringGetBytes(cfstring, whole_string, encoding,
+ 0, // lossByte
+ false, // isExternalRepresentation
+ reinterpret_cast<UInt8*>(&out_buffer[0]), out_size,
+ NULL); // usedBufLen
if (converted == 0)
return StringType();
@@ -70,7 +66,7 @@
// |OutStringType| template type. Returns an empty string on failure.
//
// Do not assert in this function since it is used by the asssertion code!
-template<typename InStringType, typename OutStringType>
+template <typename InStringType, typename OutStringType>
static OutStringType STLStringToSTLStringWithEncodingsT(
const InStringType& in,
CFStringEncoding in_encoding,
@@ -80,11 +76,8 @@
return OutStringType();
base::ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
- NULL,
- reinterpret_cast<const UInt8*>(in.data()),
- in_length * sizeof(typename InStringType::value_type),
- in_encoding,
- false,
+ NULL, reinterpret_cast<const UInt8*>(in.data()),
+ in_length * sizeof(typename InStringType::value_type), in_encoding, false,
kCFAllocatorNull));
if (!cfstring)
return OutStringType();
@@ -95,7 +88,7 @@
// Given an STL string |in| with an encoding specified by |in_encoding|,
// return it as a CFStringRef. Returns NULL on failure.
-template<typename StringType>
+template <typename StringType>
static CFStringRef STLStringToCFStringWithEncodingsT(
const StringType& in,
CFStringEncoding in_encoding) {
@@ -103,12 +96,9 @@
if (in_length == 0)
return CFSTR("");
- return CFStringCreateWithBytes(kCFAllocatorDefault,
- reinterpret_cast<const UInt8*>(in.data()),
- in_length *
- sizeof(typename StringType::value_type),
- in_encoding,
- false);
+ return CFStringCreateWithBytes(
+ kCFAllocatorDefault, reinterpret_cast<const UInt8*>(in.data()),
+ in_length * sizeof(typename StringType::value_type), in_encoding, false);
}
// Specify the byte ordering explicitly, otherwise CFString will be confused
@@ -168,8 +158,7 @@
}
string16 SysCFStringRefToUTF16(CFStringRef ref) {
- return CFStringToSTLStringWithEncodingT<string16>(ref,
- kMediumStringEncoding);
+ return CFStringToSTLStringWithEncodingT<string16>(ref, kMediumStringEncoding);
}
std::string SysNSStringToUTF8(NSString* nsstring) {
diff --git a/base/strings/sys_string_conversions_posix.cc b/base/strings/sys_string_conversions_posix.cc
index 97b027a..1a0c685 100644
--- a/base/strings/sys_string_conversions_posix.cc
+++ b/base/strings/sys_string_conversions_posix.cc
@@ -107,7 +107,7 @@
// without writing the output, counting the number of wide characters.
size_t num_out_chars = 0;
memset(&ps, 0, sizeof(ps));
- for (size_t i = 0; i < native_mb.size(); ) {
+ for (size_t i = 0; i < native_mb.size();) {
const char* src = native_mb.data() + i;
size_t res = mbrtowc(nullptr, src, native_mb.size() - i, &ps);
switch (res) {
diff --git a/base/strings/sys_string_conversions_win.cc b/base/strings/sys_string_conversions_win.cc
index 356064f..232dd78 100644
--- a/base/strings/sys_string_conversions_win.cc
+++ b/base/strings/sys_string_conversions_win.cc
@@ -4,8 +4,8 @@
#include "base/strings/sys_string_conversions.h"
-#include <windows.h>
#include <stdint.h>
+#include <windows.h>
#include "base/strings/string_piece.h"
@@ -36,8 +36,8 @@
int mb_length = static_cast<int>(mb.length());
// Compute the length of the buffer.
- int charcount = MultiByteToWideChar(code_page, 0,
- mb.data(), mb_length, NULL, 0);
+ int charcount =
+ MultiByteToWideChar(code_page, 0, mb.data(), mb_length, NULL, 0);
if (charcount == 0)
return std::wstring();
@@ -62,8 +62,8 @@
std::string mb;
mb.resize(charcount);
- WideCharToMultiByte(code_page, 0, wide.data(), wide_length,
- &mb[0], charcount, NULL, NULL);
+ WideCharToMultiByte(code_page, 0, wide.data(), wide_length, &mb[0], charcount,
+ NULL, NULL);
return mb;
}
diff --git a/base/strings/utf_offset_string_conversions.cc b/base/strings/utf_offset_string_conversions.cc
index b91ee03..177839a 100644
--- a/base/strings/utf_offset_string_conversions.cc
+++ b/base/strings/utf_offset_string_conversions.cc
@@ -20,8 +20,7 @@
size_t output_length)
: original_offset(original_offset),
original_length(original_length),
- output_length(output_length) {
-}
+ output_length(output_length) {}
// static
void OffsetAdjuster::AdjustOffsets(const Adjustments& adjustments,
@@ -79,8 +78,7 @@
if (*offset + adjustment <= i->original_offset)
break;
adjustment += static_cast<int>(i->original_length - i->output_length);
- if ((*offset + adjustment) <
- (i->original_offset + i->original_length)) {
+ if ((*offset + adjustment) < (i->original_offset + i->original_length)) {
*offset = string16::npos;
return;
}
@@ -138,8 +136,8 @@
// |adjusted_iter|, then incrementing |adjusted_iter| so it points to
// the following element.
shift += first_iter->original_length - first_iter->output_length;
- adjusted_iter = adjustments_on_adjusted_string->insert(
- adjusted_iter, *first_iter);
+ adjusted_iter =
+ adjustments_on_adjusted_string->insert(adjusted_iter, *first_iter);
++adjusted_iter;
++first_iter;
} else {
@@ -158,7 +156,7 @@
// happened in |first_iter|, then advance to the next |first_adjustments|
// because we dealt with the current one.
const int collapse = static_cast<int>(first_iter->original_length) -
- static_cast<int>(first_iter->output_length);
+ static_cast<int>(first_iter->output_length);
// This function does not know how to deal with a string that expands and
// then gets modified, only strings that collapse and then get modified.
DCHECK_GT(collapse, 0);
@@ -185,7 +183,7 @@
// the result. If non-NULL, |adjustments| is set to reflect the all the
// alterations to the string that are not one-character-to-one-character.
// It will always be sorted by increasing offset.
-template<typename SrcChar, typename DestStdString>
+template <typename SrcChar, typename DestStdString>
bool ConvertUnicode(const SrcChar* src,
size_t src_len,
DestStdString* output,
diff --git a/base/strings/utf_offset_string_conversions.h b/base/strings/utf_offset_string_conversions.h
index fdd012b..b7c4a1b 100644
--- a/base/strings/utf_offset_string_conversions.h
+++ b/base/strings/utf_offset_string_conversions.h
@@ -64,8 +64,7 @@
// Adjusts the single |offset| to reflect the reverse of the adjustments
// recorded in |adjustments|.
- static void UnadjustOffset(const Adjustments& adjustments,
- size_t* offset);
+ static void UnadjustOffset(const Adjustments& adjustments, size_t* offset);
// Combines two sequential sets of adjustments, storing the combined revised
// adjustments in |adjustments_on_adjusted_string|. That is, suppose a
@@ -90,11 +89,10 @@
// Like the conversions in utf_string_conversions.h, but also fills in an
// |adjustments| parameter that reflects the alterations done to the string.
// It may be NULL.
-bool UTF8ToUTF16WithAdjustments(
- const char* src,
- size_t src_len,
- string16* output,
- base::OffsetAdjuster::Adjustments* adjustments);
+bool UTF8ToUTF16WithAdjustments(const char* src,
+ size_t src_len,
+ string16* output,
+ base::OffsetAdjuster::Adjustments* adjustments);
string16 UTF8ToUTF16WithAdjustments(
const base::StringPiece& utf8,
base::OffsetAdjuster::Adjustments* adjustments);
diff --git a/base/strings/utf_string_conversion_utils.cc b/base/strings/utf_string_conversion_utils.cc
index 89f02d5..6098e3a 100644
--- a/base/strings/utf_string_conversion_utils.cc
+++ b/base/strings/utf_string_conversion_utils.cc
@@ -36,15 +36,14 @@
uint32_t* code_point) {
if (CBU16_IS_SURROGATE(src[*char_index])) {
if (!CBU16_IS_SURROGATE_LEAD(src[*char_index]) ||
- *char_index + 1 >= src_len ||
- !CBU16_IS_TRAIL(src[*char_index + 1])) {
+ *char_index + 1 >= src_len || !CBU16_IS_TRAIL(src[*char_index + 1])) {
// Invalid surrogate pair.
return false;
}
// Valid surrogate pair.
- *code_point = CBU16_GET_SUPPLEMENTARY(src[*char_index],
- src[*char_index + 1]);
+ *code_point =
+ CBU16_GET_SUPPLEMENTARY(src[*char_index], src[*char_index + 1]);
(*char_index)++;
} else {
// Not a surrogate, just one 16-bit word.
@@ -76,7 +75,6 @@
return 1;
}
-
// CBU8_APPEND_UNSAFE can append up to 4 bytes.
size_t char_offset = output->length();
size_t original_char_offset = char_offset;
@@ -105,7 +103,7 @@
// Generalized Unicode converter -----------------------------------------------
-template<typename CHAR>
+template <typename CHAR>
void PrepareForUTF8Output(const CHAR* src,
size_t src_len,
std::string* output) {
@@ -128,7 +126,7 @@
#endif
template void PrepareForUTF8Output(const char16*, size_t, std::string*);
-template<typename STRING>
+template <typename STRING>
void PrepareForUTF16Or32Output(const char* src,
size_t src_len,
STRING* output) {
diff --git a/base/strings/utf_string_conversion_utils.h b/base/strings/utf_string_conversion_utils.h
index 1712cee..6f89652 100644
--- a/base/strings/utf_string_conversion_utils.h
+++ b/base/strings/utf_string_conversion_utils.h
@@ -26,9 +26,10 @@
inline bool IsValidCharacter(uint32_t code_point) {
// Excludes non-characters (U+FDD0..U+FDEF, and all codepoints ending in
// 0xFFFE or 0xFFFF) from the set of valid code points.
- return code_point < 0xD800u || (code_point >= 0xE000u &&
- code_point < 0xFDD0u) || (code_point > 0xFDEFu &&
- code_point <= 0x10FFFFu && (code_point & 0xFFFEu) != 0xFFFEu);
+ return code_point < 0xD800u ||
+ (code_point >= 0xE000u && code_point < 0xFDD0u) ||
+ (code_point > 0xFDEFu && code_point <= 0x10FFFFu &&
+ (code_point & 0xFFFEu) != 0xFFFEu);
}
// ReadUnicodeCharacter --------------------------------------------------------
@@ -41,30 +42,29 @@
//
// Returns true on success. On false, |*code_point| will be invalid.
bool ReadUnicodeCharacter(const char* src,
- int32_t src_len,
- int32_t* char_index,
- uint32_t* code_point_out);
+ int32_t src_len,
+ int32_t* char_index,
+ uint32_t* code_point_out);
// Reads a UTF-16 character. The usage is the same as the 8-bit version above.
bool ReadUnicodeCharacter(const char16* src,
- int32_t src_len,
- int32_t* char_index,
- uint32_t* code_point);
+ int32_t src_len,
+ int32_t* char_index,
+ uint32_t* code_point);
#if defined(WCHAR_T_IS_UTF32)
// Reads UTF-32 character. The usage is the same as the 8-bit version above.
bool ReadUnicodeCharacter(const wchar_t* src,
- int32_t src_len,
- int32_t* char_index,
- uint32_t* code_point);
+ int32_t src_len,
+ int32_t* char_index,
+ uint32_t* code_point);
#endif // defined(WCHAR_T_IS_UTF32)
// WriteUnicodeCharacter -------------------------------------------------------
// Appends a UTF-8 character to the given 8-bit string. Returns the number of
// bytes written.
-size_t WriteUnicodeCharacter(uint32_t code_point,
- std::string* output);
+size_t WriteUnicodeCharacter(uint32_t code_point, std::string* output);
// Appends the given code point as a UTF-16 character to the given 16-bit
// string. Returns the number of 16-bit values written.
@@ -86,12 +86,12 @@
// string, and reserves that amount of space. We assume that the input
// character types are unsigned, which will be true for UTF-16 and -32 on our
// systems.
-template<typename CHAR>
+template <typename CHAR>
void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output);
// Prepares an output buffer (containing either UTF-16 or -32 data) given some
// UTF-8 input that will be converted to it. See PrepareForUTF8Output().
-template<typename STRING>
+template <typename STRING>
void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output);
} // namespace base
diff --git a/base/strings/utf_string_conversions.h b/base/strings/utf_string_conversions.h
index 45a4be3..704943e 100644
--- a/base/strings/utf_string_conversions.h
+++ b/base/strings/utf_string_conversions.h
@@ -20,24 +20,19 @@
// do the best it can and put the result in the output buffer. The versions that
// return strings ignore this error and just return the best conversion
// possible.
-bool WideToUTF8(const wchar_t* src, size_t src_len,
- std::string* output);
+bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output);
std::string WideToUTF8(WStringPiece wide);
-bool UTF8ToWide(const char* src, size_t src_len,
- std::wstring* output);
+bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output);
std::wstring UTF8ToWide(StringPiece utf8);
-bool WideToUTF16(const wchar_t* src, size_t src_len,
- string16* output);
+bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output);
string16 WideToUTF16(WStringPiece wide);
-bool UTF16ToWide(const char16* src, size_t src_len,
- std::wstring* output);
+bool UTF16ToWide(const char16* src, size_t src_len, std::wstring* output);
std::wstring UTF16ToWide(StringPiece16 utf16);
bool UTF8ToUTF16(const char* src, size_t src_len, string16* output);
string16 UTF8ToUTF16(StringPiece utf8);
-bool UTF16ToUTF8(const char16* src, size_t src_len,
- std::string* output);
+bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output);
std::string UTF16ToUTF8(StringPiece16 utf16);
// This converts an ASCII string, typically a hardcoded constant, to a UTF16
diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h
index 125bcb1..d778d13 100644
--- a/base/synchronization/condition_variable.h
+++ b/base/synchronization/condition_variable.h
@@ -102,7 +102,6 @@
void Signal();
private:
-
#if defined(OS_WIN)
CHROME_CONDITION_VARIABLE cv_;
CHROME_SRWLOCK* const srwlock_;
diff --git a/base/synchronization/condition_variable_posix.cc b/base/synchronization/condition_variable_posix.cc
index 229b529..7a5ef5f 100644
--- a/base/synchronization/condition_variable_posix.cc
+++ b/base/synchronization/condition_variable_posix.cc
@@ -15,17 +15,16 @@
namespace base {
ConditionVariable::ConditionVariable(Lock* user_lock)
- : user_mutex_(user_lock->lock_.native_handle())
-{
+ : user_mutex_(user_lock->lock_.native_handle()) {
int rv = 0;
- // http://crbug.com/293736
- // NaCl doesn't support monotonic clock based absolute deadlines.
- // On older Android platform versions, it's supported through the
- // non-standard pthread_cond_timedwait_monotonic_np. Newer platform
- // versions have pthread_condattr_setclock.
- // Mac can use relative time deadlines.
+// http://crbug.com/293736
+// NaCl doesn't support monotonic clock based absolute deadlines.
+// On older Android platform versions, it's supported through the
+// non-standard pthread_cond_timedwait_monotonic_np. Newer platform
+// versions have pthread_condattr_setclock.
+// Mac can use relative time deadlines.
#if !defined(OS_MACOSX) && !defined(OS_NACL) && \
- !(defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
+ !(defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
pthread_condattr_t attrs;
rv = pthread_condattr_init(&attrs);
DCHECK_EQ(0, rv);
@@ -70,8 +69,8 @@
(usecs % Time::kMicrosecondsPerSecond) * Time::kNanosecondsPerMicrosecond;
#if defined(OS_MACOSX)
- int rv = pthread_cond_timedwait_relative_np(
- &condition_, user_mutex_, &relative_time);
+ int rv = pthread_cond_timedwait_relative_np(&condition_, user_mutex_,
+ &relative_time);
#else
// The timeout argument to pthread_cond_timedwait is in absolute time.
struct timespec absolute_time;
@@ -87,8 +86,8 @@
DCHECK_GE(absolute_time.tv_sec, now.tv_sec); // Overflow paranoia
#if defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
- int rv = pthread_cond_timedwait_monotonic_np(
- &condition_, user_mutex_, &absolute_time);
+ int rv = pthread_cond_timedwait_monotonic_np(&condition_, user_mutex_,
+ &absolute_time);
#else
int rv = pthread_cond_timedwait(&condition_, user_mutex_, &absolute_time);
#endif // OS_ANDROID && HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC
diff --git a/base/synchronization/condition_variable_win.cc b/base/synchronization/condition_variable_win.cc
index d247e22..87cc353 100644
--- a/base/synchronization/condition_variable_win.cc
+++ b/base/synchronization/condition_variable_win.cc
@@ -12,8 +12,7 @@
namespace base {
ConditionVariable::ConditionVariable(Lock* user_lock)
- : srwlock_(user_lock->lock_.native_handle())
-{
+ : srwlock_(user_lock->lock_.native_handle()) {
DCHECK(user_lock);
InitializeConditionVariable(reinterpret_cast<PCONDITION_VARIABLE>(&cv_));
}
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index 27e493c..98668e9 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -17,7 +17,7 @@
// AssertAcquired() method.
class Lock {
public:
- // Optimized wrapper implementation
+ // Optimized wrapper implementation
Lock() : lock_() {}
~Lock() {}
void Acquire() { lock_.Lock(); }
@@ -66,9 +66,7 @@
public:
struct AlreadyAcquired {};
- explicit AutoLock(Lock& lock) : lock_(lock) {
- lock_.Acquire();
- }
+ explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); }
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
lock_.AssertAcquired();
@@ -94,9 +92,7 @@
lock_.Release();
}
- ~AutoUnlock() {
- lock_.Acquire();
- }
+ ~AutoUnlock() { lock_.Acquire(); }
private:
Lock& lock_;
diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h
index b4f713d..ee1d33a 100644
--- a/base/synchronization/waitable_event.h
+++ b/base/synchronization/waitable_event.h
@@ -241,8 +241,8 @@
// so we have a kernel of the WaitableEvent, which is reference counted.
// WaitableEventWatchers may then take a reference and thus match the Windows
// behaviour.
- struct WaitableEventKernel :
- public RefCountedThreadSafe<WaitableEventKernel> {
+ struct WaitableEventKernel
+ : public RefCountedThreadSafe<WaitableEventKernel> {
public:
WaitableEventKernel(ResetPolicy reset_policy, InitialState initial_state);
@@ -266,7 +266,8 @@
// second element is the index of the WaitableEvent in the original,
// unsorted, array.
static size_t EnqueueMany(WaiterAndIndex* waitables,
- size_t count, Waiter* waiter);
+ size_t count,
+ Waiter* waiter);
bool SignalAll();
bool SignalOne();
diff --git a/base/synchronization/waitable_event_posix.cc b/base/synchronization/waitable_event_posix.cc
index 3e32686..485038d 100644
--- a/base/synchronization/waitable_event_posix.cc
+++ b/base/synchronization/waitable_event_posix.cc
@@ -107,9 +107,7 @@
return true;
}
- WaitableEvent* signaling_event() const {
- return signaling_event_;
- }
+ WaitableEvent* signaling_event() const { return signaling_event_; }
// ---------------------------------------------------------------------------
// These waiters are always stack allocated and don't delete themselves. Thus
@@ -120,26 +118,18 @@
// ---------------------------------------------------------------------------
// Called with lock held.
// ---------------------------------------------------------------------------
- bool fired() const {
- return fired_;
- }
+ bool fired() const { return fired_; }
// ---------------------------------------------------------------------------
// During a TimedWait, we need a way to make sure that an auto-reset
// WaitableEvent doesn't think that this event has been signaled between
// unlocking it and removing it from the wait-list. Called with lock held.
// ---------------------------------------------------------------------------
- void Disable() {
- fired_ = true;
- }
+ void Disable() { fired_ = true; }
- base::Lock* lock() {
- return &lock_;
- }
+ base::Lock* lock() { return &lock_; }
- base::ConditionVariable* cv() {
- return &cv_;
- }
+ base::ConditionVariable* cv() { return &cv_; }
private:
bool fired_;
@@ -222,20 +212,19 @@
// Synchronous waiting on multiple objects.
static bool // StrictWeakOrdering
-cmp_fst_addr(const std::pair<WaitableEvent*, unsigned> &a,
- const std::pair<WaitableEvent*, unsigned> &b) {
+cmp_fst_addr(const std::pair<WaitableEvent*, unsigned>& a,
+ const std::pair<WaitableEvent*, unsigned>& b) {
return a.first < b.first;
}
// static
-size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables,
- size_t count) {
+size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables, size_t count) {
DCHECK(count) << "Cannot wait on no events";
// We need to acquire the locks in a globally consistent order. Thus we sort
// the array of waitables by address. We actually sort a pairs so that we can
// map back to the original index values later.
- std::vector<std::pair<WaitableEvent*, size_t> > waitables;
+ std::vector<std::pair<WaitableEvent*, size_t>> waitables;
waitables.reserve(count);
for (size_t i = 0; i < count; ++i)
waitables.push_back(std::make_pair(raw_waitables[i], i));
@@ -248,7 +237,7 @@
// address, we can check this cheaply by comparing pairs of consecutive
// elements.
for (size_t i = 0; i < waitables.size() - 1; ++i) {
- DCHECK(waitables[i].first != waitables[i+1].first);
+ DCHECK(waitables[i].first != waitables[i + 1].first);
}
SyncWaiter sw;
@@ -263,21 +252,21 @@
// At this point, we hold the locks on all the WaitableEvents and we have
// enqueued our waiter in them all.
sw.lock()->Acquire();
- // Release the WaitableEvent locks in the reverse order
- for (size_t i = 0; i < count; ++i) {
- waitables[count - (1 + i)].first->kernel_->lock_.Release();
- }
+ // Release the WaitableEvent locks in the reverse order
+ for (size_t i = 0; i < count; ++i) {
+ waitables[count - (1 + i)].first->kernel_->lock_.Release();
+ }
- for (;;) {
- if (sw.fired())
- break;
+ for (;;) {
+ if (sw.fired())
+ break;
- sw.cv()->Wait();
- }
+ sw.cv()->Wait();
+ }
sw.lock()->Release();
// The address of the WaitableEvent which fired is stored in the SyncWaiter.
- WaitableEvent *const signaled_event = sw.signaling_event();
+ WaitableEvent* const signaled_event = sw.signaling_event();
// This will store the index of the raw_waitables which fired.
size_t signaled_index = 0;
@@ -286,10 +275,10 @@
for (size_t i = 0; i < count; ++i) {
if (raw_waitables[i] != signaled_event) {
raw_waitables[i]->kernel_->lock_.Acquire();
- // There's no possible ABA issue with the address of the SyncWaiter here
- // because it lives on the stack. Thus the tag value is just the pointer
- // value again.
- raw_waitables[i]->kernel_->Dequeue(&sw, &sw);
+ // There's no possible ABA issue with the address of the SyncWaiter here
+ // because it lives on the stack. Thus the tag value is just the pointer
+ // value again.
+ raw_waitables[i]->kernel_->Dequeue(&sw, &sw);
raw_waitables[i]->kernel_->lock_.Release();
} else {
// By taking this lock here we ensure that |Signal| has completed by the
@@ -353,7 +342,6 @@
// -----------------------------------------------------------------------------
-
// -----------------------------------------------------------------------------
// Private functions...
@@ -371,8 +359,8 @@
bool WaitableEvent::SignalAll() {
bool signaled_at_least_one = false;
- for (std::list<Waiter*>::iterator
- i = kernel_->waiters_.begin(); i != kernel_->waiters_.end(); ++i) {
+ for (std::list<Waiter*>::iterator i = kernel_->waiters_.begin();
+ i != kernel_->waiters_.end(); ++i) {
if ((*i)->Fire(this))
signaled_at_least_one = true;
}
@@ -409,8 +397,8 @@
// actually removed. Called with lock held.
// -----------------------------------------------------------------------------
bool WaitableEvent::WaitableEventKernel::Dequeue(Waiter* waiter, void* tag) {
- for (std::list<Waiter*>::iterator
- i = waiters_.begin(); i != waiters_.end(); ++i) {
+ for (std::list<Waiter*>::iterator i = waiters_.begin(); i != waiters_.end();
+ ++i) {
if (*i == waiter && (*i)->Compare(tag)) {
waiters_.erase(i);
return true;
diff --git a/base/synchronization/waitable_event_win.cc b/base/synchronization/waitable_event_win.cc
index 15dd10a..1301840 100644
--- a/base/synchronization/waitable_event_win.cc
+++ b/base/synchronization/waitable_event_win.cc
@@ -4,8 +4,8 @@
#include "base/synchronization/waitable_event.h"
-#include <windows.h>
#include <stddef.h>
+#include <windows.h>
#include <algorithm>
#include <utility>
@@ -127,8 +127,7 @@
// The cast is safe because count is small - see the CHECK above.
DWORD result =
- WaitForMultipleObjects(static_cast<DWORD>(count),
- handles,
+ WaitForMultipleObjects(static_cast<DWORD>(count), handles,
FALSE, // don't wait for all the objects
INFINITE); // no timeout
if (result >= WAIT_OBJECT_0 + count) {
diff --git a/base/template_util.h b/base/template_util.h
index 11e7ba8..e92be91 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -38,9 +38,12 @@
namespace base {
-template <class T> struct is_non_const_reference : std::false_type {};
-template <class T> struct is_non_const_reference<T&> : std::true_type {};
-template <class T> struct is_non_const_reference<const T&> : std::false_type {};
+template <class T>
+struct is_non_const_reference : std::false_type {};
+template <class T>
+struct is_non_const_reference<T&> : std::true_type {};
+template <class T>
+struct is_non_const_reference<const T&> : std::false_type {};
namespace internal {
diff --git a/base/third_party/icu/icu_utf.cc b/base/third_party/icu/icu_utf.cc
index a3262b0..8dcb401 100644
--- a/base/third_party/icu/icu_utf.cc
+++ b/base/third_party/icu/icu_utf.cc
@@ -25,23 +25,19 @@
// source/common/utf_impl.cpp
-static const UChar32
-utf8_errorValue[6]={
+static const UChar32 utf8_errorValue[6] = {
// Same values as UTF8_ERROR_VALUE_1, UTF8_ERROR_VALUE_2, UTF_ERROR_VALUE,
// but without relying on the obsolete unicode/utf_old.h.
- 0x15, 0x9f, 0xffff,
- 0x10ffff
-};
+ 0x15, 0x9f, 0xffff, 0x10ffff};
-static UChar32
-errorValue(int32_t count, int8_t strict) {
- if(strict>=0) {
- return utf8_errorValue[count];
- } else if(strict==-3) {
- return 0xfffd;
- } else {
- return CBU_SENTINEL;
- }
+static UChar32 errorValue(int32_t count, int8_t strict) {
+ if (strict >= 0) {
+ return utf8_errorValue[count];
+ } else if (strict == -3) {
+ return 0xfffd;
+ } else {
+ return CBU_SENTINEL;
+ }
}
/*
@@ -53,79 +49,81 @@
* The "strict" parameter controls the error behavior:
* <0 "Safe" behavior of U8_NEXT():
* -1: All illegal byte sequences yield U_SENTINEL=-1.
- * -2: Same as -1, except for lenient treatment of surrogate code points as legal.
- * Some implementations use this for roundtripping of
- * Unicode 16-bit strings that are not well-formed UTF-16, that is, they
- * contain unpaired surrogates.
- * -3: All illegal byte sequences yield U+FFFD.
- * 0 Obsolete "safe" behavior of UTF8_NEXT_CHAR_SAFE(..., FALSE):
- * All illegal byte sequences yield a positive code point such that this
- * result code point would be encoded with the same number of bytes as
- * the illegal sequence.
- * >0 Obsolete "strict" behavior of UTF8_NEXT_CHAR_SAFE(..., TRUE):
- * Same as the obsolete "safe" behavior, but non-characters are also treated
- * like illegal sequences.
+ * -2: Same as -1, except for lenient treatment of surrogate code points as
+ * legal. Some implementations use this for roundtripping of Unicode 16-bit
+ * strings that are not well-formed UTF-16, that is, they contain
+ * unpaired surrogates. -3: All illegal byte sequences yield U+FFFD. 0
+ * Obsolete "safe" behavior of UTF8_NEXT_CHAR_SAFE(..., FALSE): All illegal
+ * byte sequences yield a positive code point such that this result code
+ * point would be encoded with the same number of bytes as the illegal
+ * sequence. >0 Obsolete "strict" behavior of UTF8_NEXT_CHAR_SAFE(...,
+ * TRUE): Same as the obsolete "safe" behavior, but non-characters are also
+ * treated like illegal sequences.
*
* Note that a UBool is the same as an int8_t.
*/
-UChar32
-utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict) {
- // *pi is one after byte c.
- int32_t i=*pi;
- // length can be negative for NUL-terminated strings: Read and validate one byte at a time.
- if(i==length || c>0xf4) {
- // end of string, or not a lead byte
- } else if(c>=0xf0) {
- // Test for 4-byte sequences first because
- // U8_NEXT() handles shorter valid sequences inline.
- uint8_t t1=s[i], t2, t3;
- c&=7;
- if(CBU8_IS_VALID_LEAD4_AND_T1(c, t1) &&
- ++i!=length && (t2=s[i]-0x80)<=0x3f &&
- ++i!=length && (t3=s[i]-0x80)<=0x3f) {
- ++i;
- c=(c<<18)|((t1&0x3f)<<12)|(t2<<6)|t3;
- // strict: forbid non-characters like U+fffe
- if(strict<=0 || !CBU_IS_UNICODE_NONCHAR(c)) {
- *pi=i;
- return c;
- }
+UChar32 utf8_nextCharSafeBody(const uint8_t* s,
+ int32_t* pi,
+ int32_t length,
+ UChar32 c,
+ UBool strict) {
+ // *pi is one after byte c.
+ int32_t i = *pi;
+ // length can be negative for NUL-terminated strings: Read and validate one
+ // byte at a time.
+ if (i == length || c > 0xf4) {
+ // end of string, or not a lead byte
+ } else if (c >= 0xf0) {
+ // Test for 4-byte sequences first because
+ // U8_NEXT() handles shorter valid sequences inline.
+ uint8_t t1 = s[i], t2, t3;
+ c &= 7;
+ if (CBU8_IS_VALID_LEAD4_AND_T1(c, t1) && ++i != length &&
+ (t2 = s[i] - 0x80) <= 0x3f && ++i != length &&
+ (t3 = s[i] - 0x80) <= 0x3f) {
+ ++i;
+ c = (c << 18) | ((t1 & 0x3f) << 12) | (t2 << 6) | t3;
+ // strict: forbid non-characters like U+fffe
+ if (strict <= 0 || !CBU_IS_UNICODE_NONCHAR(c)) {
+ *pi = i;
+ return c;
+ }
+ }
+ } else if (c >= 0xe0) {
+ c &= 0xf;
+ if (strict != -2) {
+ uint8_t t1 = s[i], t2;
+ if (CBU8_IS_VALID_LEAD3_AND_T1(c, t1) && ++i != length &&
+ (t2 = s[i] - 0x80) <= 0x3f) {
+ ++i;
+ c = (c << 12) | ((t1 & 0x3f) << 6) | t2;
+ // strict: forbid non-characters like U+fffe
+ if (strict <= 0 || !CBU_IS_UNICODE_NONCHAR(c)) {
+ *pi = i;
+ return c;
}
- } else if(c>=0xe0) {
- c&=0xf;
- if(strict!=-2) {
- uint8_t t1=s[i], t2;
- if(CBU8_IS_VALID_LEAD3_AND_T1(c, t1) &&
- ++i!=length && (t2=s[i]-0x80)<=0x3f) {
- ++i;
- c=(c<<12)|((t1&0x3f)<<6)|t2;
- // strict: forbid non-characters like U+fffe
- if(strict<=0 || !CBU_IS_UNICODE_NONCHAR(c)) {
- *pi=i;
- return c;
- }
- }
- } else {
- // strict=-2 -> lenient: allow surrogates
- uint8_t t1=s[i]-0x80, t2;
- if(t1<=0x3f && (c>0 || t1>=0x20) &&
- ++i!=length && (t2=s[i]-0x80)<=0x3f) {
- *pi=i+1;
- return (c<<12)|(t1<<6)|t2;
- }
- }
- } else if(c>=0xc2) {
- uint8_t t1=s[i]-0x80;
- if(t1<=0x3f) {
- *pi=i+1;
- return ((c-0xc0)<<6)|t1;
- }
- } // else 0x80<=c<0xc2 is not a lead byte
+ }
+ } else {
+ // strict=-2 -> lenient: allow surrogates
+ uint8_t t1 = s[i] - 0x80, t2;
+ if (t1 <= 0x3f && (c > 0 || t1 >= 0x20) && ++i != length &&
+ (t2 = s[i] - 0x80) <= 0x3f) {
+ *pi = i + 1;
+ return (c << 12) | (t1 << 6) | t2;
+ }
+ }
+ } else if (c >= 0xc2) {
+ uint8_t t1 = s[i] - 0x80;
+ if (t1 <= 0x3f) {
+ *pi = i + 1;
+ return ((c - 0xc0) << 6) | t1;
+ }
+ } // else 0x80<=c<0xc2 is not a lead byte
- /* error handling */
- c=errorValue(i-*pi, strict);
- *pi=i;
- return c;
+ /* error handling */
+ c = errorValue(i - *pi, strict);
+ *pi = i;
+ return c;
}
} // namespace base_icu
diff --git a/base/third_party/icu/icu_utf.h b/base/third_party/icu/icu_utf.h
index 2ba8231..b626b39 100644
--- a/base/third_party/icu/icu_utf.h
+++ b/base/third_party/icu/icu_utf.h
@@ -68,9 +68,9 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU_IS_UNICODE_NONCHAR(c) \
- ((c)>=0xfdd0 && \
- ((c)<=0xfdef || ((c)&0xfffe)==0xfffe) && (c)<=0x10ffff)
+#define CBU_IS_UNICODE_NONCHAR(c) \
+ ((c) >= 0xfdd0 && ((c) <= 0xfdef || ((c)&0xfffe) == 0xfffe) && \
+ (c) <= 0x10ffff)
/**
* Is c a Unicode code point value (0..U+10ffff)
@@ -78,9 +78,9 @@
*
* Code points that are not characters include:
* - single surrogate code points (U+d800..U+dfff, 2048 code points)
- * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
- * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
- * - the highest Unicode code point value is U+10ffff
+ * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code
+ * points) - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points) - the highest
+ * Unicode code point value is U+10ffff
*
* This means that all code points below U+d800 are character code points,
* and that boundary is tested first for performance.
@@ -90,8 +90,8 @@
* @stable ICU 2.4
*/
#define CBU_IS_UNICODE_CHAR(c) \
- ((uint32_t)(c)<0xd800 || \
- (0xdfff<(c) && (c)<=0x10ffff && !CBU_IS_UNICODE_NONCHAR(c)))
+ ((uint32_t)(c) < 0xd800 || \
+ (0xdfff < (c) && (c) <= 0x10ffff && !CBU_IS_UNICODE_NONCHAR(c)))
/**
* Is this code point a surrogate (U+d800..U+dfff)?
@@ -99,7 +99,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)
+#define CBU_IS_SURROGATE(c) (((c)&0xfffff800) == 0xd800)
/**
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
@@ -108,43 +108,51 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
+#define CBU_IS_SURROGATE_LEAD(c) (((c)&0x400) == 0)
// source/common/unicode/utf8.h
/**
- * Internal bit vector for 3-byte UTF-8 validity check, for use in U8_IS_VALID_LEAD3_AND_T1.
- * Each bit indicates whether one lead byte + first trail byte pair starts a valid sequence.
- * Lead byte E0..EF bits 3..0 are used as byte index,
- * first trail byte bits 7..5 are used as bit index into that byte.
+ * Internal bit vector for 3-byte UTF-8 validity check, for use in
+ * U8_IS_VALID_LEAD3_AND_T1. Each bit indicates whether one lead byte + first
+ * trail byte pair starts a valid sequence. Lead byte E0..EF bits 3..0 are used
+ * as byte index, first trail byte bits 7..5 are used as bit index into that
+ * byte.
* @see U8_IS_VALID_LEAD3_AND_T1
* @internal
*/
-#define CBU8_LEAD3_T1_BITS "\x20\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x10\x30\x30"
+#define CBU8_LEAD3_T1_BITS \
+ "\x20\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x10\x30\x30"
/**
* Internal 3-byte UTF-8 validity check.
- * Non-zero if lead byte E0..EF and first trail byte 00..FF start a valid sequence.
+ * Non-zero if lead byte E0..EF and first trail byte 00..FF start a valid
+ * sequence.
* @internal
*/
-#define CBU8_IS_VALID_LEAD3_AND_T1(lead, t1) (CBU8_LEAD3_T1_BITS[(lead)&0xf]&(1<<((uint8_t)(t1)>>5)))
+#define CBU8_IS_VALID_LEAD3_AND_T1(lead, t1) \
+ (CBU8_LEAD3_T1_BITS[(lead)&0xf] & (1 << ((uint8_t)(t1) >> 5)))
/**
- * Internal bit vector for 4-byte UTF-8 validity check, for use in U8_IS_VALID_LEAD4_AND_T1.
- * Each bit indicates whether one lead byte + first trail byte pair starts a valid sequence.
- * First trail byte bits 7..4 are used as byte index,
- * lead byte F0..F4 bits 2..0 are used as bit index into that byte.
+ * Internal bit vector for 4-byte UTF-8 validity check, for use in
+ * U8_IS_VALID_LEAD4_AND_T1. Each bit indicates whether one lead byte + first
+ * trail byte pair starts a valid sequence. First trail byte bits 7..4 are used
+ * as byte index, lead byte F0..F4 bits 2..0 are used as bit index into that
+ * byte.
* @see U8_IS_VALID_LEAD4_AND_T1
* @internal
*/
-#define CBU8_LEAD4_T1_BITS "\x00\x00\x00\x00\x00\x00\x00\x00\x1E\x0F\x0F\x0F\x00\x00\x00\x00"
+#define CBU8_LEAD4_T1_BITS \
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x1E\x0F\x0F\x0F\x00\x00\x00\x00"
/**
* Internal 4-byte UTF-8 validity check.
- * Non-zero if lead byte F0..F4 and first trail byte 00..FF start a valid sequence.
+ * Non-zero if lead byte F0..F4 and first trail byte 00..FF start a valid
+ * sequence.
* @internal
*/
-#define CBU8_IS_VALID_LEAD4_AND_T1(lead, t1) (CBU8_LEAD4_T1_BITS[(uint8_t)(t1)>>4]&(1<<((lead)&7)))
+#define CBU8_IS_VALID_LEAD4_AND_T1(lead, t1) \
+ (CBU8_LEAD4_T1_BITS[(uint8_t)(t1) >> 4] & (1 << ((lead)&7)))
/**
* Function for handling "next code point" with error-checking.
@@ -158,8 +166,11 @@
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-UChar32
-utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, ::base_icu::UChar32 c, ::base_icu::UBool strict);
+UChar32 utf8_nextCharSafeBody(const uint8_t* s,
+ int32_t* pi,
+ int32_t length,
+ ::base_icu::UChar32 c,
+ ::base_icu::UBool strict);
/**
* Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?
@@ -167,7 +178,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU8_IS_SINGLE(c) (((c)&0x80)==0)
+#define CBU8_IS_SINGLE(c) (((c)&0x80) == 0)
/**
* Is this code unit (byte) a UTF-8 lead byte? (0xC2..0xF4)
@@ -175,7 +186,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU8_IS_LEAD(c) ((uint8_t)((c)-0xc2)<=0x32)
+#define CBU8_IS_LEAD(c) ((uint8_t)((c)-0xc2) <= 0x32)
/**
* Is this code unit (byte) a UTF-8 trail byte? (0x80..0xBF)
@@ -183,7 +194,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU8_IS_TRAIL(c) ((int8_t)(c)<-0x40)
+#define CBU8_IS_TRAIL(c) ((int8_t)(c) < -0x40)
/**
* How many code units (bytes) are used for the UTF-8 encoding
@@ -192,19 +203,20 @@
* @return 1..4, or 0 if c is a surrogate or not a Unicode code point
* @stable ICU 2.4
*/
-#define CBU8_LENGTH(c) \
- ((uint32_t)(c)<=0x7f ? 1 : \
- ((uint32_t)(c)<=0x7ff ? 2 : \
- ((uint32_t)(c)<=0xd7ff ? 3 : \
- ((uint32_t)(c)<=0xdfff || (uint32_t)(c)>0x10ffff ? 0 : \
- ((uint32_t)(c)<=0xffff ? 3 : 4)\
- ) \
- ) \
- ) \
- )
+#define CBU8_LENGTH(c) \
+ ((uint32_t)(c) <= 0x7f \
+ ? 1 \
+ : ((uint32_t)(c) <= 0x7ff \
+ ? 2 \
+ : ((uint32_t)(c) <= 0xd7ff \
+ ? 3 \
+ : ((uint32_t)(c) <= 0xdfff || (uint32_t)(c) > 0x10ffff \
+ ? 0 \
+ : ((uint32_t)(c) <= 0xffff ? 3 : 4)))))
/**
- * The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff).
+ * The maximum number of UTF-8 code units (bytes) per Unicode code point
+ * (U+0000..U+10ffff).
* @return 4
* @stable ICU 2.4
*/
@@ -230,36 +242,37 @@
* @see U8_NEXT_UNSAFE
* @stable ICU 2.4
*/
-#define CBU8_NEXT(s, i, length, c) { \
- (c)=(uint8_t)(s)[(i)++]; \
- if(!CBU8_IS_SINGLE(c)) { \
- uint8_t __t1, __t2; \
- if( /* handle U+0800..U+FFFF inline */ \
- (0xe0<=(c) && (c)<0xf0) && \
- (((i)+1)<(length) || (length)<0) && \
- CBU8_IS_VALID_LEAD3_AND_T1((c), __t1=(s)[i]) && \
- (__t2=(s)[(i)+1]-0x80)<=0x3f) { \
- (c)=(((c)&0xf)<<12)|((__t1&0x3f)<<6)|__t2; \
- (i)+=2; \
- } else if( /* handle U+0080..U+07FF inline */ \
- ((c)<0xe0 && (c)>=0xc2) && \
- ((i)!=(length)) && \
- (__t1=(s)[i]-0x80)<=0x3f) { \
- (c)=(((c)&0x1f)<<6)|__t1; \
- ++(i); \
- } else { \
- /* function call for "complicated" and error cases */ \
- (c)=::base_icu::utf8_nextCharSafeBody((const uint8_t *)s, &(i), (length), c, -1); \
- } \
- } \
-}
+#define CBU8_NEXT(s, i, length, c) \
+ { \
+ (c) = (uint8_t)(s)[(i)++]; \
+ if (!CBU8_IS_SINGLE(c)) { \
+ uint8_t __t1, __t2; \
+ if (/* handle U+0800..U+FFFF inline */ \
+ (0xe0 <= (c) && (c) < 0xf0) && \
+ (((i) + 1) < (length) || (length) < 0) && \
+ CBU8_IS_VALID_LEAD3_AND_T1((c), __t1 = (s)[i]) && \
+ (__t2 = (s)[(i) + 1] - 0x80) <= 0x3f) { \
+ (c) = (((c)&0xf) << 12) | ((__t1 & 0x3f) << 6) | __t2; \
+ (i) += 2; \
+ } else if (/* handle U+0080..U+07FF inline */ \
+ ((c) < 0xe0 && (c) >= 0xc2) && ((i) != (length)) && \
+ (__t1 = (s)[i] - 0x80) <= 0x3f) { \
+ (c) = (((c)&0x1f) << 6) | __t1; \
+ ++(i); \
+ } else { \
+ /* function call for "complicated" and error cases */ \
+ (c) = ::base_icu::utf8_nextCharSafeBody((const uint8_t*)s, &(i), \
+ (length), c, -1); \
+ } \
+ } \
+ }
/**
* Append a code point to a string, overwriting 1 to 4 bytes.
* The offset points to the current end of the string contents
* and is advanced (post-increment).
- * "Unsafe" macro, assumes a valid code point and sufficient space in the string.
- * Otherwise, the result is undefined.
+ * "Unsafe" macro, assumes a valid code point and sufficient space in the
+ * string. Otherwise, the result is undefined.
*
* @param s const uint8_t * string buffer
* @param i string offset
@@ -267,24 +280,25 @@
* @see U8_APPEND
* @stable ICU 2.4
*/
-#define CBU8_APPEND_UNSAFE(s, i, c) { \
- if((uint32_t)(c)<=0x7f) { \
- (s)[(i)++]=(uint8_t)(c); \
- } else { \
- if((uint32_t)(c)<=0x7ff) { \
- (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
- } else { \
- if((uint32_t)(c)<=0xffff) { \
- (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
- } else { \
- (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \
- (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \
- } \
- (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
- } \
- (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
- } \
-}
+#define CBU8_APPEND_UNSAFE(s, i, c) \
+ { \
+ if ((uint32_t)(c) <= 0x7f) { \
+ (s)[(i)++] = (uint8_t)(c); \
+ } else { \
+ if ((uint32_t)(c) <= 0x7ff) { \
+ (s)[(i)++] = (uint8_t)(((c) >> 6) | 0xc0); \
+ } else { \
+ if ((uint32_t)(c) <= 0xffff) { \
+ (s)[(i)++] = (uint8_t)(((c) >> 12) | 0xe0); \
+ } else { \
+ (s)[(i)++] = (uint8_t)(((c) >> 18) | 0xf0); \
+ (s)[(i)++] = (uint8_t)((((c) >> 12) & 0x3f) | 0x80); \
+ } \
+ (s)[(i)++] = (uint8_t)((((c) >> 6) & 0x3f) | 0x80); \
+ } \
+ (s)[(i)++] = (uint8_t)(((c)&0x3f) | 0x80); \
+ } \
+ }
// source/common/unicode/utf16.h
@@ -302,7 +316,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
+#define CBU16_IS_LEAD(c) (((c)&0xfffffc00) == 0xd800)
/**
* Is this code unit a trail surrogate (U+dc00..U+dfff)?
@@ -310,7 +324,7 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
+#define CBU16_IS_TRAIL(c) (((c)&0xfffffc00) == 0xdc00)
/**
* Is this code unit a surrogate (U+d800..U+dfff)?
@@ -327,13 +341,13 @@
* @return TRUE or FALSE
* @stable ICU 2.4
*/
-#define CBU16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
+#define CBU16_IS_SURROGATE_LEAD(c) (((c)&0x400) == 0)
/**
* Helper constant for U16_GET_SUPPLEMENTARY.
* @internal
*/
-#define CBU16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
+#define CBU16_SURROGATE_OFFSET ((0xd800 << 10UL) + 0xdc00 - 0x10000)
/**
* Get a supplementary code point value (U+10000..U+10ffff)
@@ -347,7 +361,8 @@
* @stable ICU 2.4
*/
#define CBU16_GET_SUPPLEMENTARY(lead, trail) \
- (((::base_icu::UChar32)(lead)<<10UL)+(::base_icu::UChar32)(trail)-CBU16_SURROGATE_OFFSET)
+ (((::base_icu::UChar32)(lead) << 10UL) + \
+ (::base_icu::UChar32)(trail)-CBU16_SURROGATE_OFFSET)
/**
* Get the lead surrogate (0xd800..0xdbff) for a
@@ -356,7 +371,8 @@
* @return lead surrogate (U+d800..U+dbff) for supplementary
* @stable ICU 2.4
*/
-#define CBU16_LEAD(supplementary) (::base_icu::UChar)(((supplementary)>>10)+0xd7c0)
+#define CBU16_LEAD(supplementary) \
+ (::base_icu::UChar)(((supplementary) >> 10) + 0xd7c0)
/**
* Get the trail surrogate (0xdc00..0xdfff) for a
@@ -365,19 +381,22 @@
* @return trail surrogate (U+dc00..U+dfff) for supplementary
* @stable ICU 2.4
*/
-#define CBU16_TRAIL(supplementary) (::base_icu::UChar)(((supplementary)&0x3ff)|0xdc00)
+#define CBU16_TRAIL(supplementary) \
+ (::base_icu::UChar)(((supplementary)&0x3ff) | 0xdc00)
/**
- * How many 16-bit code units are used to encode this Unicode code point? (1 or 2)
- * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff).
+ * How many 16-bit code units are used to encode this Unicode code point? (1 or
+ * 2) The result is not defined if c is not a Unicode code point
+ * (U+0000..U+10ffff).
* @param c 32-bit code point
* @return 1 or 2
* @stable ICU 2.4
*/
-#define CBU16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
+#define CBU16_LENGTH(c) ((uint32_t)(c) <= 0xffff ? 1 : 2)
/**
- * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
+ * The maximum number of 16-bit code units per Unicode code point
+ * (U+0000..U+10ffff).
* @return 2
* @stable ICU 2.4
*/
@@ -395,7 +414,8 @@
* for a supplementary code point, in which case the macro will read
* the following trail surrogate as well.
* If the offset points to a trail surrogate or
- * to a single, unpaired lead surrogate, then c is set to that unpaired surrogate.
+ * to a single, unpaired lead surrogate, then c is set to that unpaired
+ * surrogate.
*
* @param s const UChar * string
* @param i string offset, must be i<length
@@ -404,23 +424,24 @@
* @see U16_NEXT_UNSAFE
* @stable ICU 2.4
*/
-#define CBU16_NEXT(s, i, length, c) { \
- (c)=(s)[(i)++]; \
- if(CBU16_IS_LEAD(c)) { \
- uint16_t __c2; \
- if((i)!=(length) && CBU16_IS_TRAIL(__c2=(s)[(i)])) { \
- ++(i); \
- (c)=CBU16_GET_SUPPLEMENTARY((c), __c2); \
- } \
- } \
-}
+#define CBU16_NEXT(s, i, length, c) \
+ { \
+ (c) = (s)[(i)++]; \
+ if (CBU16_IS_LEAD(c)) { \
+ uint16_t __c2; \
+ if ((i) != (length) && CBU16_IS_TRAIL(__c2 = (s)[(i)])) { \
+ ++(i); \
+ (c) = CBU16_GET_SUPPLEMENTARY((c), __c2); \
+ } \
+ } \
+ }
/**
* Append a code point to a string, overwriting 1 or 2 code units.
* The offset points to the current end of the string contents
* and is advanced (post-increment).
- * "Unsafe" macro, assumes a valid code point and sufficient space in the string.
- * Otherwise, the result is undefined.
+ * "Unsafe" macro, assumes a valid code point and sufficient space in the
+ * string. Otherwise, the result is undefined.
*
* @param s const UChar * string buffer
* @param i string offset
@@ -428,15 +449,16 @@
* @see U16_APPEND
* @stable ICU 2.4
*/
-#define CBU16_APPEND_UNSAFE(s, i, c) { \
- if((uint32_t)(c)<=0xffff) { \
- (s)[(i)++]=(uint16_t)(c); \
- } else { \
- (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
- (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
- } \
-}
+#define CBU16_APPEND_UNSAFE(s, i, c) \
+ { \
+ if ((uint32_t)(c) <= 0xffff) { \
+ (s)[(i)++] = (uint16_t)(c); \
+ } else { \
+ (s)[(i)++] = (uint16_t)(((c) >> 10) + 0xd7c0); \
+ (s)[(i)++] = (uint16_t)(((c)&0x3ff) | 0xdc00); \
+ } \
+ }
-} // namesapce base_icu
+} // namespace base_icu
#endif // BASE_THIRD_PARTY_ICU_ICU_UTF_H_
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h
index 6fbe327..3f1cc75 100644
--- a/base/threading/platform_thread.h
+++ b/base/threading/platform_thread.h
@@ -54,15 +54,12 @@
explicit constexpr PlatformThreadRef(RefType id) : id_(id) {}
- bool operator==(PlatformThreadRef other) const {
- return id_ == other.id_;
- }
+ bool operator==(PlatformThreadRef other) const { return id_ == other.id_; }
bool operator!=(PlatformThreadRef other) const { return id_ != other.id_; }
- bool is_null() const {
- return id_ == 0;
- }
+ bool is_null() const { return id_ == 0; }
+
private:
RefType id_;
};
@@ -84,13 +81,9 @@
return handle_ == other.handle_;
}
- bool is_null() const {
- return !handle_;
- }
+ bool is_null() const { return !handle_; }
- Handle platform_handle() const {
- return handle_;
- }
+ Handle platform_handle() const { return handle_; }
private:
Handle handle_;
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index 8174dba..2a7cd48 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -71,16 +71,14 @@
if (pthread_attr_getstacksize(&attributes, &default_stack_size) == 0 &&
getrlimit(RLIMIT_STACK, &stack_rlimit) == 0 &&
stack_rlimit.rlim_cur != RLIM_INFINITY) {
- default_stack_size =
- std::max(std::max(default_stack_size,
- static_cast<size_t>(PTHREAD_STACK_MIN)),
- static_cast<size_t>(stack_rlimit.rlim_cur));
+ default_stack_size = std::max(
+ std::max(default_stack_size, static_cast<size_t>(PTHREAD_STACK_MIN)),
+ static_cast<size_t>(stack_rlimit.rlim_cur));
}
return default_stack_size;
#endif
}
-void TerminateOnThread() {
-}
+void TerminateOnThread() {}
} // namespace base
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 32a052a..bfec23c 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -104,8 +104,8 @@
// static
PlatformThreadId PlatformThread::CurrentId() {
- // Pthreads doesn't have the concept of a thread ID, so we have to reach down
- // into the kernel.
+// Pthreads doesn't have the concept of a thread ID, so we have to reach down
+// into the kernel.
#if defined(OS_MACOSX)
return pthread_mach_thread_np(pthread_self());
#elif defined(OS_LINUX)
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 9efc951..95accd5 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -21,10 +21,10 @@
const DWORD kVCThreadNameException = 0x406D1388;
typedef struct tagTHREADNAME_INFO {
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
- DWORD dwFlags; // Reserved for future use, must be zero.
+ DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
// The SetThreadDescription API was brought in version 1607 of Windows 10.
@@ -40,9 +40,9 @@
info.dwFlags = 0;
__try {
- RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
+ RaiseException(kVCThreadNameException, 0, sizeof(info) / sizeof(DWORD),
reinterpret_cast<DWORD_PTR*>(&info));
- } __except(EXCEPTION_CONTINUE_EXECUTION) {
+ } __except (EXCEPTION_CONTINUE_EXECUTION) {
}
}
@@ -58,13 +58,9 @@
// Retrieve a copy of the thread handle to use as the key in the
// thread name mapping.
PlatformThreadHandle::Handle platform_handle;
- BOOL did_dup = DuplicateHandle(GetCurrentProcess(),
- GetCurrentThread(),
- GetCurrentProcess(),
- &platform_handle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS);
+ BOOL did_dup = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
+ GetCurrentProcess(), &platform_handle, 0,
+ FALSE, DUPLICATE_SAME_ACCESS);
win::ScopedHandle scoped_platform_handle;
diff --git a/base/time/time.cc b/base/time/time.cc
index bd746b3..8708c49 100644
--- a/base/time/time.cc
+++ b/base/time/time.cc
@@ -98,7 +98,7 @@
return std::numeric_limits<int64_t>::max();
}
return (delta_ + Time::kMicrosecondsPerMillisecond - 1) /
- Time::kMicrosecondsPerMillisecond;
+ Time::kMicrosecondsPerMillisecond;
}
int64_t TimeDelta::InMicroseconds() const {
@@ -194,8 +194,8 @@
return std::numeric_limits<time_t>::max();
}
if (std::numeric_limits<int64_t>::max() - kTimeTToMicrosecondsOffset <= us_) {
- DLOG(WARNING) << "Overflow when converting base::Time with internal " <<
- "value " << us_ << " to time_t.";
+ DLOG(WARNING) << "Overflow when converting base::Time with internal "
+ << "value " << us_ << " to time_t.";
return std::numeric_limits<time_t>::max();
}
return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
@@ -222,9 +222,8 @@
#if defined(OS_POSIX)
// static
Time Time::FromTimeSpec(const timespec& ts) {
- return FromDoubleT(ts.tv_sec +
- static_cast<double>(ts.tv_nsec) /
- base::Time::kNanosecondsPerSecond);
+ return FromDoubleT(ts.tv_sec + static_cast<double>(ts.tv_nsec) /
+ base::Time::kNanosecondsPerSecond);
}
#endif
@@ -263,8 +262,7 @@
// Preserve max without offset to prevent overflow.
return std::numeric_limits<int64_t>::max();
}
- return ((us_ - kTimeTToMicrosecondsOffset) /
- kMicrosecondsPerMillisecond);
+ return ((us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerMillisecond);
}
// static
@@ -301,14 +299,10 @@
Time::Exploded exploded;
time.UTCExplode(&exploded);
// Use StringPrintf because iostreams formatting is painful.
- return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC",
- exploded.year,
- exploded.month,
- exploded.day_of_month,
- exploded.hour,
- exploded.minute,
- exploded.second,
- exploded.millisecond);
+ return os << StringPrintf(
+ "%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", exploded.year,
+ exploded.month, exploded.day_of_month, exploded.hour,
+ exploded.minute, exploded.second, exploded.millisecond);
}
// TimeTicks ------------------------------------------------------------------
@@ -369,12 +363,9 @@
}
bool Time::Exploded::HasValidValues() const {
- return is_in_range(month, 1, 12) &&
- is_in_range(day_of_week, 0, 6) &&
- is_in_range(day_of_month, 1, 31) &&
- is_in_range(hour, 0, 23) &&
- is_in_range(minute, 0, 59) &&
- is_in_range(second, 0, 60) &&
+ return is_in_range(month, 1, 12) && is_in_range(day_of_week, 0, 6) &&
+ is_in_range(day_of_month, 1, 31) && is_in_range(hour, 0, 23) &&
+ is_in_range(minute, 0, 59) && is_in_range(second, 0, 60) &&
is_in_range(millisecond, 0, 999);
}
diff --git a/base/time/time.h b/base/time/time.h
index 931cf27..1243ac4 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -69,8 +69,8 @@
#endif
#if defined(OS_POSIX)
-#include <unistd.h>
#include <sys/time.h>
+#include <unistd.h>
#endif
#if defined(OS_WIN)
@@ -205,12 +205,8 @@
return TimeDelta(time_internal::SaturatedSub(*this, other.delta_));
}
- TimeDelta& operator+=(TimeDelta other) {
- return *this = (*this + other);
- }
- TimeDelta& operator-=(TimeDelta other) {
- return *this = (*this - other);
- }
+ TimeDelta& operator+=(TimeDelta other) { return *this = (*this + other); }
+ TimeDelta& operator-=(TimeDelta other) { return *this = (*this - other); }
constexpr TimeDelta operator-() const { return TimeDelta(-delta_); }
// Computations with numeric types. operator*() isn't constexpr because of a
@@ -317,7 +313,7 @@
// classes. Each subclass provides for strong type-checking to ensure
// semantically meaningful comparison/math of time values from the same clock
// source or timeline.
-template<class TimeClass>
+template <class TimeClass>
class TimeBase {
public:
static const int64_t kHoursPerDay = 24;
@@ -341,9 +337,7 @@
// Warning: Be careful when writing code that performs math on time values,
// since it's possible to produce a valid "zero" result that should not be
// interpreted as a "null" value.
- bool is_null() const {
- return us_ == 0;
- }
+ bool is_null() const { return us_ == 0; }
// Returns true if this object represents the maximum/minimum time.
bool is_max() const { return us_ == std::numeric_limits<int64_t>::max(); }
@@ -402,24 +396,12 @@
}
// Comparison operators
- bool operator==(TimeClass other) const {
- return us_ == other.us_;
- }
- bool operator!=(TimeClass other) const {
- return us_ != other.us_;
- }
- bool operator<(TimeClass other) const {
- return us_ < other.us_;
- }
- bool operator<=(TimeClass other) const {
- return us_ <= other.us_;
- }
- bool operator>(TimeClass other) const {
- return us_ > other.us_;
- }
- bool operator>=(TimeClass other) const {
- return us_ >= other.us_;
- }
+ bool operator==(TimeClass other) const { return us_ == other.us_; }
+ bool operator!=(TimeClass other) const { return us_ != other.us_; }
+ bool operator<(TimeClass other) const { return us_ < other.us_; }
+ bool operator<=(TimeClass other) const { return us_ <= other.us_; }
+ bool operator>(TimeClass other) const { return us_ > other.us_; }
+ bool operator>=(TimeClass other) const { return us_ >= other.us_; }
protected:
constexpr explicit TimeBase(int64_t us) : us_(us) {}
@@ -430,7 +412,7 @@
} // namespace time_internal
-template<class TimeClass>
+template <class TimeClass>
inline TimeClass operator+(TimeDelta delta, TimeClass t) {
return t + delta;
}
@@ -620,9 +602,7 @@
// Fills the given exploded structure with either the local time or UTC from
// this time structure (containing UTC).
- void UTCExplode(Exploded* exploded) const {
- return Explode(false, exploded);
- }
+ void UTCExplode(Exploded* exploded) const { return Explode(false, exploded); }
void LocalExplode(Exploded* exploded) const {
return Explode(true, exploded);
}
@@ -854,8 +834,7 @@
// thread is running.
class ThreadTicks : public time_internal::TimeBase<ThreadTicks> {
public:
- ThreadTicks() : TimeBase(0) {
- }
+ ThreadTicks() : TimeBase(0) {}
// Returns true if ThreadTicks::Now() is supported on this system.
static bool IsSupported() WARN_UNUSED_RESULT {
diff --git a/base/time/time_exploded_posix.cc b/base/time/time_exploded_posix.cc
index ae1b4df..c9ec2df 100644
--- a/base/time/time_exploded_posix.cc
+++ b/base/time/time_exploded_posix.cc
@@ -117,7 +117,7 @@
timestruct.tm_yday = 0; // mktime/timegm ignore this
timestruct.tm_isdst = -1; // attempt to figure it out
#if !defined(OS_NACL) && !defined(OS_SOLARIS) && !defined(OS_AIX)
- timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore
+ timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore
timestruct.tm_zone = nullptr; // not a POSIX field, so mktime/timegm ignore
#endif
diff --git a/base/time/time_mac.cc b/base/time/time_mac.cc
index 567696d..7b6452e 100644
--- a/base/time/time_mac.cc
+++ b/base/time/time_mac.cc
@@ -109,10 +109,8 @@
}
kern_return_t kr = thread_info(
- thread.get(),
- THREAD_BASIC_INFO,
- reinterpret_cast<thread_info_t>(&thread_info_data),
- &thread_info_count);
+ thread.get(), THREAD_BASIC_INFO,
+ reinterpret_cast<thread_info_t>(&thread_info_data), &thread_info_count);
MACH_DCHECK(kr == KERN_SUCCESS, kr) << "thread_info";
base::CheckedNumeric<int64_t> absolute_micros(
@@ -263,8 +261,8 @@
// Calculate milliseconds ourselves, since we rounded the |seconds|, making
// sure to round towards -infinity.
exploded->millisecond =
- (microsecond >= 0) ? microsecond / kMicrosecondsPerMillisecond :
- (microsecond - kMicrosecondsPerMillisecond + 1) /
+ (microsecond >= 0) ? microsecond / kMicrosecondsPerMillisecond
+ : (microsecond - kMicrosecondsPerMillisecond + 1) /
kMicrosecondsPerMillisecond;
}
#endif // OS_IOS
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index ba220d6..438049d 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
// Windows Timer Primer
//
// A good article: http://www.ddj.com/windows/184416651
@@ -34,6 +33,7 @@
#include "base/time/time.h"
#include <windows.h>
+
#include <mmsystem.h>
#include <stdint.h>
@@ -58,7 +58,7 @@
void MicrosecondsToFileTime(int64_t us, FILETIME* ft) {
DCHECK_GE(us, 0LL) << "Time is less than 0, negative values are not "
- "representable in FILETIME";
+ "representable in FILETIME";
// Multiply by 10 to convert microseconds to 100-nanoseconds. Bit_cast will
// handle alignment problems. This only works on little-endian machines.
@@ -467,7 +467,7 @@
return g_time_ticks_now_ignoring_override_function();
}
-} // namespace
+} // namespace base
namespace subtle {
TimeTicks TimeTicksNowIgnoringOverride() {
@@ -488,7 +488,8 @@
// Vista. So if we are using QPC then we are consistent which is the same as
// being high resolution.
//
- // [1] https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx
+ // [1]
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx
//
// "In general, the performance counter results are consistent across all
// processors in multi-core and multi-processor systems, even when measured on
@@ -504,8 +505,8 @@
// static
TimeTicks::Clock TimeTicks::GetClock() {
- return IsHighResolution() ?
- Clock::WIN_QPC : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME;
+ return IsHighResolution() ? Clock::WIN_QPC
+ : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME;
}
// ThreadTicks ----------------------------------------------------------------
diff --git a/base/value_iterators.h b/base/value_iterators.h
index 878ae7b..4c814c5 100644
--- a/base/value_iterators.h
+++ b/base/value_iterators.h
@@ -57,10 +57,8 @@
dict_iterator& operator--();
dict_iterator operator--(int);
- friend bool operator==(const dict_iterator& lhs,
- const dict_iterator& rhs);
- friend bool operator!=(const dict_iterator& lhs,
- const dict_iterator& rhs);
+ friend bool operator==(const dict_iterator& lhs, const dict_iterator& rhs);
+ friend bool operator!=(const dict_iterator& lhs, const dict_iterator& rhs);
private:
DictStorage::iterator dict_iter_;
@@ -104,9 +102,9 @@
const_dict_iterator operator--(int);
friend bool operator==(const const_dict_iterator& lhs,
- const const_dict_iterator& rhs);
+ const const_dict_iterator& rhs);
friend bool operator!=(const const_dict_iterator& lhs,
- const const_dict_iterator& rhs);
+ const const_dict_iterator& rhs);
private:
DictStorage::const_iterator dict_iter_;
diff --git a/base/values.cc b/base/values.cc
index 905a468..0b348b7 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -23,8 +23,8 @@
namespace {
-const char* const kTypeNames[] = {"null", "boolean", "integer",
- "string", "binary", "dictionary", "list"};
+const char* const kTypeNames[] = {"null", "boolean", "integer", "string",
+ "binary", "dictionary", "list"};
static_assert(arraysize(kTypeNames) ==
static_cast<size_t>(Value::Type::LIST) + 1,
"kTypeNames Has Wrong Size");
@@ -525,12 +525,11 @@
case Value::Type::DICTIONARY:
if (lhs.dict_.size() != rhs.dict_.size())
return false;
- return std::equal(std::begin(lhs.dict_), std::end(lhs.dict_),
- std::begin(rhs.dict_),
- [](const auto& u, const auto& v) {
- return std::tie(u.first, *u.second) ==
- std::tie(v.first, *v.second);
- });
+ return std::equal(
+ std::begin(lhs.dict_), std::end(lhs.dict_), std::begin(rhs.dict_),
+ [](const auto& u, const auto& v) {
+ return std::tie(u.first, *u.second) == std::tie(v.first, *v.second);
+ });
case Value::Type::LIST:
return lhs.list_ == rhs.list_;
}
@@ -738,8 +737,7 @@
return result.first->second.get();
}
-bool DictionaryValue::Get(StringPiece path,
- const Value** out_value) const {
+bool DictionaryValue::Get(StringPiece path, const Value** out_value) const {
DCHECK(IsStringUTF8(path));
StringPiece current_path(path);
const DictionaryValue* current_dictionary = this;
@@ -759,10 +757,9 @@
return current_dictionary->GetWithoutPathExpansion(current_path, out_value);
}
-bool DictionaryValue::Get(StringPiece path, Value** out_value) {
+bool DictionaryValue::Get(StringPiece path, Value** out_value) {
return static_cast<const DictionaryValue&>(*this).Get(
- path,
- const_cast<const Value**>(out_value));
+ path, const_cast<const Value**>(out_value));
}
bool DictionaryValue::GetBoolean(StringPiece path, bool* bool_value) const {
@@ -847,8 +844,7 @@
bool DictionaryValue::GetDictionary(StringPiece path,
DictionaryValue** out_value) {
return static_cast<const DictionaryValue&>(*this).GetDictionary(
- path,
- const_cast<const DictionaryValue**>(out_value));
+ path, const_cast<const DictionaryValue**>(out_value));
}
bool DictionaryValue::GetList(StringPiece path,
@@ -866,8 +862,7 @@
bool DictionaryValue::GetList(StringPiece path, ListValue** out_value) {
return static_cast<const DictionaryValue&>(*this).GetList(
- path,
- const_cast<const ListValue**>(out_value));
+ path, const_cast<const ListValue**>(out_value));
}
bool DictionaryValue::GetWithoutPathExpansion(StringPiece key,
@@ -885,8 +880,7 @@
bool DictionaryValue::GetWithoutPathExpansion(StringPiece key,
Value** out_value) {
return static_cast<const DictionaryValue&>(*this).GetWithoutPathExpansion(
- key,
- const_cast<const Value**>(out_value));
+ key, const_cast<const Value**>(out_value));
}
bool DictionaryValue::GetBooleanWithoutPathExpansion(StringPiece key,
@@ -946,8 +940,7 @@
const DictionaryValue& const_this =
static_cast<const DictionaryValue&>(*this);
return const_this.GetDictionaryWithoutPathExpansion(
- key,
- const_cast<const DictionaryValue**>(out_value));
+ key, const_cast<const DictionaryValue**>(out_value));
}
bool DictionaryValue::GetListWithoutPathExpansion(
@@ -966,10 +959,8 @@
bool DictionaryValue::GetListWithoutPathExpansion(StringPiece key,
ListValue** out_value) {
- return
- static_cast<const DictionaryValue&>(*this).GetListWithoutPathExpansion(
- key,
- const_cast<const ListValue**>(out_value));
+ return static_cast<const DictionaryValue&>(*this).GetListWithoutPathExpansion(
+ key, const_cast<const ListValue**>(out_value));
}
bool DictionaryValue::Remove(StringPiece path,
@@ -1015,8 +1006,7 @@
DictionaryValue* subdict = nullptr;
if (!GetDictionary(subdict_path, &subdict))
return false;
- result = subdict->RemovePath(path.substr(delimiter_position + 1),
- out_value);
+ result = subdict->RemovePath(path.substr(delimiter_position + 1), out_value);
if (result && subdict->empty())
RemoveWithoutPathExpansion(subdict_path, nullptr);
@@ -1118,8 +1108,7 @@
bool ListValue::Get(size_t index, Value** out_value) {
return static_cast<const ListValue&>(*this).Get(
- index,
- const_cast<const Value**>(out_value));
+ index, const_cast<const Value**>(out_value));
}
bool ListValue::GetBoolean(size_t index, bool* bool_value) const {
@@ -1169,8 +1158,7 @@
bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) {
return static_cast<const ListValue&>(*this).GetDictionary(
- index,
- const_cast<const DictionaryValue**>(out_value));
+ index, const_cast<const DictionaryValue**>(out_value));
}
bool ListValue::GetList(size_t index, const ListValue** out_value) const {
@@ -1187,8 +1175,7 @@
bool ListValue::GetList(size_t index, ListValue** out_value) {
return static_cast<const ListValue&>(*this).GetList(
- index,
- const_cast<const ListValue**>(out_value));
+ index, const_cast<const ListValue**>(out_value));
}
bool ListValue::Remove(size_t index, std::unique_ptr<Value>* out_value) {
diff --git a/base/values.h b/base/values.h
index 99e00c5..c3ec875 100644
--- a/base/values.h
+++ b/base/values.h
@@ -460,8 +460,7 @@
// DEPRECATED, use Value::FindPath(path) and Value::GetBlob() instead.
bool GetBinary(StringPiece path, Value** out_value);
// DEPRECATED, use Value::FindPath(path) and Value's Dictionary API instead.
- bool GetDictionary(StringPiece path,
- const DictionaryValue** out_value) const;
+ bool GetDictionary(StringPiece path, const DictionaryValue** out_value) const;
// DEPRECATED, use Value::FindPath(path) and Value's Dictionary API instead.
bool GetDictionary(StringPiece path, DictionaryValue** out_value);
// DEPRECATED, use Value::FindPath(path) and Value::GetList() instead.
@@ -742,18 +741,16 @@
std::ostream& operator<<(std::ostream& out, const Value& value);
inline std::ostream& operator<<(std::ostream& out,
- const DictionaryValue& value) {
+ const DictionaryValue& value) {
return out << static_cast<const Value&>(value);
}
-inline std::ostream& operator<<(std::ostream& out,
- const ListValue& value) {
+inline std::ostream& operator<<(std::ostream& out, const ListValue& value) {
return out << static_cast<const Value&>(value);
}
// Stream operator so that enum class Types can be used in log statements.
-std::ostream& operator<<(std::ostream& out,
- const Value::Type& type);
+std::ostream& operator<<(std::ostream& out, const Value::Type& type);
} // namespace base
diff --git a/base/win/com_init_check_hook.cc b/base/win/com_init_check_hook.cc
index 3da7622..7055bb0 100644
--- a/base/win/com_init_check_hook.cc
+++ b/base/win/com_init_check_hook.cc
@@ -4,10 +4,10 @@
#include "base/win/com_init_check_hook.h"
-#include <windows.h>
#include <objbase.h>
#include <stdint.h>
#include <string.h>
+#include <windows.h>
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
@@ -134,7 +134,8 @@
// See banner comment above why this subtracts 5 bytes.
co_create_instance_padded_address_ =
reinterpret_cast<uint32_t>(
- GetProcAddress(ole32_library_, "CoCreateInstance")) - 5;
+ GetProcAddress(ole32_library_, "CoCreateInstance")) -
+ 5;
// See banner comment above why this adds 7 bytes.
original_co_create_instance_body_function_ =
diff --git a/base/win/core_winrt_util.h b/base/win/core_winrt_util.h
index 4698f78..d760c79 100644
--- a/base/win/core_winrt_util.h
+++ b/base/win/core_winrt_util.h
@@ -30,11 +30,10 @@
void RoUninitialize();
HRESULT RoGetActivationFactory(HSTRING class_id,
- const IID& iid,
- void** out_factory);
+ const IID& iid,
+ void** out_factory);
-HRESULT RoActivateInstance(HSTRING class_id,
- IInspectable** instance);
+HRESULT RoActivateInstance(HSTRING class_id, IInspectable** instance);
// Retrieves an activation factory for the type specified.
template <typename InterfaceType, char16 const* runtime_class_id>
diff --git a/base/win/enum_variant.cc b/base/win/enum_variant.cc
index 2975560..fd81775 100644
--- a/base/win/enum_variant.cc
+++ b/base/win/enum_variant.cc
@@ -12,13 +12,9 @@
namespace win {
EnumVariant::EnumVariant(unsigned long count)
- : items_(new VARIANT[count]),
- count_(count),
- current_index_(0) {
-}
+ : items_(new VARIANT[count]), count_(count), current_index_(0) {}
-EnumVariant::~EnumVariant() {
-}
+EnumVariant::~EnumVariant() {}
VARIANT* EnumVariant::ItemAt(unsigned long index) {
DCHECK(index < count_);
diff --git a/base/win/enum_variant.h b/base/win/enum_variant.h
index b61fc8f..d12f350 100644
--- a/base/win/enum_variant.h
+++ b/base/win/enum_variant.h
@@ -15,9 +15,7 @@
namespace win {
// A simple implementation of IEnumVARIANT.
-class EnumVariant
- : public IEnumVARIANT,
- public IUnknownImpl {
+class EnumVariant : public IEnumVARIANT, public IUnknownImpl {
public:
// The constructor allocates an array of size |count|. Then use
// ItemAt to set the value of each item in the array to initialize it.
diff --git a/base/win/event_trace_consumer.h b/base/win/event_trace_consumer.h
index 9f97e0d..93e8a24 100644
--- a/base/win/event_trace_consumer.h
+++ b/base/win/event_trace_consumer.h
@@ -6,10 +6,10 @@
#ifndef BASE_WIN_EVENT_TRACE_CONSUMER_H_
#define BASE_WIN_EVENT_TRACE_CONSUMER_H_
-#include <windows.h>
-#include <wmistr.h>
#include <evntrace.h>
#include <stddef.h>
+#include <windows.h>
+#include <wmistr.h>
#include <vector>
#include "base/macros.h"
@@ -34,12 +34,9 @@
class EtwTraceConsumerBase {
public:
// Constructs a closed consumer.
- EtwTraceConsumerBase() {
- }
+ EtwTraceConsumerBase() {}
- ~EtwTraceConsumerBase() {
- Close();
- }
+ ~EtwTraceConsumerBase() { Close(); }
// Opens the named realtime session, which must be existent.
// Note: You can use OpenRealtimeSession or OpenFileSession
@@ -62,8 +59,7 @@
protected:
// Override in subclasses to handle events.
- static void ProcessEvent(EVENT_TRACE* event) {
- }
+ static void ProcessEvent(EVENT_TRACE* event) {}
// Override in subclasses to handle buffers.
static bool ProcessBuffer(EVENT_TRACE_LOGFILE* buffer) {
return true; // keep going
@@ -85,8 +81,8 @@
DISALLOW_COPY_AND_ASSIGN(EtwTraceConsumerBase);
};
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::OpenRealtimeSession(
+template <class ImplClass>
+inline HRESULT EtwTraceConsumerBase<ImplClass>::OpenRealtimeSession(
const wchar_t* session_name) {
EVENT_TRACE_LOGFILE logfile = {};
logfile.LoggerName = const_cast<wchar_t*>(session_name);
@@ -102,8 +98,8 @@
return S_OK;
}
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::OpenFileSession(
+template <class ImplClass>
+inline HRESULT EtwTraceConsumerBase<ImplClass>::OpenFileSession(
const wchar_t* file_name) {
EVENT_TRACE_LOGFILE logfile = {};
logfile.LogFileName = const_cast<wchar_t*>(file_name);
@@ -118,17 +114,16 @@
return S_OK;
}
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::Consume() {
- ULONG err = ::ProcessTrace(&trace_handles_[0],
- static_cast<ULONG>(trace_handles_.size()),
- NULL,
- NULL);
+template <class ImplClass>
+inline HRESULT EtwTraceConsumerBase<ImplClass>::Consume() {
+ ULONG err =
+ ::ProcessTrace(&trace_handles_[0],
+ static_cast<ULONG>(trace_handles_.size()), NULL, NULL);
return HRESULT_FROM_WIN32(err);
}
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::Close() {
+template <class ImplClass>
+inline HRESULT EtwTraceConsumerBase<ImplClass>::Close() {
HRESULT hr = S_OK;
for (size_t i = 0; i < trace_handles_.size(); ++i) {
if (NULL != trace_handles_[i]) {
diff --git a/base/win/event_trace_controller.cc b/base/win/event_trace_controller.cc
deleted file mode 100644
index ff392a3..0000000
--- a/base/win/event_trace_controller.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Implementation of a Windows event trace controller class.
-#include "base/win/event_trace_controller.h"
-#include "base/logging.h"
-
-namespace base {
-namespace win {
-
-EtwTraceProperties::EtwTraceProperties() {
- memset(buffer_, 0, sizeof(buffer_));
- EVENT_TRACE_PROPERTIES* prop = get();
-
- prop->Wnode.BufferSize = sizeof(buffer_);
- prop->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
- prop->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
- prop->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) +
- sizeof(wchar_t) * kMaxStringLen;
-}
-
-HRESULT EtwTraceProperties::SetLoggerName(const wchar_t* logger_name) {
- size_t len = wcslen(logger_name) + 1;
- if (kMaxStringLen < len)
- return E_INVALIDARG;
-
- memcpy(buffer_ + get()->LoggerNameOffset,
- logger_name,
- sizeof(wchar_t) * len);
- return S_OK;
-}
-
-HRESULT EtwTraceProperties::SetLoggerFileName(const wchar_t* logger_file_name) {
- size_t len = wcslen(logger_file_name) + 1;
- if (kMaxStringLen < len)
- return E_INVALIDARG;
-
- memcpy(buffer_ + get()->LogFileNameOffset,
- logger_file_name,
- sizeof(wchar_t) * len);
- return S_OK;
-}
-
-EtwTraceController::EtwTraceController() : session_(NULL) {
-}
-
-EtwTraceController::~EtwTraceController() {
- if (session_)
- Stop(NULL);
-}
-
-HRESULT EtwTraceController::Start(const wchar_t* session_name,
- EtwTraceProperties* prop) {
- DCHECK(NULL == session_ && session_name_.empty());
- EtwTraceProperties ignore;
- if (prop == NULL)
- prop = &ignore;
-
- HRESULT hr = Start(session_name, prop, &session_);
- if (SUCCEEDED(hr))
- session_name_ = session_name;
-
- return hr;
-}
-
-HRESULT EtwTraceController::StartFileSession(const wchar_t* session_name,
- const wchar_t* logfile_path, bool realtime) {
- DCHECK(NULL == session_ && session_name_.empty());
-
- EtwTraceProperties prop;
- prop.SetLoggerFileName(logfile_path);
- EVENT_TRACE_PROPERTIES& p = *prop.get();
- p.Wnode.ClientContext = 1; // QPC timer accuracy.
- p.LogFileMode = EVENT_TRACE_FILE_MODE_SEQUENTIAL; // Sequential log.
- if (realtime)
- p.LogFileMode |= EVENT_TRACE_REAL_TIME_MODE;
-
- p.MaximumFileSize = 100; // 100M file size.
- p.FlushTimer = 30; // 30 seconds flush lag.
- return Start(session_name, &prop);
-}
-
-HRESULT EtwTraceController::StartRealtimeSession(const wchar_t* session_name,
- size_t buffer_size) {
- DCHECK(NULL == session_ && session_name_.empty());
- EtwTraceProperties prop;
- EVENT_TRACE_PROPERTIES& p = *prop.get();
- p.LogFileMode = EVENT_TRACE_REAL_TIME_MODE | EVENT_TRACE_USE_PAGED_MEMORY;
- p.FlushTimer = 1; // flush every second.
- p.BufferSize = 16; // 16 K buffers.
- p.LogFileNameOffset = 0;
- return Start(session_name, &prop);
-}
-
-HRESULT EtwTraceController::EnableProvider(REFGUID provider, UCHAR level,
- ULONG flags) {
- ULONG error = ::EnableTrace(TRUE, flags, level, &provider, session_);
- return HRESULT_FROM_WIN32(error);
-}
-
-HRESULT EtwTraceController::DisableProvider(REFGUID provider) {
- ULONG error = ::EnableTrace(FALSE, 0, 0, &provider, session_);
- return HRESULT_FROM_WIN32(error);
-}
-
-HRESULT EtwTraceController::Stop(EtwTraceProperties* properties) {
- EtwTraceProperties ignore;
- if (properties == NULL)
- properties = &ignore;
-
- ULONG error = ::ControlTrace(session_, NULL, properties->get(),
- EVENT_TRACE_CONTROL_STOP);
- if (ERROR_SUCCESS != error)
- return HRESULT_FROM_WIN32(error);
-
- session_ = NULL;
- session_name_.clear();
- return S_OK;
-}
-
-HRESULT EtwTraceController::Flush(EtwTraceProperties* properties) {
- EtwTraceProperties ignore;
- if (properties == NULL)
- properties = &ignore;
-
- ULONG error = ::ControlTrace(session_, NULL, properties->get(),
- EVENT_TRACE_CONTROL_FLUSH);
- if (ERROR_SUCCESS != error)
- return HRESULT_FROM_WIN32(error);
-
- return S_OK;
-}
-
-HRESULT EtwTraceController::Start(const wchar_t* session_name,
- EtwTraceProperties* properties, TRACEHANDLE* session_handle) {
- DCHECK(properties != NULL);
- ULONG err = ::StartTrace(session_handle, session_name, properties->get());
- return HRESULT_FROM_WIN32(err);
-}
-
-HRESULT EtwTraceController::Query(const wchar_t* session_name,
- EtwTraceProperties* properties) {
- ULONG err = ::ControlTrace(NULL, session_name, properties->get(),
- EVENT_TRACE_CONTROL_QUERY);
- return HRESULT_FROM_WIN32(err);
-};
-
-HRESULT EtwTraceController::Update(const wchar_t* session_name,
- EtwTraceProperties* properties) {
- DCHECK(properties != NULL);
- ULONG err = ::ControlTrace(NULL, session_name, properties->get(),
- EVENT_TRACE_CONTROL_UPDATE);
- return HRESULT_FROM_WIN32(err);
-}
-
-HRESULT EtwTraceController::Stop(const wchar_t* session_name,
- EtwTraceProperties* properties) {
- DCHECK(properties != NULL);
- ULONG err = ::ControlTrace(NULL, session_name, properties->get(),
- EVENT_TRACE_CONTROL_STOP);
- return HRESULT_FROM_WIN32(err);
-}
-
-HRESULT EtwTraceController::Flush(const wchar_t* session_name,
- EtwTraceProperties* properties) {
- DCHECK(properties != NULL);
- ULONG err = ::ControlTrace(NULL, session_name, properties->get(),
- EVENT_TRACE_CONTROL_FLUSH);
- return HRESULT_FROM_WIN32(err);
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/event_trace_controller.h b/base/win/event_trace_controller.h
deleted file mode 100644
index 17b82bc..0000000
--- a/base/win/event_trace_controller.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Declaration of a Windows event trace controller class.
-// The controller takes care of creating and manipulating event trace
-// sessions.
-//
-// Event tracing for Windows is a system-provided service that provides
-// logging control and high-performance transport for generic, binary trace
-// events. Event trace providers register with the system by their name,
-// which is a GUID, and can from that point forward receive callbacks that
-// start or end tracing and that change their trace level and enable mask.
-//
-// A trace controller can create an event tracing session, which either
-// sends events to a binary file, or to a realtime consumer, or both.
-//
-// A trace consumer consumes events from zero or one realtime session,
-// as well as potentially from multiple binary trace files.
-#ifndef BASE_WIN_EVENT_TRACE_CONTROLLER_H_
-#define BASE_WIN_EVENT_TRACE_CONTROLLER_H_
-
-#include <windows.h>
-#include <wmistr.h>
-#include <evntrace.h>
-#include <stddef.h>
-#include <string>
-
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// Utility class to make it easier to work with EVENT_TRACE_PROPERTIES.
-// The EVENT_TRACE_PROPERTIES structure contains information about an
-// event tracing session.
-class EtwTraceProperties {
- public:
- EtwTraceProperties();
-
- EVENT_TRACE_PROPERTIES* get() {
- return &properties_;
- }
-
- const EVENT_TRACE_PROPERTIES* get() const {
- return reinterpret_cast<const EVENT_TRACE_PROPERTIES*>(&properties_);
- }
-
- const wchar_t* GetLoggerName() const {
- return reinterpret_cast<const wchar_t *>(buffer_ + get()->LoggerNameOffset);
- }
-
- // Copies logger_name to the properties structure.
- HRESULT SetLoggerName(const wchar_t* logger_name);
- const wchar_t* GetLoggerFileName() const {
- return reinterpret_cast<const wchar_t*>(buffer_ + get()->LogFileNameOffset);
- }
-
- // Copies logger_file_name to the properties structure.
- HRESULT SetLoggerFileName(const wchar_t* logger_file_name);
-
- // Max string len for name and session name is 1024 per documentation.
- static const size_t kMaxStringLen = 1024;
- // Properties buffer allocates space for header and for
- // max length for name and session name.
- static const size_t kBufSize = sizeof(EVENT_TRACE_PROPERTIES)
- + 2 * sizeof(wchar_t) * (kMaxStringLen);
-
- private:
- // The EVENT_TRACE_PROPERTIES structure needs to be overlaid on a
- // larger buffer to allow storing the logger name and logger file
- // name contiguously with the structure.
- union {
- public:
- // Our properties header.
- EVENT_TRACE_PROPERTIES properties_;
- // The actual size of the buffer is forced by this member.
- char buffer_[kBufSize];
- };
-
- DISALLOW_COPY_AND_ASSIGN(EtwTraceProperties);
-};
-
-// This class implements an ETW controller, which knows how to start and
-// stop event tracing sessions, as well as controlling ETW provider
-// log levels and enable bit masks under the session.
-class EtwTraceController {
- public:
- EtwTraceController();
- ~EtwTraceController();
-
- // Start a session with given name and properties.
- HRESULT Start(const wchar_t* session_name, EtwTraceProperties* prop);
-
- // Starts a session tracing to a file with some default properties.
- HRESULT StartFileSession(const wchar_t* session_name,
- const wchar_t* logfile_path,
- bool realtime = false);
-
- // Starts a realtime session with some default properties.
- HRESULT StartRealtimeSession(const wchar_t* session_name,
- size_t buffer_size);
-
- // Enables "provider" at "level" for this session.
- // This will cause all providers registered with the GUID
- // "provider" to start tracing at the new level, systemwide.
- HRESULT EnableProvider(const GUID& provider, UCHAR level,
- ULONG flags = 0xFFFFFFFF);
- // Disables "provider".
- HRESULT DisableProvider(const GUID& provider);
-
- // Stops our session and retrieve the new properties of the session,
- // properties may be NULL.
- HRESULT Stop(EtwTraceProperties* properties);
-
- // Flushes our session and retrieve the current properties,
- // properties may be NULL.
- HRESULT Flush(EtwTraceProperties* properties);
-
- // Static utility functions for controlling
- // sessions we don't necessarily own.
- static HRESULT Start(const wchar_t* session_name,
- EtwTraceProperties* properties,
- TRACEHANDLE* session_handle);
-
- static HRESULT Query(const wchar_t* session_name,
- EtwTraceProperties* properties);
-
- static HRESULT Update(const wchar_t* session_name,
- EtwTraceProperties* properties);
-
- static HRESULT Stop(const wchar_t* session_name,
- EtwTraceProperties* properties);
- static HRESULT Flush(const wchar_t* session_name,
- EtwTraceProperties* properties);
-
- // Accessors.
- TRACEHANDLE session() const { return session_; }
- const wchar_t* session_name() const { return session_name_.c_str(); }
-
- private:
- std::wstring session_name_;
- TRACEHANDLE session_;
-
- DISALLOW_COPY_AND_ASSIGN(EtwTraceController);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_EVENT_TRACE_CONTROLLER_H_
diff --git a/base/win/event_trace_provider.cc b/base/win/event_trace_provider.cc
deleted file mode 100644
index 8fcf67d..0000000
--- a/base/win/event_trace_provider.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-#include "base/win/event_trace_provider.h"
-#include <windows.h>
-#include <cguid.h>
-
-namespace base {
-namespace win {
-
-TRACE_GUID_REGISTRATION EtwTraceProvider::obligatory_guid_registration_ = {
- &GUID_NULL,
- NULL
-};
-
-EtwTraceProvider::EtwTraceProvider(const GUID& provider_name)
- : provider_name_(provider_name), registration_handle_(NULL),
- session_handle_(NULL), enable_flags_(0), enable_level_(0) {
-}
-
-EtwTraceProvider::EtwTraceProvider()
- : provider_name_(GUID_NULL), registration_handle_(NULL),
- session_handle_(NULL), enable_flags_(0), enable_level_(0) {
-}
-
-EtwTraceProvider::~EtwTraceProvider() {
- Unregister();
-}
-
-ULONG EtwTraceProvider::EnableEvents(void* buffer) {
- session_handle_ = ::GetTraceLoggerHandle(buffer);
- if (NULL == session_handle_) {
- return ::GetLastError();
- }
-
- enable_flags_ = ::GetTraceEnableFlags(session_handle_);
- enable_level_ = ::GetTraceEnableLevel(session_handle_);
-
- // Give subclasses a chance to digest the state change.
- OnEventsEnabled();
-
- return ERROR_SUCCESS;
-}
-
-ULONG EtwTraceProvider::DisableEvents() {
- // Give subclasses a chance to digest the state change.
- OnEventsDisabled();
-
- enable_level_ = 0;
- enable_flags_ = 0;
- session_handle_ = NULL;
-
- PostEventsDisabled();
-
- return ERROR_SUCCESS;
-}
-
-ULONG EtwTraceProvider::Callback(WMIDPREQUESTCODE request, void* buffer) {
- switch (request) {
- case WMI_ENABLE_EVENTS:
- return EnableEvents(buffer);
- case WMI_DISABLE_EVENTS:
- return DisableEvents();
- default:
- return ERROR_INVALID_PARAMETER;
- }
- // Not reached.
-}
-
-ULONG WINAPI EtwTraceProvider::ControlCallback(WMIDPREQUESTCODE request,
- void* context, ULONG *reserved, void* buffer) {
- EtwTraceProvider *provider = reinterpret_cast<EtwTraceProvider*>(context);
-
- return provider->Callback(request, buffer);
-}
-
-ULONG EtwTraceProvider::Register() {
- if (provider_name_ == GUID_NULL)
- return ERROR_INVALID_NAME;
-
- return ::RegisterTraceGuids(ControlCallback, this, &provider_name_,
- 1, &obligatory_guid_registration_, NULL, NULL, ®istration_handle_);
-}
-
-ULONG EtwTraceProvider::Unregister() {
- // If a session is active, notify subclasses that it's going away.
- if (session_handle_ != NULL)
- DisableEvents();
-
- ULONG ret = ::UnregisterTraceGuids(registration_handle_);
-
- registration_handle_ = NULL;
-
- return ret;
-}
-
-ULONG EtwTraceProvider::Log(const EtwEventClass& event_class,
- EtwEventType type, EtwEventLevel level, const char *message) {
- if (NULL == session_handle_ || enable_level_ < level)
- return ERROR_SUCCESS; // No one listening.
-
- EtwMofEvent<1> event(event_class, type, level);
-
- event.fields[0].DataPtr = reinterpret_cast<ULONG64>(message);
- event.fields[0].Length = message ?
- static_cast<ULONG>(sizeof(message[0]) * (1 + strlen(message))) : 0;
-
- return ::TraceEvent(session_handle_, &event.header);
-}
-
-ULONG EtwTraceProvider::Log(const EtwEventClass& event_class,
- EtwEventType type, EtwEventLevel level, const wchar_t *message) {
- if (NULL == session_handle_ || enable_level_ < level)
- return ERROR_SUCCESS; // No one listening.
-
- EtwMofEvent<1> event(event_class, type, level);
-
- event.fields[0].DataPtr = reinterpret_cast<ULONG64>(message);
- event.fields[0].Length = message ?
- static_cast<ULONG>(sizeof(message[0]) * (1 + wcslen(message))) : 0;
-
- return ::TraceEvent(session_handle_, &event.header);
-}
-
-ULONG EtwTraceProvider::Log(EVENT_TRACE_HEADER* event) {
- if (enable_level_ < event->Class.Level)
- return ERROR_SUCCESS;
-
- return ::TraceEvent(session_handle_, event);
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/event_trace_provider.h b/base/win/event_trace_provider.h
deleted file mode 100644
index 321f539..0000000
--- a/base/win/event_trace_provider.h
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Declaration of a Windows event trace provider class, to allow using
-// Windows Event Tracing for logging transport and control.
-#ifndef BASE_WIN_EVENT_TRACE_PROVIDER_H_
-#define BASE_WIN_EVENT_TRACE_PROVIDER_H_
-
-#include <windows.h>
-#include <wmistr.h>
-#include <evntrace.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#include <limits>
-
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-typedef GUID EtwEventClass;
-typedef UCHAR EtwEventType;
-typedef UCHAR EtwEventLevel;
-typedef USHORT EtwEventVersion;
-typedef ULONG EtwEventFlags;
-
-// Base class is a POD for correctness.
-template <size_t N> struct EtwMofEventBase {
- EVENT_TRACE_HEADER header;
- MOF_FIELD fields[N];
-};
-
-// Utility class to auto-initialize event trace header structures.
-template <size_t N> class EtwMofEvent: public EtwMofEventBase<N> {
- public:
- typedef EtwMofEventBase<N> Super;
-
- // Clang and the C++ standard don't allow unqualified lookup into dependent
- // bases, hence these using decls to explicitly pull the names out.
- using EtwMofEventBase<N>::header;
- using EtwMofEventBase<N>::fields;
-
- EtwMofEvent() {
- memset(static_cast<Super*>(this), 0, sizeof(Super));
- }
-
- EtwMofEvent(const EtwEventClass& event_class, EtwEventType type,
- EtwEventLevel level) {
- memset(static_cast<Super*>(this), 0, sizeof(Super));
- header.Size = sizeof(Super);
- header.Guid = event_class;
- header.Class.Type = type;
- header.Class.Level = level;
- header.Flags = WNODE_FLAG_TRACED_GUID | WNODE_FLAG_USE_MOF_PTR;
- }
-
- EtwMofEvent(const EtwEventClass& event_class, EtwEventType type,
- EtwEventVersion version, EtwEventLevel level) {
- memset(static_cast<Super*>(this), 0, sizeof(Super));
- header.Size = sizeof(Super);
- header.Guid = event_class;
- header.Class.Type = type;
- header.Class.Version = version;
- header.Class.Level = level;
- header.Flags = WNODE_FLAG_TRACED_GUID | WNODE_FLAG_USE_MOF_PTR;
- }
-
- void SetField(size_t field, size_t size, const void* data) {
- // DCHECK(field < N);
- if ((field < N) && (size <= std::numeric_limits<uint32_t>::max())) {
- fields[field].DataPtr = reinterpret_cast<ULONG64>(data);
- fields[field].Length = static_cast<ULONG>(size);
- }
- }
-
- EVENT_TRACE_HEADER* get() { return& header; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(EtwMofEvent);
-};
-
-// Trace provider with Event Tracing for Windows. The trace provider
-// registers with ETW by its name which is a GUID. ETW calls back to
-// the object whenever the trace level or enable flags for this provider
-// name changes.
-// Users of this class can test whether logging is currently enabled at
-// a particular trace level, and whether particular enable flags are set,
-// before other resources are consumed to generate and issue the log
-// messages themselves.
-class EtwTraceProvider {
- public:
- // Creates an event trace provider identified by provider_name, which
- // will be the name registered with Event Tracing for Windows (ETW).
- explicit EtwTraceProvider(const GUID& provider_name);
-
- // Creates an unnamed event trace provider, the provider must be given
- // a name before registration.
- EtwTraceProvider();
- virtual ~EtwTraceProvider();
-
- // Registers the trace provider with Event Tracing for Windows.
- // Note: from this point forward ETW may call the provider's control
- // callback. If the provider's name is enabled in some trace session
- // already, the callback may occur recursively from this call, so
- // call this only when you're ready to handle callbacks.
- ULONG Register();
- // Unregisters the trace provider with ETW.
- ULONG Unregister();
-
- // Accessors.
- void set_provider_name(const GUID& provider_name) {
- provider_name_ = provider_name;
- }
- const GUID& provider_name() const { return provider_name_; }
- TRACEHANDLE registration_handle() const { return registration_handle_; }
- TRACEHANDLE session_handle() const { return session_handle_; }
- EtwEventFlags enable_flags() const { return enable_flags_; }
- EtwEventLevel enable_level() const { return enable_level_; }
-
- // Returns true iff logging should be performed for "level" and "flags".
- // Note: flags is treated as a bitmask, and should normally have a single
- // bit set, to test whether to log for a particular sub "facility".
- bool ShouldLog(EtwEventLevel level, EtwEventFlags flags) {
- return NULL != session_handle_ && level >= enable_level_ &&
- (0 != (flags & enable_flags_));
- }
-
- // Simple wrappers to log Unicode and ANSI strings.
- // Do nothing if !ShouldLog(level, 0xFFFFFFFF).
- ULONG Log(const EtwEventClass& event_class, EtwEventType type,
- EtwEventLevel level, const char *message);
- ULONG Log(const EtwEventClass& event_class, EtwEventType type,
- EtwEventLevel level, const wchar_t *message);
-
- // Log the provided event.
- ULONG Log(EVENT_TRACE_HEADER* event);
-
- protected:
- // Called after events have been enabled, override in subclasses
- // to set up state or log at the start of a session.
- // Note: This function may be called ETW's thread and may be racy,
- // bring your own locking if needed.
- virtual void OnEventsEnabled() {}
-
- // Called just before events are disabled, override in subclasses
- // to tear down state or log at the end of a session.
- // Note: This function may be called ETW's thread and may be racy,
- // bring your own locking if needed.
- virtual void OnEventsDisabled() {}
-
- // Called just after events have been disabled, override in subclasses
- // to tear down state at the end of a session. At this point it's
- // to late to log anything to the session.
- // Note: This function may be called ETW's thread and may be racy,
- // bring your own locking if needed.
- virtual void PostEventsDisabled() {}
-
- private:
- ULONG EnableEvents(PVOID buffer);
- ULONG DisableEvents();
- ULONG Callback(WMIDPREQUESTCODE request, PVOID buffer);
- static ULONG WINAPI ControlCallback(WMIDPREQUESTCODE request, PVOID context,
- ULONG *reserved, PVOID buffer);
-
- GUID provider_name_;
- TRACEHANDLE registration_handle_;
- TRACEHANDLE session_handle_;
- EtwEventFlags enable_flags_;
- EtwEventLevel enable_level_;
-
- // We don't use this, but on XP we're obliged to pass one in to
- // RegisterTraceGuids. Non-const, because that's how the API needs it.
- static TRACE_GUID_REGISTRATION obligatory_guid_registration_;
-
- DISALLOW_COPY_AND_ASSIGN(EtwTraceProvider);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_EVENT_TRACE_PROVIDER_H_
diff --git a/base/win/iat_patch_function.cc b/base/win/iat_patch_function.cc
index 3cc747b..5f151f9 100644
--- a/base/win/iat_patch_function.cc
+++ b/base/win/iat_patch_function.cc
@@ -42,11 +42,15 @@
return iat_function.pointer;
}
-bool InterceptEnumCallback(const base::win::PEImage& image, const char* module,
- DWORD ordinal, const char* name, DWORD hint,
- IMAGE_THUNK_DATA* iat, void* cookie) {
+bool InterceptEnumCallback(const base::win::PEImage& image,
+ const char* module,
+ DWORD ordinal,
+ const char* name,
+ DWORD hint,
+ IMAGE_THUNK_DATA* iat,
+ void* cookie) {
InterceptFunctionInformation* intercept_information =
- reinterpret_cast<InterceptFunctionInformation*>(cookie);
+ reinterpret_cast<InterceptFunctionInformation*>(cookie);
if (NULL == intercept_information) {
NOTREACHED();
@@ -56,8 +60,8 @@
DCHECK(module);
if ((0 == lstrcmpiA(module, intercept_information->imported_from_module)) &&
- (NULL != name) &&
- (0 == lstrcmpiA(name, intercept_information->function_name))) {
+ (NULL != name) &&
+ (0 == lstrcmpiA(name, intercept_information->function_name))) {
// Save the old pointer.
if (NULL != intercept_information->old_function) {
*(intercept_information->old_function) = GetIATFunction(iat);
@@ -101,11 +105,12 @@
// as defined in winerror.h
DWORD InterceptImportedFunction(HMODULE module_handle,
const char* imported_from_module,
- const char* function_name, void* new_function,
+ const char* function_name,
+ void* new_function,
void** old_function,
IMAGE_THUNK_DATA** iat_thunk) {
if ((NULL == module_handle) || (NULL == imported_from_module) ||
- (NULL == function_name) || (NULL == new_function)) {
+ (NULL == function_name) || (NULL == new_function)) {
NOTREACHED();
return ERROR_INVALID_PARAMETER;
}
@@ -116,14 +121,13 @@
return ERROR_INVALID_PARAMETER;
}
- InterceptFunctionInformation intercept_information = {
- false,
- imported_from_module,
- function_name,
- new_function,
- old_function,
- iat_thunk,
- ERROR_GEN_FAILURE};
+ InterceptFunctionInformation intercept_information = {false,
+ imported_from_module,
+ function_name,
+ new_function,
+ old_function,
+ iat_thunk,
+ ERROR_GEN_FAILURE};
// First go through the IAT. If we don't find the import we are looking
// for in IAT, search delay import table.
@@ -170,8 +174,7 @@
: module_handle_(NULL),
intercept_function_(NULL),
original_function_(NULL),
- iat_thunk_(NULL) {
-}
+ iat_thunk_(NULL) {}
IATPatchFunction::~IATPatchFunction() {
if (NULL != intercept_function_) {
@@ -210,12 +213,9 @@
DCHECK_EQ(static_cast<void*>(NULL), intercept_function_);
DCHECK(module);
- DWORD error = InterceptImportedFunction(module,
- imported_from_module,
- function_name,
- new_function,
- &original_function_,
- &iat_thunk_);
+ DWORD error =
+ InterceptImportedFunction(module, imported_from_module, function_name,
+ new_function, &original_function_, &iat_thunk_);
if (NO_ERROR == error) {
DCHECK_NE(original_function_, intercept_function_);
@@ -226,8 +226,7 @@
}
DWORD IATPatchFunction::Unpatch() {
- DWORD error = RestoreImportedFunction(intercept_function_,
- original_function_,
+ DWORD error = RestoreImportedFunction(intercept_function_, original_function_,
iat_thunk_);
DCHECK_EQ(static_cast<DWORD>(NO_ERROR), error);
diff --git a/base/win/iat_patch_function.h b/base/win/iat_patch_function.h
index 30f0ab9..c9f2d6c 100644
--- a/base/win/iat_patch_function.h
+++ b/base/win/iat_patch_function.h
@@ -58,13 +58,10 @@
// Returns: Windows error code (winerror.h). NO_ERROR if successful
DWORD Unpatch();
- bool is_patched() const {
- return (NULL != intercept_function_);
- }
+ bool is_patched() const { return (NULL != intercept_function_); }
void* original_function() const;
-
private:
HMODULE module_handle_;
void* intercept_function_;
diff --git a/base/win/iunknown_impl.cc b/base/win/iunknown_impl.cc
index 2a88439..2d83523 100644
--- a/base/win/iunknown_impl.cc
+++ b/base/win/iunknown_impl.cc
@@ -7,12 +7,9 @@
namespace base {
namespace win {
-IUnknownImpl::IUnknownImpl()
- : ref_count_(0) {
-}
+IUnknownImpl::IUnknownImpl() : ref_count_(0) {}
-IUnknownImpl::~IUnknownImpl() {
-}
+IUnknownImpl::~IUnknownImpl() {}
ULONG STDMETHODCALLTYPE IUnknownImpl::AddRef() {
ref_count_.Increment();
diff --git a/base/win/patch_util.cc b/base/win/patch_util.cc
index eb3bd65..c53a8e4 100644
--- a/base/win/patch_util.cc
+++ b/base/win/patch_util.cc
@@ -49,4 +49,4 @@
} // namespace internal
} // namespace win
-} // namespace bsae
+} // namespace base
diff --git a/base/win/patch_util.h b/base/win/patch_util.h
index 02ac72c..6668273 100644
--- a/base/win/patch_util.h
+++ b/base/win/patch_util.h
@@ -7,7 +7,6 @@
#include <windows.h>
-
namespace base {
namespace win {
namespace internal {
@@ -19,6 +18,6 @@
} // namespace internal
} // namespace win
-} // namespace bsae
+} // namespace base
#endif // BASE_WIN_PATCH_UTIL_H_
diff --git a/base/win/pe_image.cc b/base/win/pe_image.cc
index 4705348..ea58504 100644
--- a/base/win/pe_image.cc
+++ b/base/win/pe_image.cc
@@ -48,9 +48,11 @@
} // namespace
// Callback used to enumerate imports. See EnumImportChunksFunction.
-bool ProcessImportChunk(const PEImage &image, LPCSTR module,
+bool ProcessImportChunk(const PEImage& image,
+ LPCSTR module,
PIMAGE_THUNK_DATA name_table,
- PIMAGE_THUNK_DATA iat, PVOID cookie) {
+ PIMAGE_THUNK_DATA iat,
+ PVOID cookie) {
EnumAllImportsStorage& storage =
*reinterpret_cast<EnumAllImportsStorage*>(cookie);
@@ -120,8 +122,8 @@
for (UINT i = 0; NULL != (section = GetSectionHeader(i)); i++) {
// Don't use the virtual RVAToAddr.
- PBYTE start = reinterpret_cast<PBYTE>(
- PEImage::RVAToAddr(section->VirtualAddress));
+ PBYTE start =
+ reinterpret_cast<PBYTE>(PEImage::RVAToAddr(section->VirtualAddress));
DWORD size = section->Misc.VirtualSize;
@@ -157,10 +159,9 @@
GetImageDirectoryEntrySize(IMAGE_DIRECTORY_ENTRY_DEBUG);
PIMAGE_DEBUG_DIRECTORY debug_directory =
reinterpret_cast<PIMAGE_DEBUG_DIRECTORY>(
- GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_DEBUG));
+ GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_DEBUG));
- size_t directory_count =
- debug_directory_size / sizeof(IMAGE_DEBUG_DIRECTORY);
+ size_t directory_count = debug_directory_size / sizeof(IMAGE_DEBUG_DIRECTORY);
for (size_t index = 0; index < directory_count; ++index) {
if (debug_directory[index].Type == IMAGE_DEBUG_TYPE_CODEVIEW) {
@@ -193,8 +194,8 @@
if (!GetProcOrdinal(name, &ordinal))
return NULL;
- PDWORD functions = reinterpret_cast<PDWORD>(
- RVAToAddr(exports->AddressOfFunctions));
+ PDWORD functions =
+ reinterpret_cast<PDWORD>(RVAToAddr(exports->AddressOfFunctions));
return functions + ordinal - exports->Base;
}
@@ -217,7 +218,7 @@
return reinterpret_cast<FARPROC>(function);
}
-bool PEImage::GetProcOrdinal(LPCSTR function_name, WORD *ordinal) const {
+bool PEImage::GetProcOrdinal(LPCSTR function_name, WORD* ordinal) const {
if (NULL == ordinal)
return false;
@@ -257,9 +258,8 @@
if (cmp != 0)
return false;
-
- PWORD ordinals = reinterpret_cast<PWORD>(
- RVAToAddr(exports->AddressOfNameOrdinals));
+ PWORD ordinals =
+ reinterpret_cast<PWORD>(RVAToAddr(exports->AddressOfNameOrdinals));
*ordinal = ordinals[lower - names] + static_cast<WORD>(exports->Base);
}
@@ -291,16 +291,16 @@
if (NULL == directory || 0 == size)
return true;
- PIMAGE_EXPORT_DIRECTORY exports = reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(
- directory);
+ PIMAGE_EXPORT_DIRECTORY exports =
+ reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(directory);
UINT ordinal_base = exports->Base;
UINT num_funcs = exports->NumberOfFunctions;
UINT num_names = exports->NumberOfNames;
- PDWORD functions = reinterpret_cast<PDWORD>(RVAToAddr(
- exports->AddressOfFunctions));
+ PDWORD functions =
+ reinterpret_cast<PDWORD>(RVAToAddr(exports->AddressOfFunctions));
PDWORD names = reinterpret_cast<PDWORD>(RVAToAddr(exports->AddressOfNames));
- PWORD ordinals = reinterpret_cast<PWORD>(RVAToAddr(
- exports->AddressOfNameOrdinals));
+ PWORD ordinals =
+ reinterpret_cast<PWORD>(RVAToAddr(exports->AddressOfNameOrdinals));
for (UINT count = 0; count < num_funcs; count++) {
PVOID func = RVAToAddr(functions[count]);
@@ -323,8 +323,8 @@
// Check for forwarded exports.
LPCSTR forward = NULL;
if (reinterpret_cast<char*>(func) >= reinterpret_cast<char*>(directory) &&
- reinterpret_cast<char*>(func) <= reinterpret_cast<char*>(directory) +
- size) {
+ reinterpret_cast<char*>(func) <=
+ reinterpret_cast<char*>(directory) + size) {
forward = reinterpret_cast<LPCSTR>(func);
func = 0;
}
@@ -340,8 +340,8 @@
bool PEImage::EnumRelocs(EnumRelocsFunction callback, PVOID cookie) const {
PVOID directory = GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_BASERELOC);
DWORD size = GetImageDirectoryEntrySize(IMAGE_DIRECTORY_ENTRY_BASERELOC);
- PIMAGE_BASE_RELOCATION base = reinterpret_cast<PIMAGE_BASE_RELOCATION>(
- directory);
+ PIMAGE_BASE_RELOCATION base =
+ reinterpret_cast<PIMAGE_BASE_RELOCATION>(directory);
if (!directory)
return true;
@@ -349,8 +349,8 @@
while (size >= sizeof(IMAGE_BASE_RELOCATION) && base->SizeOfBlock &&
size >= base->SizeOfBlock) {
PWORD reloc = reinterpret_cast<PWORD>(base + 1);
- UINT num_relocs = (base->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) /
- sizeof(WORD);
+ UINT num_relocs =
+ (base->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(WORD);
for (UINT i = 0; i < num_relocs; i++, reloc++) {
WORD type = *reloc >> 12;
@@ -362,7 +362,7 @@
size -= base->SizeOfBlock;
base = reinterpret_cast<PIMAGE_BASE_RELOCATION>(
- reinterpret_cast<char*>(base) + base->SizeOfBlock);
+ reinterpret_cast<char*>(base) + base->SizeOfBlock);
}
return true;
@@ -379,9 +379,9 @@
for (; import->FirstThunk; import++) {
LPCSTR module_name = reinterpret_cast<LPCSTR>(RVAToAddr(import->Name));
PIMAGE_THUNK_DATA name_table = reinterpret_cast<PIMAGE_THUNK_DATA>(
- RVAToAddr(import->OriginalFirstThunk));
- PIMAGE_THUNK_DATA iat = reinterpret_cast<PIMAGE_THUNK_DATA>(
- RVAToAddr(import->FirstThunk));
+ RVAToAddr(import->OriginalFirstThunk));
+ PIMAGE_THUNK_DATA iat =
+ reinterpret_cast<PIMAGE_THUNK_DATA>(RVAToAddr(import->FirstThunk));
if (!callback(*this, module_name, name_table, iat, cookie))
return false;
@@ -393,7 +393,8 @@
bool PEImage::EnumOneImportChunk(EnumImportsFunction callback,
LPCSTR module_name,
PIMAGE_THUNK_DATA name_table,
- PIMAGE_THUNK_DATA iat, PVOID cookie) const {
+ PIMAGE_THUNK_DATA iat,
+ PVOID cookie) const {
if (NULL == name_table)
return false;
@@ -420,14 +421,14 @@
}
bool PEImage::EnumAllImports(EnumImportsFunction callback, PVOID cookie) const {
- EnumAllImportsStorage temp = { callback, cookie };
+ EnumAllImportsStorage temp = {callback, cookie};
return EnumImportChunks(ProcessImportChunk, &temp);
}
bool PEImage::EnumDelayImportChunks(EnumDelayImportChunksFunction callback,
PVOID cookie) const {
- PVOID directory = GetImageDirectoryEntryAddr(
- IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT);
+ PVOID directory =
+ GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT);
DWORD size = GetImageDirectoryEntrySize(IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT);
PImgDelayDescr delay_descriptor = reinterpret_cast<PImgDelayDescr>(directory);
@@ -488,10 +489,10 @@
if (rvas) {
import = reinterpret_cast<PIMAGE_IMPORT_BY_NAME>(
- RVAToAddr(name_table->u1.ForwarderString));
+ RVAToAddr(name_table->u1.ForwarderString));
} else {
import = reinterpret_cast<PIMAGE_IMPORT_BY_NAME>(
- name_table->u1.ForwarderString);
+ name_table->u1.ForwarderString);
}
hint = import->Hint;
@@ -507,7 +508,7 @@
bool PEImage::EnumAllDelayImports(EnumImportsFunction callback,
PVOID cookie) const {
- EnumAllImportsStorage temp = { callback, cookie };
+ EnumAllImportsStorage temp = {callback, cookie};
return EnumDelayImportChunks(ProcessDelayImportChunk, &temp);
}
diff --git a/base/win/pe_image.h b/base/win/pe_image.h
index 3f8f868..7766b49 100644
--- a/base/win/pe_image.h
+++ b/base/win/pe_image.h
@@ -30,9 +30,10 @@
// Callback to enumerate sections.
// cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumSectionsFunction)(const PEImage &image,
+ typedef bool (*EnumSectionsFunction)(const PEImage& image,
PIMAGE_SECTION_HEADER header,
- PVOID section_start, DWORD section_size,
+ PVOID section_start,
+ DWORD section_size,
PVOID cookie);
// Callback to enumerate exports.
@@ -40,31 +41,41 @@
// contains the dll and symbol to forward this export to. cookie is the value
// passed to the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumExportsFunction)(const PEImage &image, DWORD ordinal,
- DWORD hint, LPCSTR name, PVOID function,
- LPCSTR forward, PVOID cookie);
+ typedef bool (*EnumExportsFunction)(const PEImage& image,
+ DWORD ordinal,
+ DWORD hint,
+ LPCSTR name,
+ PVOID function,
+ LPCSTR forward,
+ PVOID cookie);
// Callback to enumerate import blocks.
// name_table and iat point to the imports name table and address table for
// this block. cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumImportChunksFunction)(const PEImage &image, LPCSTR module,
+ typedef bool (*EnumImportChunksFunction)(const PEImage& image,
+ LPCSTR module,
PIMAGE_THUNK_DATA name_table,
- PIMAGE_THUNK_DATA iat, PVOID cookie);
+ PIMAGE_THUNK_DATA iat,
+ PVOID cookie);
// Callback to enumerate imports.
// module is the dll that exports this symbol. cookie is the value passed to
// the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumImportsFunction)(const PEImage &image, LPCSTR module,
- DWORD ordinal, LPCSTR name, DWORD hint,
- PIMAGE_THUNK_DATA iat, PVOID cookie);
+ typedef bool (*EnumImportsFunction)(const PEImage& image,
+ LPCSTR module,
+ DWORD ordinal,
+ LPCSTR name,
+ DWORD hint,
+ PIMAGE_THUNK_DATA iat,
+ PVOID cookie);
// Callback to enumerate delayed import blocks.
// module is the dll that exports this block of symbols. cookie is the value
// passed to the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumDelayImportChunksFunction)(const PEImage &image,
+ typedef bool (*EnumDelayImportChunksFunction)(const PEImage& image,
PImgDelayDescr delay_descriptor,
LPCSTR module,
PIMAGE_THUNK_DATA name_table,
@@ -74,8 +85,10 @@
// Callback to enumerate relocations.
// cookie is the value passed to the enumerate method.
// Returns true to continue the enumeration.
- typedef bool (*EnumRelocsFunction)(const PEImage &image, WORD type,
- PVOID address, PVOID cookie);
+ typedef bool (*EnumRelocsFunction)(const PEImage& image,
+ WORD type,
+ PVOID address,
+ PVOID cookie);
explicit PEImage(HMODULE module) : module_(module) {}
explicit PEImage(const void* module) {
@@ -155,7 +168,7 @@
// Retrieves the ordinal for a given exported symbol.
// Returns true if the symbol was found.
- bool GetProcOrdinal(LPCSTR function_name, WORD *ordinal) const;
+ bool GetProcOrdinal(LPCSTR function_name, WORD* ordinal) const;
// Enumerates PE sections.
// cookie is a generic cookie to pass to the callback.
@@ -180,11 +193,12 @@
// Enumerates the imports from a single PE import block.
// cookie is a generic cookie to pass to the callback.
// Returns true on success.
- bool EnumOneImportChunk(EnumImportsFunction callback, LPCSTR module_name,
- PIMAGE_THUNK_DATA name_table, PIMAGE_THUNK_DATA iat,
+ bool EnumOneImportChunk(EnumImportsFunction callback,
+ LPCSTR module_name,
+ PIMAGE_THUNK_DATA name_table,
+ PIMAGE_THUNK_DATA iat,
PVOID cookie) const;
-
// Enumerates PE delay imports.
// cookie is a generic cookie to pass to the callback.
// Returns true on success.
@@ -220,11 +234,11 @@
// Converts an rva value to an offset on disk.
// Returns true on success.
- bool ImageRVAToOnDiskOffset(DWORD rva, DWORD *on_disk_offset) const;
+ bool ImageRVAToOnDiskOffset(DWORD rva, DWORD* on_disk_offset) const;
// Converts an address to an offset on disk.
// Returns true on success.
- bool ImageAddrToOnDiskOffset(LPVOID address, DWORD *on_disk_offset) const;
+ bool ImageAddrToOnDiskOffset(LPVOID address, DWORD* on_disk_offset) const;
private:
HMODULE module_;
@@ -253,12 +267,12 @@
inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const {
return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>(
- GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT));
+ GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT));
}
inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const {
return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(
- GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT));
+ GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT));
}
} // namespace win
diff --git a/base/win/process_startup_helper.cc b/base/win/process_startup_helper.cc
index de44b2a..347db71 100644
--- a/base/win/process_startup_helper.cc
+++ b/base/win/process_startup_helper.cc
@@ -13,8 +13,10 @@
#pragma optimize("", off)
// Handlers for invalid parameter and pure call. They generate a breakpoint to
// tell breakpad that it needs to dump the process.
-void InvalidParameter(const wchar_t* expression, const wchar_t* function,
- const wchar_t* file, unsigned int line,
+void InvalidParameter(const wchar_t* expression,
+ const wchar_t* function,
+ const wchar_t* file,
+ unsigned int line,
uintptr_t reserved) {
__debugbreak();
_exit(1);
diff --git a/base/win/process_startup_helper.h b/base/win/process_startup_helper.h
index 2f19ac9..c579433 100644
--- a/base/win/process_startup_helper.h
+++ b/base/win/process_startup_helper.h
@@ -5,7 +5,6 @@
#ifndef BASE_WIN_PROCESS_STARTUP_HELPER_H_
#define BASE_WIN_PROCESS_STARTUP_HELPER_H_
-
namespace base {
class CommandLine;
diff --git a/base/win/registry.cc b/base/win/registry.cc
index 3de51e3..1ca839d 100644
--- a/base/win/registry.cc
+++ b/base/win/registry.cc
@@ -37,15 +37,12 @@
// RegKey ----------------------------------------------------------------------
-RegKey::RegKey() : key_(NULL), wow64access_(0) {
-}
+RegKey::RegKey() : key_(NULL), wow64access_(0) {}
-RegKey::RegKey(HKEY key) : key_(key), wow64access_(0) {
-}
+RegKey::RegKey(HKEY key) : key_(key), wow64access_(0) {}
RegKey::RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access)
- : key_(NULL),
- wow64access_(0) {
+ : key_(NULL), wow64access_(0) {
if (rootkey) {
if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
Create(rootkey, subkey, access);
@@ -66,13 +63,15 @@
return CreateWithDisposition(rootkey, subkey, &disposition_value, access);
}
-LONG RegKey::CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
- DWORD* disposition, REGSAM access) {
+LONG RegKey::CreateWithDisposition(HKEY rootkey,
+ const wchar_t* subkey,
+ DWORD* disposition,
+ REGSAM access) {
DCHECK(rootkey && subkey && access && disposition);
HKEY subhkey = NULL;
- LONG result = RegCreateKeyEx(rootkey, subkey, 0, NULL,
- REG_OPTION_NON_VOLATILE, access, NULL, &subhkey,
- disposition);
+ LONG result =
+ RegCreateKeyEx(rootkey, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, access,
+ NULL, &subhkey, disposition);
if (result == ERROR_SUCCESS) {
Close();
key_ = subhkey;
@@ -208,8 +207,8 @@
DCHECK(name);
HKEY target_key = NULL;
- LONG result = RegOpenKeyEx(key_, name, 0, KEY_READ | wow64access_,
- &target_key);
+ LONG result =
+ RegOpenKeyEx(key_, name, 0, KEY_READ | wow64access_, &target_key);
if (result != ERROR_SUCCESS)
return result;
@@ -339,12 +338,13 @@
}
LONG RegKey::WriteValue(const wchar_t* name, DWORD in_value) {
- return WriteValue(
- name, &in_value, static_cast<DWORD>(sizeof(in_value)), REG_DWORD);
+ return WriteValue(name, &in_value, static_cast<DWORD>(sizeof(in_value)),
+ REG_DWORD);
}
-LONG RegKey::WriteValue(const wchar_t * name, const wchar_t* in_value) {
- return WriteValue(name, in_value,
+LONG RegKey::WriteValue(const wchar_t* name, const wchar_t* in_value) {
+ return WriteValue(
+ name, in_value,
static_cast<DWORD>(sizeof(*in_value) * (wcslen(in_value) + 1)), REG_SZ);
}
@@ -354,8 +354,9 @@
DWORD dtype) {
DCHECK(data || !dsize);
- LONG result = RegSetValueEx(key_, name, 0, dtype,
- reinterpret_cast<LPBYTE>(const_cast<void*>(data)), dsize);
+ LONG result =
+ RegSetValueEx(key_, name, 0, dtype,
+ reinterpret_cast<LPBYTE>(const_cast<void*>(data)), dsize);
return result;
}
@@ -364,7 +365,7 @@
const wchar_t* lpSubKey,
REGSAM samDesired,
DWORD Reserved) {
- typedef LSTATUS(WINAPI* RegDeleteKeyExPtr)(HKEY, LPCWSTR, REGSAM, DWORD);
+ typedef LSTATUS(WINAPI * RegDeleteKeyExPtr)(HKEY, LPCWSTR, REGSAM, DWORD);
RegDeleteKeyExPtr reg_delete_key_ex_func =
reinterpret_cast<RegDeleteKeyExPtr>(
@@ -387,8 +388,8 @@
return result;
HKEY target_key = NULL;
- result = RegOpenKeyEx(
- root_key, name.c_str(), 0, KEY_ENUMERATE_SUB_KEYS | access, &target_key);
+ result = RegOpenKeyEx(root_key, name.c_str(), 0,
+ KEY_ENUMERATE_SUB_KEYS | access, &target_key);
if (result == ERROR_FILE_NOT_FOUND)
return ERROR_SUCCESS;
@@ -408,14 +409,9 @@
std::wstring key_name;
while (result == ERROR_SUCCESS) {
DWORD key_size = kMaxKeyNameLength;
- result = RegEnumKeyEx(target_key,
- 0,
- WriteInto(&key_name, kMaxKeyNameLength),
- &key_size,
- NULL,
- NULL,
- NULL,
- NULL);
+ result =
+ RegEnumKeyEx(target_key, 0, WriteInto(&key_name, kMaxKeyNameLength),
+ &key_size, NULL, NULL, NULL, NULL);
if (result != ERROR_SUCCESS)
break;
@@ -441,15 +437,13 @@
RegistryValueIterator::RegistryValueIterator(HKEY root_key,
const wchar_t* folder_key,
REGSAM wow64access)
- : name_(MAX_PATH, L'\0'),
- value_(MAX_PATH, L'\0') {
+ : name_(MAX_PATH, L'\0'), value_(MAX_PATH, L'\0') {
Initialize(root_key, folder_key, wow64access);
}
RegistryValueIterator::RegistryValueIterator(HKEY root_key,
const wchar_t* folder_key)
- : name_(MAX_PATH, L'\0'),
- value_(MAX_PATH, L'\0') {
+ : name_(MAX_PATH, L'\0'), value_(MAX_PATH, L'\0') {
Initialize(root_key, folder_key, 0);
}
@@ -484,8 +478,8 @@
DWORD RegistryValueIterator::ValueCount() const {
DWORD count = 0;
- LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL,
- &count, NULL, NULL, NULL, NULL);
+ LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count,
+ NULL, NULL, NULL, NULL);
if (result != ERROR_SUCCESS)
return 0;
@@ -561,8 +555,8 @@
DWORD RegistryKeyIterator::SubkeyCount() const {
DWORD count = 0;
- LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL);
+ LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
if (result != ERROR_SUCCESS)
return 0;
@@ -582,8 +576,8 @@
if (Valid()) {
DWORD ncount = arraysize(name_);
FILETIME written;
- LONG r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL,
- NULL, &written);
+ LONG r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL, NULL,
+ &written);
if (ERROR_SUCCESS == r)
return true;
}
diff --git a/base/win/registry.h b/base/win/registry.h
index 413ee7a..e2e0d30 100644
--- a/base/win/registry.h
+++ b/base/win/registry.h
@@ -34,8 +34,10 @@
LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access);
- LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
- DWORD* disposition, REGSAM access);
+ LONG CreateWithDisposition(HKEY rootkey,
+ const wchar_t* subkey,
+ DWORD* disposition,
+ REGSAM access);
// Creates a subkey or open it if it already exists.
LONG CreateKey(const wchar_t* name, REGSAM access);
diff --git a/base/win/resource_util.cc b/base/win/resource_util.cc
index 0c10078..b964aee 100644
--- a/base/win/resource_util.cc
+++ b/base/win/resource_util.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "base/win/resource_util.h"
+#include "base/logging.h"
namespace base {
namespace win {
@@ -21,8 +21,8 @@
return false;
}
- HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id),
- resource_type);
+ HRSRC hres_info =
+ FindResource(module, MAKEINTRESOURCE(resource_id), resource_type);
if (NULL == hres_info)
return false;
diff --git a/base/win/resource_util.h b/base/win/resource_util.h
index 3e6b145..b4473fd 100644
--- a/base/win/resource_util.h
+++ b/base/win/resource_util.h
@@ -8,9 +8,8 @@
#ifndef BASE_WIN_RESOURCE_UTIL_H_
#define BASE_WIN_RESOURCE_UTIL_H_
-#include <windows.h>
#include <stddef.h>
-
+#include <windows.h>
namespace base {
namespace win {
@@ -19,18 +18,18 @@
// a dll. Some resources are optional, especially in unit tests, so this
// returns false but doesn't raise an error if the resource can't be loaded.
bool GetResourceFromModule(HMODULE module,
- int resource_id,
- LPCTSTR resource_type,
- void** data,
- size_t* length);
+ int resource_id,
+ LPCTSTR resource_type,
+ void** data,
+ size_t* length);
// Function for getting a data resource (BINDATA) from a dll. Some
// resources are optional, especially in unit tests, so this returns false
// but doesn't raise an error if the resource can't be loaded.
bool GetDataResourceFromModule(HMODULE module,
- int resource_id,
- void** data,
- size_t* length);
+ int resource_id,
+ void** data,
+ size_t* length);
} // namespace win
} // namespace base
diff --git a/base/win/scoped_bstr.cc b/base/win/scoped_bstr.cc
deleted file mode 100644
index 02f3d54..0000000
--- a/base/win/scoped_bstr.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/win/scoped_bstr.h"
-
-#include <stdint.h>
-
-#include "base/logging.h"
-
-namespace base {
-namespace win {
-
-ScopedBstr::ScopedBstr(const char16* non_bstr)
- : bstr_(SysAllocString(non_bstr)) {
-}
-
-ScopedBstr::~ScopedBstr() {
- static_assert(sizeof(ScopedBstr) == sizeof(BSTR), "ScopedBstrSize");
- SysFreeString(bstr_);
-}
-
-void ScopedBstr::Reset(BSTR bstr) {
- if (bstr != bstr_) {
- // if |bstr_| is NULL, SysFreeString does nothing.
- SysFreeString(bstr_);
- bstr_ = bstr;
- }
-}
-
-BSTR ScopedBstr::Release() {
- BSTR bstr = bstr_;
- bstr_ = NULL;
- return bstr;
-}
-
-void ScopedBstr::Swap(ScopedBstr& bstr2) {
- BSTR tmp = bstr_;
- bstr_ = bstr2.bstr_;
- bstr2.bstr_ = tmp;
-}
-
-BSTR* ScopedBstr::Receive() {
- DCHECK(!bstr_) << "BSTR leak.";
- return &bstr_;
-}
-
-BSTR ScopedBstr::Allocate(const char16* str) {
- Reset(SysAllocString(str));
- return bstr_;
-}
-
-BSTR ScopedBstr::AllocateBytes(size_t bytes) {
- Reset(SysAllocStringByteLen(NULL, static_cast<UINT>(bytes)));
- return bstr_;
-}
-
-void ScopedBstr::SetByteLen(size_t bytes) {
- DCHECK(bstr_ != NULL) << "attempting to modify a NULL bstr";
- uint32_t* data = reinterpret_cast<uint32_t*>(bstr_);
- data[-1] = static_cast<uint32_t>(bytes);
-}
-
-size_t ScopedBstr::Length() const {
- return SysStringLen(bstr_);
-}
-
-size_t ScopedBstr::ByteLength() const {
- return SysStringByteLen(bstr_);
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/scoped_bstr.h b/base/win/scoped_bstr.h
deleted file mode 100644
index 02f73ed..0000000
--- a/base/win/scoped_bstr.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_BSTR_H_
-#define BASE_WIN_SCOPED_BSTR_H_
-
-#include <windows.h>
-#include <oleauto.h>
-#include <stddef.h>
-
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/strings/string16.h"
-
-namespace base {
-namespace win {
-
-// Manages a BSTR string pointer.
-// The class interface is based on unique_ptr.
-class ScopedBstr {
- public:
- ScopedBstr() : bstr_(NULL) {
- }
-
- // Constructor to create a new BSTR.
- //
- // NOTE: Do not pass a BSTR to this constructor expecting ownership to
- // be transferred - even though it compiles! ;-)
- explicit ScopedBstr(const char16* non_bstr);
- ~ScopedBstr();
-
- // Give ScopedBstr ownership over an already allocated BSTR or NULL.
- // If you need to allocate a new BSTR instance, use |allocate| instead.
- void Reset(BSTR bstr = NULL);
-
- // Releases ownership of the BSTR to the caller.
- BSTR Release();
-
- // Creates a new BSTR from a 16-bit C-style string.
- //
- // If you already have a BSTR and want to transfer ownership to the
- // ScopedBstr instance, call |reset| instead.
- //
- // Returns a pointer to the new BSTR, or NULL if allocation failed.
- BSTR Allocate(const char16* str);
-
- // Allocates a new BSTR with the specified number of bytes.
- // Returns a pointer to the new BSTR, or NULL if allocation failed.
- BSTR AllocateBytes(size_t bytes);
-
- // Sets the allocated length field of the already-allocated BSTR to be
- // |bytes|. This is useful when the BSTR was preallocated with e.g.
- // SysAllocStringLen or SysAllocStringByteLen (call |AllocateBytes|) and then
- // not all the bytes are being used.
- //
- // Note that if you want to set the length to a specific number of
- // characters, you need to multiply by sizeof(wchar_t). Oddly, there's no
- // public API to set the length, so we do this ourselves by hand.
- //
- // NOTE: The actual allocated size of the BSTR MUST be >= bytes. That
- // responsibility is with the caller.
- void SetByteLen(size_t bytes);
-
- // Swap values of two ScopedBstr's.
- void Swap(ScopedBstr& bstr2);
-
- // Retrieves the pointer address.
- // Used to receive BSTRs as out arguments (and take ownership).
- // The function DCHECKs on the current value being NULL.
- // Usage: GetBstr(bstr.Receive());
- BSTR* Receive();
-
- // Returns number of chars in the BSTR.
- size_t Length() const;
-
- // Returns the number of bytes allocated for the BSTR.
- size_t ByteLength() const;
-
- operator BSTR() const {
- return bstr_;
- }
-
- protected:
- BSTR bstr_;
-
- private:
- // Forbid comparison of ScopedBstr types. You should never have the same
- // BSTR owned by two different scoped_ptrs.
- bool operator==(const ScopedBstr& bstr2) const;
- bool operator!=(const ScopedBstr& bstr2) const;
- DISALLOW_COPY_AND_ASSIGN(ScopedBstr);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_BSTR_H_
diff --git a/base/win/scoped_co_mem.h b/base/win/scoped_co_mem.h
index a3737dd..3c31f3f 100644
--- a/base/win/scoped_co_mem.h
+++ b/base/win/scoped_co_mem.h
@@ -19,22 +19,18 @@
// SHGetSomeInfo(&file_item, ...);
// ...
// return; <-- memory released
-template<typename T>
+template <typename T>
class ScopedCoMem {
public:
ScopedCoMem() : mem_ptr_(NULL) {}
- ~ScopedCoMem() {
- Reset(NULL);
- }
+ ~ScopedCoMem() { Reset(NULL); }
- T** operator&() { // NOLINT
+ T** operator&() { // NOLINT
DCHECK(mem_ptr_ == NULL); // To catch memory leaks.
return &mem_ptr_;
}
- operator T*() {
- return mem_ptr_;
- }
+ operator T*() { return mem_ptr_; }
T* operator->() {
DCHECK(mem_ptr_ != NULL);
@@ -52,9 +48,7 @@
mem_ptr_ = ptr;
}
- T* get() const {
- return mem_ptr_;
- }
+ T* get() const { return mem_ptr_; }
private:
T* mem_ptr_;
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc
index b47183e..ddc744f 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -16,20 +16,20 @@
}
// Static.
-void VerifierTraits::StartTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2) {
-}
+void VerifierTraits::StartTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2) {}
// Static.
-void VerifierTraits::StopTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2) {
-}
+void VerifierTraits::StopTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2) {}
-void DisableHandleVerifier() {
-}
+void DisableHandleVerifier() {}
-void OnHandleBeingClosed(HANDLE handle) {
-}
+void OnHandleBeingClosed(HANDLE handle) {}
} // namespace win
} // namespace base
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 7c63bb7..e67e447 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -16,8 +16,8 @@
#include <intrin.h>
#define BASE_WIN_GET_CALLER _ReturnAddress()
#elif defined(COMPILER_GCC)
-#define BASE_WIN_GET_CALLER __builtin_extract_return_addr(\\
- __builtin_return_address(0))
+#define BASE_WIN_GET_CALLER \
+ __builtin_extract_return_addr(\ __builtin_return_address(0))
#endif
namespace base {
@@ -48,13 +48,9 @@
Set(other.Take());
}
- ~GenericScopedHandle() {
- Close();
- }
+ ~GenericScopedHandle() { Close(); }
- bool IsValid() const {
- return Traits::IsHandleValid(handle_);
- }
+ bool IsValid() const { return Traits::IsHandleValid(handle_); }
GenericScopedHandle& operator=(GenericScopedHandle&& other) {
DCHECK_NE(this, &other);
@@ -75,9 +71,7 @@
}
}
- Handle Get() const {
- return handle_;
- }
+ Handle Get() const { return handle_; }
// Transfers ownership away from this object.
Handle Take() {
@@ -118,9 +112,7 @@
}
// Returns NULL handle value.
- static HANDLE NullHandle() {
- return NULL;
- }
+ static HANDLE NullHandle() { return NULL; }
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HandleTraits);
@@ -131,10 +123,14 @@
public:
typedef HANDLE Handle;
- static void StartTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2) {}
- static void StopTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2) {}
+ static void StartTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2) {}
+ static void StopTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2) {}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(DummyVerifierTraits);
@@ -145,10 +141,14 @@
public:
typedef HANDLE Handle;
- static void StartTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2);
- static void StopTracking(HANDLE handle, const void* owner,
- const void* pc1, const void* pc2);
+ static void StartTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2);
+ static void StopTracking(HANDLE handle,
+ const void* owner,
+ const void* pc1,
+ const void* pc2);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
diff --git a/base/win/scoped_handle_test_dll.cc b/base/win/scoped_handle_test_dll.cc
index e17d6fd..9603d68 100644
--- a/base/win/scoped_handle_test_dll.cc
+++ b/base/win/scoped_handle_test_dll.cc
@@ -52,7 +52,7 @@
if (!ready_event)
return false;
- ThreadParams thread_params = { ready_event, start_event };
+ ThreadParams thread_params = {ready_event, start_event};
for (size_t i = 0; i < kNumThreads; i++) {
HANDLE thread_handle =
@@ -115,6 +115,6 @@
return InternalRunThreadTest() && InternalRunLocationTest();
}
-} // testing
-} // win
-} // base
+} // namespace testing
+} // namespace win
+} // namespace base
diff --git a/base/win/scoped_hdc.h b/base/win/scoped_hdc.h
index ef50e05..226b0b9 100644
--- a/base/win/scoped_hdc.h
+++ b/base/win/scoped_hdc.h
@@ -18,9 +18,7 @@
// GetDC.
class ScopedGetDC {
public:
- explicit ScopedGetDC(HWND hwnd)
- : hwnd_(hwnd),
- hdc_(GetDC(hwnd)) {
+ explicit ScopedGetDC(HWND hwnd) : hwnd_(hwnd), hdc_(GetDC(hwnd)) {
if (hwnd_) {
DCHECK(IsWindow(hwnd_));
DCHECK(hdc_);
@@ -53,17 +51,11 @@
public:
typedef HDC Handle;
- static bool CloseHandle(HDC handle) {
- return ::DeleteDC(handle) != FALSE;
- }
+ static bool CloseHandle(HDC handle) { return ::DeleteDC(handle) != FALSE; }
- static bool IsHandleValid(HDC handle) {
- return handle != NULL;
- }
+ static bool IsHandleValid(HDC handle) { return handle != NULL; }
- static HDC NullHandle() {
- return NULL;
- }
+ static HDC NullHandle() { return NULL; }
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CreateDCTraits);
diff --git a/base/win/scoped_hglobal.h b/base/win/scoped_hglobal.h
index abe9a5a..2fa8aaa 100644
--- a/base/win/scoped_hglobal.h
+++ b/base/win/scoped_hglobal.h
@@ -5,8 +5,8 @@
#ifndef BASE_WIN_SCOPED_HGLOBAL_H_
#define BASE_WIN_SCOPED_HGLOBAL_H_
-#include <windows.h>
#include <stddef.h>
+#include <windows.h>
#include "base/macros.h"
@@ -14,15 +14,13 @@
namespace win {
// Like ScopedHandle except for HGLOBAL.
-template<class T>
+template <class T>
class ScopedHGlobal {
public:
explicit ScopedHGlobal(HGLOBAL glob) : glob_(glob) {
data_ = static_cast<T>(GlobalLock(glob_));
}
- ~ScopedHGlobal() {
- GlobalUnlock(glob_);
- }
+ ~ScopedHGlobal() { GlobalUnlock(glob_); }
T get() { return data_; }
diff --git a/base/win/scoped_process_information.cc b/base/win/scoped_process_information.cc
index 935a4cc..93fb9e6 100644
--- a/base/win/scoped_process_information.cc
+++ b/base/win/scoped_process_information.cc
@@ -20,9 +20,8 @@
return true;
HANDLE temp = NULL;
- if (!::DuplicateHandle(::GetCurrentProcess(), source,
- ::GetCurrentProcess(), &temp, 0, FALSE,
- DUPLICATE_SAME_ACCESS)) {
+ if (!::DuplicateHandle(::GetCurrentProcess(), source, ::GetCurrentProcess(),
+ &temp, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
DWORD last_error = ::GetLastError();
DPLOG(ERROR) << "Failed to duplicate a handle " << last_error;
::SetLastError(last_error);
@@ -35,11 +34,11 @@
} // namespace
ScopedProcessInformation::ScopedProcessInformation()
- : process_id_(0), thread_id_(0) {
-}
+ : process_id_(0), thread_id_(0) {}
ScopedProcessInformation::ScopedProcessInformation(
- const PROCESS_INFORMATION& process_info) : process_id_(0), thread_id_(0) {
+ const PROCESS_INFORMATION& process_info)
+ : process_id_(0), thread_id_(0) {
Set(process_info);
}
@@ -48,8 +47,8 @@
}
bool ScopedProcessInformation::IsValid() const {
- return process_id_ || process_handle_.Get() ||
- thread_id_ || thread_handle_.Get();
+ return process_id_ || process_handle_.Get() || thread_id_ ||
+ thread_handle_.Get();
}
void ScopedProcessInformation::Close() {
diff --git a/base/win/scoped_process_information.h b/base/win/scoped_process_information.h
index ca76e21..557555d 100644
--- a/base/win/scoped_process_information.h
+++ b/base/win/scoped_process_information.h
@@ -48,24 +48,16 @@
HANDLE TakeThreadHandle();
// Returns the held process handle, if any, while retaining ownership.
- HANDLE process_handle() const {
- return process_handle_.Get();
- }
+ HANDLE process_handle() const { return process_handle_.Get(); }
// Returns the held thread handle, if any, while retaining ownership.
- HANDLE thread_handle() const {
- return thread_handle_.Get();
- }
+ HANDLE thread_handle() const { return thread_handle_.Get(); }
// Returns the held process id, if any.
- DWORD process_id() const {
- return process_id_;
- }
+ DWORD process_id() const { return process_id_; }
// Returns the held thread id, if any.
- DWORD thread_id() const {
- return thread_id_;
- }
+ DWORD thread_id() const { return thread_id_; }
private:
ScopedHandle process_handle_;
diff --git a/base/win/scoped_propvariant.h b/base/win/scoped_propvariant.h
index aa9afec..0f1d5c8 100644
--- a/base/win/scoped_propvariant.h
+++ b/base/win/scoped_propvariant.h
@@ -17,13 +17,9 @@
// construction and destruction of this class.
class ScopedPropVariant {
public:
- ScopedPropVariant() {
- PropVariantInit(&pv_);
- }
+ ScopedPropVariant() { PropVariantInit(&pv_); }
- ~ScopedPropVariant() {
- Reset();
- }
+ ~ScopedPropVariant() { Reset(); }
// Returns a pointer to the underlying PROPVARIANT for use as an out param in
// a function call.
diff --git a/base/win/scoped_select_object.h b/base/win/scoped_select_object.h
index 59b21c1..d4b1a81 100644
--- a/base/win/scoped_select_object.h
+++ b/base/win/scoped_select_object.h
@@ -17,8 +17,7 @@
class ScopedSelectObject {
public:
ScopedSelectObject(HDC hdc, HGDIOBJ object)
- : hdc_(hdc),
- oldobj_(SelectObject(hdc, object)) {
+ : hdc_(hdc), oldobj_(SelectObject(hdc, object)) {
DCHECK(hdc_);
DCHECK(object);
DCHECK(oldobj_ != NULL && oldobj_ != HGDI_ERROR);
diff --git a/base/win/scoped_variant.cc b/base/win/scoped_variant.cc
deleted file mode 100644
index 0c1ee31..0000000
--- a/base/win/scoped_variant.cc
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/win/scoped_variant.h"
-
-#include "base/logging.h"
-
-namespace base {
-namespace win {
-
-// Global, const instance of an empty variant.
-const VARIANT ScopedVariant::kEmptyVariant = {{{VT_EMPTY}}};
-
-ScopedVariant::~ScopedVariant() {
- static_assert(sizeof(ScopedVariant) == sizeof(VARIANT), "ScopedVariantSize");
- ::VariantClear(&var_);
-}
-
-ScopedVariant::ScopedVariant(const wchar_t* str) {
- var_.vt = VT_EMPTY;
- Set(str);
-}
-
-ScopedVariant::ScopedVariant(const wchar_t* str, UINT length) {
- var_.vt = VT_BSTR;
- var_.bstrVal = ::SysAllocStringLen(str, length);
-}
-
-ScopedVariant::ScopedVariant(int value, VARTYPE vt) {
- var_.vt = vt;
- var_.lVal = value;
-}
-
-ScopedVariant::ScopedVariant(double value, VARTYPE vt) {
- DCHECK(vt == VT_R8 || vt == VT_DATE);
- var_.vt = vt;
- var_.dblVal = value;
-}
-
-ScopedVariant::ScopedVariant(IDispatch* dispatch) {
- var_.vt = VT_EMPTY;
- Set(dispatch);
-}
-
-ScopedVariant::ScopedVariant(IUnknown* unknown) {
- var_.vt = VT_EMPTY;
- Set(unknown);
-}
-
-ScopedVariant::ScopedVariant(SAFEARRAY* safearray) {
- var_.vt = VT_EMPTY;
- Set(safearray);
-}
-
-ScopedVariant::ScopedVariant(const VARIANT& var) {
- var_.vt = VT_EMPTY;
- Set(var);
-}
-
-void ScopedVariant::Reset(const VARIANT& var) {
- if (&var != &var_) {
- ::VariantClear(&var_);
- var_ = var;
- }
-}
-
-VARIANT ScopedVariant::Release() {
- VARIANT var = var_;
- var_.vt = VT_EMPTY;
- return var;
-}
-
-void ScopedVariant::Swap(ScopedVariant& var) {
- VARIANT tmp = var_;
- var_ = var.var_;
- var.var_ = tmp;
-}
-
-VARIANT* ScopedVariant::Receive() {
- DCHECK(!IsLeakableVarType(var_.vt)) << "variant leak. type: " << var_.vt;
- return &var_;
-}
-
-VARIANT ScopedVariant::Copy() const {
- VARIANT ret = {{{VT_EMPTY}}};
- ::VariantCopy(&ret, &var_);
- return ret;
-}
-
-int ScopedVariant::Compare(const VARIANT& var, bool ignore_case) const {
- ULONG flags = ignore_case ? NORM_IGNORECASE : 0;
- HRESULT hr = ::VarCmp(const_cast<VARIANT*>(&var_), const_cast<VARIANT*>(&var),
- LOCALE_USER_DEFAULT, flags);
- int ret = 0;
-
- switch (hr) {
- case VARCMP_LT:
- ret = -1;
- break;
-
- case VARCMP_GT:
- case VARCMP_NULL:
- ret = 1;
- break;
-
- default:
- // Equal.
- break;
- }
-
- return ret;
-}
-
-void ScopedVariant::Set(const wchar_t* str) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_BSTR;
- var_.bstrVal = ::SysAllocString(str);
-}
-
-void ScopedVariant::Set(int8_t i8) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_I1;
- var_.cVal = i8;
-}
-
-void ScopedVariant::Set(uint8_t ui8) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_UI1;
- var_.bVal = ui8;
-}
-
-void ScopedVariant::Set(int16_t i16) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_I2;
- var_.iVal = i16;
-}
-
-void ScopedVariant::Set(uint16_t ui16) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_UI2;
- var_.uiVal = ui16;
-}
-
-void ScopedVariant::Set(int32_t i32) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_I4;
- var_.lVal = i32;
-}
-
-void ScopedVariant::Set(uint32_t ui32) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_UI4;
- var_.ulVal = ui32;
-}
-
-void ScopedVariant::Set(int64_t i64) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_I8;
- var_.llVal = i64;
-}
-
-void ScopedVariant::Set(uint64_t ui64) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_UI8;
- var_.ullVal = ui64;
-}
-
-void ScopedVariant::Set(float r32) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_R4;
- var_.fltVal = r32;
-}
-
-void ScopedVariant::Set(double r64) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_R8;
- var_.dblVal = r64;
-}
-
-void ScopedVariant::SetDate(DATE date) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_DATE;
- var_.date = date;
-}
-
-void ScopedVariant::Set(IDispatch* disp) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_DISPATCH;
- var_.pdispVal = disp;
- if (disp)
- disp->AddRef();
-}
-
-void ScopedVariant::Set(bool b) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_BOOL;
- var_.boolVal = b ? VARIANT_TRUE : VARIANT_FALSE;
-}
-
-void ScopedVariant::Set(IUnknown* unk) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- var_.vt = VT_UNKNOWN;
- var_.punkVal = unk;
- if (unk)
- unk->AddRef();
-}
-
-void ScopedVariant::Set(SAFEARRAY* array) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- if (SUCCEEDED(::SafeArrayGetVartype(array, &var_.vt))) {
- var_.vt |= VT_ARRAY;
- var_.parray = array;
- } else {
- DCHECK(!array) << "Unable to determine safearray vartype";
- var_.vt = VT_EMPTY;
- }
-}
-
-void ScopedVariant::Set(const VARIANT& var) {
- DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
- if (FAILED(::VariantCopy(&var_, &var))) {
- DLOG(ERROR) << "VariantCopy failed";
- var_.vt = VT_EMPTY;
- }
-}
-
-ScopedVariant& ScopedVariant::operator=(const VARIANT& var) {
- if (&var != &var_) {
- VariantClear(&var_);
- Set(var);
- }
- return *this;
-}
-
-bool ScopedVariant::IsLeakableVarType(VARTYPE vt) {
- bool leakable = false;
- switch (vt & VT_TYPEMASK) {
- case VT_BSTR:
- case VT_DISPATCH:
- // we treat VT_VARIANT as leakable to err on the safe side.
- case VT_VARIANT:
- case VT_UNKNOWN:
- case VT_SAFEARRAY:
-
- // very rarely used stuff (if ever):
- case VT_VOID:
- case VT_PTR:
- case VT_CARRAY:
- case VT_USERDEFINED:
- case VT_LPSTR:
- case VT_LPWSTR:
- case VT_RECORD:
- case VT_INT_PTR:
- case VT_UINT_PTR:
- case VT_FILETIME:
- case VT_BLOB:
- case VT_STREAM:
- case VT_STORAGE:
- case VT_STREAMED_OBJECT:
- case VT_STORED_OBJECT:
- case VT_BLOB_OBJECT:
- case VT_VERSIONED_STREAM:
- case VT_BSTR_BLOB:
- leakable = true;
- break;
- }
-
- if (!leakable && (vt & VT_ARRAY) != 0) {
- leakable = true;
- }
-
- return leakable;
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/scoped_variant.h b/base/win/scoped_variant.h
deleted file mode 100644
index 5390eb9..0000000
--- a/base/win/scoped_variant.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_VARIANT_H_
-#define BASE_WIN_SCOPED_VARIANT_H_
-
-#include <windows.h>
-#include <oleauto.h>
-#include <stdint.h>
-
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// Scoped VARIANT class for automatically freeing a COM VARIANT at the
-// end of a scope. Additionally provides a few functions to make the
-// encapsulated VARIANT easier to use.
-// Instead of inheriting from VARIANT, we take the containment approach
-// in order to have more control over the usage of the variant and guard
-// against memory leaks.
-class ScopedVariant {
- public:
- // Declaration of a global variant variable that's always VT_EMPTY
- static const VARIANT kEmptyVariant;
-
- // Default constructor.
- ScopedVariant() {
- // This is equivalent to what VariantInit does, but less code.
- var_.vt = VT_EMPTY;
- }
-
- // Constructor to create a new VT_BSTR VARIANT.
- // NOTE: Do not pass a BSTR to this constructor expecting ownership to
- // be transferred
- explicit ScopedVariant(const wchar_t* str);
-
- // Creates a new VT_BSTR variant of a specified length.
- ScopedVariant(const wchar_t* str, UINT length);
-
- // Creates a new integral type variant and assigns the value to
- // VARIANT.lVal (32 bit sized field).
- explicit ScopedVariant(int value, VARTYPE vt = VT_I4);
-
- // Creates a new double-precision type variant. |vt| must be either VT_R8
- // or VT_DATE.
- explicit ScopedVariant(double value, VARTYPE vt = VT_R8);
-
- // VT_DISPATCH
- explicit ScopedVariant(IDispatch* dispatch);
-
- // VT_UNKNOWN
- explicit ScopedVariant(IUnknown* unknown);
-
- // SAFEARRAY
- explicit ScopedVariant(SAFEARRAY* safearray);
-
- // Copies the variant.
- explicit ScopedVariant(const VARIANT& var);
-
- ~ScopedVariant();
-
- inline VARTYPE type() const {
- return var_.vt;
- }
-
- // Give ScopedVariant ownership over an already allocated VARIANT.
- void Reset(const VARIANT& var = kEmptyVariant);
-
- // Releases ownership of the VARIANT to the caller.
- VARIANT Release();
-
- // Swap two ScopedVariant's.
- void Swap(ScopedVariant& var);
-
- // Returns a copy of the variant.
- VARIANT Copy() const;
-
- // The return value is 0 if the variants are equal, 1 if this object is
- // greater than |var|, -1 if it is smaller.
- int Compare(const VARIANT& var, bool ignore_case = false) const;
-
- // Retrieves the pointer address.
- // Used to receive a VARIANT as an out argument (and take ownership).
- // The function DCHECKs on the current value being empty/null.
- // Usage: GetVariant(var.receive());
- VARIANT* Receive();
-
- void Set(const wchar_t* str);
-
- // Setters for simple types.
- void Set(int8_t i8);
- void Set(uint8_t ui8);
- void Set(int16_t i16);
- void Set(uint16_t ui16);
- void Set(int32_t i32);
- void Set(uint32_t ui32);
- void Set(int64_t i64);
- void Set(uint64_t ui64);
- void Set(float r32);
- void Set(double r64);
- void Set(bool b);
-
- // Creates a copy of |var| and assigns as this instance's value.
- // Note that this is different from the Reset() method that's used to
- // free the current value and assume ownership.
- void Set(const VARIANT& var);
-
- // COM object setters
- void Set(IDispatch* disp);
- void Set(IUnknown* unk);
-
- // SAFEARRAY support
- void Set(SAFEARRAY* array);
-
- // Special setter for DATE since DATE is a double and we already have
- // a setter for double.
- void SetDate(DATE date);
-
- // Allows const access to the contained variant without DCHECKs etc.
- // This support is necessary for the V_XYZ (e.g. V_BSTR) set of macros to
- // work properly but still doesn't allow modifications since we want control
- // over that.
- const VARIANT* ptr() const { return &var_; }
-
- // Like other scoped classes (e.g. scoped_refptr, ScopedBstr,
- // Microsoft::WRL::ComPtr) we support the assignment operator for the type we
- // wrap.
- ScopedVariant& operator=(const VARIANT& var);
-
- // A hack to pass a pointer to the variant where the accepting
- // function treats the variant as an input-only, read-only value
- // but the function prototype requires a non const variant pointer.
- // There's no DCHECK or anything here. Callers must know what they're doing.
- VARIANT* AsInput() const {
- // The nature of this function is const, so we declare
- // it as such and cast away the constness here.
- return const_cast<VARIANT*>(&var_);
- }
-
- // Allows the ScopedVariant instance to be passed to functions either by value
- // or by const reference.
- operator const VARIANT&() const {
- return var_;
- }
-
- // Used as a debug check to see if we're leaking anything.
- static bool IsLeakableVarType(VARTYPE vt);
-
- protected:
- VARIANT var_;
-
- private:
- // Comparison operators for ScopedVariant are not supported at this point.
- // Use the Compare method instead.
- bool operator==(const ScopedVariant& var) const;
- bool operator!=(const ScopedVariant& var) const;
- DISALLOW_COPY_AND_ASSIGN(ScopedVariant);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_VARIANT_H_
diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
index 8abd5a6..fcd8a70 100644
--- a/base/win/shortcut.cc
+++ b/base/win/shortcut.cc
@@ -5,9 +5,9 @@
#include "base/win/shortcut.h"
#include <objbase.h>
+#include <propkey.h>
#include <shellapi.h>
#include <shlobj.h>
-#include <propkey.h>
#include <wrl/client.h>
#include "base/files/file_util.h"
@@ -44,14 +44,12 @@
} // namespace
ShortcutProperties::ShortcutProperties()
- : icon_index(-1), dual_mode(false), options(0U) {
-}
+ : icon_index(-1), dual_mode(false), options(0U) {}
ShortcutProperties::ShortcutProperties(const ShortcutProperties& other) =
default;
-ShortcutProperties::~ShortcutProperties() {
-}
+ShortcutProperties::~ShortcutProperties() {}
bool CreateOrUpdateShortcutLink(const FilePath& shortcut_path,
const ShortcutProperties& properties,
@@ -114,8 +112,8 @@
return false;
} else if (old_i_persist_file.Get()) {
wchar_t current_arguments[MAX_PATH] = {0};
- if (SUCCEEDED(old_i_shell_link->GetArguments(current_arguments,
- MAX_PATH))) {
+ if (SUCCEEDED(
+ old_i_shell_link->GetArguments(current_arguments, MAX_PATH))) {
i_shell_link->SetArguments(current_arguments);
}
}
@@ -144,15 +142,13 @@
!property_store.Get())
return false;
- if (has_app_id &&
- !SetAppIdForPropertyStore(property_store.Get(),
- properties.app_id.c_str())) {
+ if (has_app_id && !SetAppIdForPropertyStore(property_store.Get(),
+ properties.app_id.c_str())) {
return false;
}
- if (has_dual_mode &&
- !SetBooleanValueForPropertyStore(property_store.Get(),
- PKEY_AppUserModel_IsDualMode,
- properties.dual_mode)) {
+ if (has_dual_mode && !SetBooleanValueForPropertyStore(
+ property_store.Get(), PKEY_AppUserModel_IsDualMode,
+ properties.dual_mode)) {
return false;
}
if (has_toast_activator_clsid &&
@@ -262,8 +258,8 @@
if (options & ShortcutProperties::PROPERTIES_APP_ID) {
ScopedPropVariant pv_app_id;
- if (property_store->GetValue(PKEY_AppUserModel_ID,
- pv_app_id.Receive()) != S_OK) {
+ if (property_store->GetValue(PKEY_AppUserModel_ID, pv_app_id.Receive()) !=
+ S_OK) {
return false;
}
switch (pv_app_id.get().vt) {
diff --git a/base/win/shortcut.h b/base/win/shortcut.h
index 1ab0188..d5bcff7 100644
--- a/base/win/shortcut.h
+++ b/base/win/shortcut.h
@@ -5,8 +5,8 @@
#ifndef BASE_WIN_SHORTCUT_H_
#define BASE_WIN_SHORTCUT_H_
-#include <windows.h>
#include <stdint.h>
+#include <windows.h>
#include "base/files/file_path.h"
#include "base/logging.h"
@@ -130,10 +130,9 @@
// |operation|: a choice from the ShortcutOperation enum.
// If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and
// |shortcut_path| does not exist, this method is a no-op and returns false.
-bool CreateOrUpdateShortcutLink(
- const FilePath& shortcut_path,
- const ShortcutProperties& properties,
- ShortcutOperation operation);
+bool CreateOrUpdateShortcutLink(const FilePath& shortcut_path,
+ const ShortcutProperties& properties,
+ ShortcutOperation operation);
// Resolves Windows shortcut (.LNK file).
// This methods tries to resolve selected properties of a shortcut .LNK file.
@@ -146,8 +145,8 @@
// properties are successfully read. Otherwise some reads have failed and
// intermediate values written to |properties| should be ignored.
bool ResolveShortcutProperties(const FilePath& shortcut_path,
- uint32_t options,
- ShortcutProperties* properties);
+ uint32_t options,
+ ShortcutProperties* properties);
// Resolves Windows shortcut (.LNK file).
// This is a wrapper to ResolveShortcutProperties() to handle the common use
@@ -157,8 +156,8 @@
// successfully. Callers can safely use the same variable for both
// |shortcut_path| and |target_path|.
bool ResolveShortcut(const FilePath& shortcut_path,
- FilePath* target_path,
- string16* args);
+ FilePath* target_path,
+ string16* args);
// Pin to taskbar is only supported on Windows 7 and Windows 8. Returns true on
// those platforms.
diff --git a/base/win/startup_information.cc b/base/win/startup_information.cc
index 9986674..fbfb093 100644
--- a/base/win/startup_information.cc
+++ b/base/win/startup_information.cc
@@ -8,7 +8,7 @@
namespace {
-typedef BOOL (WINAPI *InitializeProcThreadAttributeListFunction)(
+typedef BOOL(WINAPI* InitializeProcThreadAttributeListFunction)(
LPPROC_THREAD_ATTRIBUTE_LIST attribute_list,
DWORD attribute_count,
DWORD flags,
@@ -16,7 +16,7 @@
static InitializeProcThreadAttributeListFunction
initialize_proc_thread_attribute_list;
-typedef BOOL (WINAPI *UpdateProcThreadAttributeFunction)(
+typedef BOOL(WINAPI* UpdateProcThreadAttributeFunction)(
LPPROC_THREAD_ATTRIBUTE_LIST attribute_list,
DWORD flags,
DWORD_PTR attribute,
@@ -26,7 +26,7 @@
PSIZE_T return_size);
static UpdateProcThreadAttributeFunction update_proc_thread_attribute_list;
-typedef VOID (WINAPI *DeleteProcThreadAttributeListFunction)(
+typedef VOID(WINAPI* DeleteProcThreadAttributeListFunction)(
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList);
static DeleteProcThreadAttributeListFunction delete_proc_thread_attribute_list;
@@ -59,7 +59,7 @@
StartupInformation::~StartupInformation() {
if (startup_info_.lpAttributeList) {
delete_proc_thread_attribute_list(startup_info_.lpAttributeList);
- delete [] reinterpret_cast<BYTE*>(startup_info_.lpAttributeList);
+ delete[] reinterpret_cast<BYTE*>(startup_info_.lpAttributeList);
}
}
@@ -77,8 +77,8 @@
startup_info_.lpAttributeList =
reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(new BYTE[size]);
if (!initialize_proc_thread_attribute_list(startup_info_.lpAttributeList,
- attribute_count, 0, &size)) {
- delete [] reinterpret_cast<BYTE*>(startup_info_.lpAttributeList);
+ attribute_count, 0, &size)) {
+ delete[] reinterpret_cast<BYTE*>(startup_info_.lpAttributeList);
startup_info_.lpAttributeList = NULL;
return false;
}
@@ -86,16 +86,14 @@
return true;
}
-bool StartupInformation::UpdateProcThreadAttribute(
- DWORD_PTR attribute,
- void* value,
- size_t size) {
+bool StartupInformation::UpdateProcThreadAttribute(DWORD_PTR attribute,
+ void* value,
+ size_t size) {
if (!startup_info_.lpAttributeList)
return false;
- return !!update_proc_thread_attribute_list(startup_info_.lpAttributeList, 0,
- attribute, value, size, NULL, NULL);
+ return !!update_proc_thread_attribute_list(
+ startup_info_.lpAttributeList, 0, attribute, value, size, NULL, NULL);
}
} // namespace win
} // namespace base
-
diff --git a/base/win/startup_information.h b/base/win/startup_information.h
index f82ff75..d95f39b 100644
--- a/base/win/startup_information.h
+++ b/base/win/startup_information.h
@@ -5,8 +5,8 @@
#ifndef BASE_WIN_STARTUP_INFORMATION_H_
#define BASE_WIN_STARTUP_INFORMATION_H_
-#include <windows.h>
#include <stddef.h>
+#include <windows.h>
#include "base/macros.h"
@@ -26,9 +26,7 @@
// Sets one entry in the initialized attribute list.
// |value| needs to live at least as long as the StartupInformation object
// this is called on.
- bool UpdateProcThreadAttribute(DWORD_PTR attribute,
- void* value,
- size_t size);
+ bool UpdateProcThreadAttribute(DWORD_PTR attribute, void* value, size_t size);
LPSTARTUPINFOW startup_info() { return &startup_info_.StartupInfo; }
LPSTARTUPINFOW startup_info() const {
diff --git a/base/win/wait_chain.cc b/base/win/wait_chain.cc
deleted file mode 100644
index a18a1ea..0000000
--- a/base/win/wait_chain.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/win/wait_chain.h"
-
-#include <memory>
-
-#include "base/logging.h"
-#include "base/strings/stringprintf.h"
-
-namespace base {
-namespace win {
-
-namespace {
-
-// Helper deleter to hold a HWCT into a unique_ptr.
-struct WaitChainSessionDeleter {
- using pointer = HWCT;
- void operator()(HWCT session_handle) const {
- ::CloseThreadWaitChainSession(session_handle);
- }
-};
-
-using ScopedWaitChainSessionHandle =
- std::unique_ptr<HWCT, WaitChainSessionDeleter>;
-
-const wchar_t* WctObjectTypeToString(WCT_OBJECT_TYPE type) {
- switch (type) {
- case WctCriticalSectionType:
- return L"CriticalSection";
- case WctSendMessageType:
- return L"SendMessage";
- case WctMutexType:
- return L"Mutex";
- case WctAlpcType:
- return L"Alpc";
- case WctComType:
- return L"Com";
- case WctThreadWaitType:
- return L"ThreadWait";
- case WctProcessWaitType:
- return L"ProcessWait";
- case WctThreadType:
- return L"Thread";
- case WctComActivationType:
- return L"ComActivation";
- case WctUnknownType:
- return L"Unknown";
- case WctSocketIoType:
- return L"SocketIo";
- case WctSmbIoType:
- return L"SmbIo";
- case WctMaxType:
- break;
- }
- NOTREACHED();
- return L"";
-}
-
-const wchar_t* WctObjectStatusToString(WCT_OBJECT_STATUS status) {
- switch (status) {
- case WctStatusNoAccess:
- return L"NoAccess";
- case WctStatusRunning:
- return L"Running";
- case WctStatusBlocked:
- return L"Blocked";
- case WctStatusPidOnly:
- return L"PidOnly";
- case WctStatusPidOnlyRpcss:
- return L"PidOnlyRpcss";
- case WctStatusOwned:
- return L"Owned";
- case WctStatusNotOwned:
- return L"NotOwned";
- case WctStatusAbandoned:
- return L"Abandoned";
- case WctStatusUnknown:
- return L"Unknown";
- case WctStatusError:
- return L"Error";
- case WctStatusMax:
- break;
- }
- NOTREACHED();
- return L"";
-}
-
-} // namespace
-
-bool GetThreadWaitChain(DWORD thread_id,
- WaitChainNodeVector* wait_chain,
- bool* is_deadlock,
- base::string16* failure_reason,
- DWORD* last_error) {
- DCHECK(wait_chain);
- DCHECK(is_deadlock);
-
- constexpr wchar_t kWaitChainSessionFailureReason[] =
- L"OpenThreadWaitChainSession() failed.";
- constexpr wchar_t kGetWaitChainFailureReason[] =
- L"GetThreadWaitChain() failed.";
-
- // Open a synchronous session.
- ScopedWaitChainSessionHandle session_handle(
- ::OpenThreadWaitChainSession(0, nullptr));
- if (!session_handle) {
- if (last_error)
- *last_error = ::GetLastError();
- if (failure_reason)
- *failure_reason = kWaitChainSessionFailureReason;
- DPLOG(ERROR) << kWaitChainSessionFailureReason;
- return false;
- }
-
- DWORD nb_nodes = WCT_MAX_NODE_COUNT;
- wait_chain->resize(nb_nodes);
- BOOL is_cycle;
- if (!::GetThreadWaitChain(session_handle.get(), NULL, 0, thread_id, &nb_nodes,
- wait_chain->data(), &is_cycle)) {
- if (last_error)
- *last_error = ::GetLastError();
- if (failure_reason)
- *failure_reason = kGetWaitChainFailureReason;
- DPLOG(ERROR) << kGetWaitChainFailureReason;
- return false;
- }
-
- *is_deadlock = is_cycle ? true : false;
- wait_chain->resize(nb_nodes);
-
- return true;
-}
-
-base::string16 WaitChainNodeToString(const WAITCHAIN_NODE_INFO& node) {
- if (node.ObjectType == WctThreadType) {
- return base::StringPrintf(L"Thread %d in process %d with status %ls",
- node.ThreadObject.ThreadId,
- node.ThreadObject.ProcessId,
- WctObjectStatusToString(node.ObjectStatus));
- } else {
- return base::StringPrintf(L"Lock of type %ls with status %ls",
- WctObjectTypeToString(node.ObjectType),
- WctObjectStatusToString(node.ObjectStatus));
- }
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/wait_chain.h b/base/win/wait_chain.h
deleted file mode 100644
index 0b5947b..0000000
--- a/base/win/wait_chain.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_WAIT_CHAIN_H_
-#define BASE_WIN_WAIT_CHAIN_H_
-
-#include <windows.h>
-#include <wct.h>
-
-#include <vector>
-
-#include "base/strings/string16.h"
-
-namespace base {
-namespace win {
-
-using WaitChainNodeVector = std::vector<WAITCHAIN_NODE_INFO>;
-
-// Gets the wait chain for |thread_id|. Also specifies if the |wait_chain|
-// contains a deadlock. Returns true on success.
-//
-// From MSDN: A wait chain is an alternating sequence of threads and
-// synchronization objects; each thread waits for the object that follows it,
-// which is owned by the subsequent thread in the chain.
-//
-// On error, |failure_reason| and/or |last_error| will contain the details of
-// the failure, given that they are not null.
-// TODO(pmonette): Remove |failure_reason| and |last_error| when UMA is
-// supported in the watcher process and pre-rendez-vous.
-bool GetThreadWaitChain(DWORD thread_id,
- WaitChainNodeVector* wait_chain,
- bool* is_deadlock,
- base::string16* failure_reason,
- DWORD* last_error);
-
-// Returns a string that represents the node for a wait chain.
-base::string16 WaitChainNodeToString(
- const WAITCHAIN_NODE_INFO& node);
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_WAIT_CHAIN_H_
diff --git a/base/win/win_util.cc b/base/win/win_util.cc
index b3867b4..d9efb6e 100644
--- a/base/win/win_util.cc
+++ b/base/win/win_util.cc
@@ -125,11 +125,9 @@
void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) {
DCHECK(metrics);
metrics->cbSize = sizeof(*metrics);
- const bool success = !!SystemParametersInfo(
- SPI_GETNONCLIENTMETRICS,
- metrics->cbSize,
- reinterpret_cast<NONCLIENTMETRICS*>(metrics),
- 0);
+ const bool success =
+ !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics->cbSize,
+ reinterpret_cast<NONCLIENTMETRICS*>(metrics), 0);
DCHECK(success);
}
@@ -183,8 +181,7 @@
return false;
}
- return SetPropVariantValueForPropertyStore(property_store,
- property_key,
+ return SetPropVariantValueForPropertyStore(property_store, property_key,
property_value);
}
@@ -197,8 +194,7 @@
return false;
}
- return SetPropVariantValueForPropertyStore(property_store,
- property_key,
+ return SetPropVariantValueForPropertyStore(property_store, property_key,
property_value);
}
@@ -222,19 +218,19 @@
// See http://msdn.microsoft.com/en-us/library/dd378459%28VS.85%29.aspx
DCHECK(lstrlen(app_id) < 64 && wcschr(app_id, L' ') == NULL);
- return SetStringValueForPropertyStore(property_store,
- PKEY_AppUserModel_ID,
+ return SetStringValueForPropertyStore(property_store, PKEY_AppUserModel_ID,
app_id);
}
static const char16 kAutoRunKeyPath[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
-bool AddCommandToAutoRun(HKEY root_key, const string16& name,
+bool AddCommandToAutoRun(HKEY root_key,
+ const string16& name,
const string16& command) {
RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE);
return (autorun_key.WriteValue(name.c_str(), command.c_str()) ==
- ERROR_SUCCESS);
+ ERROR_SUCCESS);
}
bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) {
@@ -348,8 +344,8 @@
void DisableFlicks(HWND hwnd) {
::SetProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY,
- reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS |
- TABLET_DISABLE_FLICKFALLBACKKEYS));
+ reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS |
+ TABLET_DISABLE_FLICKFALLBACKKEYS));
}
bool IsProcessPerMonitorDpiAware() {
diff --git a/base/win/win_util.h b/base/win/win_util.h
index 1acd455..08738cb 100644
--- a/base/win/win_util.h
+++ b/base/win/win_util.h
@@ -62,32 +62,31 @@
bool UserAccountControlIsEnabled();
// Sets the boolean value for a given key in given IPropertyStore.
-bool SetBooleanValueForPropertyStore(
- IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- bool property_bool_value);
+bool SetBooleanValueForPropertyStore(IPropertyStore* property_store,
+ const PROPERTYKEY& property_key,
+ bool property_bool_value);
// Sets the string value for a given key in given IPropertyStore.
-bool SetStringValueForPropertyStore(
- IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- const wchar_t* property_string_value);
+bool SetStringValueForPropertyStore(IPropertyStore* property_store,
+ const PROPERTYKEY& property_key,
+ const wchar_t* property_string_value);
// Sets the CLSID value for a given key in a given IPropertyStore.
bool SetClsidForPropertyStore(IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- const CLSID& property_clsid_value);
+ const PROPERTYKEY& property_key,
+ const CLSID& property_clsid_value);
// Sets the application id in given IPropertyStore. The function is intended
// for tagging application/chromium shortcut, browser window and jump list for
// Win7.
bool SetAppIdForPropertyStore(IPropertyStore* property_store,
- const wchar_t* app_id);
+ const wchar_t* app_id);
// Adds the specified |command| using the specified |name| to the AutoRun key.
// |root_key| could be HKCU or HKLM or the root of any user hive.
-bool AddCommandToAutoRun(HKEY root_key, const string16& name,
- const string16& command);
+bool AddCommandToAutoRun(HKEY root_key,
+ const string16& name,
+ const string16& command);
// Removes the command specified by |name| from the AutoRun key. |root_key|
// could be HKCU or HKLM or the root of any user hive.
bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name);
@@ -95,8 +94,8 @@
// Reads the command specified by |name| from the AutoRun key. |root_key|
// could be HKCU or HKLM or the root of any user hive. Used for unit-tests.
bool ReadCommandFromAutoRun(HKEY root_key,
- const string16& name,
- string16* command);
+ const string16& name,
+ string16* command);
// Sets whether to crash the process during exit. This is inspected by DLLMain
// and used to intercept unexpected terminations of the process (via calls to
@@ -114,8 +113,8 @@
// This is necessary to set compatible struct sizes for different versions
// of certain Windows APIs (e.g. SystemParametersInfo).
#define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
- offsetof(struct_name, member) + \
- (sizeof static_cast<struct_name*>(NULL)->member)
+ offsetof(struct_name, member) + \
+ (sizeof static_cast<struct_name*>(NULL)->member)
// Used by tests to mock any wanted state. Call with |state| set to true to
// simulate being in a domain and false otherwise.
@@ -132,8 +131,7 @@
// HMODULEs are not add-ref'd, so they should not be closed and may be
// invalidated at any time (should a module be unloaded). |process| requires
// the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ permissions.
-bool GetLoadedModulesSnapshot(HANDLE process,
- std::vector<HMODULE>* snapshot);
+bool GetLoadedModulesSnapshot(HANDLE process, std::vector<HMODULE>* snapshot);
// Adds or removes the MICROSOFT_TABLETPENSERVICE_PROPERTY property with the
// TABLET_DISABLE_FLICKS & TABLET_DISABLE_FLICKFALLBACKKEYS flags in order to
diff --git a/base/win/windows_types.h b/base/win/windows_types.h
index 2a86195..d076c44 100644
--- a/base/win/windows_types.h
+++ b/base/win/windows_types.h
@@ -68,7 +68,6 @@
typedef DWORD ACCESS_MASK;
typedef ACCESS_MASK REGSAM;
-
// Forward declare Windows compatible handles.
#define CHROME_DECLARE_HANDLE(name) \
@@ -84,7 +83,6 @@
typedef HINSTANCE HMODULE;
#undef CHROME_DECLARE_HANDLE
-
// Forward declare some Windows struct/typedef sets.
typedef struct _OVERLAPPED OVERLAPPED;
@@ -118,10 +116,11 @@
PVOID Ptr;
};
-
// Define some commonly used Windows constants. Note that the layout of these
// macros - including internal spacing - must be 100% consistent with windows.h.
+// clang-format off
+
#ifndef INVALID_HANDLE_VALUE
// Work around there being two slightly different definitions in the SDK.
#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
@@ -196,6 +195,8 @@
#define WINAPI __stdcall
#define CALLBACK __stdcall
+// clang-format on
+
// Needed for optimal lock performance.
WINBASEAPI _Releases_exclusive_lock_(*SRWLock) VOID WINAPI
ReleaseSRWLockExclusive(_Inout_ PSRWLOCK SRWLock);
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc
index 6b7be76..dd45286 100644
--- a/base/win/windows_version.cc
+++ b/base/win/windows_version.cc
@@ -23,7 +23,7 @@
#endif
namespace {
-typedef BOOL (WINAPI *GetProductInfoPtr)(DWORD, DWORD, DWORD, DWORD, PDWORD);
+typedef BOOL(WINAPI* GetProductInfoPtr)(DWORD, DWORD, DWORD, DWORD, PDWORD);
} // namespace
namespace base {
@@ -104,8 +104,8 @@
static OSInfo* info;
if (!info) {
OSInfo* new_info = new OSInfo();
- if (InterlockedCompareExchangePointer(
- reinterpret_cast<PVOID*>(&info), new_info, NULL)) {
+ if (InterlockedCompareExchangePointer(reinterpret_cast<PVOID*>(&info),
+ new_info, NULL)) {
delete new_info;
}
}
@@ -117,7 +117,7 @@
kernel32_version_(VERSION_PRE_XP),
architecture_(OTHER_ARCHITECTURE),
wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) {
- OSVERSIONINFOEX version_info = { sizeof version_info };
+ OSVERSIONINFOEX version_info = {sizeof version_info};
::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
version_number_.major = version_info.dwMajorVersion;
version_number_.minor = version_info.dwMinorVersion;
@@ -132,9 +132,15 @@
SYSTEM_INFO system_info = {};
::GetNativeSystemInfo(&system_info);
switch (system_info.wProcessorArchitecture) {
- case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break;
- case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break;
- case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ architecture_ = X86_ARCHITECTURE;
+ break;
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ architecture_ = X64_ARCHITECTURE;
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ architecture_ = IA64_ARCHITECTURE;
+ break;
}
processors_ = system_info.dwNumberOfProcessors;
allocation_granularity_ = system_info.dwAllocationGranularity;
@@ -213,8 +219,7 @@
}
}
-OSInfo::~OSInfo() {
-}
+OSInfo::~OSInfo() {}
std::string OSInfo::processor_model_name() {
if (processor_model_name_.empty()) {
@@ -230,7 +235,7 @@
// static
OSInfo::WOW64Status OSInfo::GetWOW64StatusForProcess(HANDLE process_handle) {
- typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL);
+ typedef BOOL(WINAPI * IsWow64ProcessFunc)(HANDLE, PBOOL);
IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>(
GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process"));
if (!is_wow64_process)
diff --git a/base/win/winrt_storage_util.h b/base/win/winrt_storage_util.h
index 5578415..8cf57d4 100644
--- a/base/win/winrt_storage_util.h
+++ b/base/win/winrt_storage_util.h
@@ -9,7 +9,6 @@
#include <windows.storage.streams.h>
#include <wrl/client.h>
-
namespace base {
namespace win {