From 3ab1a69545f8c02abfe2de3e3c730044f4ded49e Mon Sep 17 00:00:00 2001 From: sphawk Date: Sun, 11 Mar 2018 19:20:51 +0900 Subject: [PATCH] fix compilation error for non-english windows (like cjk) add /utf-8 switch for msvc build. source code has several utf-8 characters fix C2001 error. escape non-printable ascii code generated by embed_test_data.go fix C4819 warning. add u8 keyword on utf-8 string literal (ripemd_test.cc) Change-Id: I8c04dc7f0359e6ee27efada066863826d263d5cd Reviewed-on: https://boringssl-review.googlesource.com/26484 Reviewed-by: David Benjamin Commit-Queue: David Benjamin CQ-Verified: CQ bot account: commit-bot@chromium.org --- CMakeLists.txt | 4 ++-- decrepit/ripemd/ripemd_test.cc | 2 +- util/embed_test_data.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4965280..4445b557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,8 +160,8 @@ elseif(MSVC) ${MSVC_DISABLED_WARNINGS_LIST}) string(REPLACE "C" " -w4" MSVC_LEVEL4_WARNINGS_STR ${MSVC_LEVEL4_WARNINGS_LIST}) - set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}") - set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}") + set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}") + set(CMAKE_CXX_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}") endif() if(WIN32) diff --git a/decrepit/ripemd/ripemd_test.cc b/decrepit/ripemd/ripemd_test.cc index 5c541961..0700baee 100644 --- a/decrepit/ripemd/ripemd_test.cc +++ b/decrepit/ripemd/ripemd_test.cc @@ -109,7 +109,7 @@ TEST(RIPEMDTest, RunTest) { 0x37, 0xf9, 0x7f, 0x68, 0xf0, 0x83, 0x25, 0xdc, 0x15, 0x28}; if (OPENSSL_memcmp(digest, kMillionADigest, sizeof(digest)) != 0) { - fprintf(stderr, "Digest incorrect for “million a's” test: "); + fprintf(stderr, u8"Digest incorrect for “million a's” test: "); hexdump(stderr, "", digest, sizeof(digest)); ok = 0; } diff --git a/util/embed_test_data.go b/util/embed_test_data.go index ffc446bb..a0838482 100644 --- a/util/embed_test_data.go +++ b/util/embed_test_data.go @@ -21,7 +21,6 @@ import ( "fmt" "io/ioutil" "os" - "unicode" ) func quote(in []byte) string { @@ -46,7 +45,8 @@ func quote(in []byte) string { case '"': buf.WriteString(`\"`) default: - if rune(b) > 127 || unicode.IsPrint(rune(b)) { + // printable ascii code [32, 126] + if 32 <= b && b <= 126 { buf.WriteByte(b) } else { fmt.Fprintf(&buf, "\\x%02x", b)