
Notes for MsDOS
---------------

For a number of reasons, entering a mawk program on the command line 
using command.com as your shell is an exercise in futility, so under 
MsDOS the command syntax is 

	mawk [-Fs] optional_list_of_files

You'll get a prompt, and then type in the program.  The -f option works 
as before.  

If you use a DOS shell that gives you a Unix style command line, to use 
it you'll need to provide a C function reargv() that retrieves argc and 
argv[] from your shell.

Some features are missing from the DOS version of mawk: No system(), and
no input or output pipes.  To provide a hook to stderr, I've added 

	errmsg( "string" )

which prints "string\n" to stderr which will be the console and only the
console under command.com.  A better solution would be to associate a 
file with handle 2, so print and printf would be available.  Consider 
the errmsg() feature as temporary.  

For compatibility with Unix, CR are silently stripped from input and LF 
silently become CRLF on output.  

WARNING: If you write an infinite loop that does not print to the 
screen, then you will have to reboot.  For example 

	x = 1 
	while( x < 10 )  A[x] = x
	x++

By mistake the x++ is outside the loop.  What you need to do is type 
control break and the keyboard hardware will generate an interrupt and 
the operating system will service that interrupt and terminate your 
program, but unfortunately MsDOS does not have such a feature.  


how to make mawk under MsDOS
---------------------------

I've provided four .bat files that make mawk with TurboC.
An anonymous reviewer provided a makefile that works with
MSC 6.0A and nmake.

Assuming you keep the same directory structure:


1)  If you want a Unix style command line for mawk, you'll need to
    write a function called reargv(int *, char ***) which passes
    mawk the modified argc and argv via reargv(&argc,&argv).
    Put it in a file called reargv.c

    The supplied reargv.c works with POLYSHELL by Polytron; for a
    different shell you could use it as an example.
    (I've looked at the MKS documentation and writing reargv() for
     MKS ksh would be easy.  (contributions welcome)).

2)  Using TurboC++
   small.bat -- makes small model without reargv
   vsmall.bat -- makes small model with reargv
   large.bat -- makes large model without reargv
   vlarge.bat -- makes large model with reargv

   You need to replace the LIB in the tlink command with the
   directory that holds your C library. 

   move the .bat file to mawk directory and run it.

3) Using MSC , move Makefile.MSC to mawk directory and
   run nmake -- makes both small and large model

4)  YACC --
Take some care that you don't trash parse.[ch] unless you're
sure you want to remake them.
(If using a make, also check that the date of parse.c is
newer than parse.y or parse2.xc)
If you don't change parse.y, the parse.c and parse.h provided
were made with Berkeley yacc and can be redistributed and you
don't need a yacc.  The executables look bigger than before,
but I reuse the parser table memory which returns 15K to the
mem pool.

5)  Large model DOS has been built and tested with this code.
Compiled with TurboC its about 33% slower.  I use two mawk's,
a small model called mawk and a large model called bmawk.
For real work I hardly ever need bmawk.

6)  The same test suite that is run on mawk under Unix can now
be run under DOS.  The same anonymous reviewer wrote  batch
files mawk_tes.bat and fpe_test.bat.  To use them copy or move
all the files in msdos/dostest to mawk/test.

==================================================================

The reason system() and pipes are missing is I haven't decided
entirely how to handle the runaway loop problem.  Dos makes
asynchronous termination of a program difficult, because DOS
itself might not be able to handle exit().

Hooking int 0x1a forces me to deal with cleanup and makes ^C
a pain.  What is the effect of my 0x1a on children? (That's why
no system() or pipes yet).  What do I have to check after a child
terminates, children can muck up the state of the parent process.


I have used mawk as is on DOS for about 6 months, what's missing
I rarely use  except to emit error messages and I use
errmsg() for that.  If I stall about fixing this stuff, DOS
might go away and I'll never have to deal with it.

Note added 8/8/91 -- I'll probably never fix the runaway loop stuff
and ignore the fact that children can damage the parent under DOS.
Then system and pipes are easy -- someone should do it.

Note added 9/12/91 -- It's not easy to stay within 64K and add
system() and pipes().  In the next release of mawk, I'll do it.
