home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / msdos / NOTES < prev    next >
Text File  |  1992-12-16  |  6KB  |  178 lines

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