OSDN Git Service

check_shrinkage().
[putex/putex.git] / src / texsourc / tex6.c
index f4c93a0..123890b 100644 (file)
@@ -81,7 +81,7 @@ void try_break_ (integer pi, small_number break_type)
   halfword r;
   halfword prev_r;
   halfword old_l;
-  bool no_break_yet;
+  boolean no_break_yet;
   halfword prev_prev_r;
   halfword s;
   halfword q;
@@ -89,12 +89,12 @@ void try_break_ (integer pi, small_number break_type)
   integer t;
   internal_font_number f;
   halfword l;
-  bool node_r_stays_active;
+  boolean node_r_stays_active;
   scaled line_width;
   char fit_class;
-  halfword b;       /* current badness */
+  halfword b;
   integer d;
-  bool artificial_demerits;
+  boolean artificial_demerits;
   halfword save_link;
   scaled shortfall;
 
@@ -108,14 +108,7 @@ void try_break_ (integer pi, small_number break_type)
   prev_r = active;
   old_l = 0;
   do_all_six(copy_to_cur_active);
-/*
-  cur_active_width[1] = active_width[1];
-  cur_active_width[2] = active_width[2];
-  cur_active_width[3] = active_width[3];
-  cur_active_width[4] = active_width[4];
-  cur_active_width[5] = active_width[5];
-  cur_active_width[6] = active_width[6];
-*/
+
   while (true)
   {
 lab22:
@@ -124,14 +117,6 @@ lab22:
     if (type(r) == delta_node)
     {
       do_all_six(update_width);
-/*
-      cur_active_width[1] = cur_active_width[1] + mem[r + 1].cint;
-      cur_active_width[2] = cur_active_width[2] + mem[r + 2].cint;
-      cur_active_width[3] = cur_active_width[3] + mem[r + 3].cint;
-      cur_active_width[4] = cur_active_width[4] + mem[r + 4].cint;
-      cur_active_width[5] = cur_active_width[5] + mem[r + 5].cint;
-      cur_active_width[6] = cur_active_width[6] + mem[r + 6].cint;
-*/
       prev_prev_r = prev_r;
       prev_r = r;
       goto lab22;
@@ -148,14 +133,6 @@ lab22:
           {
             no_break_yet = false;
             do_all_six(set_break_width_to_background);
-/*
-            break_width[1] = background[1];
-            break_width[2] = background[2];
-            break_width[3] = background[3];
-            break_width[4] = background[4];
-            break_width[5] = background[5];
-            break_width[6] = background[6];
-*/
             s = cur_p;
 
             if (break_type > unhyphenated)
@@ -170,7 +147,7 @@ lab22:
                   decr(t);
                   v = link(v);
 
-                  if ((v >= hi_mem_min))
+                  if (is_char_node(v))
                   {
                     f = font(v);
                     break_width[1] = break_width[1] - char_width(f, char_info(f, character(v)));
@@ -194,7 +171,7 @@ lab22:
                     default:
                       {
                         confusion("disc1");
-                        return;       // abort_flag set
+                        return;
                       }
                       break;
                   }
@@ -202,7 +179,7 @@ lab22:
 
                 while (s != 0)
                 {
-                  if ((s >= hi_mem_min))
+                  if (is_char_node(s))
                   {
                     f = font(s);
                     break_width[1] = break_width[1] + char_width(f, char_info(f, character(s)));
@@ -242,7 +219,7 @@ lab22:
 
               while (s != 0)
               {
-                if ((s >= hi_mem_min))
+                if (is_char_node(s))
                   goto lab30;
 
                 switch (type(s))
@@ -284,26 +261,10 @@ lab30:;
           if (type(prev_r) == delta_node)
           {
             do_all_six(convert_to_break_width);
-/*
-            mem[prev_r + 1].cint = mem[prev_r + 1].cint - cur_active_width[1] + break_width[1];
-            mem[prev_r + 2].cint = mem[prev_r + 2].cint - cur_active_width[2] + break_width[2];
-            mem[prev_r + 3].cint = mem[prev_r + 3].cint - cur_active_width[3] + break_width[3];
-            mem[prev_r + 4].cint = mem[prev_r + 4].cint - cur_active_width[4] + break_width[4];
-            mem[prev_r + 5].cint = mem[prev_r + 5].cint - cur_active_width[5] + break_width[5];
-            mem[prev_r + 6].cint = mem[prev_r + 6].cint - cur_active_width[6] + break_width[6];
-*/
           }
           else if (prev_r == active)
           {
             do_all_six(store_break_width);
-/*
-            active_width[1] = break_width[1];
-            active_width[2] = break_width[2];
-            active_width[3] = break_width[3];
-            active_width[4] = break_width[4];
-            active_width[5] = break_width[5];
-            active_width[6] = break_width[6];
-*/
           }
           else
           {
@@ -312,14 +273,6 @@ lab30:;
             type(q) = delta_node;
             subtype(q) = 0;
             do_all_six(new_delta_to_break_width);
-/*
-            mem[q + 1].cint = break_width[1]- cur_active_width[1];
-            mem[q + 2].cint = break_width[2]- cur_active_width[2];
-            mem[q + 3].cint = break_width[3]- cur_active_width[3];
-            mem[q + 4].cint = break_width[4]- cur_active_width[4];
-            mem[q + 5].cint = break_width[5]- cur_active_width[5];
-            mem[q + 6].cint = break_width[6]- cur_active_width[6];
-*/
             link(prev_r) = q;
             prev_prev_r = prev_r;
             prev_r = q;
@@ -341,7 +294,7 @@ lab30:;
 #ifdef STAT
               incr(pass_number);
               serial(q) = pass_number;
-#endif /* STAT */
+#endif
               prev_break(q) = best_place[fit_class];
               q = get_node(active_node_size);
               break_node(q) = passive;
@@ -389,14 +342,6 @@ lab30:;
             type(q) = delta_node;
             subtype(q) = 0;
             do_all_six(new_delta_from_break_width);
-/*
-            mem[q + 1].cint = cur_active_width[1] - break_width[1];
-            mem[q + 2].cint = cur_active_width[2] - break_width[2];
-            mem[q + 3].cint = cur_active_width[3] - break_width[3];
-            mem[q + 4].cint = cur_active_width[4] - break_width[4];
-            mem[q + 5].cint = cur_active_width[5] - break_width[5];
-            mem[q + 6].cint = cur_active_width[6] - break_width[6];
-*/
             link(prev_r) = q;
             prev_prev_r = prev_r;
             prev_r = q;
@@ -603,20 +548,6 @@ lab60:
         {
           do_all_six(update_active);
           do_all_six(copy_to_cur_active);
-/*
-          active_width[1] = active_width[1] + mem[r + 1].cint;
-          active_width[2] = active_width[2] + mem[r + 2].cint;
-          active_width[3] = active_width[3] + mem[r + 3].cint;
-          active_width[4] = active_width[4] + mem[r + 4].cint;
-          active_width[5] = active_width[5] + mem[r + 5].cint;
-          active_width[6] = active_width[6] + mem[r + 6].cint;
-          cur_active_width[1] = active_width[1];
-          cur_active_width[2] = active_width[2];
-          cur_active_width[3] = active_width[3];
-          cur_active_width[4] = active_width[4];
-          cur_active_width[5] = active_width[5];
-          cur_active_width[6] = active_width[6];
-*/
           link(active) = link(r);
           free_node(r, delta_node_size);
         }
@@ -628,14 +559,6 @@ lab60:
         if (r == active)
         {
           do_all_six(downdate_width);
-/*
-          cur_active_width[1] = cur_active_width[1] - mem[prev_r + 1].cint;
-          cur_active_width[2] = cur_active_width[2] - mem[prev_r + 2].cint;
-          cur_active_width[3] = cur_active_width[3] - mem[prev_r + 3].cint;
-          cur_active_width[4] = cur_active_width[4] - mem[prev_r + 4].cint;
-          cur_active_width[5] = cur_active_width[5] - mem[prev_r + 5].cint;
-          cur_active_width[6] = cur_active_width[6] - mem[prev_r + 6].cint;
-*/
           link(prev_prev_r) = active;
           free_node(prev_r, delta_node_size);
           prev_r = prev_prev_r;
@@ -644,20 +567,6 @@ lab60:
         {
           do_all_six(update_width);
           do_all_six(combine_two_deltas);
-/*
-          cur_active_width[1] = cur_active_width[1] + mem[r + 1].cint;
-          cur_active_width[2] = cur_active_width[2] + mem[r + 2].cint;
-          cur_active_width[3] = cur_active_width[3] + mem[r + 3].cint;
-          cur_active_width[4] = cur_active_width[4] + mem[r + 4].cint;
-          cur_active_width[5] = cur_active_width[5] + mem[r + 5].cint;
-          cur_active_width[6] = cur_active_width[6] + mem[r + 6].cint;
-          mem[prev_r + 1].cint = mem[prev_r + 1].cint + mem[r + 1].cint;
-          mem[prev_r + 2].cint = mem[prev_r + 2].cint + mem[r + 2].cint;
-          mem[prev_r + 3].cint = mem[prev_r + 3].cint + mem[r + 3].cint;
-          mem[prev_r + 4].cint = mem[prev_r + 4].cint + mem[r + 4].cint;
-          mem[prev_r + 5].cint = mem[prev_r + 5].cint + mem[r + 5].cint;
-          mem[prev_r + 6].cint = mem[prev_r + 6].cint + mem[r + 6].cint;
-*/
           link(prev_r) = link(r);
           free_node(r, delta_node_size);
         }
@@ -680,16 +589,14 @@ lab10:
         }
       }
 #endif /* STAT */
-/*  must exit here, there are no internal return - except for confusion */
-/*  savedbadness = b; */      /* 96/Feb/9 - for test in itex.c */
 }
 /* end of the old tex5.c here */
 /* sec 0877 */
 void post_line_break_(integer final_widow_penalty)
 {
   halfword q, r, s;
-  bool disc_break;
-  bool post_disc_break;
+  boolean disc_break;
+  boolean post_disc_break;
   scaled cur_width;
   scaled cur_indent;
   quarterword t;
@@ -871,7 +778,7 @@ lab30:
             if (q == cur_break(cur_p))
               goto lab31;
 
-            if ((q >= hi_mem_min))
+            if (is_char_node(q))
               goto lab31;
 
             if (non_discardable(q))
@@ -907,7 +814,7 @@ small_number reconstitute_(small_number j, small_number n, halfword bchar, halfw
 {
   halfword p;
   halfword t;
-  ffourquarters q;
+  four_quarters q;
   halfword cur_rh;
   halfword test_char;
   scaled w;
@@ -928,7 +835,7 @@ small_number reconstitute_(small_number j, small_number n, halfword bchar, halfw
     if (ligature_present)
       lft_hit = init_lft; 
 
-    while(p != 0) /* 94/Mar/22 BUG FIX */
+    while (p != 0) /* 94/Mar/22 BUG FIX */
     {
       append_charnode_to_t(character(p));
       p = link(p);
@@ -947,7 +854,7 @@ lab22:
   {
     k = bchar_label[hf];
 
-    if (k == non_address)    /* i.e. 0 ---  96/Jan/15 */
+    if (k == non_address)
       goto lab30;
     else
       q = font_info[k].qqqq;
@@ -968,6 +875,7 @@ lab22:
       q = font_info[k].qqqq;
     }
   }
+
   if (cur_rh < non_char)
     test_char = cur_rh;
   else
@@ -1002,12 +910,7 @@ lab22:
               if (lig_stack == 0)
                 rt_hit = true;
 
-            {
-              if (interrupt != 0)
-              {
-                pause_for_instructions();
-              }
-            }
+            check_interrupt();
 
             switch (op_byte(q))
             {
@@ -1057,19 +960,15 @@ lab22:
                 {
                   if (ligature_present)
                   {
-                    p = new_ligature(hf, cur_l, mem[cur_q].hh.v.RH);
+                    p = new_ligature(hf, cur_l, mem[cur_q].hh.rh);
 
                     if (lft_hit)
                     {
                       mem[p].hh.b1 = 2;
                       lft_hit = false;
                     }
-/*        if (false)
-        if (lig_stack == 0){
-          incr(mem[p].hh.b1); 
-          rt_hit = false; 
-        } */              /* removed 99/Jan/6 */
-                    mem[cur_q].hh.v.RH = p;
+
+                    mem[cur_q].hh.rh = p;
                     t = p;
                     ligature_present = false;
                   }
@@ -1086,14 +985,14 @@ lab22:
 
                   if (lig_stack != 0)        /* BUG FIX  */
                   {
-                    if (mem[lig_stack + 1].hh.v.RH != 0) /* l.17828 ? */
+                    if (mem[lig_stack + 1].hh.rh != 0) /* l.17828 ? */
                     {
-                      mem[t].hh.v.RH = mem[lig_stack + 1].hh.v.RH;
-                      t = mem[t].hh.v.RH;
+                      mem[t].hh.rh = mem[lig_stack + 1].hh.rh;
+                      t = mem[t].hh.rh;
                       incr(j);
                     }
                     p = lig_stack;
-                    lig_stack = mem[p].hh.v.RH;
+                    lig_stack = mem[p].hh.rh;
                     free_node(p, 2);
                     if (lig_stack == 0)  /* if lig_stack=null ? */
                     {
@@ -1222,19 +1121,20 @@ void hyphenate (void)
           incr(j);
           incr(u);
         }
-      while(!(j > hn));
+      while (!(j > hn));
 
       s = hyph_list[h];
 
       while (s != 0)
       {
-        hyf[mem[s].hh.v.LH] = 1;
-        s = mem[s].hh.v.RH;
+        hyf[info(s)] = 1;
+        s = link(s);
       }
 
       decr(hn);
       goto lab40;
     }
+
 lab30:;
     if (h > 0)
       decr(h);
@@ -1272,7 +1172,7 @@ lab45:
 
             v = hyf_next[v];
           }
-        while(!(v == min_trie_op));
+        while (!(v == min_trie_op));
       }
 
       incr(l);
@@ -1298,7 +1198,7 @@ lab41:;
   link(ha) = 0;
   bchar = hyfbchar;
 
-  if ((ha >= hi_mem_min))
+  if (is_char_node(ha))
     if (font(ha) != hf)
       goto lab42;
     else
@@ -1324,11 +1224,11 @@ lab41:;
           init_lig = false;
         }
 
-        free_node(ha, small_node_size);
+      free_node(ha, small_node_size);
     }
   else
   {
-    if (!(r >= hi_mem_min))
+    if (!is_char_node(r))
       if (type(r) == ligature_node)
         if (subtype(r) > 1)
           goto lab42;
@@ -1384,7 +1284,7 @@ lab50:
             major_tail = r;
             r_count = 0;
 
-            while (mem[major_tail].hh.v.RH != 0)
+            while (mem[major_tail].hh.rh != 0)
             {
               major_tail = link(major_tail);
               incr(r_count);
@@ -1473,7 +1373,7 @@ lab50:
                 j = reconstitute(j, hn, bchar, non_char) + 1;
                 link(major_tail) = link(hold_head);
 
-                while (mem[major_tail].hh.v.RH != 0)
+                while (mem[major_tail].hh.rh != 0)
                 {
                   major_tail = link(major_tail);
                   incr(r_count);
@@ -1497,9 +1397,9 @@ lab50:
             hyphen_passed = j - 1;
             link(hold_head) = 0;
           }
-        while(!(! odd(hyf[j - 1])));
+        while (!(! odd(hyf[j - 1])));
     }
-  while(!(j > hn));
+  while (!(j > hn));
 
   link(s) = q;
   flush_list(init_list);
@@ -1589,8 +1489,7 @@ lab21:
             if (hyph_count == hyphen_prime)
             {
               overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */
-              /*    not dynamic ---- but can be set -e=... from command line in ini-TeX */
-              return;     // abort_flag set
+              return;
             }
 
             incr(hyph_count);
@@ -1619,7 +1518,7 @@ lab21:
                   incr(u);
                   incr(v);
                 }
-              while(!(u == str_start[k + 1]));
+              while (!(u == str_start[k + 1]));
 lab40:
               q = hyph_list[h];
               hyph_list[h] = p;
@@ -1668,7 +1567,7 @@ halfword prune_page_top_(halfword p)
   prev_p = temp_head;
   link(temp_head) = p;
 
-  while(p != 0)
+  while (p != 0)
     switch(type(p))
     {
       case hlist_node:
@@ -1735,14 +1634,6 @@ halfword vert_break_(halfword p, scaled h, scaled d)
 
   least_cost = awful_bad;
   do_all_six(set_height_zero);
-/*
-  active_width[1] = 0;
-  active_width[2] = 0;
-  active_width[3] = 0;
-  active_width[4] = 0;
-  active_width[5] = 0;
-  active_width[6] = 0;
-*/
   prev_dp = 0;
 
   while (true)
@@ -1810,18 +1701,20 @@ halfword vert_break_(halfword p, scaled h, scaled d)
           b = 0;
         else
           b = badness(h - cur_height, active_width[2]);
-      else if (active_width[1] - h > active_width[6])
-        b = awful_bad;
       else
-        b = badness(cur_height - h, active_width[6]);
+        if (act_width - h > active_width[6])
+          b = awful_bad;
+        else
+          b = badness(cur_height - h, active_width[6]);
 
       if (b < awful_bad)
         if (pi <= eject_penalty)
           b = pi;
-        else if (b < inf_bad)
-          b = b + pi;
         else
-          b = deplorable;
+          if (b < inf_bad)
+            b = b + pi;
+          else
+            b = deplorable;
 
       if (b <= least_cost)
       {
@@ -1873,6 +1766,7 @@ lab45:
     prev_p = p;
     p = link(prev_p);
   }
+
 lab30:
   return best_place;
 }
@@ -1997,15 +1891,8 @@ void freeze_page_specs_(small_number s)
   page_max_depth = max_depth;
   page_depth = 0;
   do_all_six(set_page_so_far_zero);
-/*
-  page_so_far[1] = 0;
-  page_so_far[2] = 0;
-  page_so_far[3] = 0;
-  page_so_far[4] = 0;
-  page_so_far[5] = 0;
-  page_so_far[6] = 0;
-*/
   least_page_cost = awful_bad;
+
 #ifdef STAT
   if (tracing_pages > 0)
   {
@@ -2016,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)
@@ -2049,14 +1936,14 @@ void ensure_vbox_(eight_bits n)
 /* sec 1012 */
 void fire_up_(halfword c)
 {
-  halfword p, q, r, s;
-  halfword prev_p;
+  pointer p, q, r, s;
+  pointer prev_p;
 /*  unsigned char n;  */
   unsigned int n;         /* 95/Jan/7 */
-  bool wait;
+  boolean wait;
   integer save_vbadness;
   scaled save_vfuzz;
-  halfword save_split_top_skip;
+  pointer save_split_top_skip;
 
   if (type(best_page_break) == penalty_node)
   {