diff --git a/.circleci/config.yml b/.circleci/config.yml index defba1a57008181d8e3691dd58959349b36af792..9c59e482a4dabac96c356d5e3d12f338344dddf4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ jobs: - image: alpine steps: - checkout - - run: apk update && apk add ragel make pkgconfig libtool autoconf automake gettext gcc g++ glib-dev freetype-dev cairo-dev + - run: apk update && apk add ragel make pkgconfig libtool autoconf automake gettext gcc g++ glib-dev freetype-dev cairo-dev python # C??FLAGS are not needed for a regular build - run: CFLAGS="-O3" CXXFLAGS="-O3 -DHB_NO_MMAP" ./autogen.sh - run: make -j32 @@ -60,10 +60,10 @@ jobs: archlinux-py3-all: docker: - - image: base/devel + - image: archlinux/base steps: - checkout - - run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip + - run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip make which base-devel - run: pip install flake8 fonttools - run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics # C??FLAGS are not needed for a regular build @@ -71,6 +71,15 @@ jobs: - run: make -j32 CPPFLAGS="-Werror" - run: make check CPPFLAGS="-Werror" || .ci/fail.sh + ## Doesn't play well with CircleCI apparently + #void-notest: + # docker: + # - image: voidlinux/voidlinux + # steps: + # - checkout + # - run: xbps-install -Suy freetype gettext gcc glib graphite pkg-config ragel libtool autoconf automake make + # - run: ./autogen.sh && make -j32 && make check + clang-O3-O0: docker: - image: ubuntu:18.10 @@ -307,6 +316,7 @@ workflows: # autotools based builds - alpine-O3-NOMMAP - archlinux-py3-all + #- void-notest - gcc-valgrind - clang-O3-O0 - clang-everything diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 9b524c130f258fb7d4816df9c5fc81176bfe9e45..7b169d9c463c1a86f395f9b9008b34f27bf8843e 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -327,11 +327,6 @@ hb_ceil_to_4 (unsigned int v) template static inline bool hb_in_range (T u, T lo, T hi) { - /* The sizeof() is here to force template instantiation. - * I'm sure there are better ways to do this but can't think of - * one right now. Declaring a variable won't work as HB_UNUSED - * is unusable on some platforms and unused types are less likely - * to generate a warning than unused variables. */ static_assert (!hb_is_signed::value, ""); /* The casts below are important as if T is smaller than int, diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 42ea3ea2b3fbc3c833e843935af4ab1ff12fab63..5989306784ccc96083d53e25662ffaa2c2853395 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -171,7 +171,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) || CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay"))) { -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1080 # define kCTFontUIFontSystem kCTFontSystemFontType # define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType #endif @@ -214,7 +214,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) } CFURLRef original_url = nullptr; -#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 ATSFontRef atsFont; FSRef fsref; OSStatus status; @@ -244,7 +244,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) * process in Blink. This can be detected by the new file URL location * that the newly found font points to. */ CFURLRef new_url = nullptr; -#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 atsFont = CTFontGetPlatformFont (new_ct_font, NULL); status = ATSFontGetFileReference (atsFont, &fsref); if (status == noErr) @@ -711,7 +711,7 @@ resize_and_retry: /* What's the iOS equivalent of this check? * The symbols was introduced in iOS 7.0. * At any rate, our fallback is safe and works fine. */ -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1090 # define kCTLanguageAttributeName CFSTR ("NSLanguage") #endif CFStringRef lang = CFStringCreateWithCStringNoCopy (kCFAllocatorDefault, @@ -783,7 +783,7 @@ resize_and_retry: int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1; CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level); -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel; #endif CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault, diff --git a/src/hb-meta.hh b/src/hb-meta.hh index b580036381ba5f59fd6c822846eaf20426ab51df..af7e5ccd9247ad56b2118f69b52241db7c8b4ba7 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -88,24 +88,15 @@ struct hb_enable_if { typedef T type; }; */ template struct hb_is_signed; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -/* We need to define hb_is_signed for the typedefs we use on pre-Visual - * Studio 2010 for the int8_t type, since __int8/__int64 is not considered - * the same as char/long. The previous lines will suffice for the other - * types, though. Note that somehow, unsigned __int8 is considered same - * as unsigned char. - * https://github.com/harfbuzz/harfbuzz/pull/1499 - */ -#if defined(_MSC_VER) && (_MSC_VER < 1600) -template <> struct hb_is_signed<__int8> { enum { value = true }; }; -#endif +/* https://github.com/harfbuzz/harfbuzz/issues/1535 */ +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; #define hb_is_signed(T) hb_is_signed::value template struct hb_signedness_int; diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index a00b940b2ab160705ad94087613341eb467f44c5..5125e9fa9203f1acec3f5935ed4c33d625c82b28 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -215,7 +215,7 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) unsigned int gen_cat = (unsigned int) unicode->general_category (u); unsigned int props = gen_cat; - if (u >= 0x80) + if (u >= 0x80u) { buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII; @@ -232,10 +232,10 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) * FVSes are GC=Mn, we have use a separate bit to remember them. * Fixes: * https://github.com/harfbuzz/harfbuzz/issues/234 */ - else if (unlikely (hb_in_range (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_HIDDEN; + else if (unlikely (hb_in_range (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_HIDDEN; /* TAG characters need similar treatment. Fixes: * https://github.com/harfbuzz/harfbuzz/issues/463 */ - else if (unlikely (hb_in_range (u, 0xE0020u, 0xE007Fu))) props |= UPROPS_MASK_HIDDEN; + else if (unlikely (hb_in_range (u, 0xE0020u, 0xE007Fu))) props |= UPROPS_MASK_HIDDEN; /* COMBINING GRAPHEME JOINER should not be skipped; at least some times. * https://github.com/harfbuzz/harfbuzz/issues/554 */ else if (unlikely (u == 0x034Fu)) diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 50a52136b7fb2732968ec444ee92b90320b1f0f8..bdebde0f42e8af159460e977937d09074795caee 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -467,7 +467,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED, unsigned int j = new_len; for (unsigned int i = count; i; i--) { - if (!hb_in_range (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING)) + if (!hb_in_range (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING)) { if (step == CUT) { @@ -488,7 +488,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED, unsigned int end = i; while (i && - hb_in_range (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING)) + hb_in_range (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING)) { i--; hb_position_t width = font->get_glyph_h_advance (info[i].codepoint); @@ -506,7 +506,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED, unsigned int start = i; unsigned int context = i; while (context && - !hb_in_range (info[context - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING) && + !hb_in_range (info[context - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING) && (_hb_glyph_info_is_default_ignorable (&info[context - 1]) || HB_ARABIC_GENERAL_CATEGORY_IS_WORD (_hb_glyph_info_get_general_category (&info[context - 1])))) { diff --git a/test/fuzzing/hb-subset-fuzzer.cc b/test/fuzzing/hb-subset-fuzzer.cc index 3a71f221f2b7fd8b662f9d43a3e382ae851131f2..56ffd227119206584e08b215fd1056574e957257 100644 --- a/test/fuzzing/hb-subset-fuzzer.cc +++ b/test/fuzzing/hb-subset-fuzzer.cc @@ -11,11 +11,13 @@ trySubset (hb_face_t *face, const hb_codepoint_t text[], int text_length, bool drop_hints, - bool drop_layout) + bool drop_layout, + bool retain_gids) { hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_subset_input_set_drop_hints (input, drop_hints); hb_subset_input_set_drop_layout (input, drop_layout); + hb_subset_input_set_retain_gids (input, retain_gids); hb_set_t *codepoints = hb_subset_input_unicode_set (input); for (int i = 0; i < text_length; i++) @@ -32,16 +34,14 @@ trySubset (hb_face_t *face, static void trySubset (hb_face_t *face, const hb_codepoint_t text[], - int text_length) + int text_length, + const uint8_t flags[1]) { - for (unsigned int drop_hints = 0; drop_hints < 2; drop_hints++) - { - for (unsigned int drop_layout = 0; drop_layout < 2; drop_layout++) - { - trySubset (face, text, text_length, - (bool) drop_hints, (bool) drop_layout); - } - } + bool drop_hints = flags[0] & (1 << 0); + bool drop_layout = flags[0] & (1 << 1); + bool retain_gids = flags[0] & (1 << 2); + trySubset (face, text, text_length, + drop_hints, drop_layout, retain_gids); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) @@ -55,21 +55,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_face_collect_unicodes (face, output); hb_set_destroy (output); + uint8_t flags[1] = {0}; const hb_codepoint_t text[] = { 'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2', '3', '@', '_', '%', '&', ')', '*', '$', '!' }; - trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t)); + trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t), flags); hb_codepoint_t text_from_data[16]; - if (size > sizeof(text_from_data)) { + if (size > sizeof(text_from_data) + sizeof(flags)) { memcpy (text_from_data, data + size - sizeof(text_from_data), sizeof(text_from_data)); + + memcpy (flags, + data + size - sizeof(text_from_data) - sizeof(flags), + sizeof(flags)); unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t); - trySubset (face, text_from_data, text_size); + + trySubset (face, text_from_data, text_size, flags); } hb_face_destroy (face);