diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 84b4e1f26..7a953d75f 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -605,7 +605,7 @@ done: void hb_buffer_t::unsafe_to_break_impl (unsigned int start, unsigned int end) { - unsigned int cluster = (unsigned int) -1; + unsigned int cluster = UINT_MAX; cluster = _unsafe_to_break_find_min_cluster (info, start, end, cluster); _unsafe_to_break_set_mask (info, start, end, cluster); } @@ -621,7 +621,7 @@ hb_buffer_t::unsafe_to_break_from_outbuffer (unsigned int start, unsigned int en assert (start <= out_len); assert (idx <= end); - unsigned int cluster = (unsigned int) -1; + unsigned int cluster = UINT_MAX; cluster = _unsafe_to_break_find_min_cluster (out_info, start, out_len, cluster); cluster = _unsafe_to_break_find_min_cluster (info, idx, end, cluster); _unsafe_to_break_set_mask (out_info, start, out_len, cluster); @@ -1731,7 +1731,7 @@ hb_buffer_add_codepoints (hb_buffer_t *buffer, * @buffer: an #hb_buffer_t. * @source: source #hb_buffer_t. * @start: start index into source buffer to copy. Use 0 to copy from start of buffer. - * @end: end index into source buffer to copy. Use (unsigned int) -1 to copy to end of buffer. + * @end: end index into source buffer to copy. Use @HB_FEATURE_GLOBAL_END to copy to end of buffer. * * Append (part of) contents of another buffer to this buffer. * diff --git a/src/hb-common.cc b/src/hb-common.cc index dae08ee73..5b60ff4b2 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -927,14 +927,14 @@ hb_feature_to_string (hb_feature_t *feature, len += 4; while (len && s[len - 1] == ' ') len--; - if (feature->start != 0 || feature->end != (unsigned int) -1) + if (feature->start != HB_FEATURE_GLOBAL_START || feature->end != HB_FEATURE_GLOBAL_END) { s[len++] = '['; if (feature->start) len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start)); if (feature->end != feature->start + 1) { s[len++] = ':'; - if (feature->end != (unsigned int) -1) + if (feature->end != HB_FEATURE_GLOBAL_END) len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end)); } s[len++] = ']'; diff --git a/src/hb-face.hh b/src/hb-face.hh index 68834baeb..f1b472ccf 100644 --- a/src/hb-face.hh +++ b/src/hb-face.hh @@ -94,7 +94,7 @@ struct hb_face_t unsigned int get_num_glyphs () const { unsigned int ret = num_glyphs.get_relaxed (); - if (unlikely (ret == (unsigned int) -1)) + if (unlikely (ret == UINT_MAX)) return load_num_glyphs (); return ret; } diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index f0f2f8c73..20599b986 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -376,7 +376,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED, buffer->len = glyph_count; /* Positioning. */ - unsigned int currclus = (unsigned int) -1; + unsigned int currclus = UINT_MAX; const hb_glyph_info_t *info = buffer->info; hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, nullptr); if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 0a4827d74..b4f2fb904 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -134,13 +134,13 @@ struct hb_ot_map_t unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const { const feature_map_t *map = features.bsearch (feature_tag); - return map ? map->stage[table_index] : (unsigned int) -1; + return map ? map->stage[table_index] : UINT_MAX; } void get_stage_lookups (unsigned int table_index, unsigned int stage, const struct lookup_map_t **plookups, unsigned int *lookup_count) const { - if (unlikely (stage == (unsigned int) -1)) { + if (unlikely (stage == UINT_MAX)) { *plookups = nullptr; *lookup_count = 0; return; diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index f92e6378a..231c31125 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -292,7 +292,7 @@ arabic_joining (hb_buffer_t *buffer) { unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; - unsigned int prev = (unsigned int) -1, state = 0; + unsigned int prev = UINT_MAX, state = 0; /* Check pre-context */ for (unsigned int i = 0; i < buffer->context_len[0]; i++) @@ -318,7 +318,7 @@ arabic_joining (hb_buffer_t *buffer) const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; - if (entry->prev_action != NONE && prev != (unsigned int) -1) + if (entry->prev_action != NONE && prev != UINT_MAX) { info[prev].arabic_shaping_action() = entry->prev_action; buffer->unsafe_to_break (prev, i + 1); @@ -338,7 +338,7 @@ arabic_joining (hb_buffer_t *buffer) continue; const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; - if (entry->prev_action != NONE && prev != (unsigned int) -1) + if (entry->prev_action != NONE && prev != UINT_MAX) info[prev].arabic_shaping_action() = entry->prev_action; break; } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4506b55e6..0c259ea6d 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -737,7 +737,7 @@ hb_ot_shape_setup_masks (const hb_ot_shape_context_t *c) for (unsigned int i = 0; i < c->num_user_features; i++) { const hb_feature_t *feature = &c->user_features[i]; - if (!(feature->start == 0 && feature->end == (unsigned int)-1)) { + if (!(feature->start == HB_FEATURE_GLOBAL_START && feature->end == HB_FEATURE_GLOBAL_END)) { unsigned int shift; hb_mask_t mask = map->get_mask (feature->tag, &shift); buffer->set_masks (feature->value << shift, mask, feature->start, feature->end); diff --git a/src/hb-set.hh b/src/hb-set.hh index 21cb17200..e60a0ee03 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -262,7 +262,7 @@ struct hb_set_t return true; } - void dirty () { population = (unsigned int) -1; } + void dirty () { population = UINT_MAX; } void add (hb_codepoint_t g) { @@ -666,7 +666,7 @@ struct hb_set_t unsigned int get_population () const { - if (population != (unsigned int) -1) + if (population != UINT_MAX) return population; unsigned int pop = 0; diff --git a/test/shaping/data/aots/hb-aots-tester.cpp b/test/shaping/data/aots/hb-aots-tester.cpp index bd46dec36..37079abc0 100644 --- a/test/shaping/data/aots/hb-aots-tester.cpp +++ b/test/shaping/data/aots/hb-aots-tester.cpp @@ -74,8 +74,8 @@ int gNbFeatures; features = (hb_feature_t *) malloc (sizeof (*features)); features[0].tag = HB_TAG('t', 'e', 's', 't'); features[0].value = 1; - features[0].start = 0; - features[0].end = 0xffffffff; + features[0].start = HB_FEATURE_GLOBAL_START; + features[0].end = HB_FEATURE_GLOBAL_END; } else { diff --git a/util/ansi-print.cc b/util/ansi-print.cc index 58df0a65a..80b3704ba 100644 --- a/util/ansi-print.cc +++ b/util/ansi-print.cc @@ -229,7 +229,7 @@ block_best (const biimage_t &bi, bool *inverse) assert (bi.width <= CELL_W); assert (bi.height <= CELL_H); - unsigned int score = (unsigned int) -1; + unsigned int score = UINT_MAX; unsigned int row_sum[CELL_H] = {0}; unsigned int col_sum[CELL_W] = {0}; unsigned int row_sum_i[CELL_H] = {0}; @@ -279,7 +279,7 @@ block_best (const biimage_t &bi, bool *inverse) /* Find best lower line */ if (1) { - unsigned int best_s = (unsigned int) -1; + unsigned int best_s = UINT_MAX; bool best_inv = false; int best_i = 0; for (unsigned int i = 0; i < bi.height - 1; i++) @@ -311,7 +311,7 @@ block_best (const biimage_t &bi, bool *inverse) /* Find best left line */ if (1) { - unsigned int best_s = (unsigned int) -1; + unsigned int best_s = UINT_MAX; bool best_inv = false; int best_i = 0; for (unsigned int i = 0; i < bi.width - 1; i++) diff --git a/util/options.cc b/util/options.cc index 43ff90ad1..c7b3178c6 100644 --- a/util/options.cc +++ b/util/options.cc @@ -746,7 +746,7 @@ text_options_t::get_line (unsigned int *len) line = text; line_len = text_len; } - if (line_len == (unsigned int) -1) + if (line_len == UINT_MAX) line_len = strlen (line); if (!line_len) { diff --git a/util/options.hh b/util/options.hh index 9e22b4008..0fcc76e67 100644 --- a/util/options.hh +++ b/util/options.hh @@ -517,7 +517,7 @@ struct text_options_t : option_group_t fp = nullptr; gs = nullptr; line = nullptr; - line_len = (unsigned int) -1; + line_len = UINT_MAX; add_options (parser); }