wp2latex (1 of 4)

Glenn Geers glenn at extro.ucc.su.oz.au
Wed Aug 8 21:48:55 AEST 1990


By popular demand here comes the source code.
			Glenn


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	wp2latex.c
# This archive created: Wed Aug  8 21:44:44 1990
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'wp2latex.c'" '(53854 characters)'
if test -f 'wp2latex.c'
then
	echo shar: "will not over-write existing file 'wp2latex.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'wp2latex.c'
	X/* Output from p2c, the Pascal-to-C translator */
	X/* From input file "WP2LATEX.PAS" */
	X
	Xstatic char rcsid[] = "$Header: wp2latex.c,v 2.0 90/08/05 08:16:28 glenn Exp $";
	X
	X
	X#ifdef HAVE_P2C
	X#include <p2c/p2c.h>
	X#else
	X#include "p2c.h"
	X#endif
	X
	X
	X/*           Version 1.0
	X             Date 27-1-1990
	X*/
	X
	X
	XStatic Char wpd_fn[256], strip_fn[256], tabel_fn[256], latex_fn[256];
	X
	XStatic FILE *wpd, *tabel;
	XStatic FILE *strip, *latex;
	X
	XStatic unsigned short num_of_lines_stripfile;
	X
	XStatic Char open_com[0x11][256], close_com[0x11][256];
	X
	X/* Static Anyptr Exitsave; */
	XStatic Char wpd_NAME[_FNSIZE];
	XStatic Char tabel_NAME[_FNSIZE];
	XStatic Char strip_NAME[_FNSIZE];
	XStatic Char latex_NAME[_FNSIZE];
	X
	XStatic Void RunError(); /* simulate Turbo 5 builtin */
	X
	XStatic Void Rd_word(f, w)
	XFILE **f;
	Xunsigned short *w;
	X{
	X  /* Deze procedure leest een woord uit de opgegeven binaire file. */
	X  uchar b;
	X
	X  fread(&b, sizeof(uchar), 1, *f);
	X  *w = b;
	X  fread(&b, sizeof(uchar), 1, *f);
	X  *w += b * 256;
	X}
	X
	X
	XStatic Void Wr_word(f, w)
	XFILE **f;
	Xunsigned short w;
	X{
	X  /* Deze procedure schrijft een woord in de opgegeven binaire file. */
	X  uchar b;
	X
	X  b = w & 255;
	X  fwrite(&b, sizeof(uchar), 1, *f);
	X  b = w / 256;
	X  fwrite(&b, sizeof(uchar), 1, *f);
	X}
	X
	X
	XStatic Void Jump_in_file(f, dis)
	XFILE **f;
	Xlong dis;
	X{
	X  /* Deze procedure springt in een binaire file het aantal opgegeven bytes. */
	X  long cur_pos;
	X
	X  cur_pos = ftell(*f) / sizeof(uchar);
	X  fseek(*f, (cur_pos + dis) * sizeof(uchar), 0);
	X}
	X
	X
	X
	XStatic Void Wpd_check()
	X{
	X  /* Kontroleert of de opgegeven WP-document wel daadwerkelijk een   */
	X  /* WP5.0-document is.                                              */
	X  unsigned short id1, id2, std1, std2, filetype, dmp1, dmp2, dmp3;
	X  long Startdoc;
	X
	X  Rd_word(&wpd, &id1);
	X  Rd_word(&wpd, &id2);
	X  Rd_word(&wpd, &std1);
	X  Rd_word(&wpd, &std2);
	X  Rd_word(&wpd, &filetype);
	X  Rd_word(&wpd, &dmp1);
	X  Rd_word(&wpd, &dmp2);
	X  Rd_word(&wpd, &dmp3);
	X
	X  Startdoc = std2 * 65536L + std1;
	X
	X  if (id1 == 0x57ff && id2 == 0x4350 && filetype == 0xa01)
	X	/*and (dmp1=$0) and (dmp2=$0) and (dmp3=$0)*/
	X	  fseek(wpd, Startdoc * sizeof(uchar), 0);
	X  else {
	X    RunError(0x201);   /* Het is geen WP5.0-document*/
	X  }
	X
	X  /* Het is een WP5.0-document*/
	X}
	X
	X
	X
	X
	XStatic Void Filenames()
	X{
	X  /* Deze procedure handelt het opgeven van de filenamen af. */
	X  Char name[256], invoer[256], wpdef[256], latdef[256], filename[256];
	X  short l, p;
	X
	X  if (P_argc < 2)
	X    *wpdef = '\0';
	X  else
	X    strcpy(wpdef, P_argv[1]);
	X
	X  printf("\n\nWordPerfect-filename [%s] : ", wpdef);
	X  gets(invoer);
	X  if (*invoer == '\0')
	X    strcpy(wpd_fn, wpdef);
	X  else
	X    strcpy(wpd_fn, invoer);
	X
	X  if (*wpd_fn == '\0') {   /* No filename entered */
	X    RunError(0x200);
	X  }
	X
	X  strcpy(name, wpd_fn);
	X  l = strlen(name);
	X  p = strpos2(name, ".", 1);
	X  if (p == 0)
	X    p = l + 1;
	X  sprintf(filename, "%.*s", p - 1, name);
	X
	X  sprintf(strip_fn, "%s.str", filename);
	X  sprintf(tabel_fn, "%s.tbl", filename);
	X  sprintf(latdef, "%s.tex", filename);
	X
	X  printf("LaTeX-filename [%s] : ", latdef);
	X  gets(invoer);
	X  putchar('\n');
	X  if (*invoer == '\0')
	X    strcpy(latex_fn, latdef);
	X  else
	X    strcpy(latex_fn, invoer);
	X
	X  strcpy(wpd_NAME, wpd_fn);
	X  strcpy(strip_NAME, strip_fn);
	X  strcpy(tabel_NAME, tabel_fn);
	X  strcpy(latex_NAME, latex_fn);
	X
	X}
	X
	X
	XStatic Void Init_commando()
	X{
	X  strcpy(open_com[0], "{\\LARGE ");
	X  strcpy(open_com[0x1], "{\\Large ");
	X  strcpy(open_com[0x2], "{\\large ");
	X  strcpy(open_com[0x3], "{\\small ");
	X  strcpy(open_com[0x4], "{\\footnotesize ");
	X  strcpy(open_com[0x5], "$^{\\rm ");
	X  strcpy(open_com[0x6], "$_{\\rm ");
	X  *open_com[0x7] = '\0';
	X  strcpy(open_com[0x8], "{\\it ");
	X  *open_com[0x9] = '\0';
	X  *open_com[0xa] = '\0';
	X  strcpy(open_com[0xb], "\\underline{\\Underline{");
	X  strcpy(open_com[0xc], "{\\bf ");
	X  *open_com[0xd] = '\0';
	X  strcpy(open_com[0xe], "\\Underline{");
	X  strcpy(open_com[0xf], "{\\sc ");
	X
	X  strcpy(close_com[0], "}");
	X  strcpy(close_com[0x1], "}");
	X  strcpy(close_com[0x2], "}");
	X  strcpy(close_com[0x3], "}");
	X  strcpy(close_com[0x4], "}");
	X  strcpy(close_com[0x5], "}$");
	X  strcpy(close_com[0x6], "}$");
	X  *close_com[0x7] = '\0';
	X  strcpy(close_com[0x8], "\\/}");
	X  *close_com[0x9] = '\0';
	X  *close_com[0xa] = '\0';
	X  strcpy(close_com[0xb], "}}");
	X  strcpy(close_com[0xc], "}");
	X  *close_com[0xd] = '\0';
	X  strcpy(close_com[0xe], "}");
	X  strcpy(close_com[0xf], "}");
	X}
	X
	X
	X/* Local variables for Convert_first_strike: */
	Xstruct LOC_Convert_first_strike {
	X  uchar by;
	X  unsigned short regelnum;
	X
	X  Char lat[0x60][26];
	X  short char_set[0xff];
	X  short char_code[0xff];
	X  Char ext_lat[0xff][26];
	X
	X
	X  short leegptr[2], openptr[2];
	X  uchar attr_rij[2][17];
	X  boolean open_attr_rij[2];
	X  short depth;
	X
	X  Char envir, line_term;
	X
	X  boolean char_on_line, nomore_valid_tabs, indenting, indent_end, ind_text1,
	X	  ind_text2;
	X
	X  unsigned short ind_leftmargin, ind_rightmargin;
	X
	X  short num_of_tabs, latex_tabpos;
	X  unsigned short tabpos[40];
	X  boolean right_tab, align_tab, center_tab;
	X
	X  short WP_sidemargin;
	X} ;
	X
	X
	X
	X
	XLocal Void WP_Default(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  short j;
	X
	X  LINK->WP_sidemargin = 1200;
	X
	X  LINK->tabpos[0] = 0x2c5;   /* 1e WP-tab is kantlijn --> */
	X  for (j = 2; j <= 10; j++)   /* Volgende tabs 1,5  cm     */
	X    LINK->tabpos[j - 1] = LINK->tabpos[j - 2] + 0x2c5;
	X  for (j = 10; j <= 39; j++)   /* ($02c5 wpu) verder        */
	X    LINK->tabpos[j] = 0xffffL;
	X
	X  LINK->num_of_tabs = 10;
	X}
	X
	X
	XLocal Void Table_Init(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  strcpy(LINK->lat[0], " ");   /*Space*/
	X  strcpy(LINK->lat[0x1], "!");   /*!*/
	X  strcpy(LINK->lat[0x2], "\"");   /*"*/
	X  strcpy(LINK->lat[0x3], "\\#");   /*#*/
	X  strcpy(LINK->lat[0x4], "\\$");   /*dollar*/
	X  strcpy(LINK->lat[0x5], "\\%");   /*%*/
	X  strcpy(LINK->lat[0x6], "\\&");   /*&*/
	X  strcpy(LINK->lat[0x7], "'");   /*'*/
	X  strcpy(LINK->lat[0x8], "(");   /*(*/
	X  strcpy(LINK->lat[0x9], ")");   /*)*/
	X  strcpy(LINK->lat[0xa], "*");   /***/
	X  strcpy(LINK->lat[0xb], "+");   /*+*/
	X  strcpy(LINK->lat[0xc], ",");   /*,*/
	X  strcpy(LINK->lat[0xd], "-");   /*-*/
	X  strcpy(LINK->lat[0xe], ".");   /*.*/
	X  strcpy(LINK->lat[0xf], "/");   /*/*/
	X  strcpy(LINK->lat[0x10], "0");   /*0*/
	X  strcpy(LINK->lat[0x11], "1");   /*1*/
	X  strcpy(LINK->lat[0x12], "2");   /*2*/
	X  strcpy(LINK->lat[0x13], "3");   /*3*/
	X  strcpy(LINK->lat[0x14], "4");   /*4*/
	X  strcpy(LINK->lat[0x15], "5");   /*5*/
	X  strcpy(LINK->lat[0x16], "6");   /*6*/
	X  strcpy(LINK->lat[0x17], "7");   /*7*/
	X  strcpy(LINK->lat[0x18], "8");   /*8*/
	X  strcpy(LINK->lat[0x19], "9");   /*9*/
	X  strcpy(LINK->lat[0x1a], ":");   /*:*/
	X  strcpy(LINK->lat[0x1b], ";");   /*;*/
	X  strcpy(LINK->lat[0x1c], "$<$");   /*<*/
	X  strcpy(LINK->lat[0x1d], "=");   /*=*/
	X  strcpy(LINK->lat[0x1e], "$>$");   /*>*/
	X  strcpy(LINK->lat[0x1f], "?");   /*?*/
	X  strcpy(LINK->lat[0x20], "@");   /*@*/
	X  strcpy(LINK->lat[0x21], "A");   /*A*/
	X  strcpy(LINK->lat[0x22], "B");   /*B*/
	X  strcpy(LINK->lat[0x23], "C");   /*C*/
	X  strcpy(LINK->lat[0x24], "D");   /*D*/
	X  strcpy(LINK->lat[0x25], "E");   /*E*/
	X  strcpy(LINK->lat[0x26], "F");   /*F*/
	X  strcpy(LINK->lat[0x27], "G");   /*G*/
	X  strcpy(LINK->lat[0x28], "H");   /*H*/
	X  strcpy(LINK->lat[0x29], "I");   /*I*/
	X  strcpy(LINK->lat[0x2a], "J");   /*J*/
	X  strcpy(LINK->lat[0x2b], "K");   /*K*/
	X  strcpy(LINK->lat[0x2c], "L");   /*L*/
	X  strcpy(LINK->lat[0x2d], "M");   /*M*/
	X  strcpy(LINK->lat[0x2e], "N");   /*N*/
	X  strcpy(LINK->lat[0x2f], "O");   /*O*/
	X  strcpy(LINK->lat[0x30], "P");   /*P*/
	X  strcpy(LINK->lat[0x31], "Q");   /*Q*/
	X  strcpy(LINK->lat[0x32], "R");   /*R*/
	X  strcpy(LINK->lat[0x33], "S");   /*S*/
	X  strcpy(LINK->lat[0x34], "T");   /*T*/
	X  strcpy(LINK->lat[0x35], "U");   /*U*/
	X  strcpy(LINK->lat[0x36], "V");   /*V*/
	X  strcpy(LINK->lat[0x37], "W");   /*W*/
	X  strcpy(LINK->lat[0x38], "X");   /*X*/
	X  strcpy(LINK->lat[0x39], "Y");   /*Y*/
	X  strcpy(LINK->lat[0x3a], "Z");   /*Z*/
	X  strcpy(LINK->lat[0x3b], "[");   /*[*/
	X  strcpy(LINK->lat[0x3c], "$\\tt\\backslash$");   /*\*/
	X  strcpy(LINK->lat[0x3d], "]");   /*]*/
	X  strcpy(LINK->lat[0x3e], "\\^{");   /*^*/
	X  strcpy(LINK->lat[0x3f], "\\_");   /*_*/
	X  strcpy(LINK->lat[0x40], "`");   /*`*/
	X  strcpy(LINK->lat[0x41], "a");   /*a*/
	X  strcpy(LINK->lat[0x42], "b");   /*b*/
	X  strcpy(LINK->lat[0x43], "c");   /*c*/
	X  strcpy(LINK->lat[0x44], "d");   /*d*/
	X  strcpy(LINK->lat[0x45], "e");   /*e*/
	X  strcpy(LINK->lat[0x46], "f");   /*f*/
	X  strcpy(LINK->lat[0x47], "g");   /*g*/
	X  strcpy(LINK->lat[0x48], "h");   /*h*/
	X  strcpy(LINK->lat[0x49], "i");   /*i*/
	X  strcpy(LINK->lat[0x4a], "j");   /*j*/
	X  strcpy(LINK->lat[0x4b], "k");   /*k*/
	X  strcpy(LINK->lat[0x4c], "l");   /*l*/
	X  strcpy(LINK->lat[0x4d], "m");   /*m*/
	X  strcpy(LINK->lat[0x4e], "n");   /*n*/
	X  strcpy(LINK->lat[0x4f], "o");   /*o*/
	X  strcpy(LINK->lat[0x50], "p");   /*p*/
	X  strcpy(LINK->lat[0x51], "q");   /*q*/
	X  strcpy(LINK->lat[0x52], "r");   /*r*/
	X  strcpy(LINK->lat[0x53], "s");   /*s*/
	X  strcpy(LINK->lat[0x54], "t");   /*t*/
	X  strcpy(LINK->lat[0x55], "u");   /*u*/
	X  strcpy(LINK->lat[0x56], "v");   /*v*/
	X  strcpy(LINK->lat[0x57], "w");   /*w*/
	X  strcpy(LINK->lat[0x58], "x");   /*x*/
	X  strcpy(LINK->lat[0x59], "y");   /*y*/
	X  strcpy(LINK->lat[0x5a], "z");   /*z*/
	X  strcpy(LINK->lat[0x5b], "\\{");   /*{*/
	X  strcpy(LINK->lat[0x5c], "$|$");   /*|*/
	X  strcpy(LINK->lat[0x5d], "\\}");   /* */
	X  strcpy(LINK->lat[0x5e], "\\tidle{");   /*~*/
	X  strcpy(LINK->lat[0x5f], " ");   /*Doesn't exsist*/
	X}
	X
	X
	XLocal Void Ext_chr_init(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  LINK->char_set[0] = 0x1;
	X  LINK->char_code[0] = 0x26;
	X  strcpy(LINK->ext_lat[0], "\\c{C}");
	X  LINK->char_set[0x1] = 0x1;
	X  LINK->char_code[0x1] = 0x47;
	X  strcpy(LINK->ext_lat[0x1], "\\\"{u}");
	X  LINK->char_set[0x2] = 0x1;
	X  LINK->char_code[0x2] = 0x29;
	X  strcpy(LINK->ext_lat[0x2], "\\'{e}");
	X  LINK->char_set[0x3] = 0x1;
	X  LINK->char_code[0x3] = 0x1d;
	X  strcpy(LINK->ext_lat[0x3], "\\^{a}");
	X  LINK->char_set[0x4] = 0x1;
	X  LINK->char_code[0x4] = 0x1f;
	X  strcpy(LINK->ext_lat[0x4], "\\\"{a}");
	X  LINK->char_set[0x5] = 0x1;
	X  LINK->char_code[0x5] = 0x21;
	X  strcpy(LINK->ext_lat[0x5], "\\`{a}");
	X  LINK->char_set[0x6] = 0x1;
	X  LINK->char_code[0x6] = 0x23;
	X  strcpy(LINK->ext_lat[0x6], "\\aa ");
	X  LINK->char_set[0x7] = 0x1;
	X  LINK->char_code[0x7] = 0x27;
	X  strcpy(LINK->ext_lat[0x7], "\\c{c}");
	X  LINK->char_set[0x8] = 0x1;
	X  LINK->char_code[0x8] = 0x2b;
	X  strcpy(LINK->ext_lat[0x8], "\\^{e}");
	X  LINK->char_set[0x9] = 0x1;
	X  LINK->char_code[0x9] = 0x2d;
	X  strcpy(LINK->ext_lat[0x9], "\\\"{e}");
	X  LINK->char_set[0xa] = 0x1;
	X  LINK->char_code[0xa] = 0x2f;
	X  strcpy(LINK->ext_lat[0xa], "\\`{e}");
	X  LINK->char_set[0xb] = 0x1;
	X  LINK->char_code[0xb] = 0x35;
	X  strcpy(LINK->ext_lat[0xb], "\\\"{\\i}");
	X  LINK->char_set[0xc] = 0x1;
	X  LINK->char_code[0xc] = 0x33;
	X  strcpy(LINK->ext_lat[0xc], "\\^{\\i}");
	X  LINK->char_set[0xd] = 0x1;
	X  LINK->char_code[0xd] = 0x37;
	X  strcpy(LINK->ext_lat[0xd], "\\`{\\i}");
	X  LINK->char_set[0xe] = 0x1;
	X  LINK->char_code[0xe] = 0x1e;
	X  strcpy(LINK->ext_lat[0xe], "\\\"{A}");
	X  LINK->char_set[0xf] = 0x1;
	X  LINK->char_code[0xf] = 0x22;
	X  strcpy(LINK->ext_lat[0xf], "\\AA ");
	X  LINK->char_set[0x10] = 0x1;
	X  LINK->char_code[0x10] = 0x28;
	X  strcpy(LINK->ext_lat[0x10], "\\'{E}");
	X  LINK->char_set[0x11] = 0x1;
	X  LINK->char_code[0x11] = 0x25;
	X  strcpy(LINK->ext_lat[0x11], "\\ae ");
	X  LINK->char_set[0x12] = 0x1;
	X  LINK->char_code[0x12] = 0x24;
	X  strcpy(LINK->ext_lat[0x12], "\\AE ");
	X  LINK->char_set[0x13] = 0x1;
	X  LINK->char_code[0x13] = 0x3d;
	X  strcpy(LINK->ext_lat[0x13], "\\^{o}");
	X  LINK->char_set[0x14] = 0x1;
	X  LINK->char_code[0x14] = 0x3f;
	X  strcpy(LINK->ext_lat[0x14], "\\\"{o}");
	X  LINK->char_set[0x15] = 0x1;
	X  LINK->char_code[0x15] = 0x41;
	X  strcpy(LINK->ext_lat[0x15], "\\`{o}");
	X  LINK->char_set[0x16] = 0x1;
	X  LINK->char_code[0x16] = 0x45;
	X  strcpy(LINK->ext_lat[0x16], "\\^{u}");
	X  LINK->char_set[0x17] = 0x1;
	X  LINK->char_code[0x17] = 0x49;
	X  strcpy(LINK->ext_lat[0x17], "\\`{u}");
	X  LINK->char_set[0x18] = 0x1;
	X  LINK->char_code[0x18] = 0x8b;
	X  strcpy(LINK->ext_lat[0x18], "\\\"{y}");
	X  LINK->char_set[0x19] = 0x1;
	X  LINK->char_code[0x19] = 0x3e;
	X  strcpy(LINK->ext_lat[0x19], "\\\"{O}");
	X  LINK->char_set[0x1a] = 0x1;
	X  LINK->char_code[0x1a] = 0x46;
	X  strcpy(LINK->ext_lat[0x1a], "\\\"{U}");
	X  LINK->char_set[0x1b] = 0x4;
	X  LINK->char_code[0x1b] = 0x13;
	X  strcpy(LINK->ext_lat[0x1b], "\\ ");
	X  LINK->char_set[0x1c] = 0x4;
	X  LINK->char_code[0x1c] = 0xb;
	X  strcpy(LINK->ext_lat[0x1c], "\\pounds ");
	X  LINK->char_set[0x1d] = 0x4;
	X  LINK->char_code[0x1d] = 0xc;
	X  strcpy(LINK->ext_lat[0x1d], "\\ ");
	X  LINK->char_set[0x1e] = 0x4;
	X  LINK->char_code[0x1e] = 0xd;
	X  strcpy(LINK->ext_lat[0x1e], "\\ ");
	X  LINK->char_set[0x1f] = 0x4;
	X  LINK->char_code[0x1f] = 0xe;
	X  strcpy(LINK->ext_lat[0x1f], "{\\it f}\\/");
	X  LINK->char_set[0x20] = 0x1;
	X  LINK->char_code[0x20] = 0x1b;
	X  strcpy(LINK->ext_lat[0x20], "\\'{a}");
	X  LINK->char_set[0x21] = 0x1;
	X  LINK->char_code[0x21] = 0x31;
	X  strcpy(LINK->ext_lat[0x21], "\\'{\\i}");
	X  LINK->char_set[0x22] = 0x1;
	X  LINK->char_code[0x22] = 0x3b;
	X  strcpy(LINK->ext_lat[0x22], "\\'{o}");
	X  LINK->char_set[0x23] = 0x1;
	X  LINK->char_code[0x23] = 0x43;
	X  strcpy(LINK->ext_lat[0x23], "\\'{u}");
	X  LINK->char_set[0x24] = 0x1;
	X  LINK->char_code[0x24] = 0x39;
	X  strcpy(LINK->ext_lat[0x24], "\\~{n}");
	X  LINK->char_set[0x25] = 0x1;
	X  LINK->char_code[0x25] = 0x38;
	X  strcpy(LINK->ext_lat[0x25], "\\~{N}");
	X  LINK->char_set[0x26] = 0x4;
	X  LINK->char_code[0x26] = 0xf;
	X  strcpy(LINK->ext_lat[0x26], "\\astrike ");
	X  LINK->char_set[0x27] = 0x4;
	X  LINK->char_code[0x27] = 0x10;
	X  strcpy(LINK->ext_lat[0x27], "\\ostrike ");
	X  LINK->char_set[0x28] = 0x4;
	X  LINK->char_code[0x28] = 0x8;
	X  strcpy(LINK->ext_lat[0x28], "?`");
	X  LINK->char_set[0x29] = 0x5;
	X  LINK->char_code[0x29] = 0x10;
	X  strcpy(LINK->ext_lat[0x29], "~");
	X  LINK->char_set[0x2a] = 0x6;
	X  LINK->char_code[0x2a] = 0x14;
	X  strcpy(LINK->ext_lat[0x2a], "~");
	X  LINK->char_set[0x2b] = 0x4;
	X  LINK->char_code[0x2b] = 0x11;
	X  strcpy(LINK->ext_lat[0x2b], "$\\frac{1}{2}$");
	X  LINK->char_set[0x2c] = 0x4;
	X  LINK->char_code[0x2c] = 0x12;
	X  strcpy(LINK->ext_lat[0x2c], "$\\frac{1}{4}$");
	X  LINK->char_set[0x2d] = 0x4;
	X  LINK->char_code[0x2d] = 0x7;
	X  strcpy(LINK->ext_lat[0x2d], "!`");
	X  LINK->char_set[0x2e] = 0x4;
	X  LINK->char_code[0x2e] = 0x9;
	X  strcpy(LINK->ext_lat[0x2e], "$\\ll$");
	X  LINK->char_set[0x2f] = 0x4;
	X  LINK->char_code[0x2f] = 0xa;
	X  strcpy(LINK->ext_lat[0x2f], "$\\gg$");
	X  LINK->char_set[0x60] = 0x8;
	X  LINK->char_code[0x60] = 0x1;
	X  strcpy(LINK->ext_lat[0x60], "$\\alpha$");
	X  /*
	X  These are wrong
	X  LINK->char_set[0x61] = 0x1;
	X  LINK->char_code[0x61] = 0x17;
	X  They originally were used to detect beta
	X  */
	X  LINK->char_set[0x61] = 0x08;
	X  LINK->char_code[0x61] = 0x03;
	X  strcpy(LINK->ext_lat[0x61], "$\\beta$");
	X  LINK->char_set[0x62] = 0x8;
	X  LINK->char_code[0x62] = 0x6;
	X  strcpy(LINK->ext_lat[0x62], "$\\Gamma$");
	X  LINK->char_set[0x63] = 0x8;
	X  LINK->char_code[0x63] = 0x21;
	X  strcpy(LINK->ext_lat[0x63], "$\\pi$");
	X  LINK->char_set[0x64] = 0x8;
	X  LINK->char_code[0x64] = 0x24;
	X  strcpy(LINK->ext_lat[0x64], "$\\Sigma$");
	X  LINK->char_set[0x65] = 0x8;
	X  LINK->char_code[0x65] = 0x25;
	X  strcpy(LINK->ext_lat[0x65], "$\\sigma$");
	X  LINK->char_set[0x66] = 0x8;
	X  LINK->char_code[0x66] = 0x19;
	X  strcpy(LINK->ext_lat[0x66], "$\\mu$");
	X  LINK->char_set[0x67] = 0x8;
	X  LINK->char_code[0x67] = 0x29;
	X  strcpy(LINK->ext_lat[0x67], "$\\tau$");
	X  LINK->char_set[0x68] = 0x8;
	X  LINK->char_code[0x68] = 0x2c;
	X  strcpy(LINK->ext_lat[0x68], "$\\Phi$");
	X  LINK->char_set[0x69] = 0x8;
	X  LINK->char_code[0x69] = 0x10;
	X  strcpy(LINK->ext_lat[0x69], "$\\theta$");
	X  LINK->char_set[0x6a] = 0x8;
	X  LINK->char_code[0x6a] = 0x32;
	X  strcpy(LINK->ext_lat[0x6a], "$\\Omega$");
	X  LINK->char_set[0x6b] = 0x8;
	X  LINK->char_code[0x6b] = 0x9;
	X  strcpy(LINK->ext_lat[0x6b], "$\\delta$");
	X  LINK->char_set[0x6c] = 0x6;
	X  LINK->char_code[0x6c] = 0x13;
	X  strcpy(LINK->ext_lat[0x6c], "$\\infty$");
	X  LINK->char_set[0x6d] = 0x8;
	X  LINK->char_code[0x6d] = 0x2d;
	X  strcpy(LINK->ext_lat[0x6d], "$\\emptyset$");
	X  LINK->char_set[0x6e] = 0x8;
	X  LINK->char_code[0x6e] = 0xb;
	X  strcpy(LINK->ext_lat[0x6e], "$\\epsilon$");
	X  LINK->char_set[0x6f] = 0x6;
	X  LINK->char_code[0x6f] = 0x10;
	X  strcpy(LINK->ext_lat[0x6f], "$\\cap$");
	X  LINK->char_set[0x70] = 0x6;
	X  LINK->char_code[0x70] = 0xe;
	X  strcpy(LINK->ext_lat[0x70], "$\\equiv$");
	X  LINK->char_set[0x71] = 0x6;
	X  LINK->char_code[0x71] = 0x1;
	X  strcpy(LINK->ext_lat[0x71], "$\\pm$");
	X  LINK->char_set[0x72] = 0x6;
	X  LINK->char_code[0x72] = 0x3;
	X  strcpy(LINK->ext_lat[0x72], "$\\geq$");
	X  LINK->char_set[0x73] = 0x6;
	X  LINK->char_code[0x73] = 0x2;
	X  strcpy(LINK->ext_lat[0x73], "$\\leq$");
	X  LINK->char_set[0x74] = 0x7;
	X  LINK->char_code[0x74] = 0;
	X  strcpy(LINK->ext_lat[0x74], "~");
	X  LINK->char_set[0x75] = 0x7;
	X  LINK->char_code[0x75] = 0x1;
	X  strcpy(LINK->ext_lat[0x75], "~");
	X  LINK->char_set[0x76] = 0x6;
	X  LINK->char_code[0x76] = 0x8;
	X  strcpy(LINK->ext_lat[0x76], "$\\div$");
	X  LINK->char_set[0x77] = 0x6;
	X  LINK->char_code[0x77] = 0xd;
	X  strcpy(LINK->ext_lat[0x77], "$\\approx$");
	X  LINK->char_set[0x78] = 0x6;
	X  LINK->char_code[0x78] = 0x24;
	X  strcpy(LINK->ext_lat[0x78], "\\degrees ");
	X  LINK->char_set[0x79] = 0x6;
	X  LINK->char_code[0x79] = 0x1f;
	X  strcpy(LINK->ext_lat[0x79], "~");
	X  LINK->char_set[0x7a] = 0x6;
	X  LINK->char_code[0x7a] = 0x20;
	X  strcpy(LINK->ext_lat[0x7a], "~");
	X  LINK->char_set[0x7b] = 0x7;
	X  LINK->char_code[0x7b] = 0x4;
	X  strcpy(LINK->ext_lat[0x7b], "$\\surd$");
	X  LINK->char_set[0x7c] = 0x4;
	X  LINK->char_code[0x7c] = 0x15;
	X  strcpy(LINK->ext_lat[0x7c], "$^{n}$");
	X  LINK->char_set[0x7d] = 0x4;
	X  LINK->char_code[0x7d] = 0x14;
	X  strcpy(LINK->ext_lat[0x7d], "$^{2}$");
	X  LINK->char_set[0x7e] = 0x4;
	X  LINK->char_code[0x7e] = 0x2;
	X  strcpy(LINK->ext_lat[0x7e], "~");
	X/*
	X** Note: Adding characters is easy. The maximum available is
	X** now 256 not 128 (Pascal version).
	X** e.g. The Greek character set is char_set 0x8,
	X** \Alpha has char_code 0x0, \alpha has char_code 0x1 ...
	X** \Omega has char_code 0x32 and \omega has char_code 0x33
	X** I suspect that there are two versions of some letters
	X** I've only added the ones I've needed for translating.
	X** Hence the apparent randomness.
	X*/
	X  LINK->char_set[0x7f] = 0x8;
	X  LINK->char_code[0x7f] = 0x15;
	X  strcpy(LINK->ext_lat[0x7f], "$\\kappa$");
	X  LINK->char_set[0x80] = 0x8;
	X  LINK->char_code[0x80] = 0x8;
	X  strcpy(LINK->ext_lat[0x80], "$\\Delta$");
	X  LINK->char_set[0x81] = 0x8;
	X  LINK->char_code[0x81] = 0xf;
	X  strcpy(LINK->ext_lat[0x81], "$\\eta$");
	X  LINK->char_set[0x82] = 0x8;
	X  LINK->char_code[0x82] = 0x27;
	X  strcpy(LINK->ext_lat[0x82], "$\\zeta$");
	X  LINK->char_set[0x83] = 0x06;
	X  LINK->char_code[0x83] = 0x0a;
	X  strcpy(LINK->ext_lat[0x83], "$<$");
	X  LINK->char_set[0x84] = 0x06;
	X  LINK->char_code[0x84] = 0x09;
	X  strcpy(LINK->ext_lat[0x84], "$|$");
	X  LINK->char_set[0x85] = 0x8;
	X  LINK->char_code[0x85] = 0x7;
	X  strcpy(LINK->ext_lat[0x85], "$\\gamma$");
	X  LINK->char_set[0x86] = 0x8;
	X  LINK->char_code[0x86] = 0x2b;
	X  strcpy(LINK->ext_lat[0x86], "$\\phi$");
	X  LINK->char_set[0x87] = 0x6;
	X  LINK->char_code[0x87] = 0x27;
	X  strcpy(LINK->ext_lat[0x87], "$\\times$");
	X  LINK->char_set[0x88] = 0x6;
	X  LINK->char_code[0x88] = 0x28;
	X  strcpy(LINK->ext_lat[0x88], "$\\int$");
	X  LINK->char_set[0x89] = 0x8;
	X  LINK->char_code[0x89] = 0x31;
	X  strcpy(LINK->ext_lat[0x89], "$\\psi$");
	X  LINK->char_set[0x8a] = 0x6;
	X  LINK->char_code[0x8a] = 0xb;
	X  strcpy(LINK->ext_lat[0x8a], "$>$");
	X  LINK->char_set[0x8b] = 0x8;
	X  LINK->char_code[0x8b] = 0x2f;
	X  strcpy(LINK->ext_lat[0x8b], "$\\chi$");
	X  LINK->char_set[0x8c] = 0x6;
	X  LINK->char_code[0x8c] = 0x17;
	X  strcpy(LINK->ext_lat[0x8c], "$\\uparrow$");
	X  LINK->char_set[0x8d] = 0x6;
	X  LINK->char_code[0x8d] = 0x15;
	X  strcpy(LINK->ext_lat[0x8d], "$\\rightarrow$");
	X  LINK->char_set[0x8e] = 0x8;
	X  LINK->char_code[0x8e] = 0x17;
	X  strcpy(LINK->ext_lat[0x8e], "$\\lambda$");
	X  LINK->char_set[0x8f] = 0x8;
	X  LINK->char_code[0x8f] = 0x33;
	X  strcpy(LINK->ext_lat[0x8f], "$\\omega$");
	X}
	X
	X
	XLocal Void Make_tabelentry_attr(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar num_of_attr;
	X  short j;
	X
	X  num_of_attr = LINK->openptr[LINK->depth];
	X  fwrite(&num_of_attr, sizeof(uchar), 1, tabel);
	X
	X  for (j = 1; j <= num_of_attr; j++)
	X    fwrite(&LINK->attr_rij[LINK->depth][j], sizeof(uchar), 1, tabel);
	X
	X}
	X
	X
	X
	XLocal Void Make_tabelentry_tabset(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar b;
	X  short j, FORLIM;
	X
	X  b = 'S';
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X
	X  b = LINK->num_of_tabs;
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X
	X  FORLIM = LINK->num_of_tabs;
	X  for (j = 0; j < FORLIM; j++)
	X    Wr_word(&tabel, LINK->tabpos[j]);
	X}
	X
	X
	XLocal Void Make_tabelentry_rightjustification(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar b;
	X
	X  b = 'U';
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X
	X  if (LINK->by == 0x81)   /* regels NIET uitvullen */
	X    b = 1;   /* regels WEL uitvullen */
	X  else
	X    b = 0;
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X}
	X
	X
	X
	X
	XLocal Void Make_tabelentry_envir_extra_end(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar b;
	X
	X
	X  switch (LINK->envir) {
	X
	X  case 'C':
	X    b = 'C';
	X    fwrite(&b, sizeof(uchar), 1, tabel);
	X    break;
	X
	X  case 'T':
	X    b = 'T';
	X    fwrite(&b, sizeof(uchar), 1, tabel);
	X    break;
	X
	X  case 'I':
	X    b = 'I';
	X    fwrite(&b, sizeof(uchar), 1, tabel);
	X    Wr_word(&tabel, LINK->ind_leftmargin);
	X    Wr_word(&tabel, LINK->ind_rightmargin);
	X
	X    if (LINK->ind_text2) {
	X      b = 1;
	X      fwrite(&b, sizeof(uchar), 1, tabel);
	X    } else {
	X      b = 0;
	X      fwrite(&b, sizeof(uchar), 1, tabel);
	X    }
	X
	X    break;
	X
	X  }/*Case*/
	X
	X  b = LINK->line_term;
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X
	X  b = 0xff;
	X  fwrite(&b, sizeof(uchar), 1, tabel);
	X
	X}
	X
	X
	XLocal Void Reset_attr_rij(d, LINK)
	Xshort d;
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  short j;
	X
	X  for (j = 0; j <= 16; j++)
	X    LINK->attr_rij[d][j] = 0;
	X  LINK->leegptr[d] = 1;
	X  LINK->openptr[d] = 0;
	X}
	X
	X
	X
	XLocal Void Open_all_attr(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* -- Open alle commando's door de Attributen-rij af te lopen -- */
	X  short j, FORLIM;
	X
	X  FORLIM = LINK->leegptr[LINK->depth];
	X  for (j = LINK->openptr[LINK->depth] + 1; j < FORLIM; j++) {
	X    fputs(open_com[LINK->attr_rij[LINK->depth][j]], strip);
	X    LINK->openptr[LINK->depth]++;
	X  }
	X
	X  LINK->open_attr_rij[LINK->depth] = false;
	X      /* Alle attributen staan weer goed */
	X}
	X
	X
	X
	XLocal Void Close_all_attr(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
	X  short j;
	X
	X  for (j = LINK->openptr[LINK->depth]; j >= 1; j--) {
	X    fputs(close_com[LINK->attr_rij[LINK->depth][j]], strip);
	X    LINK->openptr[LINK->depth]--;
	X  }
	X  LINK->open_attr_rij[LINK->depth] = true;
	X}
	X
	X
	X
	XLocal Void Attr_ON(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* Deze procedure plaatst een attribuut (lettertype) in de attribuut-rij */
	X  uchar b;
	X
	X  fread(&b, sizeof(uchar), 1, wpd);   /* lees attribuut-code */
	X
	X  LINK->attr_rij[LINK->depth][LINK->leegptr[LINK->depth]] = b;
	X      /* attribuut in attr-rij */
	X  LINK->leegptr[LINK->depth]++;   /* plaats 1 verder. */
	X  LINK->open_attr_rij[LINK->depth] = true;   /* openstaande attr-rij */
	X
	X  fread(&b, sizeof(uchar), 1, wpd);   /* lees voorbij afsluitcode */
	X}
	X
	X
	X
	XLocal Void Attr_OFF(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* Deze procedure haalt een uit een attribuut (lettertype) uit de */
	X  /* attribuut-rij door middel van een stack principe omdat binnen  */
	X  /* LaTeX de later geopende kommando's eerst afgesloten te worden  */
	X  uchar b;
	X  boolean found;
	X  short j, codeptr, FORLIM;
	X
	X  fread(&b, sizeof(uchar), 1, wpd);   /* lees attribuut-code */
	X
	X  j = LINK->leegptr[LINK->depth];   /* zoek vanaf top attr-rij */
	X  found = false;   /* nog niet gevonden */
	X
	X  while (j > 1 && !found) {   /* zoek attr-code in attr-rij */
	X    j--;
	X    found = (LINK->attr_rij[LINK->depth][j] == b);
	X  }
	X
	X  if (j <= 0) {   /* Moet nooit kunnen voorkomen */
	X    RunError(0x100);
	X  }
	X  codeptr = j;   /* plaats van attr-code in rij */
	X
	X  /* Sluit alle commando's t/m de desbetreffende code als deze nog niet */
	X  /* gesloten zijn.                                                     */
	X
	X  if (codeptr <= LINK->openptr[LINK->depth]) {
	X    for (j = LINK->openptr[LINK->depth]; j >= codeptr; j--) {
	X      fputs(close_com[LINK->attr_rij[LINK->depth][j]], strip);
	X      LINK->openptr[LINK->depth]--;
	X    }
	X  }
	X
	X  FORLIM = LINK->leegptr[LINK->depth];
	X  /* Haal de desbetreffende attribuut uit de rij en werk pointers bij */
	X
	X  for (j = codeptr; j < FORLIM; j++)
	X    LINK->attr_rij[LINK->depth][j] = LINK->attr_rij[LINK->depth][j + 1];
	X  LINK->leegptr[LINK->depth]--;
	X
	X  LINK->open_attr_rij[LINK->depth] = true;   /* openstaande attr-rij */
	X
	X  fread(&b, sizeof(uchar), 1, wpd);   /* lees voorbij afsluitcode */
	X}
	X
	X
	X
	XLocal Void Center(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* Deze procedure zorgt voor center environment zolang er nog geen */
	X  /* andere environment is begonnen.                                 */
	X  if (LINK->envir == ' ')   /* environment = center */
	X    LINK->envir = 'C';
	X
	X  Jump_in_file(&wpd, 7L);   /* rest van code overslaan */
	X}
	X
	X
	X
	XLocal Void End_Align(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  if (LINK->align_tab) {
	X    Close_all_attr(LINK);
	X    fprintf(strip, "\\'");
	X    LINK->align_tab = false;
	X    Open_all_attr(LINK);
	X  }
	X
	X  if (LINK->right_tab) {
	X    Close_all_attr(LINK);
	X    fprintf(strip, "\\'");
	X    LINK->right_tab = false;
	X    Open_all_attr(LINK);
	X  }
	X
	X  if (!LINK->center_tab)
	X    return;
	X  Close_all_attr(LINK);
	X  putc('}', strip);
	X  LINK->center_tab = false;
	X  Open_all_attr(LINK);
	X}
	X
	X
	X
	XLocal Void Tab(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  short j;
	X  unsigned short wpu;
	X  short tabnum, new_tabs, FORLIM;
	X
	X  if (LINK->envir == 'I' || LINK->nomore_valid_tabs)
	X  {   /* Noggeen indent --> normaal tab */
	X    Jump_in_file(&wpd, 7L);
	X    return;
	X  }
	X
	X
	X  if (LINK->by == 0x48)
	X    LINK->right_tab = true;
	X
	X  if (LINK->by == 0x40)
	X    LINK->align_tab = true;
	X
	X  if (LINK->by == 0xc8)
	X    LINK->center_tab = true;
	X
	X  Jump_in_file(&wpd, 2L);
	X
	X  Rd_word(&wpd, &wpu);   /* Lees abs.-indent [wpu] */
	X  wpu -= LINK->WP_sidemargin;   /* Correctie ivm WP kantlijn */
	X
	X  tabnum = 0;
	X  FORLIM = LINK->num_of_tabs;
	X  for (j = 1; j <= FORLIM; j++) {   /* Bepaal welke tabpos */
	X    if (wpu >= LINK->tabpos[j - 1])
	X      tabnum = j;
	X  }
	X
	X  new_tabs = tabnum - LINK->latex_tabpos;
	X
	X  if (new_tabs > 0) {
	X    Close_all_attr(LINK);
	X
	X    for (j = 1; j <= new_tabs; j++)
	X      fprintf(strip, "\\>");
	X
	X    if (LINK->center_tab)
	X      fprintf(strip, "\\ctab{");
	X
	X    Open_all_attr(LINK);
	X  }
	X
	X  LINK->latex_tabpos = tabnum;
	X
	X  Jump_in_file(&wpd, 3L);
	X
	X  LINK->envir = 'T';   /* Er zit een tab in deze regel */
	X}
	X
	X
	X
	XLocal Void Flush_right_tab(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  if (LINK->envir != 'I') {
	X    Close_all_attr(LINK);
	X    fprintf(strip, "\\`");
	X    Open_all_attr(LINK);
	X
	X    LINK->nomore_valid_tabs = true;
	X
	X    LINK->envir = 'T';
	X  }
	X
	X  Jump_in_file(&wpd, 7L);
	X}
	X
	X
	X
	XLocal Void Indent(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  unsigned short dif, abs;
	X  uchar b;
	X
	X  if (LINK->envir == 'T') {
	X	/*Al een tabcommando gezet dus er mag geen insp */
	X	  Jump_in_file(&wpd, 10L);
	X    return;
	X  }
	X  LINK->envir = 'I';
	X  LINK->indenting = true;
	X
	X  if (LINK->ind_text2) {
	X    Jump_in_file(&wpd, 10L);
	X    return;
	X  }
	X  fread(&b, sizeof(uchar), 1, wpd);
	X  b &= 0x1;
	X
	X  Rd_word(&wpd, &dif);
	X  Rd_word(&wpd, &abs);   /* Eigenlijk Old current column */
	X  Rd_word(&wpd, &abs);
	X
	X  LINK->ind_leftmargin = abs - LINK->WP_sidemargin;
	X
	X  if (b == 1)
	X    LINK->ind_rightmargin += dif;
	X  /*Margins bepaald lees voorby rest van functie-codes */
	X  Jump_in_file(&wpd, 3L);
	X
	X  if (LINK->ind_text1)
	X    return;
	X  if (LINK->char_on_line) {
	X    putc('}', strip);
	X    LINK->ind_text1 = true;
	X  }
	X}
	X
	X
	XLocal Void End_of_indent(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  LINK->indent_end = true;
	X  Jump_in_file(&wpd, 5L);
	X}
	X
	X
	X
	XLocal Void Tabset(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  short j;
	X  unsigned short w;
	X
	X  Jump_in_file(&wpd, 102L);   /* Ga naar TAB-info */
	X
	X  LINK->num_of_tabs = 0;
	X
	X  for (j = 1; j <= 40; j++) {
	X    Rd_word(&wpd, &w);
	X    if (w > LINK->WP_sidemargin && w != 0xffffL) {
	X      LINK->num_of_tabs++;
	X      LINK->tabpos[LINK->num_of_tabs - 1] = w - LINK->WP_sidemargin;
	X    }
	X  }
	X
	X  Jump_in_file(&wpd, 24L);
	X
	X  Make_tabelentry_tabset(LINK);
	X}
	X
	X
	X
	XLocal Void Page_number_position(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar position_code;
	X
	X  Jump_in_file(&wpd, 5L);   /*Skip length of code; always 10*/
	X  /* + old information */
	X  fread(&position_code, sizeof(uchar), 1, wpd);
	X
	X  fprintf(strip, "\\pagenumpos");
	X  switch (position_code) {
	X
	X  case 0x1:
	X    fprintf(strip, "{\\pntl}");
	X    break;
	X
	X  case 0x2:
	X    fprintf(strip, "{\\pntc}");
	X    break;
	X
	X  case 0x3:
	X    fprintf(strip, "{\\pntr}");
	X    break;
	X
	X  case 0x5:
	X    fprintf(strip, "{\\pnbl}");
	X    break;
	X
	X  case 0x6:
	X    fprintf(strip, "{\\pnbc}");
	X    break;
	X
	X  case 0x7:
	X    fprintf(strip, "{\\pnbr}");
	X    break;
	X
	X  default:
	X    fprintf(strip, "{\\pnno}");
	X    break;
	X  }
	X
	X  Jump_in_file(&wpd, 6L);
	X}
	X
	X
	X
	XLocal Void Character(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  Char ch[256];
	X
	X  short j;
	X  uchar chr_code, chr_set, b;
	X  boolean found;
	X
	X
	X  if (LINK->open_attr_rij[LINK->depth])
	X    Open_all_attr(LINK);
	X
	X  switch (LINK->by) {
	X
	X  case 0xa9:   /* Special_char */
	X    if (LINK->by == 0xa9)
	X      strcpy(ch, "-");
	X    else
	X      strcpy(ch, "\\ ");
	X    break;
	X
	X  case 0xc0:   /* Extended_char */
	X    j = 127;
	X    found = false;
	X
	X    fread(&chr_code, sizeof(uchar), 1, wpd);
	X    fread(&chr_set, sizeof(uchar), 1, wpd);
	X
	X    while (j < 511 && !found) {
	X      j++;
	X      if (chr_code == LINK->char_code[j - 0x80] &&
	X	  chr_set == LINK->char_set[j - 0x80])
	X	found = true;
	X    }
	X
	X    if (found)
	X      strcpy(ch, LINK->ext_lat[j - 0x80]);
	X    else
	X      strcpy(ch, "\\ ");
	X
	X    fread(&b, sizeof(uchar), 1, wpd);
	X    break;
	X
	X  default:
	X    if (LINK->by >= 0x20 && LINK->by <= 0x7f) {
	X      /* Normal_char  */
	X      strcpy(ch, LINK->lat[LINK->by - 0x20]);
	X    }
	X
	X    break;
	X  }
	X
	X  fputs(ch, strip);
	X
	X}
	X
	X
	X
	XLocal Void Return_Page(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  switch (LINK->by) {
	X
	X  case 0x0a:
	X  case 0x8c:   /* Hard return */
	X    LINK->line_term = 'R';
	X    break;
	X
	X  case 0x0d:   /* Soft return */
	X    LINK->line_term = 'r';
	X    break;
	X
	X  case 0xc:   /* Hard page */
	X    LINK->line_term = 'P';
	X    break;
	X
	X  case 0xb:   /* Soft page */
	X    LINK->line_term = 'p';
	X    break;
	X  }
	X
	X  putc('\n', strip);
	X
	X  Make_tabelentry_envir_extra_end(LINK);
	X
	X  if (LINK->indent_end) {
	X    LINK->envir = ' ';
	X    LINK->indenting = false;
	X    LINK->ind_text1 = false;
	X    LINK->ind_text2 = false;
	X    LINK->ind_leftmargin = 0;
	X    LINK->ind_rightmargin = 0;
	X
	X    LINK->indent_end = false;
	X  } else if (LINK->envir != 'I')
	X    LINK->envir = ' ';
	X
	X
	X  LINK->char_on_line = false;
	X  LINK->nomore_valid_tabs = false;
	X
	X  LINK->regelnum++;
	X
	X  Make_tabelentry_attr(LINK);
	X
	X  LINK->latex_tabpos = 0;
	X}
	X
	X
	XLocal Void Nop80(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  /* Om dat het een 1-byte funktie is hoeft er niks overgeslagen */
	X  /* te worden.                                                  */
	X}
	X
	X
	X
	XLocal Void NopC0(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  if (LINK->by == 0xc0)
	X    Jump_in_file(&wpd, 3L);
	X  if (LINK->by == 0xc1)
	X    Jump_in_file(&wpd, 8L);
	X  if (LINK->by == 0xc2)
	X    Jump_in_file(&wpd, 10L);
	X  if (LINK->by == 0xc3)
	X    Jump_in_file(&wpd, 2L);
	X  if (LINK->by == 0xc4)
	X    Jump_in_file(&wpd, 2L);
	X  if (LINK->by == 0xc5)
	X    Jump_in_file(&wpd, 4L);
	X  if (LINK->by == 0xc6)
	X    Jump_in_file(&wpd, 5L);
	X  if (LINK->by == 0xc7)
	X    Jump_in_file(&wpd, 6L);
	X}
	X
	X
	X
	XLocal Void NopD0(already_read_subfunc_code, LINK)
	Xboolean already_read_subfunc_code;
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar b;
	X  unsigned short w;
	X
	X  if (!already_read_subfunc_code)   /* Lees subfunctioncode */
	X    fread(&b, sizeof(uchar), 1, wpd);
	X
	X  Rd_word(&wpd, &w);   /* Lees lengte 'die nog volgt ' */
	X  fseek(wpd, (ftell(wpd) / sizeof(uchar) + w) * sizeof(uchar), 0);
	X}
	X
	X
	X
	XLocal Void Overstrike(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  boolean first_char_os;
	X
	X  unsigned short char_width_os, len_of_code;
	X  long end_of_code;
	X
	X  Rd_word(&wpd, &len_of_code);   /* Lees lengte */
	X  end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
	X
	X  Rd_word(&wpd, &char_width_os);
	X
	X  first_char_os = true;
	X
	X  while (ftell(wpd) / sizeof(uchar) < end_of_code) {
	X    fread(&LINK->by, sizeof(uchar), 1, wpd);
	X
	X
	X    if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
	X	LINK->by == 0xc0) {
	X      if (first_char_os) {
	X	Character(LINK);
	X	first_char_os = false;
	X      } else {
	X	fprintf(strip, "\\llap{");
	X	Character(LINK);
	X	putc('}', strip);
	X      }
	X      continue;
	X    }
	X
	X    if (LINK->by <= 0xbf)
	X      Nop80(LINK);
	X    else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
	X      NopC0(LINK);
	X    else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
	X      NopD0(false, LINK);
	X  }
	X
	X  Jump_in_file(&wpd, 4L);
	X
	X}
	X
	X
	X
	XLocal Void Footnote(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar flags, num_of_pages;
	X
	X  unsigned short fn_num, len_of_code;
	X  long end_of_code;
	X
	X  Rd_word(&wpd, &len_of_code);   /* Lees lengte */
	X  end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
	X
	X  fread(&flags, sizeof(uchar), 1, wpd);
	X
	X  Rd_word(&wpd, &fn_num);
	X
	X  /* Skip all the shit */
	X
	X  fread(&num_of_pages, sizeof(uchar), 1, wpd);
	X  Jump_in_file(&wpd, (num_of_pages + 1L) * 2 + 9);
	X
	X  Close_all_attr(LINK);
	X
	X  LINK->depth = 1;
	X  Reset_attr_rij(LINK->depth, LINK);
	X
	X  fprintf(strip, "\\footnote[%u]{", fn_num);
	X
	X  while (ftell(wpd) / sizeof(uchar) < end_of_code) {
	X    fread(&LINK->by, sizeof(uchar), 1, wpd);
	X
	X    switch (LINK->by) {
	X
	X    case 0xa:
	X    case 0xc:
	X      fprintf(strip, "\\\\ ");
	X      break;
	X
	X    case 0xb:
	X    case 0xd:
	X      putc(' ', strip);
	X      break;
	X
	X    case 0xc3:
	X      Attr_ON(LINK);
	X      break;
	X
	X    case 0xc4:
	X      Attr_OFF(LINK);
	X      break;
	X
	X    default:
	X      if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
	X	  LINK->by == 0xc0)
	X	Character(LINK);
	X      else if (LINK->by <= 0xbf)
	X	Nop80(LINK);
	X      else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
	X	NopC0(LINK);
	X      else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
	X	NopD0(false, LINK);
	X
	X      break;
	X    }
	X
	X  }
	X
	X  Close_all_attr(LINK);   /* Echt nodig ? */
	X  putc('}', strip);
	X
	X  Jump_in_file(&wpd, 4L);
	X
	X  LINK->depth = 0;
	X  Open_all_attr(LINK);
	X
	X}
	X
	X
	X
	XLocal Void Header_Footer(LINK)
	Xstruct LOC_Convert_first_strike *LINK;
	X{
	X  uchar subfunc, occurance;
	X  unsigned short len_of_code;
	X  long end_of_code;
	X
	X  boolean hf_left, hf_center, hf_right;
	X
	X  short j;
	X
	X  fread(&subfunc, sizeof(uchar), 1, wpd);
	X  Rd_word(&wpd, &len_of_code);
	X
	X  if (len_of_code <= 22) {
	X    Jump_in_file(&wpd, (long)len_of_code);
	X    return;
	X  }
	X
	X
	X  end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
	X
	X  Jump_in_file(&wpd, 7L);
	X
	X  fread(&occurance, sizeof(uchar), 1, wpd);
	X
	X  Jump_in_file(&wpd, 10L);
	X
	X  Close_all_attr(LINK);
	X  LINK->depth = 1;
	X
	X  /* Geen schone attr._lei; Kopieer attributen uit Niveau 0;  Fout in WP 5.0 ? */
	X
	X  for (j = 0; j <= 15; j++)
	X    LINK->attr_rij[1][j] = LINK->attr_rij[0][j];
	X
	X  LINK->leegptr[1] = LINK->leegptr[0];
	X  LINK->openptr[1] = LINK->openptr[0];
	X
	X  switch (subfunc) {
	X
	X  case 0:
	X  case 1:
	X    fprintf(strip, "\\headtext");
	X    break;
	X
	X  case 2:
	X  case 3:
	X    fprintf(strip, "\\foottext");
	X    break;
	X  }
	X
	X  switch (occurance) {
	X
	X  case 0:
	X    fprintf(strip, "{\\neverpages}{");
	X    break;
	X
	X  case 1:
	X    fprintf(strip, "{\\allpages}{");
	X    break;
	X
	X  case 2:
	X    fprintf(strip, "{\\oddpages}{");
	X    break;
	X
	X  case 3:
	X    fprintf(strip, "{\\evenpages}{");
	X    break;
	X  }
	X
	X  Open_all_attr(LINK);
	X  hf_left = true;   /* Beginnen met de linkerkant */
	X  hf_center = false;
	X  hf_right = false;
	X
	X  while (ftell(wpd) / sizeof(uchar) < end_of_code) {
	X    fread(&LINK->by, sizeof(uchar), 1, wpd);
	X
	X    switch (LINK->by) {
	X
	X    case 0xc1:
	X      fread(&LINK->by, sizeof(uchar), 1, wpd);
	X      LINK->by &= 0xe0;
	X      Jump_in_file(&wpd, 7L);
	X
	X      if (LINK->by == 0xe0) {
	X	if (hf_left) {
	X	  Close_all_attr(LINK);
	X	  fprintf(strip, "}{");
	X	  Open_all_attr(LINK);
	X
	X	  hf_left = false;
	X	  hf_center = true;
	X	}
	X      }
	X
	X      if (LINK->by == 0x60) {
	X	if (hf_left) {
	X	  Close_all_attr(LINK);
	X	  fprintf(strip, "}{}{");
	X	  Open_all_attr(LINK);
	X
	X	  hf_left = false;
	X	  hf_right = true;
	X	}
	X
	X	if (hf_center) {
	X	  Close_all_attr(LINK);
	X	  fprintf(strip, "}{");
	X	  Open_all_attr(LINK);
	X
	X	  hf_center = false;
	X	  hf_right = true;
	X	}
	X      }
	X      break;
	X
	X    case 0xc3:
	X      Attr_ON(LINK);
	X      break;
	X
	X    case 0xc4:
	X      Attr_OFF(LINK);
	X      break;
	X
	X    default:
	X      if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
	X	  LINK->by == 0xc0)
	X	Character(LINK);
	X      else if (LINK->by <= 0xbf)
	X	Nop80(LINK);
	X      else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
	X	NopC0(LINK);
	X      else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
	X	NopD0(false, LINK);
	X
	X
	X      break;
	X    }
	X  }
	X
	X  Close_all_attr(LINK);   /* Echt nodig ? */
	X
	X  Jump_in_file(&wpd, 4L);
	X
	X  if (hf_left)
	X    fprintf(strip, "}{}{}");
	X  if (hf_center)
	X    fprintf(strip, "}{}");
	X  if (hf_right)
	X    putc('}', strip);
	X
	X  LINK->depth = 0;
	X  Open_all_attr(LINK);
	X
	X
	X
	X}
	X
	X
	X/*---SLAG1----*/
	X
	XStatic Void Convert_first_strike()
	X{
	X  /* Dit is de komplete procedure van de eerste slag met zijn eigen proc.'s. */
	X  struct LOC_Convert_first_strike V;
	X
	X  short convperc;
	X
	X  long srtdocpos, fsize;
	X
	X
	X  Table_Init(&V);
	X  Ext_chr_init(&V);
	X
	X  Reset_attr_rij(0, &V);
	X  Reset_attr_rij(1, &V);
	X  V.depth = 0;
	X
	X  WP_Default(&V);
	X
	X  V.latex_tabpos = 0;
	X  V.right_tab = false;
	X  V.align_tab = false;
	X  V.center_tab = false;
	X
	X  V.indenting = false;
	X  V.indent_end = false;
	X  V.ind_text1 = false;
	X  V.ind_text2 = false;
	X  V.ind_leftmargin = 0;
	X  V.ind_rightmargin = 0;
	X
	X  V.envir = ' ';
	X
	X  V.nomore_valid_tabs = false;
	X
	X  printf("First strike :\n");
	X#ifndef sun
	X  printf("Converting-percentage :     ");
	X#endif
	X
	X  srtdocpos = ftell(wpd) / sizeof(uchar);
	X  fsize = P_maxpos(wpd) / sizeof(uchar) + 1;
	X
	X  V.regelnum = 0;
	X
	X  Make_tabelentry_attr(&V);   /* attribuut instelling */
	X
	X  Make_tabelentry_tabset(&V);   /* Geef de defaulttabinstelling door */
	X  /* aan de 2e slag */
	X
	X  while (ftell(wpd) / sizeof(uchar) < fsize-2) {
	X#ifndef sun
	X    convperc = (long)floor((double)(ftell(wpd) / sizeof(uchar) - srtdocpos) /
	X			   (fsize - srtdocpos) * 100 + 0.5);
	X    printf("\b\b\b\b%3d%%", convperc);
	X#endif
	X
	X    fread(&V.by, sizeof(uchar), 1, wpd);
	X
	X    switch (V.by) {
	X
	X    case 0xa:
	X    case 0xd:
	X    case 0xb:
	X    case 0xc:
	X    case 0x8c:
	X      Return_Page(&V);
	X      break;
	X
	X    case 0xc1:
	X      fread(&V.by, sizeof(uchar), 1, wpd);
	X      V.by &= 0xe8;
	X
	X      switch (V.by) {
	X
	X      case 0:
	X      case 0xc8:
	X      case 0x48:
	X      case 0x40:
	X	Tab(&V);
	X	break;
	X
	X      case 0x60:
	X	Flush_right_tab(&V);
	X	break;
	X
	X      case 0xe0:
	X	Center(&V);
	X	break;
	X
	X      default:
	X	Jump_in_file(&wpd, 7L);
	X	break;
	X      }
	X      break;
	X
	X    case 0x81:
	X    case 0x82:
	X      Make_tabelentry_rightjustification(&V);
	X      break;
	X
	X    case 0x83:
	X      End_Align(&V);
	X      break;
	X
	X    case 0xc3:
	X      Attr_ON(&V);
	X      break;
	X
	X    case 0xc4:
	X      Attr_OFF(&V);
	X      break;
	X
	X    case 0xc2:
	X      Indent(&V);
	X      break;
	X
	X    case 0xc6:
	X      End_of_indent(&V);
	X      break;
	X
	X    case 0xc5:
	X    case 0xc7:
	X      NopC0(&V);
	X      break;
	X
	X    case 0xd0:
	X      fread(&V.by, sizeof(uchar), 1, wpd);
	X      switch (V.by) {
	X
	X      case 0x4:
	X	Tabset(&V);
	X	break;
	X
	X      case 0x8:
	X	Page_number_position(&V);
	X	break;
	X
	X      default:
	X	NopD0(true, &V);
	X	break;
	X      }
	X      break;
	X
	X    case 0xd5:
	X      Header_Footer(&V);
	X      break;
	X
	X    case 0xd6:
	X      fread(&V.by, sizeof(uchar), 1, wpd);
	X      switch (V.by) {
	X
	X      case 0:
	X	Footnote(&V);
	X	break;
	X
	X      default:
	X	NopD0(true, &V);
	X	break;
	X      }
	X      break;
	X
	X    case 0xd8:
	X      fread(&V.by, sizeof(uchar), 1, wpd);
	X      switch (V.by) {
	X
	X      case 0x2:
	X	Overstrike(&V);
	X	break;
	X
	X      default:
	X	NopD0(true, &V);
	X	break;
	X      }
	X      break;
	X
	X    default:
	X      if (V.by >= 0x20 && V.by <= 0x7f || V.by == 0xa9 || V.by == 0xc0) {
	X	V.char_on_line = true;   /*Er (al) is een karakter op deze regel */
	X	if (V.indenting) {   /*Als er is ingeprongen er na een stuk */
	X	  if (V.ind_text1)   /*tekst is weer ingesprongen (ind_text1) */
	X	    V.ind_text2 = true;
	X	}
	X	/*dan hoort dit char bij het ind_txt-blok */
	X
	X	Character(&V);
	X      } else if (V.by <= 0x1f || V.by >= 0x80 && V.by <= 0xbf)
	X	Nop80(&V);
	X      else if (V.by >= 0xd0 && V.by <= 0xff)
	X	NopD0(false, &V);
	X
	X      break;
	X    }
	X  }
	X
	X  putchar('\n');
	X  Make_tabelentry_envir_extra_end(&V);
	X
	X  num_of_lines_stripfile = V.regelnum;
	X
	X
	X
	X
	X}
	X
	X
	X/* Local variables for Convert_second_strike: */
	Xstruct LOC_Convert_second_strike {
	X  boolean just_envir_closed;
	X
	X  short num_of_tabs;
	X  unsigned short tabpos[40];
	X
	X  short tabent_num_of_tabs[3];
	X  unsigned short tabent_tabpos[3][40];
	X
	X  unsigned short ind_leftmargin[3], ind_rightmargin[3];
	X  uchar ind_label[3];
	X
	X  short pre, cur, next;
	X
	X  Char envir[3], line_term[3];
	X  boolean new_tabset[3];
	X  boolean new_rightjust;
	X  boolean new_tabent_rightjust[3], tabent_rightjust[3];
	X
	X  short num_of_attr[3];
	X  uchar attr_BOL[3][0x11];
	X  boolean attr_closed;
	X} ;
	X
	X
	X
	XLocal Void Read_tabelentry(n, LINK)
	Xshort n;
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  unsigned short w;
	X  uchar b;
	X  short j, FORLIM;
	X
	X  /* Begin met een schone lei die dan door deze procedure verder wordt */
	X  /* opgevuld. */
	X
	X  LINK->envir[n] = ' ';
	X  LINK->new_tabset[n] = false;
	X  LINK->new_tabent_rightjust[n] = false;
	X
	X  LINK->num_of_attr[n] = 0;
	X  for (j = 1; j <= 16; j++)
	X    LINK->attr_BOL[n][j] = 0;
	X
	X  if (ftell(tabel) / sizeof(uchar) > P_maxpos(tabel) / sizeof(uchar))
	X    return;
	X
	X
	X  /* Er is geen volgende tabelentry dus ook geen volgende regel */
	X  /* De tabelentry is 'schoon'.                                 */
	X  /* Zodat het document 'schoon' wordt afgesloten.              */
	X
	X  fread(&b, sizeof(uchar), 1, tabel);
	X  LINK->num_of_attr[n] = b;
	X  FORLIM = LINK->num_of_attr[n];
	X  for (j = 1; j <= FORLIM; j++)
	X    fread(&LINK->attr_BOL[n][j], sizeof(uchar), 1, tabel);
	X
	X  b = 0;
	X  while ((b != 0xff) && !feof(tabel)) {
	X    fread(&b, sizeof(uchar), 1, tabel);
	X
	X    switch (b) {   /*Case*/
	X
	X    case 'C':
	X      LINK->envir[n] = 'C';
	X      break;
	X
	X    case 'T':
	X      LINK->envir[n] = 'T';
	X      break;
	X
	X    case 'I':
	X      LINK->envir[n] = 'I';
	X      Rd_word(&tabel, &LINK->ind_leftmargin[n]);
	X      Rd_word(&tabel, &LINK->ind_rightmargin[n]);
	X      fread(&LINK->ind_label[n], sizeof(uchar), 1, tabel);
	X      break;
	X
	X    case 'S':
	X      LINK->new_tabset[n] = true;
	X      fread(&b, sizeof(uchar), 1, tabel);
	X      LINK->tabent_num_of_tabs[n] = b;
	X
	X      FORLIM = LINK->tabent_num_of_tabs[n];
	X      for (j = 0; j < FORLIM; j++) {
	X	Rd_word(&tabel, &w);
	X	LINK->tabent_tabpos[n][j] = w;
	X      }
	X      break;
	X
	X    case 'U':
	X      LINK->new_tabent_rightjust[n] = true;
	X      fread(&b, sizeof(uchar), 1, tabel);
	X      if (b == 0)
	X	LINK->tabent_rightjust[n] = false;
	X      else
	X	LINK->tabent_rightjust[n] = true;
	X      break;
	X
	X    case 'R':
	X    case 'r':
	X    case 'P':
	X    case 'p':
	X      LINK->line_term[n] = b;
	X      break;
	X
	X    }
	X  }
	X}
	X
	X
	X
	XLocal Void Open_all_attr_BOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Open alle commando's door de Attributen-rij af te lopen -- */
	X  short j, FORLIM;
	X
	X  FORLIM = LINK->num_of_attr[LINK->cur];
	X  for (j = 0x1; j <= FORLIM; j++)
	X    fputs(open_com[LINK->attr_BOL[LINK->cur][j]], latex);
	X
	X  LINK->attr_closed = false;
	X}
	X
	X
	XLocal Void Close_all_attr_BOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
	X  short j;
	X
	X  for (j = LINK->num_of_attr[LINK->cur]; j >= 0x1; j--)
	X    fputs(close_com[LINK->attr_BOL[LINK->cur][j]], latex);
	X
	X  LINK->attr_closed = true;
	X}
	X
	X
	X
	XLocal Void Open_all_attr_EOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Open alle commando's door de Attributen-rij af te lopen -- */
	X  short j, FORLIM;
	X
	X  FORLIM = LINK->num_of_attr[LINK->next];
	X  for (j = 0x1; j <= FORLIM; j++)
	X    fputs(open_com[LINK->attr_BOL[LINK->next][j]], latex);
	X
	X  LINK->attr_closed = false;
	X}
	X
	X
	X
	XLocal Void Close_all_attr_EOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
	X  short j;
	X
	X  for (j = LINK->num_of_attr[LINK->next]; j >= 0x1; j--)
	X    fputs(close_com[LINK->attr_BOL[LINK->next][j]], latex);
	X
	X  LINK->attr_closed = true;
	X}
	X
	X
	X
	XLocal Void Latex_head(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Maak het de standard-heading voor een latex-file aan -- */
	X  fprintf(latex, "\\documentstyle[11pt,wp2latex]{report}\n");
	X  fprintf(latex, "\\begin{document}\n");
	X}
	X
	X
	X
	XLocal Void Latex_foot(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  /* -- Sluit de latex-file op de juiste wijze af -- */
	X  fprintf(latex, "\\end{document}\n");
	X}
	X
	X
	X
	XLocal Void Latex_tabset(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  short atpr, j;
	X  double l, ol;
	X  short FORLIM;
	X
	X  atpr = 0;   /* Huiding aantal tabs per regel */
	X  ol = 0.0;
	X  FORLIM = LINK->num_of_tabs;
	X  for (j = 0; j < FORLIM; j++) {
	X    l = LINK->tabpos[j] / 1200.0 * 2.54;
	X    fprintf(latex, "\\hspace{%3.2fcm}\\=", l - ol);
	X    atpr++;
	X    if (atpr >= 4) {
	X      fprintf(latex, "%%\n");
	X      atpr = 0;
	X    }
	X    ol = l;
	X  }
	X  fprintf(latex, "\\kill\n");
	X}
	X
	X
	X
	XLocal boolean Change_envir_BOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  boolean hulp;
	X
	X  hulp = false;
	X
	X  hulp = (LINK->envir[LINK->cur] == 'C' && LINK->envir[LINK->pre] != 'C' ||
	X	  hulp);
	X  hulp = (LINK->envir[LINK->cur] == 'T' && LINK->envir[LINK->pre] != 'T' ||
	X	  hulp);
	X  hulp = (LINK->envir[LINK->cur] == 'I' && LINK->envir[LINK->pre] != 'I' ||
	X	  hulp);
	X
	X  return hulp;
	X}
	X
	X
	X
	XLocal boolean Change_envir_EOL(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  boolean hulp;
	X
	X  hulp = false;
	X
	X  hulp = (((LINK->envir[LINK->next] == 'C') ^ (LINK->envir[LINK->cur] == 'C')) ||
	X	  hulp);
	X  hulp = (((LINK->envir[LINK->next] == 'T') ^ (LINK->envir[LINK->cur] == 'T')) ||
	X	  hulp);
	X  hulp = (((LINK->envir[LINK->next] == 'I') ^ (LINK->envir[LINK->cur] == 'I')) ||
	X	  hulp);
	X
	X  return hulp;
	X}
	X
	X
	X
	X
	XLocal Void Open_environment(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  if (!Change_envir_BOL(LINK)) {   /* andere environment ? */
	X    if (LINK->new_tabset[LINK->cur] && LINK->envir[LINK->cur] == 'T')
	X      Latex_tabset(LINK);
	X    return;
	X  }
	X
	X
	X  if (!LINK->attr_closed)
	X    Close_all_attr_BOL(LINK);
	X
	X  switch (LINK->envir[LINK->cur]) {
	X
	X  case 'C':
	X    fprintf(latex, "\\begin{center}\n");
	X    break;
	X
	X  case 'T':
	X    fprintf(latex, "\\begin{tabbing}\n");
	X    Latex_tabset(LINK);
	X    break;
	X
	X  case 'I':
	X    fprintf(latex, "\\begin{indenting}");
	X    fprintf(latex, "{%3.2fcm}",
	X	    LINK->ind_leftmargin[LINK->cur] / 1200.0 * 2.54);
	X    fprintf(latex, "{%3.2fcm}",
	X	    LINK->ind_rightmargin[LINK->cur] / 1200.0 * 2.54);
	X    if (LINK->ind_label[LINK->cur] == 1) {
	X      fprintf(latex, "%%\n");
	X      putc('{', latex);
	X    } else
	X      fprintf(latex, "{}\n");
	X    break;
	X  }
	X
	X}
	X
	X
	X
	XLocal Void Close_environment(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  switch (LINK->envir[LINK->cur]) {
	X
	X  case 'C':
	X    fprintf(latex, "\\end{center}\n");
	X    break;
	X
	X  case 'T':
	X    fprintf(latex, "\\end{tabbing}\n");
	X    break;
	X
	X  case 'I':
	X    fprintf(latex, "\\end{indenting}\n");
	X    break;
	X  }
	X
	X  LINK->just_envir_closed = true;
	X
	X}
	X
	X
	X
	XLocal Void Update_global_information(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  short j, FORLIM;
	X
	X  if (LINK->new_tabset[LINK->cur]) {
	X    LINK->num_of_tabs = LINK->tabent_num_of_tabs[LINK->cur];
	X    FORLIM = LINK->num_of_tabs;
	X    for (j = 0; j < FORLIM; j++)
	X      LINK->tabpos[j] = LINK->tabent_tabpos[LINK->cur][j];
	X  }
	X
	X  if (LINK->new_tabent_rightjust[LINK->cur])
	X    LINK->new_rightjust = LINK->tabent_rightjust[LINK->cur];
	X
	X}
	X
	X
	XLocal Void Change_tabelentry(LINK)
	Xstruct LOC_Convert_second_strike *LINK;
	X{
	X  short help;
	X
	X  help = LINK->pre;
	X  LINK->pre = LINK->cur;
	X  LINK->cur = LINK->next;
	X  LINK->next = help;
	X  Read_tabelentry(LINK->next, LINK);
	X}
	X
	X
	X/*---SLAG2---*/
	X
	XStatic Void Convert_second_strike()
	X{
	X  struct LOC_Convert_second_strike V;
	X  unsigned short regelnum;
	X  short convperc;
	X
	X  boolean underline;
	X
	X  short i;
	X
	X  Char regel[256], hulp_regel[256];
	X  short len_reg;
	X
	X  boolean rightjust;
	X  Char STR3[256];
	X  Char *TEMP;
	X
	X
	X  V.pre = 0;
	X  V.cur = 1;
	X  V.next = 2;
	X
	X  V.envir[V.pre] = ' ';
	X  V.new_tabset[V.pre] = false;
	X
	X  V.just_envir_closed = true;
	X  V.attr_closed = false;
	X
	X  rightjust = true;
	X  V.new_rightjust = true;
	X  for (i = 0; i <= 2; i++) {
	X    V.new_tabent_rightjust[i] = false;
	X    V.tabent_rightjust[i] = false;
	X  }
	X
	X  Read_tabelentry(V.cur, &V);
	X  Read_tabelentry(V.next, &V);
	X
	X  regelnum = 1;
	X
	X  printf("\nSecond strike :\n");
	X#ifndef sun
	X  printf("Converting-percentage :     ");
	X#endif
	X
	X
	X
	X  Latex_head(&V);
	X
	X  while (!P_eof(strip)) {
	X    Update_global_information(&V);
	X
	X#ifndef sun
	X    convperc = (long)floor(regelnum * 100.0 / num_of_lines_stripfile + 0.5);
	X    if (convperc > 100)
	X      convperc = 100;
	X    printf("\b\b\b\b%3d%%", convperc);
	X#endif
	X
	X    fgets(regel, 256, strip);
	X    TEMP = (char *)strchr(regel, '\n');
	X    if (TEMP != NULL)
	X      *TEMP = 0;
	X
	X    /* Werk eventueel de regel bij d.m.v. een hulp regel. */
	X
	X    strcpy(hulp_regel, regel);
	X    len_reg = strlen(hulp_regel);
	X
	X    /* Meerdere spaties achter elkaar vervangen door harde spaties. */
	X
	X    for (i = 1; i < len_reg; i++) {
	X      if (regel[i - 1] == ' ' && regel[i] == ' ')
	X	hulp_regel[i] = '~';
	X    }
	X
	X    /* Zoek naar een illegaal argument en zet hier accolades voor. */
	X
	X    if (len_reg >= 1 && hulp_regel[0] == '[' ||
	X	len_reg >= 2 && hulp_regel[0] == ' ' && hulp_regel[1] == '[')
	X      sprintf(hulp_regel, "{}%s", strcpy(STR3, hulp_regel));
	X
	X    /* De regel is verwerkt. */
	X
	X    strcpy(regel, hulp_regel);
	X    len_reg = strlen(regel);
	X
	X    if (V.new_rightjust ^ rightjust) {
	X      rightjust = V.new_rightjust;
	X      if (rightjust)
	X	fprintf(latex, "\\justified\n");
	X      else
	X	fprintf(latex, "\\raggedright\n");
	X    }
	X
	X    Open_environment(&V);
	X
	X    if (len_reg > 0) {
	X      if (V.attr_closed)
	X	Open_all_attr_BOL(&V);
	X
	X      fputs(regel, latex);
	X
	X      V.just_envir_closed = false;
	X    }
	X
	X    switch (V.line_term[V.cur]) {   /*Case*/
	X
	X    case 'r':
	X    case 'p':
	X	  fputc('\n', latex);
	X      if (Change_envir_EOL(&V)) {
	X	     if (!V.attr_closed) {
	X	       Close_all_attr_EOL(&V);
	X		 }
	X
	X	     Close_environment(&V);
	X      }
	X      break;
	X
	X    case 'R':
	X      if (V.envir[V.cur] == 'I') {
	X	if (!V.attr_closed)
	X	  Close_all_attr_EOL(&V);
	X
	X	putc('\n', latex);
	X	Close_environment(&V);
	X	V.envir[V.cur] = ' ';
	X      } else {
	X	underline = false;
	X	for (i = 0x1; i <= 0x10; i++)
	X	  underline = (underline || V.attr_BOL[V.next][i] == 0xb ||
	X		       V.attr_BOL[V.next][i] == 0xe);
	X
	X	if (underline && !V.attr_closed)
	X	  Close_all_attr_EOL(&V);
	X
	X	/* Elke Indent-environment moet na een harde Return*/
	X	/* Afgesloten worden.*/
	X
	X
	X	if (Change_envir_EOL(&V)) {
	X	  if (V.just_envir_closed)
	X	    fprintf(latex, "\\nwln\n");
	X	  else
	X	    putc('\n', latex);
	X
	X	  if (!V.attr_closed)
	X	    Close_all_attr_EOL(&V);
	X
	X	  Close_environment(&V);
	X	} else {
	X	  if (V.just_envir_closed)
	X	    fprintf(latex, "\\nwln\n");
	X	  else
	X	    fprintf(latex, "\\\\\n");
	X	}
	X      }
	X
	X      break;
	X
	X
	X    case 'P':
	X      if (!V.attr_closed)
	X	Close_all_attr_EOL(&V);
	X
	X      putc('\n', latex);
	X      Close_environment(&V);
	X      fprintf(latex, "\\newpage\n");
	X      V.envir[V.cur] = ' ';
	X      break;
	X
	X    }
	X
	X
	X
	X    Change_tabelentry(&V);
	X
	X    regelnum++;
	X  }
	X
	X  Latex_foot(&V);
	X  putchar('\n');
	X}
	X
	X/*---HOOFDPROG---*/
	X
	Xmain(argc, argv)
	Xint argc;
	XChar *argv[];
	X{
	X
	X  PASCAL_MAIN(argc, argv);
	X  latex = NULL;
	X  strip = NULL;
	X  tabel = NULL;
	X  wpd = NULL;
	X
	X  Init_commando();
	X
	X  /* ClrScr(); */
	X  putchar(0xc);
	X  printf("\n     Conversion program : From Wordperfect 5.1 to LaTeX  (wp2latex)\n\n");
	X  printf("  (c) TUE-Eindhoven ---- Written by R.C.Houtepen ---- Date : 24 Jan 1990\n");
	X  printf("      Translated into C by G. Geers ---- Date : 2 Aug 1990\n");
	X
	X  Filenames();
	X
	X  if (wpd != NULL)
	X    wpd = freopen(wpd_NAME, "r+b", wpd);
	X  else
	X    wpd = fopen(wpd_NAME, "r+b");
	X  if (wpd == NULL)
	X    _EscIO(FileNotFound);
	X  Wpd_check();
	X
	X  if (strip != NULL)
	X    strip = freopen(strip_NAME, "w", strip);
	X  else
	X    strip = fopen(strip_NAME, "w");
	X  if (strip == NULL)
	X    _EscIO(FileNotFound);
	X  if (tabel != NULL)
	X    tabel = freopen(tabel_NAME, "w+b", tabel);
	X  else
	X    tabel = fopen(tabel_NAME, "w+b");
	X  if (tabel == NULL)
	X    _EscIO(FileNotFound);
	X
	X  printf("Converting ...\n\n");
	X
	X  Convert_first_strike();
	X
	X  if (wpd != NULL)
	X    fclose(wpd);
	X  wpd = NULL;
	X  if (strip != NULL)
	X    fclose(strip);
	X  strip = NULL;
	X  if (tabel != NULL)
	X    fclose(tabel);
	X  tabel = NULL;
	X
	X  if (strip != NULL)
	X    strip = freopen(strip_NAME, "r", strip);
	X  else
	X    strip = fopen(strip_NAME, "r");
	X  if (strip == NULL)
	X    _EscIO(FileNotFound);
	X  if (tabel != NULL)
	X    tabel = freopen(tabel_NAME, "r+b", tabel);
	X  else
	X    tabel = fopen(tabel_NAME, "r+b");
	X  if (tabel == NULL)
	X    _EscIO(FileNotFound);
	X  if (latex != NULL)
	X    latex = freopen(latex_NAME, "w", latex);
	X  else
	X    latex = fopen(latex_NAME, "w");
	X  if (latex == NULL)
	X    _EscIO(FileNotFound);
	X
	X  Convert_second_strike();
	X
	X  if (wpd != NULL)
	X    fclose(wpd);
	X  if (latex != NULL)
	X    fclose(latex);
	X
	X/*
	X** Delete auxillary files
	X*/
	X  if (strip != NULL)
	X    unlink(strip_fn);
	X  if (tabel != NULL)
	X    unlink(tabel_fn);
	X
	X  printf("\nConversion completed.\n");
	X  exit(0);
	X}
	X/* End. */
	X
	X/*
	X** Extras - hand coded 
	X*/
	X
	XStatic Void
	XRunError(errcode)
	Xint errcode;
	X{
	X	switch (errcode) {
	X		case 0x201:
	X			fprintf(stderr, "Not a WordPerfect 5.1 document !\n");
	X			break;
	X		case 0x200:
	X			fprintf(stderr, "No filename entered !\n");
	X			break;
	X		case 0x100:
	X			fprintf(stderr, "Program error.\n");
	X			break;
	X		case 0x03:
	X			fprintf(stderr, "Path not found.\n");
	X			break;
	X		case 0x02:
	X			fprintf(stderr, "File not found.\n");
	X			break;
	X	}
	X	exit(errcode);
	X}
SHAR_EOF
if test 53854 -ne "`wc -c < 'wp2latex.c'`"
then
	echo shar: "error transmitting 'wp2latex.c'" '(should have been 53854 characters)'
fi
fi
exit 0
#	End of shell archive
--
Glenn Geers                       | "So when it's over, we're back to people.
Department of Theoretical Physics |  Just to prove that human touch can have
The University of Sydney          |  no equal."
Sydney NSW 2006 Australia         |  - Basia Trzetrzelewska, 'Prime Time TV'



More information about the Alt.sources mailing list