home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / mawk11as.zip / MSDOS / NOTES < prev    next >
Text File  |  1992-01-22  |  5KB  |  153 lines

  1.  
  2. Notes for MsDOS (mawk 1.1)
  3. ---------------
  4.  
  5. command.com doesn't understand ' so if you use command.com as your
  6. shell (the norm under DOS) then on the command line (and NOT from
  7. files) the meanings of " and ' are reversed.
  8.  
  9.     mawk "{ print 'hello world' }"
  10.  
  11. If this seems too weird, use
  12.  
  13.     mawk -f con
  14.     { print "hello world" }
  15.     ^Z
  16.  
  17. If you use a DOS shell that gives you a Unix style command line, to use 
  18. it you'll need to provide a C function reargv() that retrieves argc and 
  19. argv[] from your shell.
  20.  
  21. To enable system and pipes you need to tell mawk about your shell by
  22. setting the environment variable MAWKSHELL.  E.g, with command.com
  23.  
  24.       set MAWKSHELL=c:\sys\command.com /c
  25.  
  26. or with a unix like shell
  27.  
  28.       set MAWKSHELL=c:\bin\sh.exe -c
  29.  
  30. in your autoexec.bat.  The full path with drive and extension and
  31. appropriate switch is required.  (Small model is a tight squeeze
  32. and there's not enought room for PATH searching code.)
  33.  
  34. If you want to use a ram disk for the pipes, set MAWKTMPDIR.
  35.  
  36.       set MAWKTMPDIR=d:\
  37.  
  38. The trailing backslash is required.  You have to set MAWKSHELL,
  39. MAWKTMPDIR is optional -- defaulting to the current directory.
  40.  
  41. For compatibility with Unix, CR are silently stripped from input and LF 
  42. silently become CRLF on output.  Also ^Z indicates EOF on input (
  43. evidently for compatibility with CPM!!!).
  44.  
  45. CR control can be turned off, with a new variable BINMODE.
  46. BINMODE defaults to 0.
  47.  
  48.      BINMODE = 1 gives binary input.
  49.      BINMODE = 2 gives binary output.
  50.      BINMODE = 3 gives both.
  51.  
  52. Setting BINMODE with -v or in the BEGIN section affects all
  53. files, otherwise it only affects files opened after the 
  54. assignment to BINMODE.  Once a file is open, later assignment to
  55. BINMODE does not affect it.  Note that with binary output, printf
  56. will behave strangely -- you'll need to explicitly use \r
  57.  
  58.   Eg    mawk -v BINMODE=2 '{ printf "%d %s\r\n", NR, $0}'
  59.  
  60. Assignment to BINMODE does not change RS or ORS; however there is
  61. a -W feature 
  62.  
  63.    -W BINMODE=1   is the same as
  64.    -v BINMODE=1 -v RS="\r\n" or BEGIN{BINMODE=1 ; RS = "\r\n" }
  65.  
  66.    -W BINMODE=2   is the same as
  67.    -v BINMODE=2 -v ORS="\r\n" or BEGIN{BINMODE=2 ; ORS = "\r\n" }
  68.  
  69.    -W BINMODE=3  is the same as
  70.    -v BINMODE=3 -v RS=ORS="\r\n" or BEGIN{BINMODE=2 ; RS=ORS = "\r\n" }
  71.  
  72.  
  73. Setting MAWKBINMODE in the environment is the same as using -W,
  74. except its permanent.
  75. If you rarely have to deal with text files that contain ^Z,
  76. then setting MAWKBINMODE=1 in the environment would speed up input
  77. slightly.
  78.  
  79.  
  80. ----------------------------------------------------------
  81. WARNING: If you write an infinite loop that does not print to the 
  82. screen, then you will have to reboot.  For example 
  83.  
  84.     x = 1 
  85.     while( x < 10 )  A[x] = x
  86.     x++
  87.  
  88. By mistake the x++ is outside the loop.  What you need to do is type 
  89. control break and the keyboard hardware will generate an interrupt and 
  90. the operating system will service that interrupt and terminate your 
  91. program, but unfortunately MsDOS does not have such a feature.  
  92.  
  93.  
  94. how to make mawk under MsDOS
  95. ---------------------------
  96.  
  97.    Rename Makefile Makefile.unx
  98.    Move or copy msdos\dosexec.c to source directory
  99.  
  100. TurboC: Move msdos\Makefile.tcc to Makefile
  101.     copy msdos\tcc_dos.h to config.h
  102.  
  103. MSC:    Move msdos\Makefile.MSC to Makefile
  104.  
  105. Assuming you keep the same directory structure:
  106.  
  107. 1)  If you want a Unix style command line for mawk, you'll need to
  108.     write a function called reargv(int *, char ***) which passes
  109.     mawk the modified argc and argv via reargv(&argc,&argv).
  110.     Put it in a file called reargv.c
  111.  
  112.     The supplied reargv.c works with POLYSHELL by Polytron; for a
  113.     different shell you could use it as an example.
  114.     (I've looked at the MKS documentation and writing reargv() for
  115.      MKS ksh would be easy.  (contributions welcome)).
  116.  
  117. 2)  TurboC look at comments in Makefile.  Remember to remove
  118.     .obj between make of bmawk.exe and mawk.exe.
  119.  
  120.  
  121. 3) Using MSC , move Makefile.MSC to mawk directory and
  122.    run nmake -- makes both small and large model
  123.  
  124.  
  125. 4)  YACC --
  126. Take some care that you don't trash parse.[ch] unless you're
  127. sure you want to remake them.
  128. (If using a make, also check that the date of parse.c is
  129. newer than parse.y or parse2.xc)
  130. If you don't change parse.y, the parse.c and parse.h provided
  131. were made with Berkeley yacc and can be redistributed and you
  132. don't need a yacc.  The executables look bigger than before,
  133. but I reuse the parser table memory which returns 15K to the
  134. mem pool.
  135.  
  136. 5)  The same test suite that is run on mawk under Unix can now
  137. be run under DOS.  The same anonymous reviewer wrote  batch
  138. files mawktest.bat and fpe_test.bat.
  139.  
  140.  
  141.  
  142. POSSIBLE PROBLEMS:
  143.  
  144. 1) Using TurboC++ 1.0, the code segment is 153 bytes short of
  145. 64K.  With another compiler or a different version of TurboC++,
  146. this might not fit in 64K. If this is a problem,
  147. then compile with -DNO_BINMODE which removes the BINMODE features
  148. from small model only and then it should fit.
  149.  
  150. 2)  MSC 5.1 requires /Os and /Gs for small model to fit in 64K.
  151. Reports indicate this is also true with 6.0.
  152.  
  153.