%%%  WEB Change File for MFT (Win32 version)
%%%  Time-stamp: "97/01/03 18:14:44 mik"
%%%
%%%  Copyright (C) 1991, 92, 93, 94, 95, 96, 97
%%%	Christian Schenk  <cschenk@berlin.snafu.de>
%%%
%%%  This file is part of MiKTeX.
%%%
%%%  MiKTeX 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, or (at
%%%  your option) any later version.
%%%  
%%%  MiKTeX 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.
%%%  
%%%  You should have received a copy of the GNU General Public License
%%%  along with MiKTeX; if not, write to the Free Software
%%%  Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
%%%  USA.

@x
\def\title{MFT}
@y
\def\MiKTeX{MiK\TeX}
\def\title{MFT for Win32 (\MiKTeX\ 1.06)}
@z

%% **     3  ******************************************************************

@x
@d end_of_MFT = 9999 {go here to wrap it up}
@y
@d end_of_MFT = 9999 {go here to wrap it up}
@d goto_end_of_MFT==c4p_longjmp(jump_env, 1)
@z

@x
@<Error handling procedures@>@/
procedure initialize;
@y
@<Error handling procedures@>@/
@<External C routines@>@/
procedure initialize;
@z

%% **     14  ******************************************************************

@x
@d text_char == char {the data type of characters in text files}
@d first_text_char=0 {ordinal number of the smallest element of |text_char|}
@d last_text_char=255 {ordinal number of the largest element of |text_char|}
@y
@d text_char == char {the data type of characters in text files}
@d first_text_char=-128 {ordinal number of the smallest element of |text_char|}
@d last_text_char=127 {ordinal number of the largest element of |text_char|}
@z

%% **     21  ******************************************************************

@x
@ Different systems have different ways of specifying that the output on a
certain file will appear on the user's terminal. Here is one way to do this
on the \PASCAL\ system that was used in \.{WEAVE}'s initial development:
@^system dependencies@>

@<Set init...@>=
rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
@y
@ Different systems have different ways of specifying that the output on a
certain file will appear on the user's terminal.
@^system dependencies@>

@<Set init...@>=

term_out:=output; {send |term_out| output to the terminal}
@z

%% **     24  ******************************************************************

@x
@ The following code opens the input files.  Since these files were listed
in the program header, we assume that the \PASCAL\ runtime system has
already checked that suitable file names have been given; therefore no
additional error checking needs to be done.
@^system dependencies@>

@p procedure open_input; {prepare to read the inputs}
begin reset(mf_file); reset(change_file); reset(style_file);
end;

@ The main output goes to |tex_file|.

@<Globals...@>=
@!tex_file: text_file;

@ The following code opens |tex_file|.
Since this file was listed in the program header, we assume that the
\PASCAL\ runtime system has checked that a suitable external file name has
been given.
@^system dependencies@>

@<Set init...@>=
rewrite(tex_file);
@y
@ The following code opens the input files.
@^system dependencies@>

@p procedure open_input; {prepare to read the inputs}
begin
if c4p_argc <> 5 then
      fatal_error ('Usage: mft inputfile changefile stylefile outputfile');
c4p_fopen(mf_file, c4p_argv[1], c4p_r_mode, true);
c4p_fopen(change_file, c4p_argv[2], c4p_r_mode, true);
c4p_fopen(style_file, c4p_argv[3], c4p_r_mode, true);
reset(mf_file); reset(change_file); reset(style_file);
end;

@ The main output goes to |tex_file|.

@<Globals...@>=
@!tex_file: text_file;

@ The following code opens |tex_file|.
@^system dependencies@>

@<Set init...@>=
if c4p_argc <> 5 then
      fatal_error ('Usage: mft inputfile changefile stylefile outputfile');
c4p_fopen(tex_file, c4p_argv[4], c4p_w_mode, true);
@z

%% **    31  ******************************************************************

@x
begin goto end_of_MFT;
@y
begin goto_end_of_MFT;
@z

%% **    112  ******************************************************************

@x
@p begin initialize; {beginning of the main program}
print_ln(banner); {print a ``banner line''}
@<Store all the primitives@>;
@<Store all the translations@>;
@<Initialize the input...@>;
do_the_translation;
@<Check that all changes have been read@>;
end_of_MFT:{here files should be closed if the operating system requires it}
@<Print the job |history|@>;
end.
@y
@p begin initialize; {beginning of the main program}
if (c4p_setjmp(jump_env) <> 0) then goto end_of_MFT;
print(banner); miktex_banner(output); write_ln; {print a ``banner line''}
@<Store all the primitives@>;
@<Store all the translations@>;
@<Initialize the input...@>;
do_the_translation;
@<Check that all changes have been read@>;
end_of_MFT:{here files should be closed if the operating system requires it}
@<Print the job |history|@>;
end.
@z

%% **   113  ******************************************************************

@x
@ Some implementations may wish to pass the |history| value to the
operating system so that it can be used to govern whether or not other
programs are started. Here we simply report the history to the user.
@^system dependencies@>

@<Print the job |history|@>=
case history of
spotless: print_nl('(No errors were found.)');
harmless_message: print_nl('(Did you see the warning message above?)');
error_message: print_nl('(Pardon me, but I think I spotted something wrong.)');
fatal_message: print_nl('(That was a fatal error, my friend.)');
end {there are no other cases}
@y
@ We pass the |history| value to the
operating system so that it can be used to govern whether or not other
programs are started.
@^system dependencies@>

@<Print the job |history|@>=
case history of
spotless: print_nl('(No errors were found.)');
harmless_message: print_nl('(Did you see the warning message above?)');
error_message: print_nl('(Pardon me, but I think I spotted something wrong.)');
fatal_message: print_nl('(That was a fatal error, my friend.)');
end; {there are no other cases}
new_line;
c4p_exit(history);
@z

%% **   114  ******************************************************************

@x
which introduce new modules, can be inserted here; then only the index
itself will get a new module number.
@^system dependencies@>

@y
which introduce new modules, can be inserted here; then only the index
itself will get a new module number.
@^system dependencies@>

@ @<External C routines@>=
procedure miktex_banner (var f:text_file); forward;

@ @<Globals...@>=
@!jump_env : c4p_jmp_buf;
@z
