-#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
+
+ 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 */
-
/* sec 0581 */
void char_warning_(internal_font_number f, eight_bits c)
{
if (font_bc[f] <= c)
if (font_ec[f] >= c)
- if ((font_info[char_base[f] + c].qqqq.b0 > 0))
+ if (char_exists(char_info(f, c)))
{
p = get_avail();
font(p) = f;
return p;
}
- char_warning(f, c); /* char_warning(f,c); l.11283 */
+ char_warning(f, c);
return 0;
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0598 */
void dvi_swap (void)
{
dvi_gone = dvi_gone + half_buf;
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* attempt at speeding up bkph - is compiler smart ? */
/* sec 0600 */
void dvi_four_(integer x)
{
if (x >= 0)
- // dvi_out(x % 16777216L);
- dvi_out((x >> 24));
+ dvi_out(x / 0100000000); // dvi_out((x >> 24));
else
{
- x = x + 1073741824L; /* 2^30 40000000 hex */
- x = x + 1073741824L;
- //dvi_out((x / 16777216L) + 128);
- dvi_out((x >> 24) + 128);
+ x = x + 010000000000;
+ x = x + 010000000000;
+ dvi_out((x / 0100000000) + 128); // dvi_out((x >> 24) + 128);
}
-/* x = x % 16777216L; */ /* % 2^24 */
- x = x & 16777215L;
- //dvi_out(x / 65536L);
- dvi_out((x >> 16));
-/* x = x % 65536L; */ /* % 2^16 */
- x = x & 65535L;
- //dvi_out(x / 256);
- dvi_out((x >> 8));
- //dvi_out(x % 256);
- dvi_out(x & 255);
+
+ 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);
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0601 */
void zdvipop(integer l)
{
else
dvi_out(142);
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0602 */
-/*
-void pdf_font_def_(internal_font_number f)
-{
-}
-*/
void dvi_font_def_(internal_font_number f)
{
pool_pointer k;
dvi_out(fnt_def1);
dvi_out(f - 1);
#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* spit out the font checksum now */
+
dvi_out(font_check[f].b0);
dvi_out(font_check[f].b1);
dvi_out(font_check[f].b2);
for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
dvi_out(str_pool[k]);
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0607 */
void zmovement(scaled w, eight_bits o)
{
down_ptr = link(p);
free_node(p, movement_node_size);
}
+
lab30:
while (right_ptr != 0)
{
free_node(p, movement_node_size);
}
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 1368 */
void special_out_(halfword p)
{
char old_setting;
pool_pointer k;
- if (cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, right1);
- dvi_h = cur_h;
- }
-
- if (cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, down1);
- dvi_v = cur_v;
- }
-
+ synch_h();
+ synch_v();
old_setting = selector;
selector = new_string;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* About output \special{...} make some space in string pool 97/Mar/9 */
#ifdef ALLOCATESTRING
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(link(write_tokens(p)), 0, 10000000L);
-/* Above is safe, since print/print_char/print_esc will extend string space */
#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
#endif
+
selector = old_setting;
str_room(1);
- if (cur_length < 256) /* can use xxx1 ? */
+ if (cur_length < 256)
{
dvi_out(xxx1);
dvi_out(cur_length);
dvi_four(cur_length);
}
-#ifdef IGNORED
-/* debugging code for \special{src: ... } 98/Nov/11 */
- {
- int k = str_start[str_ptr];
- int kend = pool_ptr;
- /* \special{src: ... } */
- if (kend > k + 4)
- {
- if (str_pool [k] == 's' && str_pool [k + 1] == 'r' && str_pool [k + 2] == 'c' && str_pool [k + 3] == ':')
- {
- 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('(');
- print_int(line); /* line number */
- print_char(')');
- print_char(' ');
- print_char(':');
- }
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
- }
- }
- }
-#endif
for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
dvi_out(str_pool[k]);
pool_ptr = str_start[str_ptr];
}
-/* noew returns -1 if it fails */
/* sec 1370 */
void write_out_(halfword p)
{
{
get_token();
}
- while(!(cur_tok == end_write_token)); /*1996/Jan/10*/
+ while(!(cur_tok == end_write_token));
}
mode = oldmode;
break;
}
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0619 */
void hlist_out (void)
{
decr(cur_s);
}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
/* sec 0629 */
void vlist_out (void)
{
decr(cur_s);
}
/* sec 0638 */
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-/*
-void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
-{
- printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
- longjmp(jumpbuffer, 1);
-}
-*/
-/* sec 0638 */
void dvi_ship_out_(halfword p)
{
integer page_loc;
if (total_pages == 0)
{
- /* HPDF init.*/
-// yandy_pdf = HPDF_New(error_handler, NULL);
-// yandy_pdf->pdf_version = HPDF_VER_17;
-// HPDF_SetCompressionMode(yandy_pdf, HPDF_COMP_ALL);
- /* */
dvi_out(pre);
dvi_out(id_byte);
dvi_four(25400000L); /* magic DVI scale factor */
page_loc = dvi_offset + dvi_ptr;
dvi_out(bop);
-// yandy_font = HPDF_GetFont (yandy_pdf, "Helvetica", NULL);
-// pdf_font_def wrapper?
-// pdf_special_out ? fig?
-// yandy_page = HPDF_AddPage (yandy_pdf);
-// HPDF_Page_SetWidth (yandy_page, 210);
-// HPDF_Page_SetHeight (yandy_page, 210);
-// HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 10);
-// HPDF_Page_BeginText (yandy_page);
-// HPDF_Page_MoveTextPos(yandy_page, 10, 190);
-// HPDF_Page_ShowText (yandy_page, "The page");
-// HPDF_Page_EndText (yandy_page);
for (k = 0; k <= 9; k++)
dvi_four(count(k));
}
void ship_out_(halfword p)
{
- dvi_ship_out_(p);
+ if (pdf_output_flag)
+ pdf_ship_out(p);
+ else
+ dvi_ship_out_(p);
}
/* sec 0645 */
void scan_spec_(group_code c, bool three_codes)
/* glue_ord o; */
int o; /* 95/Jan/7 */
internal_font_number f;
- ffourquarters i;
+ four_quarters i;
eight_bits hd;
last_badness = 0;
/* sec 0709 */
halfword char_box_(internal_font_number f, quarterword c)
{
- ffourquarters q;
+ four_quarters q;
eight_bits hd;
halfword b, p;
height(b) = height(p);
}
/* sec 0712 */
-scaled height_plus_depth_(internal_font_number f, fquarterword c)
+scaled height_plus_depth_(internal_font_number f, quarterword c)
{
- ffourquarters q;
+ four_quarters q;
eight_bits hd;
q = char_info(f, c);
integer m, n;
scaled u;
scaled w;
- ffourquarters q;
- ffourquarters r;
+ four_quarters q;
+ four_quarters r;
eight_bits hd;
/* small_number z; */
int z; /* 95/Jan/7 */