Formatted WV utils/src files.

[ Merge of http://go/wvgerrit/80944 ]

Ran `git clang-format` on files in utils/src.

Used the new .clang-format config.

Bug: 134365840
Test: WV unit tests
Change-Id: Idbba01ec65fc019327fc59dc1d95d7cefa4a5aa7
This commit is contained in:
Alex Dale
2019-06-27 13:48:27 -07:00
parent 906dc12c5d
commit fc31b3ef2a
2 changed files with 10 additions and 11 deletions

View File

@@ -6,7 +6,6 @@
// //
#include <windows.h> #include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
LPVOID lpReserved) {
return TRUE; return TRUE;
} }

View File

@@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@@ -24,12 +25,11 @@ static const char kBase64Codes[] =
// Gets the given (zero-indexed) bits [a, b) of |in|. // Gets the given (zero-indexed) bits [a, b) of |in|.
#define GET_BITS(in, a, b) GET_LOW_BITS((in) >> (a), (b) - (a)) #define GET_BITS(in, a, b) GET_LOW_BITS((in) >> (a), (b) - (a))
// Calculates a/b using round-up division (only works for positive numbers). // Calculates a/b using round-up division (only works for positive numbers).
#define CEIL_DIVIDE(a, b) ((((a) - 1) / (b)) + 1) #define CEIL_DIVIDE(a, b) ((((a)-1) / (b)) + 1)
int DecodeBase64Char(char c) { int DecodeBase64Char(char c) {
const char* it = strchr(kBase64Codes, c); const char* it = strchr(kBase64Codes, c);
if (it == NULL) if (it == NULL) return -1;
return -1;
return it - kBase64Codes; return it - kBase64Codes;
} }
@@ -121,8 +121,8 @@ std::string Base64Encode(const std::vector<uint8_t>& bin_input) {
if (i % 3 == 2) { if (i % 3 == 2) {
result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)];
result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)];
result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)];
result[out_index++] = kBase64Codes[GET_BITS(temp, 0, 6)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 0, 6)];
temp = 0; temp = 0;
} }
} }
@@ -135,7 +135,7 @@ std::string Base64Encode(const std::vector<uint8_t>& bin_input) {
} else if (bin_input.size() % 3 == 2) { } else if (bin_input.size() % 3 == 2) {
result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)];
result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)];
result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)]; result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)];
result[out_index++] = '='; result[out_index++] = '=';
} }
@@ -208,8 +208,8 @@ std::vector<uint8_t> Base64Decode(const std::string& b64_input) {
if (i % 4 == 3) { if (i % 4 == 3) {
result[out_index++] = GET_BITS(temp, 16, 24); result[out_index++] = GET_BITS(temp, 16, 24);
result[out_index++] = GET_BITS(temp, 8, 16); result[out_index++] = GET_BITS(temp, 8, 16);
result[out_index++] = GET_BITS(temp, 0, 8); result[out_index++] = GET_BITS(temp, 0, 8);
temp = 0; temp = 0;
} }
} }
@@ -223,7 +223,7 @@ std::vector<uint8_t> Base64Decode(const std::string& b64_input) {
break; break;
case 3: case 3:
result[out_index++] = GET_BITS(temp, 16, 24); result[out_index++] = GET_BITS(temp, 16, 24);
result[out_index++] = GET_BITS(temp, 8, 16); result[out_index++] = GET_BITS(temp, 8, 16);
break; break;
} }
result.resize(out_index); result.resize(out_index);