Prefer UINT_MAX instead of uint overflow.
Also, prefer HB_FEATURE_GLOBAL_START and HB_FEATURE_GLOBAL_END.
This commit is contained in:
parent
b618e0ae13
commit
b79ceac3c6
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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++] = ']';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue