diff options
Diffstat (limited to 'chromium/third_party/cld_3')
-rw-r--r-- | chromium/third_party/cld_3/src/README.md | 14 | ||||
-rw-r--r-- | chromium/third_party/cld_3/src/src/base.cc | 8 | ||||
-rw-r--r-- | chromium/third_party/cld_3/src/src/script_span/utf8statetable.cc | 26 |
3 files changed, 34 insertions, 14 deletions
diff --git a/chromium/third_party/cld_3/src/README.md b/chromium/third_party/cld_3/src/README.md index 16daddc984c..86008330c43 100644 --- a/chromium/third_party/cld_3/src/README.md +++ b/chromium/third_party/cld_3/src/README.md @@ -29,21 +29,27 @@ To get a language prediction for the input text, we simply perform a forward ### Installation CLD3 is designed to run in the Chrome browser, so it relies on code in [Chromium](http://www.chromium.org/). -The steps for building and running the language detection model are: +The steps for building and running the demo of the language detection model are: - [check out](http://www.chromium.org/developers/how-tos/get-the-code) the Chromium repository. - copy the code to `//third_party/cld_3` +- Uncomment `language_identifier_main` executable in `src/BUILD.gn`. - build and run the model using the commands: ```shell gn gen out/Default -ninja -C out/Default third_party/cld_3/src:language_identifier_main +ninja -C out/Default third_party/cld_3/src/src:language_identifier_main out/Default/language_identifier_main ``` -### Contact +### Bugs and Feature Requests -To ask questions or report issues please contact cld3-users@google.com. +Open a [GitHub issue](https://github.com/google/cld3/issues) for this repository to file bugs and feature requests. + +### Announcements and Discussion + +For announcements regarding major updates as well as general discussion list, please subscribe to: +[cld3-users@googlegroups.com](https://groups.google.com/forum/#!forum/cld3-users) ### Credits diff --git a/chromium/third_party/cld_3/src/src/base.cc b/chromium/third_party/cld_3/src/src/base.cc index 701ca2bfd3a..aaa363c9c6d 100644 --- a/chromium/third_party/cld_3/src/src/base.cc +++ b/chromium/third_party/cld_3/src/src/base.cc @@ -16,14 +16,14 @@ limitations under the License. #include "base.h" #include <string> -#ifdef COMPILER_MSVC +#if defined(COMPILER_MSVC) || defined(_WIN32) #include <sstream> -#endif // COMPILER_MSVC +#endif // defined(COMPILER_MSVC) || defined(_WIN32) namespace chrome_lang_id { // TODO(abakalov): Pick the most efficient approach. -#ifdef COMPILER_MSVC +#if defined(COMPILER_MSVC) || defined(_WIN32) std::string Int64ToString(int64 input) { std::stringstream stream; stream << input; @@ -31,6 +31,6 @@ std::string Int64ToString(int64 input) { } #else std::string Int64ToString(int64 input) { return std::to_string(input); } -#endif // COMPILER_MSVC +#endif // defined(COMPILER_MSVC) || defined(_WIN32) } // namespace chrome_lang_id diff --git a/chromium/third_party/cld_3/src/src/script_span/utf8statetable.cc b/chromium/third_party/cld_3/src/src/script_span/utf8statetable.cc index 0b3d3493576..8fcfb1e8f9d 100644 --- a/chromium/third_party/cld_3/src/src/script_span/utf8statetable.cc +++ b/chromium/third_party/cld_3/src/src/script_span/utf8statetable.cc @@ -158,6 +158,20 @@ static const int kHtmlPlaintextFlag = 0x80; // Bit in add byte to distinguish * **/ +// All intentional fallthroughs in breakpad are in this file, so define +// this macro locally. +// If you ever move this to a .h file, make sure it's defined in a +// private header file: clang suggests the first macro expanding to +// [[clang::fallthrough]] in its diagnostics, so if BP_FALLTHROUGH +// is visible in code depending on breakpad, clang would suggest +// BP_FALLTHROUGH for code depending on breakpad, instead of the +// client code's own fallthrough macro. +#if defined(__clang__) +#define CLD_FALLTHROUGH [[clang::fallthrough]] +#else +#define CLD_FALLTHROUGH +#endif + // Return true if current Tbl pointer is within state0 range // Note that unsigned compare checks both ends of range simultaneously static inline bool InStateZero(const UTF8ScanObj* st, const uint8* Tbl) { @@ -715,10 +729,10 @@ static int UTF8GenericReplaceInternal(const UTF8ReplaceObj* st, goto Do_state_table; case kExitReplace3: // update 3 bytes to change dst[-3] = (unsigned char)Tbl[c + (nEntries * 3)]; - // Fall into next case + CLD_FALLTHROUGH; case kExitReplace2: // update 2 bytes to change dst[-2] = (unsigned char)Tbl[c + (nEntries * 2)]; - // Fall into next case + CLD_FALLTHROUGH; case kExitReplace1: // update 1 byte to change dst[-1] = (unsigned char)Tbl[c + (nEntries * 1)]; total_changed++; @@ -736,7 +750,7 @@ static int UTF8GenericReplaceInternal(const UTF8ReplaceObj* st, } else { offset += ((unsigned char)Tbl[c + (nEntries * 2)] << 8); } - // Fall into next case + CLD_FALLTHROUGH; case kExitSpecial: // Apply special fixups [read: hacks] case kExitReplaceOffset1: if ((nEntries != 256) && InStateZero(st, Tbl)) { @@ -986,10 +1000,10 @@ static int UTF8GenericReplaceInternalTwoByte(const UTF8ReplaceObj_2* st, goto Do_state_table_2; case kExitReplace3_2: // update 3 bytes to change dst[-3] = (unsigned char)(Tbl[c + (nEntries * 2)] & 0xff); - // Fall into next case + CLD_FALLTHROUGH; case kExitReplace2_2: // update 2 bytes to change dst[-2] = (unsigned char)(Tbl[c + (nEntries * 1)] >> 8 & 0xff); - // Fall into next case + CLD_FALLTHROUGH; case kExitReplace1_2: // update 1 byte to change dst[-1] = (unsigned char)(Tbl[c + (nEntries * 1)] & 0xff); total_changed++; @@ -1007,7 +1021,7 @@ static int UTF8GenericReplaceInternalTwoByte(const UTF8ReplaceObj_2* st, } else { offset += ((unsigned char)(Tbl[c + (nEntries * 1)] >> 8 & 0xff) << 8); } - // Fall into next case + CLD_FALLTHROUGH; case kExitReplaceOffset1_2: if ((nEntries != 256) && InStateZero_2(st, Tbl)) { // For space-optimized table, we need multiples of 256 bytes |