* include/grub/unicode.h (grub_unicode_compact_range): Replace end with
len and make it smaller. All users updated. * util/import_unicode.py: Put length and not end character. Check length.
This commit is contained in:
parent
8569f13d8d
commit
5da8dbc5bc
4 changed files with 34 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2011-12-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* include/grub/unicode.h (grub_unicode_compact_range): Replace end with
|
||||||
|
len and make it smaller. All users updated.
|
||||||
|
* util/import_unicode.py: Put length and not end character.
|
||||||
|
Check length.
|
||||||
|
|
||||||
2011-12-25 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-12-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Make better Unicode-compliant and unify some UTF-8 code pathes.
|
Make better Unicode-compliant and unify some UTF-8 code pathes.
|
||||||
|
|
|
@ -367,9 +367,9 @@ unpack_join (void)
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
for (i = cur->start; i <= cur->end
|
for (i = cur->start; i < cur->start + (unsigned) cur->len
|
||||||
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
||||||
join_types[i] = cur->join_type;
|
join_types[i] = cur->join_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,9 +387,9 @@ unpack_bidi (void)
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
for (i = cur->start; i <= cur->end
|
for (i = cur->start; i < cur->start + (unsigned) cur->len
|
||||||
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
||||||
if (cur->bidi_mirror)
|
if (cur->bidi_mirror)
|
||||||
bidi_types[i] = cur->bidi_type | 0x80;
|
bidi_types[i] = cur->bidi_type | 0x80;
|
||||||
else
|
else
|
||||||
|
@ -407,8 +407,8 @@ get_bidi_type (grub_uint32_t c)
|
||||||
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
||||||
return bidi_types[c] & 0x7f;
|
return bidi_types[c] & 0x7f;
|
||||||
|
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
if (cur->start <= c && c <= cur->end)
|
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
|
||||||
return cur->bidi_type;
|
return cur->bidi_type;
|
||||||
|
|
||||||
return GRUB_BIDI_TYPE_L;
|
return GRUB_BIDI_TYPE_L;
|
||||||
|
@ -425,8 +425,8 @@ get_join_type (grub_uint32_t c)
|
||||||
if (join_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
if (join_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
||||||
return join_types[c];
|
return join_types[c];
|
||||||
|
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
if (cur->start <= c && c <= cur->end)
|
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
|
||||||
return cur->join_type;
|
return cur->join_type;
|
||||||
|
|
||||||
return GRUB_JOIN_TYPE_NONJOINING;
|
return GRUB_JOIN_TYPE_NONJOINING;
|
||||||
|
@ -443,8 +443,8 @@ is_mirrored (grub_uint32_t c)
|
||||||
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
||||||
return !!(bidi_types[c] & 0x80);
|
return !!(bidi_types[c] & 0x80);
|
||||||
|
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
if (cur->start <= c && c <= cur->end)
|
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
|
||||||
return cur->bidi_mirror;
|
return cur->bidi_mirror;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -461,8 +461,8 @@ grub_unicode_get_comb_type (grub_uint32_t c)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
comb_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
|
comb_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
|
||||||
if (comb_types)
|
if (comb_types)
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
for (i = cur->start; i <= cur->end
|
for (i = cur->start; i < cur->start + (unsigned) cur->len
|
||||||
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
|
||||||
comb_types[i] = cur->comb_type;
|
comb_types[i] = cur->comb_type;
|
||||||
else
|
else
|
||||||
|
@ -472,8 +472,8 @@ grub_unicode_get_comb_type (grub_uint32_t c)
|
||||||
if (comb_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
if (comb_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
|
||||||
return comb_types[c];
|
return comb_types[c];
|
||||||
|
|
||||||
for (cur = grub_unicode_compact; cur->end; cur++)
|
for (cur = grub_unicode_compact; cur->len; cur++)
|
||||||
if (cur->start <= c && c <= cur->end)
|
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
|
||||||
return cur->comb_type;
|
return cur->comb_type;
|
||||||
|
|
||||||
return GRUB_UNICODE_COMB_NONE;
|
return GRUB_UNICODE_COMB_NONE;
|
||||||
|
|
|
@ -31,12 +31,12 @@ struct grub_unicode_bidi_pair
|
||||||
|
|
||||||
struct grub_unicode_compact_range
|
struct grub_unicode_compact_range
|
||||||
{
|
{
|
||||||
grub_uint32_t start:21;
|
unsigned start:21;
|
||||||
grub_uint32_t end:21;
|
unsigned len:9;
|
||||||
grub_uint8_t bidi_type:5;
|
unsigned bidi_type:5;
|
||||||
grub_uint8_t comb_type;
|
unsigned comb_type:8;
|
||||||
grub_uint8_t bidi_mirror:1;
|
unsigned bidi_mirror:1;
|
||||||
grub_uint8_t join_type:3;
|
unsigned join_type:3;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Old-style Arabic shaping. Used for "visual UTF-8" and
|
/* Old-style Arabic shaping. Used for "visual UTF-8" and
|
||||||
|
|
|
@ -130,9 +130,13 @@ for line in infile:
|
||||||
if begincode != -2 and (lastbiditype != "L" or lastcombtype != 0 or \
|
if begincode != -2 and (lastbiditype != "L" or lastcombtype != 0 or \
|
||||||
lastmirrortype):
|
lastmirrortype):
|
||||||
outfile.write (("{0x%x, 0x%x, GRUB_BIDI_TYPE_%s, %d, %d, GRUB_JOIN_TYPE_%s},\n" \
|
outfile.write (("{0x%x, 0x%x, GRUB_BIDI_TYPE_%s, %d, %d, GRUB_JOIN_TYPE_%s},\n" \
|
||||||
% (begincode, lastcode, lastbiditype, \
|
% (begincode, lastcode - begincode + 1, \
|
||||||
|
lastbiditype, \
|
||||||
lastcombtype, lastmirrortype, \
|
lastcombtype, lastmirrortype, \
|
||||||
lastjoin)))
|
lastjoin)))
|
||||||
|
if lastcode - begincode + 1 >= 0x200:
|
||||||
|
print "Too long range"
|
||||||
|
raise
|
||||||
begincode = curcode
|
begincode = curcode
|
||||||
lastcode = curcode
|
lastcode = curcode
|
||||||
lastjoin = curjoin
|
lastjoin = curjoin
|
||||||
|
|
Loading…
Reference in a new issue