From 26968bafc2023039c6f9abfdd4ce8dbed0334a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 10 Oct 2018 16:17:35 +0200 Subject: [PATCH] Delete unused utf8 conversion utilities And drop a few unneeded includes of rtc_base/stringencode.h. Bug: webrtc:6424 Change-Id: I8be92a2ca199afaae1d3a177c23acbf2b9bdc465 Reviewed-on: https://webrtc-review.googlesource.com/c/105002 Reviewed-by: Karl Wiberg Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#25125} --- media/engine/webrtcvoiceengine.cc | 1 - p2p/base/dtlstransportinternal.h | 1 - p2p/base/icetransportinternal.h | 1 - p2p/base/stun.cc | 1 - p2p/base/stunrequest.cc | 1 - p2p/base/turnport.cc | 1 - p2p/base/turnserver.cc | 1 - pc/jsepicecandidate.cc | 1 - pc/jsepsessiondescription.cc | 1 - pc/peerconnectionendtoend_unittest.cc | 1 - pc/srtpfilter.cc | 1 - rtc_base/optionsfile.cc | 1 - rtc_base/stringencode.cc | 61 --------------------------- video/screenshare_loopback.cc | 1 - video/sv_loopback.cc | 1 - 15 files changed, 75 deletions(-) diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index bc2f2d3378..a98676c820 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -38,7 +38,6 @@ #include "rtc_base/helpers.h" #include "rtc_base/logging.h" #include "rtc_base/race_checker.h" -#include "rtc_base/stringencode.h" #include "rtc_base/strings/audio_format_to_string.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/stringutils.h" diff --git a/p2p/base/dtlstransportinternal.h b/p2p/base/dtlstransportinternal.h index 58d36fa08d..238057e4c9 100644 --- a/p2p/base/dtlstransportinternal.h +++ b/p2p/base/dtlstransportinternal.h @@ -18,7 +18,6 @@ #include "p2p/base/icetransportinternal.h" #include "p2p/base/packettransportinternal.h" #include "rtc_base/sslstreamadapter.h" -#include "rtc_base/stringencode.h" namespace cricket { diff --git a/p2p/base/icetransportinternal.h b/p2p/base/icetransportinternal.h index 31e7078c94..a4af24b7c3 100644 --- a/p2p/base/icetransportinternal.h +++ b/p2p/base/icetransportinternal.h @@ -20,7 +20,6 @@ #include "p2p/base/packettransportinternal.h" #include "p2p/base/port.h" #include "p2p/base/transportdescription.h" -#include "rtc_base/stringencode.h" namespace cricket { diff --git a/p2p/base/stun.cc b/p2p/base/stun.cc index cc9fb4e4c0..fa6b6f832e 100644 --- a/p2p/base/stun.cc +++ b/p2p/base/stun.cc @@ -22,7 +22,6 @@ #include "rtc_base/crc32.h" #include "rtc_base/logging.h" #include "rtc_base/messagedigest.h" -#include "rtc_base/stringencode.h" using rtc::ByteBufferReader; using rtc::ByteBufferWriter; diff --git a/p2p/base/stunrequest.cc b/p2p/base/stunrequest.cc index 7e4d2dceea..edba4d68e5 100644 --- a/p2p/base/stunrequest.cc +++ b/p2p/base/stunrequest.cc @@ -18,7 +18,6 @@ #include "rtc_base/checks.h" #include "rtc_base/helpers.h" #include "rtc_base/logging.h" -#include "rtc_base/stringencode.h" #include "rtc_base/timeutils.h" // For TimeMillis namespace cricket { diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc index 97541f60c0..43cefc4879 100644 --- a/p2p/base/turnport.cc +++ b/p2p/base/turnport.cc @@ -24,7 +24,6 @@ #include "rtc_base/logging.h" #include "rtc_base/nethelpers.h" #include "rtc_base/socketaddress.h" -#include "rtc_base/stringencode.h" #include "rtc_base/strings/string_builder.h" namespace cricket { diff --git a/p2p/base/turnserver.cc b/p2p/base/turnserver.cc index 022113e7e7..99ca80a9a9 100644 --- a/p2p/base/turnserver.cc +++ b/p2p/base/turnserver.cc @@ -24,7 +24,6 @@ #include "rtc_base/logging.h" #include "rtc_base/messagedigest.h" #include "rtc_base/socketadapters.h" -#include "rtc_base/stringencode.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/thread.h" diff --git a/pc/jsepicecandidate.cc b/pc/jsepicecandidate.cc index 277f1bab4f..2133d9dadd 100644 --- a/pc/jsepicecandidate.cc +++ b/pc/jsepicecandidate.cc @@ -14,7 +14,6 @@ #include "absl/memory/memory.h" #include "pc/webrtcsdp.h" -#include "rtc_base/stringencode.h" namespace webrtc { diff --git a/pc/jsepsessiondescription.cc b/pc/jsepsessiondescription.cc index 64a7a2bd59..b590eca2a9 100644 --- a/pc/jsepsessiondescription.cc +++ b/pc/jsepsessiondescription.cc @@ -17,7 +17,6 @@ #include "pc/mediasession.h" #include "pc/webrtcsdp.h" #include "rtc_base/arraysize.h" -#include "rtc_base/stringencode.h" using cricket::SessionDescription; diff --git a/pc/peerconnectionendtoend_unittest.cc b/pc/peerconnectionendtoend_unittest.cc index 60da2d242c..3e0c2c39eb 100644 --- a/pc/peerconnectionendtoend_unittest.cc +++ b/pc/peerconnectionendtoend_unittest.cc @@ -20,7 +20,6 @@ #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "rtc_base/gunit.h" #include "rtc_base/logging.h" -#include "rtc_base/stringencode.h" #include "rtc_base/stringutils.h" #ifdef WEBRTC_ANDROID diff --git a/pc/srtpfilter.cc b/pc/srtpfilter.cc index 5ffe34212e..cd0393a03e 100644 --- a/pc/srtpfilter.cc +++ b/pc/srtpfilter.cc @@ -19,7 +19,6 @@ #include "rtc_base/byteorder.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/stringencode.h" #include "rtc_base/third_party/base64/base64.h" #include "rtc_base/timeutils.h" #include "rtc_base/zero_memory.h" diff --git a/rtc_base/optionsfile.cc b/rtc_base/optionsfile.cc index 535859b4cc..075c15dda0 100644 --- a/rtc_base/optionsfile.cc +++ b/rtc_base/optionsfile.cc @@ -14,7 +14,6 @@ #include "rtc_base/logging.h" #include "rtc_base/stream.h" -#include "rtc_base/stringencode.h" namespace rtc { diff --git a/rtc_base/stringencode.cc b/rtc_base/stringencode.cc index 6a065cb8b2..36c3f91236 100644 --- a/rtc_base/stringencode.cc +++ b/rtc_base/stringencode.cc @@ -48,67 +48,6 @@ size_t url_decode(char* buffer, return bufpos; } -size_t utf8_decode(const char* source, size_t srclen, unsigned long* value) { - const unsigned char* s = reinterpret_cast(source); - if ((s[0] & 0x80) == 0x00) { // Check s[0] == 0xxxxxxx - *value = s[0]; - return 1; - } - if ((srclen < 2) || ((s[1] & 0xC0) != 0x80)) { // Check s[1] != 10xxxxxx - return 0; - } - // Accumulate the trailer byte values in value16, and combine it with the - // relevant bits from s[0], once we've determined the sequence length. - unsigned long value16 = (s[1] & 0x3F); - if ((s[0] & 0xE0) == 0xC0) { // Check s[0] == 110xxxxx - *value = ((s[0] & 0x1F) << 6) | value16; - return 2; - } - if ((srclen < 3) || ((s[2] & 0xC0) != 0x80)) { // Check s[2] != 10xxxxxx - return 0; - } - value16 = (value16 << 6) | (s[2] & 0x3F); - if ((s[0] & 0xF0) == 0xE0) { // Check s[0] == 1110xxxx - *value = ((s[0] & 0x0F) << 12) | value16; - return 3; - } - if ((srclen < 4) || ((s[3] & 0xC0) != 0x80)) { // Check s[3] != 10xxxxxx - return 0; - } - value16 = (value16 << 6) | (s[3] & 0x3F); - if ((s[0] & 0xF8) == 0xF0) { // Check s[0] == 11110xxx - *value = ((s[0] & 0x07) << 18) | value16; - return 4; - } - return 0; -} - -size_t utf8_encode(char* buffer, size_t buflen, unsigned long value) { - if ((value <= 0x7F) && (buflen >= 1)) { - buffer[0] = static_cast(value); - return 1; - } - if ((value <= 0x7FF) && (buflen >= 2)) { - buffer[0] = 0xC0 | static_cast(value >> 6); - buffer[1] = 0x80 | static_cast(value & 0x3F); - return 2; - } - if ((value <= 0xFFFF) && (buflen >= 3)) { - buffer[0] = 0xE0 | static_cast(value >> 12); - buffer[1] = 0x80 | static_cast((value >> 6) & 0x3F); - buffer[2] = 0x80 | static_cast(value & 0x3F); - return 3; - } - if ((value <= 0x1FFFFF) && (buflen >= 4)) { - buffer[0] = 0xF0 | static_cast(value >> 18); - buffer[1] = 0x80 | static_cast((value >> 12) & 0x3F); - buffer[2] = 0x80 | static_cast((value >> 6) & 0x3F); - buffer[3] = 0x80 | static_cast(value & 0x3F); - return 4; - } - return 0; -} - static const char HEX[] = "0123456789abcdef"; char hex_encode(unsigned char val) { diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc index f5dac784ed..245d2636b0 100644 --- a/video/screenshare_loopback.cc +++ b/video/screenshare_loopback.cc @@ -12,7 +12,6 @@ #include "rtc_base/flags.h" #include "rtc_base/logging.h" -#include "rtc_base/stringencode.h" #include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" #include "test/gtest.h" diff --git a/video/sv_loopback.cc b/video/sv_loopback.cc index b143241e61..864fc634ef 100644 --- a/video/sv_loopback.cc +++ b/video/sv_loopback.cc @@ -12,7 +12,6 @@ #include "rtc_base/flags.h" #include "rtc_base/logging.h" -#include "rtc_base/stringencode.h" #include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" #include "test/gtest.h"