]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* include/grub/unicode.h (grub_unicode_compact_range): Replace end with
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 25 Dec 2011 15:03:42 +0000 (16:03 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 25 Dec 2011 15:03:42 +0000 (16:03 +0100)
len and make it smaller. All users updated.
* util/import_unicode.py: Put length and not end character.
Check length.

ChangeLog
grub-core/normal/charset.c
include/grub/unicode.h
util/import_unicode.py

index ada61af4c82e10c7e3c75a08bfde26a331048889..e15c6d8247ac44fe75184e6ad6ddb60c0b32a69d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 6ddd91827a58f563d259be37e16ac190330fbbb5..314a1be6694ff59b392882f0eded2a66275c1999 100644 (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;
index 64769258a9137ef7e6203114412ddba8a6c7b25c..ebdfbddbf6648ad9e5531fea527a01b54070f25d 100644 (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
index 8d17e7ef67c94b9c8feebadba9e4c42798afa677..ec3db08424455339893cda3af397a152e5c1bbc6 100644 (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