emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/coding.c,v


From: Kenichi Handa
Subject: [Emacs-diffs] Changes to emacs/src/coding.c,v
Date: Fri, 21 Nov 2008 02:23:07 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Kenichi Handa <handa>   08/11/21 02:23:07

Index: coding.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/coding.c,v
retrieving revision 1.394
retrieving revision 1.395
diff -u -b -r1.394 -r1.395
--- coding.c    23 Oct 2008 06:55:14 -0000      1.394
+++ coding.c    21 Nov 2008 02:23:06 -0000      1.395
@@ -2758,6 +2758,7 @@
   int i;
   int rejected = 0;
   int found = 0;
+  int composition_count = -1;
 
   detect_info->checked |= CATEGORY_MASK_ISO;
 
@@ -2826,10 +2827,20 @@
              rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
              break;
            }
+         else if (c == '1')
+           {
+             /* End of composition.  */
+             if (composition_count < 0
+                 || composition_count > MAX_COMPOSITION_COMPONENTS)
+               /* Invalid */
+               break;
+             composition_count = -1;
+             found |= CATEGORY_MASK_ISO;
+           }
          else if (c >= '0' && c <= '4')
            {
              /* ESC <Fp> for start/end composition.  */
-             found |= CATEGORY_MASK_ISO;
+             composition_count = 0;
              break;
            }
          else
@@ -2900,6 +2911,8 @@
            continue;
          if (c < 0x80)
            {
+             if (composition_count >= 0)
+               composition_count++;
              single_shifting = 0;
              break;
            }
@@ -2924,9 +2937,17 @@
                    }
 
                  if (i & 1 && src < src_end)
+                   {
                    rejected |= CATEGORY_MASK_ISO_8_2;
+                     if (composition_count >= 0)
+                       composition_count += i;
+                   }
                  else
+                   {
                    found |= CATEGORY_MASK_ISO_8_2;
+                     if (composition_count >= 0)
+                       composition_count += i / 2;
+                   }
                }
              break;
            }
@@ -3043,6 +3064,8 @@
            break;                                                      \
        if (p == src_end - 1)                                           \
          {                                                             \
+           if (coding->mode & CODING_MODE_LAST_BLOCK)                  \
+             goto invalid_code;                                        \
            /* The current composition doesn't end in the current       \
               source.  */                                              \
            record_conversion_result                                    \
@@ -3190,11 +3213,16 @@
              if (composition_state == COMPOSING_RULE
                  || composition_state == COMPOSING_COMPONENT_RULE)
                {
+                 if (component_idx < MAX_COMPOSITION_COMPONENTS * 2 + 1)
+                   {
                  DECODE_COMPOSITION_RULE (c1);
                  components[component_idx++] = c1;
                  composition_state--;
                  continue;
                }
+                 /* Too long composition.  */
+                 MAYBE_FINISH_COMPOSITION ();
+               }
            }
          if (charset_id_0 < 0
              || ! CHARSET_ISO_CHARS_96 (CHARSET_FROM_ID (charset_id_0)))
@@ -3210,11 +3238,15 @@
              if (composition_state == COMPOSING_RULE
                  || composition_state == COMPOSING_COMPONENT_RULE)
                {
+                 if (component_idx < MAX_COMPOSITION_COMPONENTS * 2 + 1)
+                   {
                  DECODE_COMPOSITION_RULE (c1);
                  components[component_idx++] = c1;
                  composition_state--;
                  continue;
                }
+                 MAYBE_FINISH_COMPOSITION ();
+               }
            }
          if (charset_id_0 < 0)
            charset = CHARSET_FROM_ID (charset_ascii);
@@ -3571,12 +3603,21 @@
        }
       else
        {
+         if (component_idx < MAX_COMPOSITION_COMPONENTS * 2 + 1)
+           {
          components[component_idx++] = c;
          if (method == COMPOSITION_WITH_RULE
              || (method == COMPOSITION_WITH_RULE_ALTCHARS
                  && composition_state == COMPOSING_COMPONENT_CHAR))
            composition_state++;
        }
+         else
+           {
+             MAYBE_FINISH_COMPOSITION ();
+             *charbuf++ = c;
+             char_offset++;
+           }
+       }
       continue;
 
     invalid_code:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]