* 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:
Vladimir 'phcoder' Serbinenko 2011-12-25 16:03:42 +01:00
parent 8569f13d8d
commit 5da8dbc5bc
4 changed files with 34 additions and 23 deletions

View File

@ -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>
Make better Unicode-compliant and unify some UTF-8 code pathes.

View File

@ -367,9 +367,9 @@ unpack_join (void)
grub_errno = GRUB_ERR_NONE;
return;
}
for (cur = grub_unicode_compact; cur->end; cur++)
for (i = cur->start; i <= cur->end
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
for (cur = grub_unicode_compact; cur->len; cur++)
for (i = cur->start; i < cur->start + (unsigned) cur->len
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
join_types[i] = cur->join_type;
}
@ -387,9 +387,9 @@ unpack_bidi (void)
grub_errno = GRUB_ERR_NONE;
return;
}
for (cur = grub_unicode_compact; cur->end; cur++)
for (i = cur->start; i <= cur->end
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
for (cur = grub_unicode_compact; cur->len; cur++)
for (i = cur->start; i < cur->start + (unsigned) cur->len
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
if (cur->bidi_mirror)
bidi_types[i] = cur->bidi_type | 0x80;
else
@ -407,8 +407,8 @@ get_bidi_type (grub_uint32_t c)
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
return bidi_types[c] & 0x7f;
for (cur = grub_unicode_compact; cur->end; cur++)
if (cur->start <= c && c <= cur->end)
for (cur = grub_unicode_compact; cur->len; cur++)
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
return cur->bidi_type;
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)
return join_types[c];
for (cur = grub_unicode_compact; cur->end; cur++)
if (cur->start <= c && c <= cur->end)
for (cur = grub_unicode_compact; cur->len; cur++)
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
return cur->join_type;
return GRUB_JOIN_TYPE_NONJOINING;
@ -443,8 +443,8 @@ is_mirrored (grub_uint32_t c)
if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
return !!(bidi_types[c] & 0x80);
for (cur = grub_unicode_compact; cur->end; cur++)
if (cur->start <= c && c <= cur->end)
for (cur = grub_unicode_compact; cur->len; cur++)
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
return cur->bidi_mirror;
return 0;
@ -461,8 +461,8 @@ grub_unicode_get_comb_type (grub_uint32_t c)
unsigned i;
comb_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
if (comb_types)
for (cur = grub_unicode_compact; cur->end; cur++)
for (i = cur->start; i <= cur->end
for (cur = grub_unicode_compact; cur->len; cur++)
for (i = cur->start; i < cur->start + (unsigned) cur->len
&& i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
comb_types[i] = cur->comb_type;
else
@ -472,8 +472,8 @@ grub_unicode_get_comb_type (grub_uint32_t c)
if (comb_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
return comb_types[c];
for (cur = grub_unicode_compact; cur->end; cur++)
if (cur->start <= c && c <= cur->end)
for (cur = grub_unicode_compact; cur->len; cur++)
if (cur->start <= c && c < cur->start + (unsigned) cur->len)
return cur->comb_type;
return GRUB_UNICODE_COMB_NONE;

View File

@ -31,12 +31,12 @@ struct grub_unicode_bidi_pair
struct grub_unicode_compact_range
{
grub_uint32_t start:21;
grub_uint32_t end:21;
grub_uint8_t bidi_type:5;
grub_uint8_t comb_type;
grub_uint8_t bidi_mirror:1;
grub_uint8_t join_type:3;
unsigned start:21;
unsigned len:9;
unsigned bidi_type:5;
unsigned comb_type:8;
unsigned bidi_mirror:1;
unsigned join_type:3;
} __attribute__ ((packed));
/* Old-style Arabic shaping. Used for "visual UTF-8" and

View File

@ -130,9 +130,13 @@ for line in infile:
if begincode != -2 and (lastbiditype != "L" or lastcombtype != 0 or \
lastmirrortype):
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, \
lastjoin)))
if lastcode - begincode + 1 >= 0x200:
print "Too long range"
raise
begincode = curcode
lastcode = curcode
lastjoin = curjoin