From 8e545d59610211261e684c10158b9e5df6fae24d Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 22 Jun 2015 22:29:04 -0400 Subject: [PATCH 1/5] Fix all VC++ warnings and errors in the current commit's builds. --- src/hb-common.cc | 4 ++-- src/hb-fallback-shape.cc | 2 +- src/hb-ot-layout.cc | 2 +- src/hb-ot-map.cc | 2 +- src/hb-ot-shape-complex-hangul.cc | 2 +- src/hb-ot-shape-complex-hebrew.cc | 2 +- src/hb-ot-shape-complex-indic.cc | 4 ++-- src/hb-ot-shape-normalize.cc | 6 +++--- src/hb-ot-shape.cc | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 21d3b4117..1484bbb2e 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -219,7 +219,7 @@ struct hb_language_item_t { } inline hb_language_item_t & operator = (const char *s) { - lang = (hb_language_t) strdup (s); + lang = (hb_language_t) _strdup (s); for (unsigned char *p = (unsigned char *) lang; *p; p++) *p = canon_map[*p]; @@ -518,7 +518,7 @@ hb_user_data_array_t::set (hb_user_data_key_t *key, } } hb_user_data_item_t item = {key, data, destroy}; - bool ret = !!items.replace_or_insert (item, lock, replace); + bool ret = !!items.replace_or_insert (item, lock, replace != 0); return ret; } diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc index 9d061a9e8..0cd623e99 100644 --- a/src/hb-fallback-shape.cc +++ b/src/hb-fallback-shape.cc @@ -106,7 +106,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, */ hb_codepoint_t space; - bool has_space = font->get_glyph (' ', 0, &space); + bool has_space = font->get_glyph (' ', 0, &space) != 0; buffer->clear_positions (); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 05ea0603c..160d7bba2 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -719,7 +719,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, hb_bool_t zero_context) { if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false; - OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, zero_context); + OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, zero_context != 0); const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 4985eb22b..28acbda4c 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -89,7 +89,7 @@ hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_, for (unsigned int table_index = 0; table_index < 2; table_index++) { hb_tag_t table_tag = table_tags[table_index]; - found_script[table_index] = hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index], &chosen_script[table_index]); + found_script[table_index] = hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index], &chosen_script[table_index]) != 0; hb_ot_layout_script_find_language (face, table_tag, script_index[table_index], language_tag, &language_index[table_index]); } } diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index 6ac18b08b..37c160031 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -305,7 +305,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan, { /* Have , , or */ hb_codepoint_t s = u; - bool has_glyph = font->has_glyph (s); + bool has_glyph = font->has_glyph (s) != 0; unsigned int lindex = (s - SBase) / NCount; unsigned int nindex = (s - SBase) % NCount; unsigned int vindex = nindex / TCount; diff --git a/src/hb-ot-shape-complex-hebrew.cc b/src/hb-ot-shape-complex-hebrew.cc index c7b7a5eba..0330c9c1d 100644 --- a/src/hb-ot-shape-complex-hebrew.cc +++ b/src/hb-ot-shape-complex-hebrew.cc @@ -68,7 +68,7 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c, 0xFB4Au /* TAV */ }; - bool found = c->unicode->compose (a, b, ab); + bool found = c->unicode->compose (a, b, ab) != 0; if (!found && !c->plan->has_mark) { diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 772360041..1a1eba095 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1847,7 +1847,7 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c, } } - return c->unicode->decompose (ab, a, b); + return c->unicode->decompose (ab, a, b) != 0; } static bool @@ -1863,7 +1863,7 @@ compose_indic (const hb_ot_shape_normalize_context_t *c, /* Composition-exclusion exceptions that we want to recompose. */ if (a == 0x09AFu && b == 0x09BCu) { *ab = 0x09DFu; return true; } - return c->unicode->compose (a, b, ab); + return c->unicode->compose (a, b, ab) != 0; } diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 8cc64af01..f67ddb100 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -88,7 +88,7 @@ decompose_unicode (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t *a, hb_codepoint_t *b) { - return c->unicode->decompose (ab, a, b); + return c->unicode->decompose (ab, a, b) != 0; } static bool @@ -97,7 +97,7 @@ compose_unicode (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t b, hb_codepoint_t *ab) { - return c->unicode->compose (a, b, ab); + return c->unicode->compose (a, b, ab) != 0; } static inline void @@ -139,7 +139,7 @@ decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint (b && !font->get_glyph (b, 0, &b_glyph))) return 0; - bool has_a = font->get_glyph (a, 0, &a_glyph); + bool has_a = font->get_glyph (a, 0, &a_glyph) != 0; if (shortest && has_a) { /* Output a and b */ output_char (buffer, a, a_glyph); diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index a531d7706..e133115fa 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -538,7 +538,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) { bool ret = false; unsigned int count = c->buffer->len; - bool has_positioning = hb_ot_layout_has_positioning (c->face); + bool has_positioning = hb_ot_layout_has_positioning (c->face) != 0; /* If the font has no GPOS, AND, no fallback positioning will * happen, AND, direction is forward, then when zeroing mark * widths, we shift the mark with it, such that the mark From e0a828ecbd708757d67977f7e92a6f4c1b0b92fd Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 23 Jun 2015 09:07:17 -0400 Subject: [PATCH 2/5] Back to using regular `strdup`, with an `hb-private.hh` fix that special-cases VC++'s definition and usage of the words --- src/hb-common.cc | 2 +- src/hb-private.hh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 1484bbb2e..a37154579 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -219,7 +219,7 @@ struct hb_language_item_t { } inline hb_language_item_t & operator = (const char *s) { - lang = (hb_language_t) _strdup (s); + lang = (hb_language_t) strdup (s); for (unsigned char *p = (unsigned char *) lang; *p; p++) *p = canon_map[*p]; diff --git a/src/hb-private.hh b/src/hb-private.hh index 45afc20b1..996d88d29 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -132,6 +132,9 @@ static int errno = 0; /* Use something better? */ # endif # if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf +# elif defined(_MSC_VER) && _MSC_VER >= 1900 +# /* Covers VC++ Error for strdup being a deprected POSIX name and to instead use _strdup instead */ +# define strdup _strdup # endif #endif From 8ad89f057d737ccbc6f411e9ebcf11b8130a50bb Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 23 Jun 2015 09:09:24 -0400 Subject: [PATCH 3/5] Spelling words is not my strong point. --- src/hb-private.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-private.hh b/src/hb-private.hh index 996d88d29..570c4897a 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -133,7 +133,7 @@ static int errno = 0; /* Use something better? */ # if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf # elif defined(_MSC_VER) && _MSC_VER >= 1900 -# /* Covers VC++ Error for strdup being a deprected POSIX name and to instead use _strdup instead */ +# /* Covers VC++ Error for strdup being a deprecated POSIX name and to instead use _strdup instead */ # define strdup _strdup # endif #endif From 23237b0279a04407addf33f599c45faa60f002ca Mon Sep 17 00:00:00 2001 From: ThePhD Date: Fri, 14 Aug 2015 01:19:08 -0400 Subject: [PATCH 4/5] Last apparent boolean fix! --- src/hb-ot-shape-complex-use.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 1d44d2200..cc2a9d4d8 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -572,7 +572,7 @@ compose_use (const hb_ot_shape_normalize_context_t *c, if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a))) return false; - return c->unicode->compose (a, b, ab); + return c->unicode->compose (a, b, ab) != 0; } From f798b8e2d683a1b89b6905b1a8615375b847b468 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 21 Nov 2015 16:57:26 -0500 Subject: [PATCH 5/5] c-style cast --- src/hb-ot-shape-complex-use.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index cc2a9d4d8..d7138c8c2 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -572,7 +572,7 @@ compose_use (const hb_ot_shape_normalize_context_t *c, if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a))) return false; - return c->unicode->compose (a, b, ab) != 0; + return (bool)c->unicode->compose (a, b, ab); }