-#ifdef _WINDOWS
- #define NOCOMM
- #define NOSOUND
- #define NODRIVERS
- #define STRICT
- #pragma warning(disable:4115) // kill rpcasync.h complaint
- #include <windows.h>
- #define MYLIBAPI __declspec(dllexport)
-#endif
+/* Copyright 2014 Clerk Ma
-#include "texwin.h"
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-#pragma warning(disable:4996)
-#pragma warning(disable:4131) // old style declarator
-#pragma warning(disable:4135) // conversion between different integral types
-#pragma warning(disable:4127) // conditional expression is constant
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
-#include <setjmp.h>
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA. */
#define EXTERN extern
#include "texd.h"
-#pragma warning(disable:4244) /* 96/Jan/10 */
-
-/* #pragma optimize("a", off) */ /* 98/Dec/10 experiment */
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
+/* sec 0581 */
void char_warning_(internal_font_number f, eight_bits c)
{
- if(eqtb[(hash_size + 3198)].cint > 0)
+ if (tracing_lost_chars > 0)
{
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if (show_missing == 0) /* show on screen 94/June/10 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- begin_diagnostic ();
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if (show_missing) { /* add ! before 94/June/10 */
- print_nl("! "); /* ! */
- print_string("Missing character: there is no");
- }
- else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- print_nl("Missing character: there is no"); /* */
- print(c);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if (show_numeric) { /* bkph 93/Dec/21 */
- print_char(32); /* */
- print_char(40); /*(*/
- if (c / 100 > 0) {
- print_char(48 + c / 100);
-/* c = c % 100; */
- c = c - (c / 100) * 100; /* ? */
- print_char(48 + c / 10);
+ if (show_missing == 0)
+ begin_diagnostic();
+
+ if (show_missing) /* add ! before 94/June/10 */
+ {
+ print_nl("! ");
+ print_string("Missing character: there is no ");
}
- else {
+ else
+ print_nl("Missing character: there is no ");
+
+ print(c);
+
+ if (show_numeric) /* bkph 93/Dec/21 */
+ {
+ print_char(' ');
+ print_char('(');
+
+ if (c / 100 > 0)
+ {
+ print_char(48 + c / 100);
/* c = c % 100; */
- c = c - (c / 100) * 100; /* ? */
- if (c / 10 > 0) print_char(48 + c / 10);
- }
- print_char(48 + c % 10);
- print_char(41); /*)*/
+ c = c - (c / 100) * 100; /* ? */
+ print_char(48 + c / 10);
+ }
+ else
+ {
+/* c = c % 100; */
+ c = c - (c / 100) * 100; /* ? */
+ if (c / 10 > 0) print_char(48 + c / 10);
+ }
+ print_char(48 + c % 10);
+ print_char(')');
/* print_char(32); */
- }
+ }
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- print_string("in font");
- slow_print(font_name[f]);
- print_char(33); /* ! */
+ print_string(" in font ");
+ slow_print(font_name[f]);
+ print_char('!');
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
/* if (show_missing) show_context(); */ /* in tex2.c 94/June/10 */
- if (show_missing) {
- if (f != 0) show_context(); /* not if its the nullfont */
- }
- if (show_missing == 0) /* show on screen 94/June/10 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- end_diagnostic(false);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- missing_characters++; /* bkph 93/Dec/16 */
+ if (show_missing)
+ {
+ if (f != 0)
+ show_context(); /* not if its the nullfont */
+ }
+
+ if (show_missing == 0) /* show on screen 94/June/10 */
+ end_diagnostic(false);
+
+ missing_characters++; /* bkph 93/Dec/16 */
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- }
-}
+ }
+}
+/* sec 0582 */
halfword new_character_(internal_font_number f, eight_bits c)
-{/* 10 */ register halfword Result;
- halfword p;
- if(font_bc[f]<= c)
- if(font_ec[f]>= c)
- if((font_info[char_base[f]+ c].qqqq.b0 > 0))
- {
- p = get_avail ();
-/* long to unsigned short ... */
- mem[p].hh.b0 = f;
- mem[p].hh.b1 = c;
- Result = p;
- return(Result);
- }
- char_warning(f, c); /* char_warning(f,c); l.11283 */
- Result = 0; /* new_character:=null */
- return Result;
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void dvi_swap (void)
-{
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if (trace_flag) {
- show_char('\n');
- sprintf(log_line, "dvi_swap %d", dvi_gone);
- show_line(log_line, 0);
+{
+ halfword p;
+
+ if (font_bc[f] <= c)
+ if (font_ec[f] >= c)
+ if (char_exists(char_info(f, c)))
+ {
+ p = get_avail();
+ font(p) = f;
+ character(p) = c;
+ return p;
+ }
+
+ char_warning(f, c);
+ return 0;
}
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if(dvi_limit == dvi_buf_size) {
- writedvi(0, half_buf - 1);
- dvi_limit = half_buf;
- dvi_offset = dvi_offset + dvi_buf_size;
- dvi_ptr = 0;
- }
- else {
- writedvi(half_buf, dvi_buf_size - 1);
- dvi_limit = dvi_buf_size;
- }
- dvi_gone = dvi_gone + half_buf;
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void dvi_four_(integer x) /* attempt at speeding up bkph - is compiler smart ? */
+/* sec 0598 */
+void dvi_swap (void)
{
- if(x >= 0)
+ if (trace_flag)
{
-/* dvi_buf[dvi_ptr]= x / 16777216L; */ /* 2^24 */
-/* dvi_buf[dvi_ptr]=(x >> 24); */
- dvi_buf[dvi_ptr]= (unsigned char)(x >> 24);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- else {
- x = x + 1073741824L; /* 2^30 40000000 hex */
- x = x + 1073741824L;
- {
-/* dvi_buf[dvi_ptr]=(x / 16777216L)+ 128; */ /* 2^24 */
- dvi_buf[dvi_ptr]=(x >> 24)+ 128; /* set sign bit */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- }
-/* x = x % 16777216L; */ /* % 2^24 */
- x = x & 16777215L;
+ show_char('\n');
+ sprintf(log_line, "dvi_swap %d", dvi_gone);
+ show_line(log_line, 0);
+ }
+
+ if (dvi_limit == dvi_buf_size)
{
-/* dvi_buf[dvi_ptr]= x / 65536L; */
-/* dvi_buf[dvi_ptr]=(x >> 16); */
- dvi_buf[dvi_ptr]= (unsigned char)(x >> 16);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
-/* x = x % 65536L; */ /* % 2^16 */
- x = x & 65535L;
+ write_dvi(0, half_buf - 1);
+ dvi_limit = half_buf;
+ dvi_offset = dvi_offset + dvi_buf_size;
+ dvi_ptr = 0;
+ }
+ else
{
-/* dvi_buf[dvi_ptr]= x / 256; */
-/* dvi_buf[dvi_ptr]=(x >> 8); */
- dvi_buf[dvi_ptr]= (unsigned char)(x >> 8);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ write_dvi(half_buf, dvi_buf_size - 1);
+ dvi_limit = dvi_buf_size;
+ }
+
+ dvi_gone = dvi_gone + half_buf;
+}
+/* attempt at speeding up bkph - is compiler smart ? */
+/* sec 0600 */
+void dvi_four_(integer x)
+{
+ if (x >= 0)
+ dvi_out(x / 0100000000); // dvi_out((x >> 24));
+ else
{
-/* dvi_buf[dvi_ptr]= x % 256; */ /* % 2^8 */
- dvi_buf[dvi_ptr]= x & 255;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
+ x = x + 010000000000;
+ x = x + 010000000000;
+ dvi_out((x / 0100000000) + 128); // dvi_out((x >> 24) + 128);
+ }
+
+ x = x % 0100000000; // x = x & 16777215L;
+ dvi_out(x / 0200000); // dvi_out((x >> 16));
+ x = x % 0200000; // x = x & 65535L;
+ dvi_out(x / 0400); // dvi_out((x >> 8));
+ dvi_out(x % 0400); // dvi_out(x & 255);
+}
+/* sec 0601 */
void zdvipop(integer l)
-{
- if((l == dvi_offset + dvi_ptr)&&(dvi_ptr > 0))
- decr(dvi_ptr);
- else {
-
- dvi_buf[dvi_ptr]= 142;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
+{
+ if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
+ decr(dvi_ptr);
+ else
+ dvi_out(142);
+}
+/* sec 0602 */
void dvi_font_def_(internal_font_number f)
-{
- pool_pointer k;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+{
+ pool_pointer k;
+
#ifdef INCREASEFONTS
- if (f <= 256) {
- {
- dvi_buf[dvi_ptr]= 243;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ if (f <= 256)
{
- dvi_buf[dvi_ptr]= f - 1;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ dvi_out(fnt_def1);
+ dvi_out(f - 1);
}
- else {
- {
- dvi_buf[dvi_ptr]= 244;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= (f - 1) >> 8; /* top byte */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ else
{
- dvi_buf[dvi_ptr]= (f - 1) & 255; /* bottom byte */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ dvi_out(fnt_def2);
+ dvi_out(((f - 1) >> 8));
+ dvi_out(((f - 1) & 255));
}
#else
- {
- dvi_buf[dvi_ptr]= 243;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= f - 1;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ dvi_out(fnt_def1);
+ dvi_out(f - 1);
#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* spit out the font checksum now */
- {
- dvi_buf[dvi_ptr]= font_check[f].b0;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= font_check[f].b1;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= font_check[f].b2;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= font_check[f].b3;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+
+ dvi_out(font_check[f].b0);
+ dvi_out(font_check[f].b1);
+ dvi_out(font_check[f].b2);
+ dvi_out(font_check[f].b3);
dvi_four(font_size[f]);
- dvi_four(font_dsize[f]);
- {
-/* long to unsigned char ... */
- dvi_buf[dvi_ptr]=
- (str_start[font_area[f]+ 1]- str_start[font_area[f]]);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ dvi_four(font_dsize[f]);
+ dvi_out(length(font_area[f]));
+ dvi_out(length(font_name[f]));
+
+ for (k = str_start[font_area[f]]; k <= str_start[font_area[f] + 1] - 1; k++)
+ dvi_out(str_pool[k]);
+
+ for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
+ dvi_out(str_pool[k]);
+}
+/* sec 0607 */
+void zmovement(scaled w, eight_bits o)
+{
+ small_number mstate;
+ halfword p, q;
+ integer k;
+
+ q = get_node(movement_node_size);
+ width(q) = w;
+ location(q) = dvi_offset + dvi_ptr;
+
+ if (o == down1)
{
-/* long to unsigned char ... */
- dvi_buf[dvi_ptr]=
- (str_start[font_name[f]+ 1]- str_start[font_name[f]]);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ link(q) = down_ptr;
+ down_ptr = q;
+ }
+ else
{
- register integer for_end;
- k = str_start[font_area[f]];
- for_end = str_start[font_area[f]+ 1]- 1;
- if(k <= for_end) do
- {
- dvi_buf[dvi_ptr]= str_pool[k];
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(k++ < for_end);
- }
+ link(q) = right_ptr;
+ right_ptr = q;
+ }
+
+ p = link(q);
+ mstate = none_seen;
+
+ while (p != 0)
{
- register integer for_end;
- k = str_start[font_name[f]];
- for_end = str_start[font_name[f]+ 1]- 1;
- if(k <= for_end) do
+ if (width(p) == w)
+ switch(mstate + info(p))
+ {
+ case none_seen + yz_OK:
+ case none_seen + y_OK:
+ case z_seen + yz_OK:
+ case z_seen + y_OK:
+ if (location(p) < dvi_gone)
+ goto lab45;
+ else
+ {
+ k = location(p) - dvi_offset;
+
+ if (k < 0)
+ k = k + dvi_buf_size;
+
+ dvi_buf[k] = dvi_buf[k] + y1 - down1;
+ info(p) = y_here;
+ goto lab40;
+ }
+ break;
+
+ case none_seen + z_OK:
+ case y_seen + yz_OK:
+ case y_seen + z_OK:
+ if (location(p) < dvi_gone)
+ goto lab45;
+ else
+ {
+ k = location(p) - dvi_offset;
+
+ if (k < 0)
+ k = k + dvi_buf_size;
+
+ dvi_buf[k] = dvi_buf[k] + z1 - down1;
+ info(p) = z_here;
+ goto lab40;
+ }
+ break;
+
+ case none_seen + y_here:
+ case none_seen + z_here:
+ case y_seen + z_here:
+ case z_seen + y_here:
+ goto lab40;
+ break;
+
+ default:
+ break;
+ }
+ else switch (mstate + info(p))
{
- dvi_buf[dvi_ptr]= str_pool[k];
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(k++ < for_end);
- }
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void zmovement(scaled w, eight_bits o)
-{/* 10 40 45 2 1 */
- small_number mstate;
- halfword p, q;
- integer k;
- q = get_node(3);
- mem[q + 1].cint = w;
- mem[q + 2].cint = dvi_offset + dvi_ptr;
- if(o == 157) /* 157 == down1 */
- {
- mem[q].hh.v.RH = down_ptr;
- down_ptr = q;
- }
- else { /* 143 == right1 */
-
- mem[q].hh.v.RH = right_ptr;
- right_ptr = q;
- }
- p = mem[q].hh.v.RH;
- mstate = 0;
- while(p != 0){ /* while p<>null do l.12153 */
-
- if(mem[p + 1].cint == w)
- switch(mstate + mem[p].hh.v.LH)
- {case 3 :
- case 4 :
- case 15 :
- case 16 :
- if(mem[p + 2].cint < dvi_gone)
- goto lab45;
- else {
-
- k = mem[p + 2].cint - dvi_offset;
- if(k < 0)
- k = k + dvi_buf_size;
- dvi_buf[k]= dvi_buf[k]+ 5;
- mem[p].hh.v.LH = 1;
- goto lab40;
- }
- break;
- case 5 :
- case 9 :
- case 11 :
- if(mem[p + 2].cint < dvi_gone)
- goto lab45;
- else {
-
- k = mem[p + 2].cint - dvi_offset;
- if(k < 0)
- k = k + dvi_buf_size;
- dvi_buf[k]= dvi_buf[k]+ 10;
- mem[p].hh.v.LH = 2;
- goto lab40;
- }
- break;
- case 1 :
- case 2 :
- case 8 :
- case 13 :
- goto lab40;
- break;
- default:
- ;
- break;
- }
- else switch(mstate + mem[p].hh.v.LH)
- {case 1 :
- mstate = 6;
- break;
- case 2 :
- mstate = 12;
- break;
- case 8 :
- case 13 :
- goto lab45;
- break;
- default:
- ;
- break;
- }
- p = mem[p].hh.v.RH;
- }
- lab45:;
- mem[q].hh.v.LH = 3;
- if(abs(w)>= 8388608L) /* 2^23 */
+ case none_seen + y_here:
+ mstate = y_seen;
+ break;
+
+ case none_seen + z_here:
+ mstate = z_seen;
+ break;
+
+ case y_seen + z_here:
+ case z_seen + y_here:
+ goto lab45;
+ break;
+
+ default:
+ break;
+ }
+ p = link(p);
+ }
+lab45:
+
+ info(q) = yz_OK;
+
+ if (abs(w) >= 8388608L) /* 2^23 */
{
- {
- dvi_buf[dvi_ptr]= o + 3;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- dvi_four(w);
- return;
- }
- if(abs(w)>= 32768L)
+ dvi_out(o + 3);
+ dvi_four(w);
+ return;
+ }
+
+ if (abs(w) >= 32768L)
{
- {
- dvi_buf[dvi_ptr]= o + 2;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- if(w < 0)
- w = w + 16777216L; /* 2^24 */
- {
-/* dvi_buf[dvi_ptr]= w / 65536L; */
-/* dvi_buf[dvi_ptr]=(w >> 16); */
- dvi_buf[dvi_ptr]= (unsigned char)(w >> 16);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ dvi_out(o + 2);
+
+ if (w < 0)
+ w = w + 16777216L; /* 2^24 */
+ //dvi_out(w / 65536L);
+ dvi_out((w >> 16));
/* w = w % 65536L; */
- w = w & 65535L;
- goto lab2;
- }
- if(abs(w)>= 128)
- {
- {
- dvi_buf[dvi_ptr]= o + 1;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- if(w < 0)
- w = w + 65536L;
- goto lab2;
- }
+ w = w & 65535L;
+ goto lab2;
+ }
+
+ if (abs(w)>= 128)
{
- dvi_buf[dvi_ptr]= o;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- if(w < 0)
- w = w + 256;
- goto lab1;
- lab2: {
-
-/* dvi_buf[dvi_ptr]= w / 256; */
-/* dvi_buf[dvi_ptr]=(w >> 8); */
- dvi_buf[dvi_ptr]= (unsigned char)(w >> 8);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- lab1: {
-
-/* dvi_buf[dvi_ptr]= w % 256; */
- dvi_buf[dvi_ptr]= w & 255;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- return;
- lab40: mem[q].hh.v.LH = mem[p].hh.v.LH;
- if(mem[q].hh.v.LH == 1)
+ dvi_out(o + 1);
+
+ if (w < 0)
+ w = w + 65536L;
+
+ goto lab2;
+ }
+
+ dvi_out(o);
+
+ if (w < 0)
+ w = w + 256;
+
+ goto lab1;
+lab2:
+ //dvi_out(w / 256);
+ dvi_out((w >> 8));
+lab1:
+ //dvi_out(w % 256);
+ dvi_out(w & 255);
+ return;
+lab40:
+ info(q) = info(p);
+
+ if (info(q) == y_here)
{
+ dvi_out(o + y0 - down1);
+
+ while (link(q) != p)
{
- dvi_buf[dvi_ptr]= o + 4;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(mem[q].hh.v.RH != p){
-
- q = mem[q].hh.v.RH;
- switch(mem[q].hh.v.LH)
- {case 3 :
- mem[q].hh.v.LH = 5;
- break;
- case 4 :
- mem[q].hh.v.LH = 6;
- break;
- default:
- ;
- break;
- }
- }
- }
- else {
-
+ q = link(q);
+
+ switch (info(q))
+ {
+ case yz_OK:
+ info(q) = z_OK;
+ break;
+
+ case y_OK:
+ info(q) = d_fixed;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ dvi_out(o + z0 - down1);
+
+ while (link(q) != p)
{
- dvi_buf[dvi_ptr]= o + 9;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(mem[q].hh.v.RH != p){
-
- q = mem[q].hh.v.RH;
- switch(mem[q].hh.v.LH)
- {case 3 :
- mem[q].hh.v.LH = 4;
- break;
- case 5 :
- mem[q].hh.v.LH = 6;
- break;
- default:
- ;
- break;
- }
- }
- }
-}
-void prune_movements_(integer l)
-{/* 30 10 */
- halfword p;
- while(down_ptr != 0){ /* while down_ptr<>null do l.12206 */
-
- if(mem[down_ptr + 2].cint < l)
- goto lab30;
- p = down_ptr;
- down_ptr = mem[p].hh.v.RH;
- free_node(p, 3);
- }
- lab30: while(right_ptr != 0){ /* done: while right_ptr<>null do */
-
- if(mem[right_ptr + 2].cint < l)
- return;
- p = right_ptr;
- right_ptr = mem[p].hh.v.RH;
- free_node(p, 3);
- }
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void special_out_(halfword p)
+ q = link(q);
+
+ switch (info(q))
+ {
+ case yz_OK:
+ info(q) = y_OK;
+ break;
+
+ case z_OK:
+ info(q) = d_fixed;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+}
+/* sec 0615 */
+void prune_movements_(integer l)
{
- char old_setting;
- pool_pointer k;
- if(cur_h != dvi_h)
+ halfword p;
+
+ while (down_ptr != 0)
{
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- if(cur_v != dvi_v)
+ if (location(down_ptr) < l)
+ goto lab30;
+
+ p = down_ptr;
+ down_ptr = link(p);
+ free_node(p, movement_node_size);
+ }
+
+lab30:
+ while (right_ptr != 0)
{
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- old_setting = selector;
- selector = 21;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* About output \special{...} make some space in string pool 97/Mar/9 */
+ if (location(right_ptr) < l)
+ return;
+
+ p = right_ptr;
+ right_ptr = link(p);
+ free_node(p, movement_node_size);
+ }
+}
+/* sec 1368 */
+void special_out_(pointer p)
+{
+ char old_setting;
+ pool_pointer k;
+
+ synch_h();
+ synch_v();
+ old_setting = selector;
+ selector = new_string;
+
#ifdef ALLOCATESTRING
- if(pool_ptr + 32000 > current_pool_size)
+ if (pool_ptr + 32000 > current_pool_size)
str_pool = realloc_str_pool (increment_pool_size);
-/* We don't bother to check whether this worked - will catch later */
-#endif
-/* Potential problem here if current_pool_size is not much more than pool_ptr! */
-/* Fixed 97/Mar/9 in version 2.0.3 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-#ifdef ALLOCATESTRING
-/* show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
- current_pool_size - pool_ptr); */
- show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
- 10000000L);
-/* Above is safe, since print/print_char/print_esc will extend string space */
+
+ show_token_list(link(write_tokens(p)), 0, 10000000L);
#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
- pool_size - pool_ptr);
+ show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
#endif
- selector = old_setting;
+ selector = old_setting;
+ str_room(1);
+
+ if (cur_length < 256)
{
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* str_room(1) - is there space for one more character in string pool ? */
-#ifdef ALLOCATESTRING
- if(pool_ptr + 1 > current_pool_size)
- str_pool = realloc_str_pool (increment_pool_size);
- if(pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
- overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
- return; // abort_flag set
- }
-#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if(pool_ptr + 1 > pool_size){
- overflow("pool size", pool_size - init_pool_ptr); /* pool size */
- return; // abort_flag set
+ dvi_out(xxx1);
+ dvi_out(cur_length);
}
-#endif
- }
- if((pool_ptr - str_start[str_ptr])< 256) /* can use xxx1 ? */
+ else
{
- {
- dvi_buf[dvi_ptr]= 239; /* xxx1 */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
-/* long to unsigned char ... */
- dvi_buf[dvi_ptr]=(pool_ptr - str_start[str_ptr]);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- }
- else { /* use xxx4 instead */
-
- {
- dvi_buf[dvi_ptr]= 242; /* xxx4 */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- dvi_four((pool_ptr - str_start[str_ptr]));
+ dvi_out(xxx4);
+ dvi_four(cur_length);
}
-#ifdef IGNORED
-/* debugging code for \special{src: ... } 98/Nov/11 */
- {
- int k = str_start[str_ptr];
- int kend = pool_ptr;
- if (kend > k + 4) {
- if (str_pool [k] == 's' &&
- str_pool [k+1] == 'r' &&
- str_pool [k+2] == 'c' &&
- str_pool [k+3] == ':') { /* \special{src: ... } */
- show_char('\n');
- s = log_line;
- while (k < kend) {
- *s++ = str_pool[k++];
- }
- *s++ = ' ';
- *s++ = '\0';
- show_line(log_line, 0)
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
- if (cur_input.name_field > 17) { /* redundant ? */
- print(cur_input.name_field);
- print_char(40); /*(*/
- print_int(line); /* line number */
- print_char(41); /*)*/
- print_char(32); /* */
- print_char(58); /* : */
- }
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
- }
- }
- }
-#endif
+ for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
+ dvi_out(str_pool[k]);
- {
- register integer for_end;
- k = str_start[str_ptr];
- for_end = pool_ptr - 1;
- if(k <= for_end) do
- {
- dvi_buf[dvi_ptr]= str_pool[k];
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(k++ < for_end);
- }
- pool_ptr = str_start[str_ptr];
-}
-/* noew returns -1 if it fails */
-void write_out_(halfword p)
+ pool_ptr = str_start[str_ptr];
+}
+/* sec 1370 */
+void write_out_(pointer p)
{
- char old_setting;
+ char old_setting;
/* integer oldmode; */
int oldmode; /* 1995/Jan/7 */
/* small_number j; */
int j; /* 1995/Jan/7 */
- halfword q, r;
-/* q:=get_avail; info(q):=right_brace_token+"}";@/ */
- q = get_avail ();
- mem[q].hh.v.LH = 637;
-/* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
-/* @d end_write_token==cs_token_flag+end_write */
- r = get_avail ();
- mem[q].hh.v.RH = r;
-/* mem[r].hh.v.LH = (hash_size + 4617); */
-/* mem[r].hh.v.LH = (hash_size + 4095 + 522); */
- mem[r].hh.v.LH = (hash_size + hash_extra + 4095 + 522);
- begin_token_list(q, 4);
- begin_token_list(mem[p + 1].hh.v.RH, 15);
- q = get_avail ();
- mem[q].hh.v.LH = 379;
- begin_token_list(q, 4);
- oldmode = mode;
- mode = 0;
- cur_cs = write_loc;
- q = scan_toks(false, true);
- get_token ();
-/* if(cur_tok != (hash_size + 4617)) */
-/* if(cur_tok != (hash_size + 4095 + 522)) */
- if(cur_tok != (hash_size + hash_extra + 4095 + 522))
+ halfword q, r;
+
+ q = get_avail();
+ info(q) = right_brace_token + '}';
+ r = get_avail();
+ link(q) = r;
+ info(r) = end_write_token;
+ ins_list(q);
+ begin_token_list(write_tokens(p), write_text);
+ q = get_avail();
+ info(q) = left_brace_token + '{';
+ ins_list(q);
+ oldmode = mode;
+ mode = 0;
+ cur_cs = write_loc;
+ q = scan_toks(false, true);
+ get_token();
+
+ if (cur_tok != end_write_token)
{
- print_err("Unbalanced write command");
- help2("On this page there's a \\write with fewer real {'s than }'s.",
- "I can't handle that very well; good luck.");
- error ();
- do {
- get_token ();
-/* } while(!(cur_tok == (hash_size + 4617))); */
-/* } while(!(cur_tok == (hash_size + 4095 + 522))); */
- } while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
- }
- mode = oldmode;
- end_token_list ();
- old_setting = selector;
- j = mem[p + 1].hh.v.LH;
- if(write_open[j])selector = j;
- else {
- if((j == 17)&&(selector == 19))
- selector = 18;
- print_nl(""); /* */
- }
- token_show(def_ref);
- print_ln ();
- flush_list(def_ref);
- selector = old_setting;
-}
-void out_what_(halfword p)
+ print_err("Unbalanced write command");
+ help2("On this page there's a \\write with fewer real {'s than }'s.",
+ "I can't handle that very well; good luck.");
+ error();
+
+ do
+ {
+ get_token();
+ }
+ while(!(cur_tok == end_write_token));
+ }
+
+ mode = oldmode;
+ end_token_list();
+ old_setting = selector;
+ j = write_stream(p);
+
+ if (write_open[j])
+ selector = j;
+ else
+ {
+ if ((j == 17) && (selector == term_and_log))
+ selector = log_only;
+
+ print_nl("");
+ }
+
+ token_show(def_ref);
+ print_ln();
+ flush_list(def_ref);
+ selector = old_setting;
+}
+/* sec 1373 */
+void out_what_(pointer p)
{
/* small_number j; */
int j; /* 1995/Jan/7 */
- switch(mem[p].hh.b1)
- {case 0 :
- case 1 :
- case 2 :
- if(! doing_leaders){
- j = mem[p + 1].hh.v.LH;
- if(mem[p].hh.b1 == 1){
- write_out(p);
- }
- else {
- if(write_open[j])
- (void) a_close(write_file[j]);
- if(mem[p].hh.b1 == 2)
- write_open[j]= false;
- else if(j < 16){
- cur_name = mem[p + 1].hh.v.RH;
- cur_area = mem[p + 2].hh.v.LH;
- cur_ext = mem[p + 2].hh.v.RH;
- if(cur_ext == 335) /* "" */
- cur_ext = 785; /* => ".tex" */
- pack_file_name(cur_name, cur_area, cur_ext);
- while(! a_open_out(write_file[j])) {
- prompt_file_name(1294, 785); /* output file name .tex */
- }
- write_open[j]= true;
- }
- }
- }
- break;
- case 3 :
- special_out(p);
- break;
- case 4 :
- ;
- break;
- default:
- {
- confusion(1293); /* ext4 */
- return; // abort_flag set
- }
- break;
- }
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void hlist_out (void)
-{/* 21 13 14 15 */
- scaled baseline;
- scaled leftedge;
- scaled saveh, savev;
- halfword thisbox;
-/* glue_ord gorder; */
- int gorder; /* 95/Jan/7 */
-/* char gsign; */
- int gsign; /* 95/Jan/7 */
- halfword p;
- integer saveloc;
- halfword leaderbox;
- scaled leaderwd;
- scaled lx;
- bool outerdoingleaders;
- scaled edge;
-/* ********************************************************************* */
- real gluetemp; /* new in 3.14159 */
-/* ********************************************************************* */
- thisbox = temp_ptr;
- gorder = mem[thisbox + 5].hh.b1;
- gsign = mem[thisbox + 5].hh.b0;
- p = mem[thisbox + 5].hh.v.RH;
- incr(cur_s);
- if(cur_s > 0)
- {
- dvi_buf[dvi_ptr]= 141;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- if(cur_s > max_push)
- max_push = cur_s;
- saveloc = dvi_offset + dvi_ptr;
- baseline = cur_v;
- leftedge = cur_h;
-/* while p<>null do l.12314 */
- while(p != 0)lab21: if((p >= hi_mem_min))
+
+ switch (subtype(p))
{
- if(cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- if(cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- do {
- f = mem[p].hh.b0;
- c = mem[p].hh.b1;
- if(f != dvi_f)
+ case open_node:
+ case write_node:
+ case close_node:
+ if (!doing_leaders)
{
- if(! font_used[f])
- {
- dvi_font_def(f);
- font_used[f]= true;
- }
- if(f <= 64)
- { /* fnt_num_0 --- fnt_num_63 */
- dvi_buf[dvi_ptr]= f + 170;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+ j = write_stream(p);
+
+ if (subtype(p) == write_node)
+ {
+ write_out(p);
+ }
+ else
+ {
+ if (write_open[j])
+ (void) a_close(write_file[j]);
+
+ if (subtype(p) == close_node)
+ write_open[j]= false;
+ else if (j < 16)
+ {
+ cur_name = open_name(p);
+ cur_area = open_area(p);
+ cur_ext = open_ext(p);
+
+ if (cur_ext == 335) /* "" */
+ cur_ext = 785; /* => ".tex" */
+
+ pack_file_name(cur_name, cur_area, cur_ext);
+
+ while(! a_open_out(write_file[j]))
+ {
+ prompt_file_name("output file name", ".tex");
+ }
+
+ write_open[j] = true;
+ }
+ }
+ }
+ break;
+
+ case special_node:
+ special_out(p);
+ break;
+
+ case language_node:
+ ;
+ break;
+
+ default:
+ {
+ confusion("ext4");
+ return; // abort_flag set
+ }
+ break;
+ }
+}
+/* sec 0619 */
+void hlist_out (void)
+{
+ scaled base_line;
+ scaled left_edge;
+ scaled save_h, save_v;
+ halfword this_box;
+/* glue_ord g_order; */
+ int g_order; /* 95/Jan/7 */
+/* char g_sign; */
+ int g_sign; /* 95/Jan/7 */
+ halfword p;
+ integer save_loc;
+ halfword leader_box;
+ scaled leader_wd;
+ scaled lx;
+ boolean outer_doing_leaders;
+ scaled edge;
+ real glue_temp;
+ real cur_glue;
+ scaled cur_g;
+
+ cur_g = 0;
+ cur_glue = 0.0;
+ this_box = temp_ptr;
+ g_order = glue_order(this_box);
+ g_sign = glue_sign(this_box);
+ p = list_ptr(this_box);
+ incr(cur_s);
+
+ if (cur_s > 0)
+ dvi_out(141);
+
+ if (cur_s > max_push)
+ max_push = cur_s;
+
+ save_loc = dvi_offset + dvi_ptr;
+ base_line = cur_v;
+ left_edge = cur_h;
+
+ while (p != 0)
+lab21:
+ if (is_char_node(p))
+ {
+ synch_h();
+ synch_v();
+
+ do
+ {
+ f = font(p);
+ c = character(p);
+
+ if (f != dvi_f)
+ {
+ if (!font_used[f])
+ {
+ dvi_font_def(f);
+ font_used[f] = true;
+ }
+
+ if (f <= 64 + font_base)
+ dvi_out(f - font_base - 1 + fnt_num_0);
#ifdef INCREASEFONTS
- else if(f <= 256){ /* if we allow greater than 256 fonts */
+ /* if we allow greater than 256 fonts */
+ else if (f <= 256)
+ {
+ dvi_out(fnt1);
+ dvi_out(f - 1);
+ }
#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- else { /* normal TeX 82 case */
+ /* normal TeX 82 case */
+ else
+ {
+ dvi_out(fnt1);
+ dvi_out(f - 1);
+ }
#endif
- { /* fnt1 followed by f */
- dvi_buf[dvi_ptr]= 235;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= f - 1;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- }
+
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
#ifdef INCREASEFONTS
- else { /* fnt2 followed by f / 256, f % 256 */
- {
- dvi_buf[dvi_ptr]= 236;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= (f - 1) >> 8; /* top byte */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= (f - 1) & 255; /* bottom byte */
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- }
+ /* fnt2 followed by f / 256, f % 256 */
+ else
+ {
+ dvi_out(fnt2);
+ dvi_out(((f - 1) >> 8)); /* top byte */
+ dvi_out(((f - 1) & 255)); /* bottom byte */
+ }
#endif
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- dvi_f = f;
- }
- if(c >= 128)
- {
- dvi_buf[dvi_ptr]= 128;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= c;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- cur_h = cur_h + font_info[width_base[f]+ font_info[char_base[f]+ c
- ].qqqq.b0].cint;
- p = mem[p].hh.v.RH;
- } while(!(!(p >= hi_mem_min)));
- dvi_h = cur_h;
- }
- else {
-
- switch(mem[p].hh.b0)
- {case 0 :
- case 1 :
-/* if list_ptr(p)=null then cur_h:=cur_h+width(p) l.12371 */
- if(mem[p + 5].hh.v.RH == 0)
- cur_h = cur_h + mem[p + 1].cint;
- else {
-
- saveh = dvi_h;
- savev = dvi_v;
- cur_v = baseline + mem[p + 4].cint;
- temp_ptr = p;
- edge = cur_h;
- if(mem[p].hh.b0 == 1)vlist_out ();
- else hlist_out ();
- dvi_h = saveh;
- dvi_v = savev;
- cur_h = edge + mem[p + 1].cint;
- cur_v = baseline;
- }
- break;
- case 2 :
- {
- rule_ht = mem[p + 3].cint;
- rule_dp = mem[p + 2].cint;
- rule_wd = mem[p + 1].cint;
- goto lab14;
- }
- break;
- case 8 :
- out_what(p);
- break;
- case 10 :
- {
- g = mem[p + 1].hh.v.LH;
- rule_wd = mem[g + 1].cint;
- if(gsign != 0)
- {
- if(gsign == 1)
- {
- if(mem[g].hh.b0 == gorder)
-/* *********************************************************************** */
-/* rule_wd = rule_wd + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
-/* ******************** 3.14159 ******************************************* */
- {
- gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
- if(gluetemp > 1000000000.0)
- gluetemp = 1000000000.0;
- else if(gluetemp < -1000000000.0)
- gluetemp = -1000000000.0;
- rule_wd = rule_wd + round(gluetemp);
- }
-/* ************************************************************************* */
- }
-/* else { */
-/* if(mem[g].hh.b1 == gorder)*/
-/* rule_wd = rule_wd - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
-/* } */
-/* ******************** 3.14159 ******************************************* */
- else if(mem[g].hh.b1 == gorder)
- {
- gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
- if(gluetemp > 1000000000.0)
- gluetemp = 1000000000.0;
- else if(gluetemp < -1000000000.0)
- gluetemp = -1000000000.0;
- rule_wd = rule_wd - round(gluetemp);
- }
-/* ************************************************************************* */
- }
- if(mem[p].hh.b1 >= 100)
+ dvi_f = f;
+ }
+
+ if (c >= 128)
+ dvi_out(set1);
+
+ dvi_out(c);
+ cur_h = cur_h + char_width(f, char_info(f, c));
+ p = link(p);
+ }
+ while(!(!(p >= hi_mem_min)));
+
+ dvi_h = cur_h;
+ }
+ else
{
- leaderbox = mem[p + 1].hh.v.RH;
- if(mem[leaderbox].hh.b0 == 2)
- {
- rule_ht = mem[leaderbox + 3].cint;
- rule_dp = mem[leaderbox + 2].cint;
- goto lab14;
- }
- leaderwd = mem[leaderbox + 1].cint;
- if((leaderwd > 0)&&(rule_wd > 0))
+ switch (type(p))
{
- rule_wd = rule_wd + 10;
- edge = cur_h + rule_wd;
- lx = 0;
- if(mem[p].hh.b1 == 100)
- {
- saveh = cur_h;
- cur_h = leftedge + leaderwd *((cur_h - leftedge)/ leaderwd)
- ;
- if(cur_h < saveh)
- cur_h = cur_h + leaderwd;
- }
- else {
-
- lq = rule_wd / leaderwd;
- lr = rule_wd % leaderwd;
- if(mem[p].hh.b1 == 101)
- cur_h = cur_h +(lr / 2);
- else {
-
- lx =(2 * lr + lq + 1)/(2 * lq + 2);
- cur_h = cur_h +((lr -(lq - 1)* lx)/ 2);
- }
- }
- while(cur_h + leaderwd <= edge){
-
- cur_v = baseline + mem[leaderbox + 4].cint;
- if(cur_v != dvi_v)
+ case hlist_node:
+ case vlist_node:
+ if (list_ptr(p) == 0)
+ cur_h = cur_h + width(p);
+ else
{
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- savev = dvi_v;
- if(cur_h != dvi_h)
+ save_h = dvi_h;
+ save_v = dvi_v;
+ cur_v = base_line + shift_amount(p);
+ temp_ptr = p;
+ edge = cur_h;
+
+ if (type(p) == vlist_node)
+ vlist_out();
+ else
+ hlist_out();
+
+ dvi_h = save_h;
+ dvi_v = save_v;
+ cur_h = edge + width(p);
+ cur_v = base_line;
+ }
+ break;
+
+ case rule_node:
{
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- saveh = dvi_h;
- temp_ptr = leaderbox;
- outerdoingleaders = doing_leaders;
- doing_leaders = true;
- if(mem[leaderbox].hh.b0 == 1)vlist_out ();
- else hlist_out ();
- doing_leaders = outerdoingleaders;
- dvi_v = savev;
- dvi_h = saveh;
-/* ****************************************************************** */
-/* cur_v = saveh; */
- cur_v = baseline; /* changed in 3.1415 */
-/* ****************************************************************** */
- cur_h = saveh + leaderwd + lx;
- }
- cur_h = edge - 10;
- goto lab15;
- }
- }
- goto lab13;
- }
- break;
- case 11 :
- case 9 :
- cur_h = cur_h + mem[p + 1].cint;
- break;
- case 6 :
- {
- mem[mem_top - 12]= mem[p + 1];
- mem[mem_top - 12].hh.v.RH = mem[p].hh.v.RH;
- p = mem_top - 12;
- goto lab21;
- }
- break;
- default:
- ;
- break;
- }
- goto lab15;
- lab14: if((rule_ht == -1073741824L)) /* - 2^30 */
- rule_ht = mem[thisbox + 3].cint;
- if((rule_dp == -1073741824L)) /* - 2^30 */
- rule_dp = mem[thisbox + 2].cint;
- rule_ht = rule_ht + rule_dp;
- if((rule_ht > 0)&&(rule_wd > 0))
+ rule_ht = height(p);
+ rule_dp = depth(p);
+ rule_wd = width(p);
+ goto lab14;
+ }
+ break;
+
+ case whatsit_node:
+ out_what(p);
+ break;
+
+ case glue_node:
+ {
+ g = glue_ptr(p);
+ rule_wd = width(g) - cur_g;
+
+ if (g_sign != normal)
+ {
+ if (g_sign == stretching)
+ {
+ if (stretch_order(g) == g_order)
+ {
+ cur_glue = cur_glue + stretch(g);
+ glue_temp = glue_set(this_box) * cur_glue;
+
+ if (glue_temp > 1000000000.0)
+ glue_temp = 1000000000.0;
+ else if (glue_temp < -1000000000.0)
+ glue_temp = -1000000000.0;
+
+ cur_g = round(glue_temp);
+ }
+ }
+ else if (shrink_order(g) == g_order)
+ {
+ cur_glue = cur_glue - shrink(g);
+ glue_temp = glue_set(this_box) * cur_glue;
+
+ if (glue_temp > 1000000000.0)
+ glue_temp = 1000000000.0;
+ else if (glue_temp < -1000000000.0)
+ glue_temp = -1000000000.0;
+
+ cur_g = round(glue_temp);
+ }
+ }
+
+ rule_wd = rule_wd + cur_g;
+
+ if (subtype(p) >= a_leaders)
+ {
+ leader_box = leader_ptr(p);
+
+ if (type(leader_box) == rule_node)
+ {
+ rule_ht = height(leader_box);
+ rule_dp = depth(leader_box);
+ goto lab14;
+ }
+
+ leader_wd = width(leader_box);
+
+ if ((leader_wd > 0) && (rule_wd > 0))
+ {
+ rule_wd = rule_wd + 10;
+ edge = cur_h + rule_wd;
+ lx = 0;
+
+ if (subtype(p) == a_leaders)
+ {
+ save_h = cur_h;
+ cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
+
+ if (cur_h < save_h)
+ cur_h = cur_h + leader_wd;
+ }
+ else
+ {
+ lq = rule_wd / leader_wd;
+ lr = rule_wd % leader_wd;
+
+ if (subtype(p) == c_leaders)
+ cur_h = cur_h + (lr / 2);
+ else
+ {
+ lx =(2 * lr + lq + 1) / (2 * lq + 2);
+ cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
+ }
+ }
+
+ while (cur_h + leader_wd <= edge)
+ {
+ cur_v = base_line + shift_amount(leader_box);
+ synch_v();
+ save_v = dvi_v;
+ synch_h();
+ save_h = dvi_h;
+ temp_ptr = leader_box;
+ outer_doing_leaders = doing_leaders;
+ doing_leaders = true;
+
+ if (type(leader_box) == vlist_node)
+ vlist_out();
+ else
+ hlist_out();
+
+ doing_leaders = outer_doing_leaders;
+ dvi_v = save_v;
+ dvi_h = save_h;
+ cur_v = base_line;
+ cur_h = save_h + leader_wd + lx;
+ }
+
+ cur_h = edge - 10;
+ goto lab15;
+ }
+ }
+
+ goto lab13;
+ }
+ break;
+
+ case kern_node:
+ case math_node:
+ cur_h = cur_h + width(p);
+ break;
+
+ case ligature_node:
+ {
+ mem[lig_trick] = mem[lig_char(p)];
+ link(lig_trick) = link(p);
+ p = lig_trick;
+ goto lab21;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ goto lab15;
+lab14:
+ if ((rule_ht == -1073741824L)) /* - 2^30 */
+ rule_ht = height(this_box);
+
+ if ((rule_dp == -1073741824L)) /* - 2^30 */
+ rule_dp = depth(this_box);
+
+ rule_ht = rule_ht + rule_dp;
+
+ if ((rule_ht > 0) && (rule_wd > 0))
{
- if(cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- cur_v = baseline + rule_dp;
- if(cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- {
- dvi_buf[dvi_ptr]= 132;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- dvi_four(rule_ht);
- dvi_four(rule_wd);
- cur_v = baseline;
- dvi_h = dvi_h + rule_wd;
- }
- lab13: cur_h = cur_h + rule_wd;
- lab15: p = mem[p].hh.v.RH;
- }
- prune_movements(saveloc);
- if(cur_s > 0)
- dvi_pop(saveloc);
- decr(cur_s);
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void vlist_out (void)
-{/* 13 14 15 */
- scaled leftedge;
- scaled topedge;
- scaled saveh, savev;
- halfword thisbox;
-/* glue_ord gorder; */
- int gorder; /* 95/Jan/7 */
-/* char gsign; */
- int gsign; /* 95/Jan/7 */
- halfword p;
- integer saveloc;
- halfword leaderbox;
- scaled leaderht;
- scaled lx;
- bool outerdoingleaders;
- scaled edge;
-/* ************************************************************************ */
- real gluetemp; /* new in 3.14159 */
-/* ************************************************************************ */
- thisbox = temp_ptr;
- gorder = mem[thisbox + 5].hh.b1;
- gsign = mem[thisbox + 5].hh.b0;
- p = mem[thisbox + 5].hh.v.RH;
- incr(cur_s);
- if(cur_s > 0)
- {
- dvi_buf[dvi_ptr]= 141;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- if(cur_s > max_push)
- max_push = cur_s;
- saveloc = dvi_offset + dvi_ptr;
- leftedge = cur_h;
- cur_v = cur_v - mem[thisbox + 3].cint;
- topedge = cur_v;
- while(p != 0){ /* while p<>null do l.12494 OK */
- if((p >= hi_mem_min)) {
- confusion(822); /* vlist_out */
- return; // abort_flag set
+ synch_h();
+ cur_v = base_line + rule_dp;
+ synch_v();
+ dvi_out(set_rule);
+ dvi_four(rule_ht);
+ dvi_four(rule_wd);
+ cur_v = base_line;
+ dvi_h = dvi_h + rule_wd;
+ }
+lab13:
+ cur_h = cur_h + rule_wd;
+lab15:
+ p = link(p);
}
- else {
- switch(mem[p].hh.b0)
- {case 0 :
- case 1 :
-/* if list_ptr(p)=null then cur_v:=cur_v+height(p)+depth(p) l.12529 */
- if(mem[p + 5].hh.v.RH == 0)
- cur_v = cur_v + mem[p + 3].cint + mem[p + 2].cint;
- else {
-
- cur_v = cur_v + mem[p + 3].cint;
- if(cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- saveh = dvi_h;
- savev = dvi_v;
- cur_h = leftedge + mem[p + 4].cint;
- temp_ptr = p;
- if(mem[p].hh.b0 == 1)vlist_out ();
- else hlist_out ();
- dvi_h = saveh;
- dvi_v = savev;
- cur_v = savev + mem[p + 2].cint;
- cur_h = leftedge;
- }
- break;
- case 2 :
- {
- rule_ht = mem[p + 3].cint;
- rule_dp = mem[p + 2].cint;
- rule_wd = mem[p + 1].cint;
- goto lab14;
- }
- break;
- case 8 :
- out_what(p);
- break;
- case 10 :
+
+ prune_movements(save_loc);
+
+ if (cur_s > 0)
+ dvi_pop(save_loc);
+
+ decr(cur_s);
+}
+/* sec 0629 */
+void vlist_out (void)
+{
+ scaled left_edge;
+ scaled top_edge;
+ scaled save_h, save_v;
+ halfword this_box;
+/* glue_ord g_order; */
+ int g_order; /* 95/Jan/7 */
+/* char g_sign; */
+ int g_sign; /* 95/Jan/7 */
+ halfword p;
+ integer save_loc;
+ halfword leader_box;
+ scaled leader_ht;
+ scaled lx;
+ boolean outer_doing_leaders;
+ scaled edge;
+ real glue_temp;
+ real cur_glue;
+ scaled cur_g;
+
+ cur_g = 0;
+ cur_glue = 0.0;
+ this_box = temp_ptr;
+ g_order = glue_order(this_box);
+ g_sign = glue_sign(this_box);
+ p = list_ptr(this_box);
+ incr(cur_s);
+
+ if (cur_s > 0)
+ dvi_out(141);
+
+ if (cur_s > max_push)
+ max_push = cur_s;
+
+ save_loc = dvi_offset + dvi_ptr;
+ left_edge = cur_h;
+ cur_v = cur_v - height(this_box);
+ top_edge = cur_v;
+
+ while (p != 0)
{
- g = mem[p + 1].hh.v.LH;
- rule_ht = mem[g + 1].cint;
- if(gsign != 0)
+ if ((p >= hi_mem_min))
{
- if(gsign == 1)
- {
- if(mem[g].hh.b0 == gorder)
-/* ************************************************************************ */
-/* rule_ht = rule_ht + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
-/* ************************ 3.14159 **************************************** */
- {
- gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
- if(gluetemp > 1000000000.0)
- gluetemp = 1000000000.0;
- else if(gluetemp < -1000000000.0)
- gluetemp = -1000000000.0;
- rule_ht = rule_ht + round(gluetemp);
- }
-/* ************************************************************************* */
- }
-/* ************************************************************************* */
-/* else { */
-/* if(mem[g].hh.b1 == gorder) */
-/* rule_ht = rule_ht - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
-/* } */
- else if(mem[g].hh.b1 == gorder) /* BUG FIX !!! */
- {
- gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
- if(gluetemp > 1000000000.0)
- gluetemp = 1000000000.0;
- else if(gluetemp < -1000000000.0)
- gluetemp = -1000000000.0;
- rule_ht = rule_ht - round(gluetemp);
- }
-/* ************************************************************************* */
- }
- if(mem[p].hh.b1 >= 100)
+ confusion("vlistout");
+ return; // abort_flag set
+ }
+ else
{
- leaderbox = mem[p + 1].hh.v.RH;
- if(mem[leaderbox].hh.b0 == 2)
- {
- rule_wd = mem[leaderbox + 1].cint;
- rule_dp = 0;
- goto lab14;
- }
- leaderht = mem[leaderbox + 3].cint + mem[leaderbox + 2]
- .cint;
- if((leaderht > 0)&&(rule_ht > 0))
+ switch (type(p))
{
- rule_ht = rule_ht + 10;
- edge = cur_v + rule_ht;
- lx = 0;
- if(mem[p].hh.b1 == 100)
- {
- savev = cur_v;
- cur_v = topedge + leaderht *((cur_v - topedge)/ leaderht)
- ;
- if(cur_v < savev)
- cur_v = cur_v + leaderht;
- }
- else {
-
- lq = rule_ht / leaderht;
- lr = rule_ht % leaderht;
- if(mem[p].hh.b1 == 101)
- cur_v = cur_v +(lr / 2);
- else {
-
- lx =(2 * lr + lq + 1)/(2 * lq + 2);
- cur_v = cur_v +((lr -(lq - 1)* lx)/ 2);
- }
- }
- while(cur_v + leaderht <= edge){
-
- cur_h = leftedge + mem[leaderbox + 4].cint;
- if(cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- saveh = dvi_h;
- cur_v = cur_v + mem[leaderbox + 3].cint;
- if(cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- savev = dvi_v;
- temp_ptr = leaderbox;
- outerdoingleaders = doing_leaders;
- doing_leaders = true;
- if(mem[leaderbox].hh.b0 == 1)vlist_out ();
- else hlist_out ();
- doing_leaders = outerdoingleaders;
- dvi_v = savev;
- dvi_h = saveh;
-/* ************************************************************************ */
-/* cur_h = saveh; */
- cur_h = leftedge; /* 3.1415 */
-/* ************************************************************************ */
- cur_v = savev - mem[leaderbox + 3].cint + leaderht + lx;
- }
- cur_v = edge - 10;
- goto lab15;
- }
- }
- goto lab13;
- }
- break;
- case 11 :
- cur_v = cur_v + mem[p + 1].cint;
- break;
- default:
- ;
- break;
- }
- goto lab15;
- lab14: if((rule_wd == -1073741824L)) /* -2^30 */
- rule_wd = mem[thisbox + 1].cint;
- rule_ht = rule_ht + rule_dp;
- cur_v = cur_v + rule_ht;
- if((rule_ht > 0)&&(rule_wd > 0))
+ case hlist_node:
+ case vlist_node:
+ if (list_ptr(p) == 0)
+ cur_v = cur_v + height(p) + depth(p);
+ else
+ {
+ cur_v = cur_v + height(p);
+ synch_v();
+ save_h = dvi_h;
+ save_v = dvi_v;
+ cur_h = left_edge + shift_amount(p);
+ temp_ptr = p;
+
+ if (type(p) == vlist_node)
+ vlist_out();
+ else
+ hlist_out();
+
+ dvi_h = save_h;
+ dvi_v = save_v;
+ cur_v = save_v + depth(p);
+ cur_h = left_edge;
+ }
+ break;
+
+ case rule_node:
+ {
+ rule_ht = height(p);
+ rule_dp = depth(p);
+ rule_wd = width(p);
+ goto lab14;
+ }
+ break;
+
+ case whatsit_node:
+ out_what(p);
+ break;
+
+ case glue_node:
+ {
+ g = glue_ptr(p);
+ rule_ht = width(g) - cur_g;
+
+ if (g_sign != normal)
+ {
+ if (g_sign == stretching)
+ {
+ if (stretch_order(g) == g_order)
+ {
+ cur_glue = cur_glue + stretch(g);
+ glue_temp = glue_set(this_box) * cur_glue;
+
+ if (glue_temp > 1000000000.0)
+ glue_temp = 1000000000.0;
+ else if (glue_temp < -1000000000.0)
+ glue_temp = -1000000000.0;
+
+ cur_g = round(glue_temp);
+ }
+ }
+ else if (shrink_order(g) == g_order) /* BUG FIX !!! */
+ {
+ cur_glue = cur_glue - shrink(g);
+ glue_temp = glue_set(this_box) * cur_glue;
+
+ if (glue_temp > 1000000000.0)
+ glue_temp = 1000000000.0;
+ else if (glue_temp < -1000000000.0)
+ glue_temp = -1000000000.0;
+
+ cur_g = round(glue_temp);
+ }
+ }
+
+ rule_ht = rule_ht + cur_g;
+
+ if (subtype(p) >= a_leaders)
+ {
+ leader_box = leader_ptr(p);
+
+ if (type(leader_box) == rule_node)
+ {
+ rule_wd = width(leader_box);
+ rule_dp = 0;
+ goto lab14;
+ }
+
+ leader_ht = height(leader_box) + depth(leader_box);
+
+ if ((leader_ht > 0) && (rule_ht > 0))
+ {
+ rule_ht = rule_ht + 10;
+ edge = cur_v + rule_ht;
+ lx = 0;
+
+ if (subtype(p) == a_leaders)
+ {
+ save_v = cur_v;
+ cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
+
+ if (cur_v < save_v)
+ cur_v = cur_v + leader_ht;
+ }
+ else
+ {
+ lq = rule_ht / leader_ht;
+ lr = rule_ht % leader_ht;
+
+ if (subtype(p) == c_leaders)
+ cur_v = cur_v + (lr / 2);
+ else
+ {
+ lx = (2 * lr + lq + 1) / (2 * lq + 2);
+ cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
+ }
+ }
+
+ while (cur_v + leader_ht <= edge)
+ {
+ cur_h = left_edge + shift_amount(leader_box);
+ synch_h();
+ save_h = dvi_h;
+ cur_v = cur_v + height(leader_box);
+ synch_v();
+ save_v = dvi_v;
+ temp_ptr = leader_box;
+ outer_doing_leaders = doing_leaders;
+ doing_leaders = true;
+
+ if (type(leader_box) == vlist_node)
+ vlist_out();
+ else
+ hlist_out();
+
+ doing_leaders = outer_doing_leaders;
+ dvi_v = save_v;
+ dvi_h = save_h;
+ cur_h = left_edge;
+ cur_v = save_v - height(leader_box) + leader_ht + lx;
+ }
+
+ cur_v = edge - 10;
+ goto lab15;
+ }
+ }
+
+ goto lab13;
+ }
+ break;
+
+ case kern_node:
+ cur_v = cur_v + width(p);
+ break;
+
+ default:
+ break;
+ }
+ goto lab15;
+lab14:
+ if ((rule_wd == -1073741824L)) /* -2^30 */
+ rule_wd = width(this_box);
+
+ rule_ht = rule_ht + rule_dp;
+ cur_v = cur_v + rule_ht;
+
+ if ((rule_ht > 0) && (rule_wd > 0))
{
- if(cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, 143); /* 143 == right1 */
- dvi_h = cur_h;
- }
- if(cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, 157); /* 157 == down1 */
- dvi_v = cur_v;
- }
- {
- dvi_buf[dvi_ptr]= 137;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- dvi_four(rule_ht);
- dvi_four(rule_wd);
- }
- goto lab15;
- lab13: cur_v = cur_v + rule_ht;
- }
- lab15: p = mem[p].hh.v.RH;
- }
- prune_movements(saveloc);
- if(cur_s > 0)
- dvi_pop(saveloc);
- decr(cur_s);
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-void ship_out_(halfword p)
-{/* 30 */
- integer pageloc;
- char j, k;
- pool_pointer s;
- char old_setting;
- if(eqtb[(hash_size + 3197)].cint > 0)
+ synch_h();
+ synch_v();
+ dvi_out(put_rule);
+ dvi_four(rule_ht);
+ dvi_four(rule_wd);
+ }
+
+ goto lab15;
+lab13:
+ cur_v = cur_v + rule_ht;
+ }
+lab15:
+ p = link(p);
+ }
+
+ prune_movements(save_loc);
+
+ if (cur_s > 0)
+ dvi_pop(save_loc);
+
+ decr(cur_s);
+}
+/* sec 0638 */
+void dvi_ship_out_(halfword p)
+{
+ integer page_loc;
+ char j, k;
+ pool_pointer s;
+ char old_setting;
+
+ if (tracing_output > 0)
{
- print_nl(""); /* */
- print_ln ();
+ print_nl("");
+ print_ln();
print_string("Completed box being shipped out");
- }
- if(term_offset > max_print_line - 9)
- print_ln ();
- else if((term_offset > 0)||(file_offset > 0))
- print_char(32); /* */
- print_char(91); /*[*/
- j = 9;
- while((eqtb[(hash_size + 3218) + j].cint == 0)&&(j > 0)) decr(j);
+ }
+
+ if (term_offset > max_print_line - 9)
+ print_ln();
+ else if ((term_offset > 0) || (file_offset > 0))
+ print_char(' ');
+
+ print_char('[');
+ j = 9;
+
+ while((count(j) == 0) && (j > 0))
+ decr(j);
+
+ for (k = 0; k <= j; k++)
{
- register integer for_end;
- k = 0;
- for_end = j;
- if(k <= for_end) do
- {
- print_int(eqtb[(hash_size + 3218) + k].cint);
- if(k < j)
- print_char(46); /* . */
- }
- while(k++ < for_end);
- }
+ print_int(count(k));
+
+ if (k < j)
+ print_char('.');
+ }
+
#ifndef _WINDOWS
- fflush(stdout);
+ fflush(stdout);
#endif
- if(eqtb[(hash_size + 3197)].cint > 0)
- {
- print_char(93); /*]*/
- begin_diagnostic ();
- show_box(p);
- end_diagnostic(true);
- }
- if((mem[p + 3].cint > 1073741823L)|| /* 2^30 - 1 */
- (mem[p + 2].cint > 1073741823L)||
- (mem[p + 3].cint + mem[p + 2].cint +
- eqtb[(hash_size + 3749)].cint > 1073741823L)||
- (mem[p + 1].cint + eqtb[(hash_size + 3748)].cint > 1073741823L))
+
+ if (tracing_output > 0)
{
- print_err("Huge page cannot be shipped out");
- help2("The page just created is more than 18 feet tall or",
- "more than 18 feet wide, so I suspect something went wrong.");
- error ();
- if(eqtb[(hash_size + 3197)].cint <= 0)
+ print_char(']');
+ begin_diagnostic();
+ show_box(p);
+ end_diagnostic(true);
+ }
+
+ if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
+ (height(p) + depth(p) + v_offset > max_dimen) ||
+ (width(p) + h_offset > max_dimen))
+ {
+ print_err("Huge page cannot be shipped out");
+ help2("The page just created is more than 18 feet tall or",
+ "more than 18 feet wide, so I suspect something went wrong.");
+ error();
+
+ if (tracing_output <= 0)
{
- begin_diagnostic ();
- print_nl("The following box has been deleted:"); /* */
- show_box(p);
- end_diagnostic(true);
- }
- goto lab30;
- }
- if(mem[p + 3].cint + mem[p + 2].cint + eqtb[(hash_size + 3749)].cint > max_v
-)
- max_v = mem[p + 3].cint + mem[p + 2].cint + eqtb[(hash_size + 3749)].cint;
- if(mem[p + 1].cint + eqtb[(hash_size + 3748)].cint > max_h)
- max_h = mem[p + 1].cint + eqtb[(hash_size + 3748)].cint;
- dvi_h = 0;
- dvi_v = 0;
- cur_h = eqtb[(hash_size + 3748)].cint;
- dvi_f = 0;
- if(output_file_name == 0)
- {
- if(job_name == 0)open_log_file ();
- pack_job_name(788); /* .dvi */
- while(! b_open_out(dvi_file)) {
- prompt_file_name(789, 788); /* file name for output .dvi */
+ begin_diagnostic();
+ print_nl("The following box has been deleted:");
+ show_box(p);
+ end_diagnostic(true);
+ }
+
+ goto lab30;
}
- output_file_name = b_make_name_string(dvi_file);
- }
- if(total_pages == 0)
+ if (height(p) + depth(p) + v_offset > max_v)
+ max_v = height(p) + depth(p) + v_offset;
+
+ if (width(p) + h_offset > max_h)
+ max_h = width(p) + h_offset;
+
+ dvi_h = 0;
+ dvi_v = 0;
+ cur_h = h_offset;
+ dvi_f = null_font;
+
+ if (output_file_name == 0)
{
+ if (job_name == 0)
+ open_log_file();
+
+ pack_job_name(".dvi");
+
+ while(!b_open_out(dvi_file))
{
- dvi_buf[dvi_ptr]= 247;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- dvi_buf[dvi_ptr]= 2;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
+ prompt_file_name("file name for output", ".dvi");
+ }
+
+ output_file_name = b_make_name_string(dvi_file);
+ }
+
+ if (total_pages == 0)
+ {
+ dvi_out(pre);
+ dvi_out(id_byte);
dvi_four(25400000L); /* magic DVI scale factor */
dvi_four(473628672L); /* 7227 * 65536 */
- prepare_mag ();
- dvi_four(eqtb[(hash_size + 3180)].cint);
- old_setting = selector;
- selector = 21;
- print_string("TeX output ");
- print_int(eqtb[(hash_size + 3186)].cint);
- print_char(46); /* . */
- print_two(eqtb[(hash_size + 3185)].cint);
- print_char(46); /* . */
- print_two(eqtb[(hash_size + 3184)].cint);
- print_char(58); /* : */
- print_two(eqtb[(hash_size + 3183)].cint / 60);
- print_two(eqtb[(hash_size + 3183)].cint % 60);
- selector = old_setting;
- {
-/* long to unsigned char ... */
- dvi_buf[dvi_ptr]=(pool_ptr - str_start[str_ptr]);
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- register integer for_end;
- s = str_start[str_ptr];
- for_end = pool_ptr - 1;
- if(s <= for_end) do
- {
- dvi_buf[dvi_ptr]= str_pool[s];
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- while(s++ < for_end);
- }
- pool_ptr = str_start[str_ptr];
- } // end of if total_pages == 0
+ prepare_mag();
+ dvi_four(mag);
+ old_setting = selector;
+ selector = new_string;
+ print_string(" TeX output ");
+ print_int(year);
+ print_char('.');
+ print_two(month);
+ print_char('.');
+ print_two(day);
+ print_char(':');
+ print_two(tex_time / 60);
+ print_two(tex_time % 60);
+ selector = old_setting;
+ dvi_out(cur_length);
+
+ for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++)
+ dvi_out(str_pool[s]);
+
+ pool_ptr = str_start[str_ptr];
+ }
+
+ page_loc = dvi_offset + dvi_ptr;
+ dvi_out(bop);
+
+ for (k = 0; k <= 9; k++)
+ dvi_four(count(k));
+
+ dvi_four(last_bop);
+ last_bop = page_loc;
+ cur_v = height(p) + v_offset;
+ temp_ptr = p;
+
+ if (type(p) == vlist_node)
+ vlist_out();
+ else
+ hlist_out();
+
+ dvi_out(eop); // do not need a endpage in haru.
+ incr(total_pages);
+ cur_s = -1;
+lab30:;
+ if (tracing_output <= 0)
+ print_char(']');
+
+ dead_cycles = 0;
- pageloc = dvi_offset + dvi_ptr;
- {
- dvi_buf[dvi_ptr]= 139;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- {
- register integer for_end;
- k = 0;
- for_end = 9;
- if(k <= for_end) do
- dvi_four(eqtb[(hash_size + 3218) + k].cint);
- while(k++ < for_end);
- }
- dvi_four(last_bop);
- last_bop = pageloc;
- cur_v = mem[p + 3].cint + eqtb[(hash_size + 3749)].cint;
- temp_ptr = p;
- if(mem[p].hh.b0 == 1)vlist_out ();
- else hlist_out ();
- {
- dvi_buf[dvi_ptr]= 140;
- incr(dvi_ptr);
- if(dvi_ptr == dvi_limit)dvi_swap ();
- }
- incr(total_pages);
- cur_s = -1;
- lab30:;
- if(eqtb[(hash_size + 3197)].cint <= 0)
- print_char(93); /*]*/
- dead_cycles = 0;
#ifndef _WINDOWS
- fflush(stdout);
+ fflush(stdout);
#endif
- ;
+
#ifdef STAT
- if(eqtb[(hash_size + 3194)].cint > 1)
+ if (tracing_stats > 1)
{
- print_nl("Memory usage before: "); /* */
- print_int(var_used);
- print_char(38); /* & */
- print_int(dyn_used);
- print_char(59); /*; */
- }
+ print_nl("Memory usage before: ");
+ print_int(var_used);
+ print_char('&');
+ print_int(dyn_used);
+ print_char(';');
+ }
#endif /* STAT */
- flush_node_list(p);
- ;
+
+ flush_node_list(p);
+
#ifdef STAT
- if(eqtb[(hash_size + 3194)].cint > 1)
+ if (tracing_stats > 1)
{
- print_string("after");
- print_int(var_used);
- print_char(38); /* & */
- print_int(dyn_used);
- print_string("still utouched");
+ print_string(" after: ");
+ print_int(var_used);
+ print_char('&');
+ print_int(dyn_used);
+ print_string("; still utouched: ");
print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
- print_ln ();
- }
+ print_ln();
+ }
#endif /* STAT */
-}
-void scan_spec_(group_code c, bool threecodes)
-{/* 40 */
- integer s;
- char speccode;
- if(threecodes)
- s = save_stack[save_ptr + 0].cint;
- if(scan_keyword(836)) /* to */
- speccode = 0;
- else if(scan_keyword(837)) /* spread */
- speccode = 1;
- else {
- speccode = 1;
- cur_val = 0;
- goto lab40;
- }
- scan_dimen(false, false, false);
- lab40: if(threecodes)
+}
+void ship_out_(halfword p)
+{
+ switch (shipout_flag)
+ {
+ case out_pdf_flag:
+ pdf_ship_out(p);
+ break;
+ case out_dvi_flag:
+ case out_xdv_flag:
+ dvi_ship_out_(p);
+ break;
+ }
+}
+/* sec 0645 */
+void scan_spec_(group_code c, boolean three_codes)
+{
+ integer s;
+ char spec_code;
+
+ if (three_codes)
+ s = saved(0);
+
+ if (scan_keyword("to"))
+ spec_code = exactly;
+ else if (scan_keyword("spread"))
+ spec_code = additional;
+ else
+ {
+ spec_code = additional;
+ cur_val = 0;
+ goto lab40;
+ }
+
+ scan_dimen(false, false, false);
+
+lab40:
+ if (three_codes)
{
- save_stack[save_ptr + 0].cint = s; /* s may be used without ... */
- incr(save_ptr);
- }
- save_stack[save_ptr + 0].cint = speccode;
- save_stack[save_ptr + 1].cint = cur_val;
- save_ptr = save_ptr + 2;
- new_save_level(c);
- scan_left_brace ();
-}
+ saved(0) = s;
+ incr(save_ptr);
+ }
+
+ saved(0) = spec_code;
+ saved(1) = cur_val;
+ save_ptr = save_ptr + 2;
+ new_save_level(c);
+ scan_left_brace();
+}
+/* sec 0649 */
halfword hpack_(halfword p, scaled w, small_number m)
-{/* 21 50 10 */ register halfword Result;
- halfword r;
- halfword q;
- scaled h, d, x;
- scaled s;
- halfword g;
+{
+ halfword r;
+ halfword q;
+ scaled h, d, x;
+ scaled s;
+ halfword g;
/* glue_ord o; */
int o; /* 95/Jan/7 */
- internal_font_number f;
- ffourquarters i;
- eight_bits hd;
- last_badness = 0;
- r = get_node(7);
- mem[r].hh.b0 = 0;
- mem[r].hh.b1 = 0;
- mem[r + 4].cint = 0;
- q = r + 5;
- mem[q].hh.v.RH = p;
- h = 0;
- d = 0;
- x = 0;
- totalstretch[0]= 0;
- totalshrink[0]= 0;
- totalstretch[1]= 0;
- totalshrink[1]= 0;
- totalstretch[2]= 0;
- totalshrink[2]= 0;
- totalstretch[3]= 0;
- totalshrink[3]= 0;
- while(p != 0){ /* while p<>null do l.12862 */
-
- lab21: while((p >= hi_mem_min)) {
-
- f = mem[p].hh.b0;
- i = font_info[char_base[f]+ mem[p].hh.b1].qqqq;
- hd = i.b1;
- x = x + font_info[width_base[f]+ i.b0].cint;
- s = font_info[height_base[f]+(hd)/ 16].cint;
- if(s > h)
- h = s;
- s = font_info[depth_base[f]+(hd)% 16].cint;
- if(s > d)
- d = s;
- p = mem[p].hh.v.RH;
- }
- if(p != 0) /* if p<>null then l.12886 */
- {
- switch(mem[p].hh.b0)
- {case 0 :
- case 1 :
- case 2 :
- case 13 :
- {
- x = x + mem[p + 1].cint;
- if(mem[p].hh.b0 >= 2)
- s = 0;
- else s = mem[p + 4].cint;
- if(mem[p + 3].cint - s > h)
- h = mem[p + 3].cint - s;
- if(mem[p + 2].cint + s > d)
- d = mem[p + 2].cint + s;
- }
- break;
- case 3 :
- case 4 :
- case 5 :
-/* if adjust_tail<>null then link(adjust_tail):=null; l.12865 / 12891 */
- if(adjust_tail != 0)
+ internal_font_number f;
+ four_quarters i;
+ eight_bits hd;
+
+ last_badness = 0;
+ r = get_node(box_node_size);
+ type(r) = hlist_node;
+ subtype(r) = 0;
+ shift_amount(r) = 0;
+ q = r + list_offset;
+ link(q) = p;
+ h = 0;
+ d = 0;
+ x = 0;
+ total_stretch[normal] = 0;
+ total_shrink[normal] = 0;
+ total_stretch[fil] = 0;
+ total_shrink[fil] = 0;
+ total_stretch[fill] = 0;
+ total_shrink[fill] = 0;
+ total_stretch[filll] = 0;
+ total_shrink[filll] = 0;
+
+ while (p != 0)
{
- while(mem[q].hh.v.RH != p)q = mem[q].hh.v.RH;
- if(mem[p].hh.b0 == 5)
+lab21:
+ while ((p >= hi_mem_min))
{
- mem[adjust_tail].hh.v.RH = mem[p + 1].cint;
- while(mem[adjust_tail].hh.v.RH != 0)adjust_tail = mem[
- adjust_tail].hh.v.RH;
- p = mem[p].hh.v.RH;
- free_node(mem[q].hh.v.RH, 2);
- }
- else {
-
- mem[adjust_tail].hh.v.RH = p;
- adjust_tail = p;
- p = mem[p].hh.v.RH;
- }
- mem[q].hh.v.RH = p;
- p = q;
- }
- break;
- case 8 :
- ;
- break;
- case 10 :
- {
- g = mem[p + 1].hh.v.LH;
- x = x + mem[g + 1].cint;
- o = mem[g].hh.b0;
- totalstretch[o]= totalstretch[o]+ mem[g + 2].cint;
- o = mem[g].hh.b1;
- totalshrink[o]= totalshrink[o]+ mem[g + 3].cint;
- if(mem[p].hh.b1 >= 100)
+ f = font(p);
+ i = char_info(f, character(p));
+ hd = height_depth(i);
+ x = x + char_width(f, i);
+ s = char_height(f, hd);
+
+ if (s > h)
+ h = s;
+
+ s = char_depth(f, hd);
+
+ if (s > d)
+ d = s;
+
+ p = link(p);
+ }
+
+ if (p != 0)
{
- g = mem[p + 1].hh.v.RH;
- if(mem[g + 3].cint > h)
- h = mem[g + 3].cint;
- if(mem[g + 2].cint > d)
- d = mem[g + 2].cint;
- }
- }
- break;
- case 11 :
- case 9 :
- x = x + mem[p + 1].cint;
- break;
- case 6 :
- {
- mem[mem_top - 12]= mem[p + 1];
- mem[mem_top - 12].hh.v.RH = mem[p].hh.v.RH;
- p = mem_top - 12;
- goto lab21;
- }
- break;
- default:
- ;
- break;
- }
- p = mem[p].hh.v.RH;
- }
- }
- if(adjust_tail != 0)
- mem[adjust_tail].hh.v.RH = 0;
- mem[r + 3].cint = h;
- mem[r + 2].cint = d;
- if(m == 1)
- w = x + w;
- mem[r + 1].cint = w;
- x = w - x;
- if(x == 0)
- {
- mem[r + 5].hh.b0 = 0;
- mem[r + 5].hh.b1 = 0;
- mem[r + 6].gr = 0.0;
- goto lab10;
- }
- else if(x > 0)
+ switch (type(p))
+ {
+ case hlist_node:
+ case vlist_node:
+ case rule_node:
+ case unset_node:
+ {
+ x = x + width(p);
+
+ if (type(p) >= rule_node)
+ s = 0;
+ else
+ s = shift_amount(p);
+
+ if (height(p) - s > h)
+ h = height(p) - s;
+
+ if (depth(p) + s > d)
+ d = depth(p) + s;
+ }
+ break;
+
+ case ins_node:
+ case mark_node:
+ case adjust_node:
+ if (adjust_tail != 0)
+ {
+ while (link(q) != p)
+ q = link(q);
+
+ if (type(p) == adjust_node)
+ {
+ link(adjust_tail) = adjust_ptr(p);
+
+ while (link(adjust_tail) != 0)
+ adjust_tail = link(adjust_tail);
+
+ p = link(p);
+ free_node(link(q), small_node_size);
+ }
+ else
+ {
+ link(adjust_tail) = p;
+ adjust_tail = p;
+ p = link(p);
+ }
+
+ link(q) = p;
+ p = q;
+ }
+ break;
+
+ case whatsit_node:
+ break;
+ case glue_node:
+ {
+ g = glue_ptr(p);
+ x = x + width(g);
+ o = stretch_order(g);
+ total_stretch[o] = total_stretch[o] + stretch(g);
+ o = shrink_order(g);
+ total_shrink[o] = total_shrink[o] + shrink(g);
+
+ if (subtype(p) >= a_leaders)
+ {
+ g = leader_ptr(p);
+
+ if (height(g) > h)
+ h = height(g);
+
+ if (depth(g) > d)
+ d = depth(g);
+ }
+ }
+ break;
+
+ case kern_node:
+ case math_node:
+ x = x + width(p);
+ break;
+
+ case ligature_node:
+ {
+ mem[lig_trick] = mem[lig_char(p)];
+ link(lig_trick) = link(p);
+ p = lig_trick;
+ goto lab21;
+ }
+ break;
+
+ default:
+ break;
+ }
+ p = link(p);
+ }
+ }
+
+ if (adjust_tail != 0)
+ link(adjust_tail) = 0;
+
+ height(r) = h;
+ depth(r) = d;
+
+ if (m == additional)
+ w = x + w;
+
+ width(r) = w;
+ x = w - x;
+
+ if (x == 0)
{
- if(totalstretch[3]!= 0)
- o = 3;
- else if(totalstretch[2]!= 0)
- o = 2;
- else if(totalstretch[1]!= 0)
- o = 1;
- else o = 0;
- mem[r + 5].hh.b1 = o;
- mem[r + 5].hh.b0 = 1;
-/* if total_stretch[o]<>0 then glue_set(r):=... l.12982 */
- if(totalstretch[o]!= 0)
- mem[r + 6].gr = x / ((double) totalstretch[o]);
- else {
-
- mem[r + 5].hh.b0 = 0;
- mem[r + 6].gr = 0.0;
- }
-/* if o=normal then if list_ptr(r)<>null then l.12987 */
- if(o == 0)
- if(mem[r + 5].hh.v.RH != 0)
+ glue_sign(r) = normal;
+ glue_order(r) = normal;
+ glue_set(r) = 0.0;
+ goto lab10;
+ }
+ else if (x > 0)
+ {
+ if (total_stretch[filll] != 0)
+ o = filll;
+ else if (total_stretch[fill] != 0)
+ o = fill;
+ else if (total_stretch[fil] != 0)
+ o = fil;
+ else
+ o = normal;
+
+ glue_order(r) = o;
+ glue_sign(r) = stretching;
+
+ if (total_stretch[o] != 0)
+ glue_set(r) = x / ((double) total_stretch[o]);
+ else
{
- last_badness = badness(x, totalstretch[0]);
- if(last_badness > eqtb[(hash_size + 3189)].cint)
+ glue_sign(r) = normal;
+ glue_set(r) = 0.0;
+ }
+
+ if (o == normal)
+ if (list_ptr(r) != 0)
{
- print_ln ();
- if(last_badness > 100)
- print_nl("Underfull"); /* */
- else print_nl("Loose"); /* */
- print_string("\\hbox (badness");
- print_int(last_badness);
- if(last_badness > 100)underfull_hbox++; /* 1996/Feb/9 */
- goto lab50;
- }
- }
- goto lab10;
- }
- else {
-
- if(totalshrink[3]!= 0)
- o = 3;
- else if(totalshrink[2]!= 0)
- o = 2;
- else if(totalshrink[1]!= 0)
- o = 1;
- else o = 0;
- mem[r + 5].hh.b1 = o;
- mem[r + 5].hh.b0 = 2;
- if(totalshrink[o]!= 0)
- mem[r + 6].gr =(- (integer) x)/ ((double) totalshrink[o]);
- else {
-
- mem[r + 5].hh.b0 = 0;
- mem[r + 6].gr = 0.0;
- }
-/* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13946 */
- if((totalshrink[o]< - (integer) x)&&(o == 0)&&(mem[r + 5
- ].hh.v.RH != 0))
+ last_badness = badness(x, total_stretch[normal]);
+
+ if (last_badness > hbadness)
+ {
+ print_ln();
+
+ if (last_badness > 100)
+ print_nl("Underfull");
+ else
+ print_nl("Loose");
+
+ print_string(" \\hbox (badness ");
+ print_int(last_badness);
+
+ if (last_badness > 100) /* Y&Y TeX */
+ underfull_hbox++; /* 1996/Feb/9 */
+
+ goto lab50;
+ }
+ }
+ goto lab10;
+ }
+ else
+ {
+ if (total_shrink[filll] != 0)
+ o = filll;
+ else if (total_shrink[fill] != 0)
+ o = fill;
+ else if (total_shrink[fil] != 0)
+ o = fil;
+ else
+ o = normal;
+
+ glue_order(r) = o;
+ glue_sign(r) = shrinking;
+
+ if (total_shrink[o] != 0)
+ glue_set(r) =(- (integer) x) / ((double) total_shrink[o]);
+ else
{
- last_badness = 1000000L;
-/* set_glue_ratio_one(glue_set(r)); {use the maximum shrinkage} */
- mem[r + 6].gr = 1.0;
-/* if (-x-total_shrink[normal]>hfuzz)or(hbadness<100) then */
- if((- (integer) x - totalshrink[0]> eqtb[(hash_size + 3738)].cint)||(
- eqtb[(hash_size + 3189)].cint < 100))
- {
- if((eqtb[(hash_size + 3746)].cint > 0)&&(- (integer) x - totalshrink[0
- ] > eqtb[(hash_size + 3738)].cint))
- {
- while(mem[q].hh.v.RH != 0)q = mem[q].hh.v.RH;
- mem[q].hh.v.RH = new_rule ();
- mem[mem[q].hh.v.RH + 1].cint = eqtb[(hash_size + 3746)].cint;
- }
- print_ln ();
- print_nl("Overfull \\hbox("); /* */
- print_scaled(- (integer) x - totalshrink[0]);
- print_string("pt too wide");
- overfull_hbox++; /* 1996/Feb/9 */
- goto lab50;
- }
- }
- else if(o == 0)
- if(mem[r + 5].hh.v.RH != 0)
+ glue_sign(r) = normal;
+ glue_set(r) = 0.0;
+ }
+
+ if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
{
- last_badness = badness(- (integer) x, totalshrink[0]);
- if(last_badness > eqtb[(hash_size + 3189)].cint)
+ last_badness = 1000000L;
+ glue_set(r) = 1.0;
+
+ if ((- (integer) x - total_shrink[normal] > hfuzz) || (hbadness < 100))
{
- print_ln ();
- print_nl("Tight \\hbox (badness "); /* */
- print_int(last_badness);
- goto lab50;
- }
- }
- goto lab10;
- }
- lab50: if(output_active)
- print_string(")has occurred while \\output is active");
- else {
-
- if(pack_begin_line != 0)
+ if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
+ {
+ while(link(q) != 0)
+ q = link(q);
+
+ link(q) = new_rule();
+ width(link(q)) = overfull_rule;
+ }
+
+ print_ln();
+ print_nl("Overfull \\hbox (");
+ print_scaled(- (integer) x - total_shrink[normal]);
+ print_string("pt too wide");
+
+ overfull_hbox++; /* 1996/Feb/9 */
+
+ goto lab50;
+ }
+ }
+ else if (o == normal)
+ if (list_ptr(r) != 0)
+ {
+ last_badness = badness(- (integer) x, total_shrink[normal]);
+
+ if (last_badness > hbadness)
+ {
+ print_ln();
+ print_nl("Tight \\hbox (badness ");
+ print_int(last_badness);
+ goto lab50;
+ }
+ }
+ goto lab10;
+ }
+lab50:
+ if (output_active)
+ print_string(") has occurred while \\output is active");
+ else
+ {
+ if (pack_begin_line != 0)
{
- if(pack_begin_line > 0)
- print_string(")in paragraph at lines ");
- else print_string(")in alignment at lines ");
- print_int(abs(pack_begin_line));
+ if (pack_begin_line > 0)
+ print_string(") in paragraph at lines ");
+ else
+ print_string(") in alignment at lines ");
+
+ print_int(abs(pack_begin_line));
print_string("--");
- }
- else print_string(")detected at line ");
- print_int(line);
- }
- print_ln ();
- font_in_short_display = 0;
- short_display(mem[r + 5].hh.v.RH);
- print_ln ();
- begin_diagnostic ();
- show_box(r);
- end_diagnostic(true);
- lab10: Result = r;
- return Result;
-}
+ }
+ else
+ print_string(") detected at line ");
+
+ print_int(line);
+ }
+
+ print_ln();
+ font_in_short_display = null_font;
+ short_display(list_ptr(r));
+ print_ln();
+ begin_diagnostic();
+ show_box(r);
+ end_diagnostic(true);
+lab10:
+ return r;
+}
+/* sec 0668 */
halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
-{/* 50 10 */ register halfword Result;
- halfword r;
- scaled w, d, x;
- scaled s;
- halfword g;
+{
+ halfword r;
+ scaled w, d, x;
+ scaled s;
+ halfword g;
/* glue_ord o; */
int o; /* 95/Jan/7 */
- last_badness = 0;
- r = get_node(7);
- mem[r].hh.b0 = 1;
- mem[r].hh.b1 = 0;
- mem[r + 4].cint = 0;
- mem[r + 5].hh.v.RH = p;
- w = 0;
- d = 0;
- x = 0;
- totalstretch[0]= 0;
- totalshrink[0]= 0;
- totalstretch[1]= 0;
- totalshrink[1]= 0;
- totalstretch[2]= 0;
- totalshrink[2]= 0;
- totalstretch[3]= 0;
- totalshrink[3]= 0;
- while(p != 0){
-
- if((p >= hi_mem_min)) {
- confusion(849); /* vpack */
- return 0; // abort_flag set
- }
- else switch(mem[p].hh.b0)
- {case 0 :
- case 1 :
- case 2 :
- case 13 :
- {
- x = x + d + mem[p + 3].cint;
- d = mem[p + 2].cint;
- if(mem[p].hh.b0 >= 2)
- s = 0;
- else s = mem[p + 4].cint;
- if(mem[p + 1].cint + s > w)
- w = mem[p + 1].cint + s;
- }
- break;
- case 8 :
- ;
- break;
- case 10 :
- {
- x = x + d;
- d = 0;
- g = mem[p + 1].hh.v.LH;
- x = x + mem[g + 1].cint;
- o = mem[g].hh.b0;
- totalstretch[o]= totalstretch[o]+ mem[g + 2].cint;
- o = mem[g].hh.b1;
- totalshrink[o]= totalshrink[o]+ mem[g + 3].cint;
- if(mem[p].hh.b1 >= 100)
- {
- g = mem[p + 1].hh.v.RH;
- if(mem[g + 1].cint > w)
- w = mem[g + 1].cint;
- }
- }
- break;
- case 11 :
- {
- x = x + d + mem[p + 1].cint;
- d = 0;
- }
- break;
- default:
- ;
- break;
- }
- p = mem[p].hh.v.RH;
- }
- mem[r + 1].cint = w;
- if(d > l)
+
+ last_badness = 0;
+ r = get_node(box_node_size);
+ type(r) = vlist_node;
+ subtype(r) = min_quarterword;
+ shift_amount(r) = 0;
+ list_ptr(r) = p;
+ w = 0;
+ d = 0;
+ x = 0;
+ total_stretch[normal] = 0;
+ total_shrink[normal] = 0;
+ total_stretch[fil] = 0;
+ total_shrink[fil] = 0;
+ total_stretch[fill] = 0;
+ total_shrink[fill] = 0;
+ total_stretch[filll] = 0;
+ total_shrink[filll] = 0;
+
+ while (p != 0)
{
- x = x + d - l;
- mem[r + 2].cint = l;
- }
- else mem[r + 2].cint = d;
- if(m == 1)
- h = x + h;
- mem[r + 3].cint = h;
- x = h - x;
- if(x == 0)
+ if ((p >= hi_mem_min))
+ {
+ confusion("vpack");
+ return 0; // abort_flag set
+ }
+ else switch (type(p))
+ {
+ case hlist_node:
+ case vlist_node:
+ case rule_node:
+ case unset_node:
+ {
+ x = x + d + height(p);
+ d = depth(p);
+
+ if (type(p) >= rule_node)
+ s = 0;
+ else
+ s = shift_amount(p);
+
+ if (width(p) + s > w)
+ w = width(p) + s;
+ }
+ break;
+
+ case whatsit_node:
+ break;
+
+ case glue_node:
+ {
+ x = x + d;
+ d = 0;
+ g = glue_ptr(p);
+ x = x + width(g);
+ o = stretch_order(g);
+ total_stretch[o] = total_stretch[o] + stretch(g);
+ o = shrink_order(g);
+ total_shrink[o] = total_shrink[o] + shrink(g);
+
+ if (subtype(p) >= a_leaders)
+ {
+ g = leader_ptr(p);
+
+ if (width(g) > w)
+ w = width(g);
+ }
+ }
+ break;
+
+ case kern_node:
+ {
+ x = x + d + width(p);
+ d = 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+ p = link(p);
+ }
+
+ width(r) = w;
+
+ if (d > l)
{
- mem[r + 5].hh.b0 = 0;
- mem[r + 5].hh.b1 = 0;
- mem[r + 6].gr = 0.0;
- goto lab10;
- }
- else if(x > 0)
+ x = x + d - l;
+ depth(r) = l;
+ }
+ else
+ depth(r) = d;
+
+ if (m == additional)
+ h = x + h;
+
+ height(r) = h;
+ x = h - x;
+
+ if (x == 0)
{
- if(totalstretch[3]!= 0)
- o = 3;
- else if(totalstretch[2]!= 0)
- o = 2;
- else if(totalstretch[1]!= 0)
- o = 1;
- else o = 0;
- mem[r + 5].hh.b1 = o;
- mem[r + 5].hh.b0 = 1;
- if(totalstretch[o]!= 0)
- mem[r + 6].gr = x / ((double) totalstretch[o]);
- else {
-
- mem[r + 5].hh.b0 = 0;
- mem[r + 6].gr = 0.0;
- }
- if(o == 0)
- if(mem[r + 5].hh.v.RH != 0)
+ glue_sign(r) = normal;
+ glue_order(r) = normal;
+ glue_set(r) = 0.0;
+ goto lab10;
+ }
+ else if (x > 0)
+ {
+ if (total_stretch[filll] != 0)
+ o = filll;
+ else if (total_stretch[fill] != 0)
+ o = fill;
+ else if (total_stretch[fil] != 0)
+ o = fil;
+ else
+ o = normal;
+
+ glue_order(r) = o;
+ glue_sign(r) = stretching;
+
+ if (total_stretch[o] != 0)
+ glue_set(r) = x / ((double) total_stretch[o]);
+ else
{
- last_badness = badness(x, totalstretch[0]);
- if(last_badness > eqtb[(hash_size + 3190)].cint)
+ glue_sign(r) = normal;
+ glue_set(r) = 0.0;
+ }
+
+ if (o == normal)
+ if (list_ptr(r) != 0)
{
- print_ln ();
- if(last_badness > 100)
- print_nl("Underfull"); /* */
- else print_nl("Loose"); /* */
- print_string("\\vbox (badness");
- print_int(last_badness);
- if(last_badness > 100)underfull_vbox++; /* 1996/Feb/9 */
- goto lab50;
- }
- }
- goto lab10;
- }
- else {
-
- if(totalshrink[3]!= 0)
- o = 3;
- else if(totalshrink[2]!= 0)
- o = 2;
- else if(totalshrink[1]!= 0)
- o = 1;
- else o = 0;
- mem[r + 5].hh.b1 = o;
- mem[r + 5].hh.b0 = 2;
- if(totalshrink[o]!= 0)
- mem[r + 6].gr =(- (integer) x)/ ((double) totalshrink[o]);
- else {
-
- mem[r + 5].hh.b0 = 0;
- mem[r + 6].gr = 0.0;
- }
-/* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13046 */
- if((totalshrink[o]< - (integer) x)&&(o == 0)&&(mem[r + 5
- ].hh.v.RH != 0))
+ last_badness = badness(x, total_stretch[normal]);
+
+ if (last_badness > vbadness)
+ {
+ print_ln();
+
+ if (last_badness > 100)
+ print_nl("Underfull");
+ else
+ print_nl("Loose");
+
+ print_string(" \\vbox (badness ");
+ print_int(last_badness);
+
+ if (last_badness > 100)
+ underfull_vbox++; /* 1996/Feb/9 */
+
+ goto lab50;
+ }
+ }
+ goto lab10;
+ }
+ else
+ {
+ if (total_shrink[filll] != 0)
+ o = filll;
+ else if (total_shrink[fill] != 0)
+ o = fill;
+ else if (total_shrink[fil] != 0)
+ o = fil;
+ else
+ o = normal;
+
+ glue_order(r) = o;
+ glue_sign(r) = shrinking;
+
+ if (total_shrink[o] != 0)
+ glue_set(r) =(- (integer) x)/ ((double) total_shrink[o]);
+ else
{
- last_badness = 1000000L;
- mem[r + 6].gr = 1.0;
- if((- (integer) x - totalshrink[0]> eqtb[(hash_size + 3739)].cint)||(
- eqtb[(hash_size + 3190)].cint < 100))
- {
- print_ln ();
- print_nl("Overfull \\vbox("); /* */
- print_scaled(- (integer) x - totalshrink[0]);
- print_string("pt too high");
- overfull_vbox++; /* 1996/Feb/9 */
- goto lab50;
- }
- }
-/* else if o=normal then if list_ptr(r)<>null then l.13052 */
- else if(o == 0)
- if(mem[r + 5].hh.v.RH != 0)
+ glue_sign(r) = normal;
+ glue_set(r) = 0.0;
+ }
+
+ if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
{
- last_badness = badness(- (integer) x, totalshrink[0]);
- if(last_badness > eqtb[(hash_size + 3190)].cint)
+ last_badness = 1000000L;
+ glue_set(r) = 1.0;
+
+ if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
{
- print_ln ();
- print_nl("Tight \\vbox (badness "); /* */
- print_int(last_badness);
- goto lab50;
- }
- }
- goto lab10;
- }
- lab50: if(output_active)
- print_string(")has occurred while \\output is active");
- else {
-
- if(pack_begin_line != 0)
+ print_ln();
+ print_nl("Overfull \\vbox (");
+ print_scaled(- (integer) x - total_shrink[0]);
+ print_string("pt too high");
+
+ overfull_vbox++; /* 1996/Feb/9 */
+
+ goto lab50;
+ }
+ }
+ else if (o == 0)
+ if (list_ptr(r) != 0)
+ {
+ last_badness = badness(- (integer) x, total_shrink[normal]);
+ if (last_badness > vbadness)
+ {
+ print_ln();
+ print_nl("Tight \\vbox (badness ");
+ print_int(last_badness);
+ goto lab50;
+ }
+ }
+ goto lab10;
+ }
+lab50:
+ if (output_active)
+ print_string(") has occurred while \\output is active");
+ else
+ {
+ if (pack_begin_line != 0)
{
- print_string(")in alignment at lines ");
- print_int(abs(pack_begin_line));
+ print_string(") in alignment at lines ");
+ print_int(abs(pack_begin_line));
print_string("--");
- }
- else print_string(")detected at line ");
- print_int(line);
- print_ln ();
- }
- begin_diagnostic ();
- show_box(r);
- end_diagnostic(true);
- lab10: Result = r;
- return Result;
-}
+ }
+ else
+ print_string(") detected at line ");
+
+ print_int(line);
+ print_ln();
+ }
+
+ begin_diagnostic();
+ show_box(r);
+ end_diagnostic(true);
+lab10:
+ return r;
+}
+/* sec 0679 */
void append_to_vlist_(halfword b)
-{
- scaled d;
- halfword p;
- if(cur_list.aux_field.cint > ignore_depth)
+{
+ scaled d;
+ halfword p;
+
+ if (cur_list.aux_field.cint > ignore_depth)
{
- d = mem[eqtb[(hash_size + 783)].hh.v.RH + 1].cint - cur_list.aux_field.cint -
- mem[b + 3].cint;
- if(d < eqtb[(hash_size + 3732)].cint)
- p = new_param_glue(0);
- else {
-
- p = new_skip_param(1);
- mem[temp_ptr + 1].cint = d;
- }
- mem[tail].hh.v.RH = p;
- tail = p;
- }
- mem[tail].hh.v.RH = b;
- tail = b;
- cur_list.aux_field.cint = mem[b + 2].cint;
-}
-halfword new_noad (void)
-{register halfword Result;
- halfword p;
- p = get_node(4);
- mem[p].hh.b0 = 16;
- mem[p].hh.b1 = 0;
- mem[p + 1].hh = empty_field;
- mem[p + 3].hh = empty_field;
- mem[p + 2].hh = empty_field;
- Result = p;
- return Result;
-}
+ d = width(baseline_skip) - prev_depth - height(b);
+
+ if (d < line_skip_limit)
+ p = new_param_glue(line_skip_code);
+ else
+ {
+ p = new_skip_param(baseline_skip_code);
+ width(temp_ptr) = d;
+ }
+ link(tail) = p;
+ tail = p;
+ }
+
+ link(tail) = b;
+ tail = b;
+ prev_depth = depth(b);
+}
+/* sec 0686 */
+halfword new_noad (void)
+{
+ halfword p;
+
+ p = get_node(noad_size);
+ type(p) = ord_noad;
+ subtype(p) = normal;
+ mem[nucleus(p)].hh = empty_field;
+ mem[subscr(p)].hh = empty_field;
+ mem[supscr(p)].hh = empty_field;
+
+ return p;
+}
+/* sec 0688 */
halfword new_style_(small_number s)
-{register halfword Result;
- halfword p;
- p = get_node(3);
- mem[p].hh.b0 = 14;
- mem[p].hh.b1 = s;
- mem[p + 1].cint = 0;
- mem[p + 2].cint = 0;
- Result = p;
- return Result;
-}
-halfword new_choice (void)
-{register halfword Result;
- halfword p;
- p = get_node(3);
- mem[p].hh.b0 = 15;
- mem[p].hh.b1 = 0;
- mem[p + 1].hh.v.LH = 0;
- mem[p + 1].hh.v.RH = 0;
- mem[p + 2].hh.v.LH = 0;
- mem[p + 2].hh.v.RH = 0;
- Result = p;
- return Result;
-}
-void show_info (void)
-{
- show_node_list(mem[temp_ptr].hh.v.LH);
-}
+{
+ halfword p;
+
+ p = get_node(style_node_size);
+ type(p) = style_node;
+ subtype(p) = s;
+ width(p) = 0;
+ depth(p) = 0;
+
+ return p;
+}
+/* sec 0689 */
+halfword new_choice (void)
+{
+ halfword p;
+
+ p = get_node(style_node_size);
+ type(p) = choice_node;
+ subtype(p) = 0;
+ display_mlist(p) = 0;
+ text_mlist(p) = 0;
+ script_mlist(p) = 0;
+ script_script_mlist(p) = 0;
+
+ return p;
+}
+/* sec 0693 */
+void show_info (void)
+{
+ show_node_list(info(temp_ptr));
+}
+/* sec 0704 */
halfword fraction_rule_(scaled t)
-{register halfword Result;
- halfword p;
- p = new_rule ();
- mem[p + 3].cint = t;
- mem[p + 2].cint = 0;
- Result = p;
- return Result;
-}
+{
+ halfword p;
+
+ p = new_rule();
+ height(p) = t;
+ depth(p) = 0;
+
+ return p;
+}
+/* sec 0705 */
halfword overbar_(halfword b, scaled k, scaled t)
-{register halfword Result;
- halfword p, q;
- p = new_kern(k);
- mem[p].hh.v.RH = b;
- q = fraction_rule(t);
- mem[q].hh.v.RH = p;
- p = new_kern(t);
- mem[p].hh.v.RH = q;
- Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
- return Result;
-}
+{
+ halfword p, q;
+
+ p = new_kern(k);
+ link(p) = b;
+ q = fraction_rule(t);
+ link(q) = p;
+ p = new_kern(t);
+ link(p) = q;
+ return vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
+}
+/* sec 0709 */
halfword char_box_(internal_font_number f, quarterword c)
-{register halfword Result;
- ffourquarters q;
- eight_bits hd;
- halfword b, p;
- q = font_info[char_base[f]+ c].qqqq;
- hd = q.b1;
- b = new_null_box ();
- mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info
- [italic_base[f]+(q.b2)/ 4].cint;
- mem[b + 3].cint = font_info[height_base[f]+(hd)/ 16].cint;
- mem[b + 2].cint = font_info[depth_base[f]+(hd)% 16].cint;
-/* long to unsigned short ... */
- p = get_avail ();
- mem[p].hh.b1 = c;
- mem[p].hh.b0 = f;
- mem[b + 5].hh.v.RH = p;
- Result = b;
- return Result;
-}
+{
+ four_quarters q;
+ eight_bits hd;
+ halfword b, p;
+
+ q = char_info(f, c);
+ hd = height_depth(q);
+ b = new_null_box();
+ width(b) = char_width(f, q) + char_italic(f, q);
+ height(b) = char_height(f, hd);
+ depth(b) = char_depth(f, hd);
+ p = get_avail();
+ character(p) = c;
+ font(p) = f;
+ list_ptr(b) = p;
+
+ return b;
+}
+/* sec 0711 */
void stack_into_box_(halfword b, internal_font_number f, quarterword c)
{
- halfword p;
- p = char_box(f, c);
- mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
- mem[b + 5].hh.v.RH = p;
- mem[b + 3].cint = mem[p + 3].cint;
-}
-scaled height_plus_depth_(internal_font_number f, fquarterword c)
-{register scaled Result;
- ffourquarters q;
- eight_bits hd;
- q = font_info[char_base[f]+ c].qqqq;
- hd = q.b1;
- Result = font_info[height_base[f]+(hd)/ 16].cint + font_info[
- depth_base[f]+(hd)% 16].cint;
- return Result;
-}
+ halfword p;
+
+ p = char_box(f, c);
+ link(p) = list_ptr(b);
+ list_ptr(b) = p;
+ height(b) = height(p);
+}
+/* sec 0712 */
+scaled height_plus_depth_(internal_font_number f, quarterword c)
+{
+ four_quarters q;
+ eight_bits hd;
+
+ q = char_info(f, c);
+ hd = height_depth(q);
+ return char_height(f, hd) + char_depth(f, hd);
+}
+/* sec 0706 */
halfword var_delimiter_(halfword d, small_number s, scaled v)
-{/* 40 22 */ register halfword Result;
- halfword b;
- internal_font_number f, g;
- quarterword c, x, y;
- integer m, n;
- scaled u;
- scaled w;
- ffourquarters q;
- ffourquarters r;
- eight_bits hd;
+{
+ halfword b;
+ internal_font_number f, g;
+ quarterword c, x, y;
+ integer m, n;
+ scaled u;
+ scaled w;
+ four_quarters q;
+ four_quarters r;
+ eight_bits hd;
/* small_number z; */
int z; /* 95/Jan/7 */
-/* bool largeattempt; */
- int largeattempt; /* 95/Jan/7 */
- f = 0;
- w = 0;
- largeattempt = false;
- z = mem[d].qqqq.b0;
- x = mem[d].qqqq.b1;
- while(true){
- if((z != 0)||(x != 0))
- {
- z = z + s + 16;
- do {
- z = z - 16;
- g = eqtb[(hash_size + 1835) + z].hh.v.RH;
- if(g != 0)
+/* boolean large_attempt; */
+ int large_attempt; /* 95/Jan/7 */
+
+ f = null_font;
+ w = 0;
+ large_attempt = false;
+ z = small_fam(d);
+ x = small_char(d);
+
+ while (true)
{
- y = x;
- if((y >= font_bc[g])&&(y <= font_ec[g]))
+ if ((z != 0) || (x != 0))
{
- lab22: q = font_info[char_base[g]+ y].qqqq;
- if((q.b0 > 0))
- {
- if(((q.b2)% 4)== 3)
- {
- f = g;
- c = y;
- goto lab40;
- }
- hd = q.b1;
- u = font_info[height_base[g]+(hd)/ 16].cint + font_info
- [depth_base[g]+(hd)% 16].cint;
- if(u > w)
- {
- f = g;
- c = y;
- w = u;
- if(u >= v)
- goto lab40;
- }
- if(((q.b2)% 4)== 2)
+ z = z + s + 16;
+
+ do
{
- y = q.b3;
- goto lab22;
- }
- }
- }
- }
- } while(!(z < 16));
- }
- if(largeattempt)
- goto lab40;
- largeattempt = true;
- z = mem[d].qqqq.b2;
- x = mem[d].qqqq.b3;
- }
- lab40: if(f != 0)
- if(((q.b2)% 4)== 3) /* q may be used without ... */
- {
- b = new_null_box ();
- mem[b].hh.b0 = 1;
- r = font_info[exten_base[f]+ q.b3].qqqq;
- c = r.b3;
- u = height_plus_depth(f, c);
- w = 0;
- q = font_info[char_base[f]+ c].qqqq;
- mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint +
- font_info[italic_base[f]+(q.b2)/ 4].cint;
- c = r.b2;
- if(c != 0)
- w = w + height_plus_depth(f, c);
- c = r.b1;
- if(c != 0)
- w = w + height_plus_depth(f, c);
- c = r.b0;
- if(c != 0)
- w = w + height_plus_depth(f, c);
- n = 0;
- if(u > 0)
- while(w < v){
-
- w = w + u;
- incr(n);
- if(r.b1 != 0)
- w = w + u;
- }
- c = r.b2;
- if(c != 0)
- stack_into_box(b, f, c);
- c = r.b3;
- {
- register integer for_end;
- m = 1;
- for_end = n;
- if(m <= for_end) do
- stack_into_box(b, f, c);
- while(m++ < for_end);
- }
- c = r.b1;
- if(c != 0)
+ z = z - 16;
+ g = fam_fnt(z);
+
+ if (g != null_font)
+ {
+ y = x;
+
+ if ((y >= font_bc[g]) && (y <= font_ec[g]))
+ {
+lab22:
+ q = char_info(g, y);
+
+ if ((q.b0 > 0))
+ {
+ if (char_tag(q) == ext_tag)
+ {
+ f = g;
+ c = y;
+ goto lab40;
+ }
+
+ hd = height_depth(q);
+ u = char_height(g, hd) + char_depth(g, hd);
+
+ if (u > w)
+ {
+ f = g;
+ c = y;
+ w = u;
+
+ if (u >= v)
+ goto lab40;
+ }
+
+ if (char_tag(q) == list_tag)
+ {
+ y = rem_byte(q);
+ goto lab22;
+ }
+ }
+ }
+ }
+ }
+ while (!(z < 16));
+ }
+
+ if (large_attempt)
+ goto lab40;
+
+ large_attempt = true;
+ z = large_fam(d);
+ x = large_char(d);
+ }
+lab40:
+ if (f != null_font)
+ if (char_tag(q) == ext_tag)
{
- stack_into_box(b, f, c);
- c = r.b3;
+ b = new_null_box();
+ type(b) = vlist_node;
+ r = font_info[exten_base[f] + rem_byte(q)].qqqq;
+ c = ext_rep(r);
+ u = height_plus_depth(f, c);
+ w = 0;
+ q = char_info(f, c);
+ width(b) = char_width(f, q) + char_italic(f, q);
+ c = ext_bot(r);
+
+ if (c != min_quarterword)
+ w = w + height_plus_depth(f, c);
+
+ c = ext_mid(r);
+
+ if (c != min_quarterword)
+ w = w + height_plus_depth(f, c);
+
+ c = ext_top(r);
+
+ if (c != min_quarterword)
+ w = w + height_plus_depth(f, c);
+
+ n = 0;
+
+ if (u > 0)
+ while(w < v)
+ {
+ w = w + u;
+ incr(n);
+
+ if (ext_mid(r) != min_quarterword)
+ w = w + u;
+ }
+
+ c = ext_bot(r);
+
+ if (c != min_quarterword)
+ stack_into_box(b, f, c);
+
+ c = ext_rep(r);
+
+ for (m = 1; m <= n; m++)
+ stack_into_box(b, f, c);
+
+ c = ext_mid(r);
+
+ if (c != min_quarterword)
{
- register integer for_end;
- m = 1;
- for_end = n;
- if(m <= for_end) do
- stack_into_box(b, f, c);
- while(m++ < for_end);
- }
- }
- c = r.b0;
- if(c != 0)
- stack_into_box(b, f, c);
- mem[b + 2].cint = w - mem[b + 3].cint;
- }
- else b = char_box(f, c);
- else { /* c may be used without ... */
- b = new_null_box ();
- mem[b + 1].cint = eqtb[(hash_size + 3741)].cint;
- }
- mem[b + 4].cint = half(mem[b + 3].cint - mem[b + 2].cint)-
- font_info[22 + param_base[eqtb[(hash_size + 1837) + s].hh.v.RH]].cint;
- Result = b;
- return Result;
+ stack_into_box(b, f, c);
+ c = ext_rep(r);
+
+ for (m = 1; m <= n; m++)
+ stack_into_box(b, f, c);
+ }
+
+ c = ext_top(r);
+
+ if (c != 0)
+ stack_into_box(b, f, c);
+
+ depth(b) = w - height(b);
+ }
+ else
+ b = char_box(f, c);
+ else
+ {
+ b = new_null_box();
+ width(b) = null_delimiter_space;
+ }
+
+ shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
+
+ return b;
}
-/* rebox_ etc used to follow here in tex4.c */
+/* rebox_ etc used to follow here in tex4.c */
\ No newline at end of file