diff options
author | Lukas Zilka <zilka@google.com> | 2018-09-28 14:35:00 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-09-28 14:35:00 -0700 |
commit | 37c41ce97d1b9c349a16fc0b7723108b56deaf89 (patch) | |
tree | 3c0412e95154d1a2139c53bb85e36350faab87da | |
parent | c82befbcbfc2a77f6e51927566da381d2c8f1648 (diff) | |
parent | a91263e8760ffc1d399224e2640b8ec3dd87bff2 (diff) | |
download | libutf-37c41ce97d1b9c349a16fc0b7723108b56deaf89.tar.gz |
Adds METADATA and updates rune.c.android-o-mr1-iot-release-smart-display-r9android-o-mr1-iot-release-smart-display-r8android-o-mr1-iot-release-smart-display-r5android-o-mr1-iot-release-smart-display-r40.1Jandroid-o-mr1-iot-release-smart-display-r4android-o-mr1-iot-release-smart-display-r39android-o-mr1-iot-release-smart-display-r30android-o-mr1-iot-release-smart-display-r22android-o-mr1-iot-release-smart-display-r14android-o-mr1-iot-release-smart-clock-r6android-o-mr1-iot-release-smart-clock-r2android-o-mr1-iot-release-smart-clock-fsiandroid-o-mr1-iot-release-smart-clock-fcsandroid-o-mr1-iot-release-cube_r2android-o-mr1-iot-release-cube-fsiandroid-o-mr1-iot-release-cube-fcs
am: a91263e876
Change-Id: Ifa30c6c8a7b776ab90d1e8b06df844007f4c6b99
-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; } |