Commit graph

10 commits

Author SHA1 Message Date
Colin Cross
17b5b82d64 Fix warnings in libutils headers
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in libutils
headers in preparation for moving from -isystem to -I.

- Fix implicit cast from int64_t to long in Condition.h.  Remove
  the __LP64__ check and always compare against LONG_MAX before
  casting.
- Fix implicit cast from size_t to ssize_t in KeyedVector.h
- Fix -Wshadow-field-in-constructor warnings in Looper.h and RefBase.h
- Move destructors for MessageHandler and LooperCallback to Looper.cpp
  and ReferenceRenamer and VirtualLightRefBase to RefBase.cpp to prevent
  vtables in every compilation unit.
- Declare template variables in Singleton.h
- Fix old-style casts in StrongPointer.h and TypeHelpers.h
- Use template metaprogramming in TypeHelpers.h to avoid warnings on
  memmove on non-trivial types.
- Add an assignment operator to key_value_pair_t to complete
  rule-of-three
- Use memcpy instead of dereferencing a reinterpret_casted pointer to
  treat the bits of a float or double as int32_t or int64_t
- Escape unicode sequences inside doxygen comments between \code and
  \endcode
- Remove WIN32 ZD definition in Compat.h, %zd works fine with mingw
- Fix WIN32 printf warnings in Filemap.cpp
- Initialize mNullValue with 0 in LruCache.h, some of the tests use a
  non-pointer type for TValue.

Test: m -j native
Bug: 31492149
Change-Id: I385a05a3ca01258e44fe3b37ef77e4aaff547b26
2016-09-22 13:03:15 -07:00
Sergio Giro
1cfa56d46c libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length
is causing a heap overflow.

Correcting the length computation and adding bound checks to the
conversion functions.

Test: ran libutils_tests
Bug: 29250543
Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb
(cherry picked from commit c4966a363e)
2016-08-25 20:07:51 +00:00
Sergio Giro
9de6776321 Unicode: specify destination length in utf8_to_utf16 methods
String16(const char *utf8) now returns the empty string in case
a string ends halfway throw a utf8 character.

Bug: 29267949
Clean cherry-pick from 1dcc0c8239

Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-25 19:57:06 +00:00
Michael Wright
5bacef33c9 Add String16#contains and strstr16 methods.
These are needed for aapt to find javadoc comments that contain
"@removed" in order to skip them when printing styleable docs.

Bug: 28663748
Change-Id: I8866d2167c41e11d6c2586da369560d5815fd13e
2016-05-09 19:45:07 +01:00
Dan Albert
c59932f937 Remove incompatible Unicode compatibility types.
As well intentioned as these were, uint16_t and C++11's char16_t are
_not_ actually compatible. They are not implicitly convertible, and
they mangle differently, so they are not even ABI compatible. In our
now wonderous world of C++11, no one should be using these, so just
kill them.

Bug: 18300613
Change-Id: I06d92d7f1d937dd94a620874323d4c50eb6a31bd
2014-11-20 11:54:39 -08:00
Dan Albert
2f5ad5ff86 Make Unicode.h use types that match libc++.
libc++ also defines these types for pre-C++11, and the two definitions
need to match to avoid redefinition errors.

Bug: 18300613
Change-Id: I1e9198d39f7c470f37bc6edba2dca2d499f54c9b
2014-11-08 20:22:30 +00:00
Tim Murray
ae83f84548 Add guards to prevent typedefs when C++11 is available.
char32_t and char16_t are both defined in C++11.

Change-Id: I44fe8f4f05f230c18a1b77fa21b6a40c8f8ecc2d
2014-04-07 14:11:21 -07:00
Dianne Hackborn
0f10d0abf3 Add a new utf8-to-utf16 conversion function.
Change-Id: I957c22fb219596ca4239db7a169473d3894b09eb
2013-07-31 16:04:39 -07:00
Jeff Brown
aa983c91ca Fix regression in CursorWindow.copyStingToBuffer.
Bug: 5332296

Change-Id: Iff9eed786f0a8293b6156f883a66a322ddad5e99
2013-07-30 13:56:58 -07:00
Kenny Root
ba0165bef0 Split UTF functions from String8/16
Split out all the UTF-8/16/32 handling code from String8/16 to its own
file to allow better reuse of code.

Change-Id: If9ce63920edc75472c38da4adce0d13cda9ad2f7
2013-07-30 13:56:55 -07:00