Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
diff --git a/rtc_base/stringutils.cc b/rtc_base/stringutils.cc
index 7664bb8..bef128c 100644
--- a/rtc_base/stringutils.cc
+++ b/rtc_base/stringutils.cc
@@ -10,8 +10,8 @@
#include <algorithm>
#include <cstdio>
-#include "rtc_base/stringutils.h"
#include "rtc_base/checks.h"
+#include "rtc_base/stringutils.h"
namespace rtc {
@@ -33,8 +33,8 @@
return true;
}
while (*target) {
- if ((toupper(*pattern) == toupper(*target))
- && string_match(target + 1, pattern + 1)) {
+ if ((toupper(*pattern) == toupper(*target)) &&
+ string_match(target + 1, pattern + 1)) {
return true;
}
++target;
@@ -52,25 +52,32 @@
}
#if defined(WEBRTC_WIN)
-int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n,
+int ascii_string_compare(const wchar_t* s1,
+ const char* s2,
+ size_t n,
CharacterTransformation transformation) {
wchar_t c1, c2;
while (true) {
- if (n-- == 0) return 0;
+ if (n-- == 0)
+ return 0;
c1 = transformation(*s1);
// Double check that characters are not UTF-8
RTC_DCHECK_LT(*s2, 128);
// Note: *s2 gets implicitly promoted to wchar_t
c2 = transformation(*s2);
- if (c1 != c2) return (c1 < c2) ? -1 : 1;
- if (!c1) return 0;
+ if (c1 != c2)
+ return (c1 < c2) ? -1 : 1;
+ if (!c1)
+ return 0;
++s1;
++s2;
}
}
-size_t asccpyn(wchar_t* buffer, size_t buflen,
- const char* source, size_t srclen) {
+size_t asccpyn(wchar_t* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen) {
if (buflen <= 0)
return 0;
@@ -91,11 +98,11 @@
#endif // WEBRTC_WIN
-void replace_substrs(const char *search,
+void replace_substrs(const char* search,
size_t search_len,
- const char *replace,
+ const char* replace,
size_t replace_len,
- std::string *s) {
+ std::string* s) {
size_t pos = 0;
while ((pos = s->find(search, pos, search_len)) != std::string::npos) {
s->replace(pos, search_len, replace, replace_len);
@@ -103,11 +110,11 @@
}
}
-bool starts_with(const char *s1, const char *s2) {
+bool starts_with(const char* s1, const char* s2) {
return strncmp(s1, s2, strlen(s2)) == 0;
}
-bool ends_with(const char *s1, const char *s2) {
+bool ends_with(const char* s1, const char* s2) {
size_t s1_length = strlen(s1);
size_t s2_length = strlen(s2);
@@ -123,7 +130,7 @@
std::string string_trim(const std::string& s) {
std::string::size_type first = s.find_first_not_of(kWhitespace);
- std::string::size_type last = s.find_last_not_of(kWhitespace);
+ std::string::size_type last = s.find_last_not_of(kWhitespace);
if (first == std::string::npos || last == std::string::npos) {
return std::string("");