OSDN Git Service

check_shrinkage().
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 12 Jun 2014 09:09:20 +0000 (17:09 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 12 Jun 2014 09:09:20 +0000 (17:09 +0800)
act_width -> active_width[1].
kern_break().
is_hex().
end_line_char_inactive().
cur_file.

src/texsourc/itex.c
src/texsourc/tex2.c
src/texsourc/tex3.c
src/texsourc/tex6.c
src/texsourc/yandy_macros.h

index 3f1a49e..e7c8b9f 100644 (file)
@@ -297,7 +297,7 @@ void initialize_aux (void)
 void line_break_ (integer final_widow_penalty)
 {
   boolean auto_breaking;
-  halfword prevp;
+  halfword prev_p;
   halfword q, r, s, prevs;
   internal_font_number f;
 /*  small_number j;  */
@@ -326,13 +326,8 @@ void line_break_ (integer final_widow_penalty)
   init_r_hyf = (prev_graf / 65536L) % 64;
   pop_nest();
   no_shrink_error_yet = true;
-
-  if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0))
-    left_skip = finite_shrink(left_skip);
-
-  if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0))
-    right_skip = finite_shrink(right_skip);
-
+  check_shrinkage(left_skip);
+  check_shrinkage(right_skip);
   q = left_skip;
   r = right_skip;
   background[1] = width(q) + width(r);
@@ -452,7 +447,7 @@ void line_break_ (integer final_widow_penalty)
     line_number(q) = prev_graf + 1;
     total_demerits(q) = 0;
     link(active) = q;
-    active_width[1] = background[1];
+    act_width = background[1];
     active_width[2] = background[2];
     active_width[3] = background[3];
     active_width[4] = background[4];
@@ -466,18 +461,18 @@ void line_break_ (integer final_widow_penalty)
 
     cur_p = link(temp_head);
     auto_breaking = true;
-    prevp = cur_p;
+    prev_p = cur_p;
 
     while ((cur_p != 0) && (link(active) != active))
     {
       if (is_char_node(cur_p))
       {
-        prevp = cur_p;
+        prev_p = cur_p;
 
         do
           {
             f = font(cur_p);
-            active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
+            act_width = act_width + char_width(f, char_info(f, character(cur_p)));
             cur_p = link(cur_p);
           }
         while (!(!is_char_node(cur_p)));
@@ -488,7 +483,7 @@ void line_break_ (integer final_widow_penalty)
         case hlist_node:
         case vlist_node:
         case rule_node:
-          active_width[1] = active_width[1] + width(cur_p);
+          act_width = act_width + width(cur_p);
           break;
 
         case whatsit_node:
@@ -504,21 +499,17 @@ void line_break_ (integer final_widow_penalty)
           {
             if (auto_breaking)
             {
-              if (is_char_node(prevp))
+              if (is_char_node(prev_p))
                 try_break(0, unhyphenated);
-              else if ((mem[prevp].hh.b0 < 9))
+              else if ((mem[prev_p].hh.b0 < 9))
                 try_break(0, unhyphenated);
-              else if ((type(prevp) == kern_node) && (subtype(prevp) != explicit))
+              else if ((type(prev_p) == kern_node) && (subtype(prev_p) != explicit))
                 try_break(0, unhyphenated);
             }
 
-            if ((mem[glue_ptr(cur_p)].hh.b1 != 0) && (mem[glue_ptr(cur_p) + 3].cint != 0))
-            {
-              glue_ptr(cur_p) = finite_shrink(glue_ptr(cur_p));
-            }
-
+            check_shrinkage(glue_ptr(cur_p));
             q = glue_ptr(cur_p);
-            active_width[1] = active_width[1]+ width(q);
+            act_width = act_width+ width(q);
             active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
             active_width[6] = active_width[6] + shrink(q);
 
@@ -691,20 +682,14 @@ lab31:;
           break;
         case kern_node:
           if (subtype(cur_p) == explicit)
-          {
-            if (!is_char_node(link(cur_p)) && auto_breaking)
-              if (type(link(cur_p)) == glue_node)
-                try_break(0, unhyphenated);
-
-            active_width[1] = active_width[1] + width(cur_p);
-          }
+            kern_break();
           else
-            active_width[1] = active_width[1] + width(cur_p);
+            act_width = act_width + width(cur_p);
           break;
         case ligature_node:
           {
             f = font(lig_char(cur_p));
-            active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(cur_p))));
+            act_width = act_width + char_width(f, char_info(f, character(lig_char(cur_p))));
           }
           break;
         case disc_node:
@@ -748,9 +733,9 @@ lab31:;
               }
               while (!(s == 0));
 
-              active_width[1] = active_width[1] + disc_width;
+              act_width = act_width + disc_width;
               try_break(hyphen_penalty, hyphenated);
-              active_width[1] = active_width[1] - disc_width;
+              act_width = act_width - disc_width;
             }
             r = replace_count(cur_p);
             s = link(cur_p);
@@ -760,14 +745,14 @@ lab31:;
               if (is_char_node(s))
               {
                 f = font(s);
-                active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
+                act_width = act_width + char_width(f, char_info(f, character(s)));
               }
               else switch(type(s))
               {
                 case ligature_node:
                   {
                     f = font(lig_char(s));
-                    active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
+                    act_width = act_width + char_width(f, char_info(f, character(lig_char(s))));
                   }
                   break;
 
@@ -775,7 +760,7 @@ lab31:;
                 case vlist_node:
                 case rule_node:
                 case kern_node:
-                  active_width[1] = active_width[1] + width(s);
+                  act_width = act_width + width(s);
                   break;
 
                 default:
@@ -790,7 +775,7 @@ lab31:;
               s = link(s);
             }
 
-            prevp = cur_p;
+            prev_p = cur_p;
             cur_p = s;
             goto lab35;
           }
@@ -798,14 +783,8 @@ lab31:;
 
         case math_node:
           {
-            auto_breaking = (subtype(cur_p) == 1);
-            {
-              if (!is_char_node(link(cur_p)) && auto_breaking)
-                if (type(link(cur_p)) == glue_node)
-                  try_break(0, unhyphenated);
-
-              active_width[1] = active_width[1] + width(cur_p);
-            }
+            auto_breaking = (subtype(cur_p) == after);
+            kern_break();
           }
           break;
 
@@ -826,7 +805,7 @@ lab31:;
           break;
       }
 
-      prevp = cur_p;
+      prev_p = cur_p;
       cur_p = link(cur_p);
 lab35:;
     }
@@ -926,7 +905,7 @@ lab35:;
 #ifdef STAT
       if (tracing_paragraphs > 0)
         print_nl("@secondpass");
-#endif /* STAT */
+#endif
       threshold = tolerance;
       second_pass = true;
       second_pass_count++;          /* 96 Feb 9 */
@@ -2314,7 +2293,7 @@ lab1:
         incr(loc);
     }
 
-    if ((end_line_char < 0) || (end_line_char > 255))
+    if (end_line_char_inactive())
       decr(limit);
     else
       buffer[limit] = end_line_char;
index 242242d..0730df5 100644 (file)
@@ -670,7 +670,7 @@ void end_file_reading (void)
   line = line_stack[index];
 
   if (cur_input.name_field > 17)
-    a_close(input_file[index]);
+    a_close(cur_file);
 
   pop_input();
   decr(in_open);
@@ -2019,27 +2019,18 @@ lab26:
                         if (c < 128)
                         {
                           d = 2;
-                          if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+                          if (is_hex(c))
                             if (k + 2 <= limit)
                             {
                               cc = buffer[k + 2];
 
-                              if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                              if (is_hex(cc))
                                 incr(d);
                             }
 
                           if (d > 2)
                           {
-                            if (c <= 57)
-                              cur_chr = c - 48;
-                            else
-                              cur_chr = c - 87;
-
-                            if (cc <= 57)
-                              cur_chr = 16 * cur_chr + cc - 48;
-                            else
-                              cur_chr = 16 * cur_chr + cc - 87;
-
+                            hex_to_cur_chr();
                             buffer[k - 1] = cur_chr;
                           }
                           else if (c < 64)
@@ -2082,27 +2073,19 @@ lab26:
                       if (c < 128)             /* ? */
                       {
                         d = 2;
-                        if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+
+                        if (is_hex(c))
                           if (k + 2 <= limit)
                           {
                             cc = buffer[k + 2];
 
-                            if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                            if (is_hex(cc))
                               incr(d);
                           }
 
                         if (d > 2)
                         {
-                          if (c <= 57)
-                            cur_chr = c - 48;
-                          else
-                            cur_chr = c - 87;
-
-                          if (cc <= 57)          /* cc may be used without ... */
-                            cur_chr = 16 * cur_chr + cc - 48;
-                          else
-                            cur_chr = 16 * cur_chr + cc - 87;
-
+                          hex_to_cur_chr();
                           buffer[k - 1] = cur_chr;
                         }
                         else if (c < 64)
@@ -2157,25 +2140,15 @@ lab40:
                 {
                   loc = loc + 2;
 
-                  if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+                  if (is_hex(c))
                     if (loc <= limit)
                     {
                       cc = buffer[loc];
 
-                      if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                      if (is_hex(cc))
                       {
                         incr(loc);
-
-                        if (c <= 57)
-                          cur_chr = c - 48;
-                        else
-                          cur_chr = c - 87;
-
-                        if (cc <= 57)
-                          cur_chr = 16 * cur_chr + cc - 48;
-                        else
-                          cur_chr = 16 * cur_chr + cc - 87;
-
+                        hex_to_cur_chr();
                         goto lab21;
                       }
                     }
@@ -2284,7 +2257,7 @@ lab40:
 
         if (!force_eof)
         {
-          if (input_ln(input_file[index], true))
+          if (input_ln(cur_file, true))
             firm_up_the_line();
           else
             force_eof = true;
@@ -2303,7 +2276,7 @@ lab40:
           goto lab20;
         }
 
-        if ((end_line_char < 0) || (end_line_char > 255))
+        if (end_line_char_inactive())
           decr(limit);
         else
           buffer[limit] = end_line_char;
@@ -2331,7 +2304,7 @@ lab40:
 
         if (interaction > nonstop_mode)
         {
-          if ((end_line_char < 0) || (end_line_char > 255))
+          if (end_line_char_inactive())
             incr(limit);
 
           if (limit == start)
@@ -2342,7 +2315,7 @@ lab40:
           prompt_input("*");
           limit = last;
 
-          if ((end_line_char < 0) || (end_line_char > 255))
+          if (end_line_char_inactive())
             decr(limit);
           else
             buffer[limit]= end_line_char;
index 44e9726..acc4212 100644 (file)
@@ -1003,7 +1003,7 @@ void read_toks_(integer n, halfword r)
 
       limit = last;
 
-      if ((end_line_char < 0) || (end_line_char > 255))
+      if (end_line_char_inactive())
         decr(limit);
       else
         buffer[limit] = end_line_char;
@@ -1964,7 +1964,7 @@ void start_input(void)
   {
     begin_file_reading();
     
-    if (a_open_in(input_file[index], TEXINPUTPATH))
+    if (a_open_in(cur_file, TEXINPUTPATH))
       goto lab30;
 
     end_file_reading();
@@ -1972,7 +1972,7 @@ void start_input(void)
   }
 
 lab30: 
-  cur_input.name_field = a_make_name_string(input_file[index]);
+  cur_input.name_field = a_make_name_string(cur_file);
 
   if (job_name == 0)
   {
@@ -2002,11 +2002,11 @@ lab30:
   {
     line = 1;
 
-    if (input_ln(input_file[index], false));
+    if (input_ln(cur_file, false));
 
     firm_up_the_line();
 
-    if ((end_line_char < 0) || (end_line_char > 255))
+    if (end_line_char_inactive())
       decr(limit);
     else
       buffer[limit] = end_line_char;
index 1faa571..123890b 100644 (file)
@@ -1702,7 +1702,7 @@ halfword vert_break_(halfword p, scaled h, scaled d)
         else
           b = badness(h - cur_height, active_width[2]);
       else
-        if (active_width[1] - h > active_width[6])
+        if (act_width - h > active_width[6])
           b = awful_bad;
         else
           b = badness(cur_height - h, active_width[6]);
@@ -1903,7 +1903,7 @@ void freeze_page_specs_(small_number s)
     print_scaled(page_max_depth);
     end_diagnostic(false);
   }
-#endif /* STAT */
+#endif
 }
 /* sec 0992 */
 void box_error_(eight_bits n)
index a4f5b0c..46dfbaa 100644 (file)
@@ -743,6 +743,8 @@ while (0)
 #define mid_line    1
 #define skip_blanks 2 + max_char_code // 17
 #define new_line    3 + max_char_code + max_char_code // 33
+/* sec 0304 */
+#define cur_file input_file[index]
 /* sec 0305 */
 #define skipping  1
 #define defining  2
@@ -790,6 +792,26 @@ while (0)
   case (a) + sub_mark:   \
   case (a) + letter:     \
   case (a) + other_char
+/* sec 0352 */
+#define is_hex(a) \
+  (((a >= '0') && (a <= '9')) || ((a >= 'a') && (a <= 'f')))
+#define hex_to_cur_chr()                    \
+do                                          \
+{                                           \
+  if (c <= '9')                             \
+    cur_chr = c - '0';                      \
+  else                                      \
+    cur_chr = c - 'a' + 10;                 \
+                                            \
+  if (cc <= '9')                            \
+    cur_chr = 16 * cur_chr + cc - '0';      \
+  else                                      \
+    cur_chr = 16 * cur_chr + cc - 'a' + 10; \
+}                                           \
+while (0)
+/* sec 0360 */
+#define end_line_char_inactive()  \
+  (end_line_char < 0) || (end_line_char > 255)
 /* sec 0358 */
 /* sec 0371 */
 #define store_new_token(a)  \
@@ -1191,6 +1213,14 @@ while (0)
 #define delta_node      2
 /* sec 0823 */
 #define do_all_six(a) a(1); a(2); a(3); a(4); a(5); a(6)
+/* sec 0825 */
+#define check_shrinkage(s)                            \
+do                                                    \
+{                                                     \
+  if ((shrink_order(s) != normal) && (shrink(s) != 0))\
+    s = finite_shrink(s);                             \
+}                                                     \
+while (0)
 /* sec 0829 */
 #define copy_to_cur_active(a) cur_active_width[a] = active_width[a]
 /* sec 0832 */
@@ -1210,6 +1240,18 @@ while (0)
 #define downdate_width(a)     cur_active_width[(a)] = cur_active_width[(a)] - mem[prev_r + (a)].cint
 /* sec 0861 */
 #define update_active(a) active_width[(a)] = active_width[(a)] + mem[r + (a)].cint
+/* sec 0866 */
+#define act_width active_width[1]
+#define kern_break()                                \
+do                                                  \
+{                                                   \
+  if (!is_char_node(link(cur_p)) && auto_breaking)  \
+    if (type(link(cur_p)) == glue_node)             \
+      try_break(0, unhyphenated);                   \
+                                                    \
+  act_width = act_width + width(cur_p);             \
+}                                                   \
+while (0)
 /* sec 0877 */
 #define next_break prev_break
 /* sec 0908 */