diff options
author | Lukas Zilka <zilka@google.com> | 2018-09-27 10:01:57 +0200 |
---|---|---|
committer | Lukas Zilka <zilka@google.com> | 2018-09-27 10:01:57 +0200 |
commit | a91263e8760ffc1d399224e2640b8ec3dd87bff2 (patch) | |
tree | 3c0412e95154d1a2139c53bb85e36350faab87da | |
parent | c991aa5c2a6da248ea95871d23880c25ebe2974e (diff) | |
download | libutf-a91263e8760ffc1d399224e2640b8ec3dd87bff2.tar.gz |
Adds METADATA and updates rune.c.android-o-mr1-iot-release-smart-display-r3android-o-mr1-iot-release-1.0.5oreo-mr1-1.2-iot-releasemaster-cuttlefish-testing-release
Test: builds
-rw-r--r-- | Android.mk | 37 | ||||
-rw-r--r-- | METADATA | 15 | ||||
-rw-r--r-- | rune.c | 11 |
3 files changed, 61 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..887a1ab --- /dev/null +++ b/Android.mk @@ -0,0 +1,37 @@ +LOCAL_PATH := $(call my-dir) + +utf_src := \ + rune.c \ + runestrcat.c \ + runestrchr.c \ + runestrcmp.c \ + runestrcpy.c \ + runestrdup.c \ + runestrlen.c \ + runestrecpy.c \ + runestrncat.c \ + runestrncmp.c \ + runestrncpy.c \ + runestrrchr.c \ + runestrstr.c \ + runetype.c \ + utfecpy.c \ + utflen.c \ + utfnlen.c \ + utfrrune.c \ + utfrune.c \ + utfutf.c + +utf_cflags := -Wall -Wno-missing-braces -Wno-parentheses -Wno-switch + +# We only build the static library at the moment. +include $(CLEAR_VARS) + +LOCAL_MODULE := libutf +LOCAL_SRC_FILES := $(utf_src) +LOCAL_CFLAGS += -O3 $(utf_cflags) +LOCAL_ARM_MODE := arm +LOCAL_SDK_VERSION := 14 + +include $(BUILD_STATIC_LIBRARY) + diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..6abebed --- /dev/null +++ b/METADATA @@ -0,0 +1,15 @@ +name: "utf" +description: "Library for handling UTF-8" + +third_party { + url { + type: HOMEPAGE + value: "http://swtch.com/plan9port/unix/" + } + url { + type: PIPER + value: "http://google3/third_party/libutf" + } + version: "1.1" + last_upgrade_date { year: 2018 month: 9 day: 19 } +} @@ -139,6 +139,8 @@ charntorune(Rune *rune, const char *str, int length) l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4; if (l <= Rune3) goto bad; + if (l > Runemax) + goto bad; *rune = l; return 4; } @@ -222,6 +224,8 @@ chartorune(Rune *rune, const char *str) l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4; if (l <= Rune3) goto bad; + if (l > Runemax) + goto bad; *rune = l; return 4; } @@ -313,7 +317,8 @@ runelen(Rune rune) int runenlen(const Rune *r, int nrune) { - int nb, c; + int nb; + ulong c; /* Rune is signed, so use unsigned for range check. */ nb = 0; while(nrune--) { @@ -324,8 +329,10 @@ runenlen(const Rune *r, int nrune) nb += 2; else if (c <= Rune3) nb += 3; - else /* assert(c <= Rune4) */ + else if (c <= Runemax) nb += 4; + else + nb += 3; /* Runeerror = 0xFFFD, see runetochar */ } return nb; } |