home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume03 / mawkpch3 / 1 < prev    next >
Encoding:
Text File  |  1993-03-13  |  60.4 KB  |  2,455 lines

  1. From brennan@atc.boeing.com Mon Feb  8 14:18:21 1993
  2.  
  3. patch3 for mawk1.1 posted to volume1 follows in 2 parts (this+1)
  4. --------------------------------------------------------------
  5.  
  6. A script to patch mawk1.1.2 to mawk1.1.3 follows.
  7. Changes are:
  8.  
  9. 1) New configurations:
  10.    hpux coherent 386bsd linux
  11.  
  12. 2) Changed some ints to longs so that Unix and Dos versions
  13.    give same output.  E.g.,
  14.  
  15.    printf "%d" and printf "%ld" are now the same on Dos.
  16.  
  17.    msdos/examples directory with scripts by Ben Myers
  18.  
  19.    Infinity+1 large model pointer bug caused by modulo 2^16
  20.    arithmetic fixed.
  21.  
  22. 3) Grossly surprised to discover  (int) d causes a floating
  23.    point exception on hpux when d is a large double.
  24.    Integer casts are now done more carefully.  Thanks to
  25.    Ken Poulton for finding this bug.
  26.  
  27. 4) Removed ApolloSR10.3 from working configurations. Mawk will
  28.    not work if compiled with CC6.8.
  29.  
  30. 5) A few minor fixes and tweaks.  ($Logs$ contain more detail).
  31.  
  32.  
  33. #!/bin/sh
  34. # This is a shell archive (produced by shar 3.50)
  35. # To extract the files from this archive, save it to a file, remove
  36. # everything above the "!/bin/sh" line above, and type "sh file_name".
  37. #
  38. # made 02/08/1993 19:09 UTC by brennan@blacksmith
  39. # Source directory /a/bronte/users4/brennan/tmp/M
  40. #
  41. # existing files will NOT be overwritten unless -c is specified
  42. #
  43. # This is part 1 of a multipart archive                                    
  44. # do not concatenate these parts, unpack them in order with /bin/sh        
  45. #
  46. # This shar contains:
  47. # length  mode       name
  48. # ------ ---------- ------------------------------------------
  49. # 111555 -rw-r----- patch3
  50. #
  51. if test -r _shar_seq_.tmp; then
  52.     echo 'Must unpack archives in sequence!'
  53.     echo Please unpack part `cat _shar_seq_.tmp` next
  54.     exit 1
  55. fi
  56. # ============= patch3 ==============
  57. if test -f 'patch3' -a X"$1" != X"-c"; then
  58.     echo 'x - skipping patch3 (File already exists)'
  59.     rm -f _shar_wnt_.tmp
  60. else
  61. > _shar_wnt_.tmp
  62. echo 'x - extracting patch3 (Text)'
  63. sed 's/^X//' << 'SHAR_EOF' > 'patch3' &&
  64. #!/bin/sh
  65. X
  66. # Execute this script to convert mawk1.1.2 to mawk1.1.3
  67. X
  68. X    rm -f msdos/reargv.c
  69. X    mkdir msdos/examples
  70. X
  71. X
  72. X    patch -s <<'DIFFGEN_EOF'
  73. X
  74. *** /dev/null    Sat Feb  6 02:07:00 1993
  75. --- msdos/examples/winobj.awk    Sat Dec  5 13:57:16 1992
  76. ***************
  77. *** 0 ****
  78. --- 1,81 ----
  79. + # Ben Myers <0003571400@mcimail.com>
  80. + # Sum up sizes of Windows OBJ files in current directory
  81. + # requires DOS 5.0 and Borland TDUMP
  82. + # A clumsy script to count Windows OBJs and sum up the CODE sizes
  83. + # run with
  84. + #       awk -fwinobj.awk work1
  85. + # where work1 is a work file
  86. + # You must have at least one filename as an arg, else awk will want to read
  87. + # from con:, hence the requirement for work1
  88. + BEGIN {
  89. + # redirection done by shelled command
  90. + ocount = 0  # obj module counter
  91. + otsize = 0  # text size accumulator
  92. + odsize = 0  # data size accumulator
  93. + system("del workfile.$%$") # Will probably cause a File Not Found message
  94. + # Generate a list of OBJs
  95. + system("dir *.obj /b >" ARGV[1])
  96. + while (getline < ARGV[1] > 0) {
  97. + # TDUMP selects only the SEGDEFs to speed things up a lot
  98. + # and keeps on piping to the workfile
  99. + system("tdump " $1 " -oiSEGDEF >>workfile.$%$")
  100. + ocount++
  101. + }
  102. + # Now read workfile back, processing lines that are module ids and SEGDEF info
  103. + # Print one line for each SEGDEF processed
  104. + j = 1
  105. + while (getline < "workfile.$%$" > 0) {
  106. + # module name
  107. + if($1 == "Display" && $2 == "of" && $3 == "File") { module_name = $4 }
  108. + # SEGDEF CODE
  109. + if($2 == "SEGDEF" && $9 =="'CODE'") {
  110. + decval = hexdec($11)
  111. + otsize += decval
  112. + printf ("%12s CODE %4s %7i\n", module_name, $11, decval)
  113. + j++ }
  114. + # SEGDEF DATA
  115. + if($2 == "SEGDEF" && $9 =="'DATA'") {
  116. + decval = hexdec($11)
  117. + odsize += decval
  118. + printf ("%12s DATA %4s %7i\n", module_name, $11, decval)
  119. + j++ }
  120. + } # while
  121. + } # end of BEGIN section
  122. + # no main loop at all!
  123. + END {
  124. + # print summary and delete work files
  125. + printf ("%i OBJ files\n", ocount)
  126. + printf ("Total CODE size   %04x %7li bytes\n", otsize, otsize)
  127. + printf ("Total DATA size   %04x %7li bytes\n", odsize, odsize)
  128. + system("del "ARGV[1])
  129. + system("del workfile.$%$")
  130. + }  # end of END section
  131. + # No scanf in awk, so convert hex string x to decimal the hard way
  132. + function hexdec (x) {
  133. + result = 0
  134. + for (i=1; i<=length(x); i++) {
  135. + thechar = substr(x,i,1)
  136. + # digits 0-9 and lower case hex produced by TDUMP
  137. + # use brute force
  138. + if (thechar == "0") {result = result*16}
  139. + if (thechar == "1") {result = result*16 + 1}
  140. + if (thechar == "2") {result = result*16 + 2}
  141. + if (thechar == "3") {result = result*16 + 3}
  142. + if (thechar == "4") {result = result*16 + 4}
  143. + if (thechar == "5") {result = result*16 + 5}
  144. + if (thechar == "6") {result = result*16 + 6}
  145. + if (thechar == "7") {result = result*16 + 7}
  146. + if (thechar == "8") {result = result*16 + 8}
  147. + if (thechar == "9") {result = result*16 + 9}
  148. + if (thechar == "a") {result = result*16 + 10}
  149. + if (thechar == "b") {result = result*16 + 11}
  150. + if (thechar == "c") {result = result*16 + 12}
  151. + if (thechar == "d") {result = result*16 + 13}
  152. + if (thechar == "e") {result = result*16 + 14}
  153. + if (thechar == "f") {result = result*16 + 15}
  154. + } # for (i=1;i<length(x);i++)
  155. + return result
  156. + } # function hexdec (x)
  157. *** /dev/null    Sat Feb  6 02:07:00 1993
  158. --- msdos/argvmks.c    Wed Dec 16 18:48:01 1992
  159. ***************
  160. *** 0 ****
  161. --- 1,106 ----
  162. + /*  argvmks.c
  163. +     for MKS Korn Shell
  164. +     If you use this file, add -DHAVE_REARGV=1 to your
  165. +     CFLAGS
  166. +     Contributed by Jack Fitts (fittsj%wmv009@bcsaic.boeing.com)
  167. + */
  168. + /*
  169. + $Log: argvmks.c,v $
  170. +  * Revision 1.2  1992/12/17  02:48:01  mike
  171. +  * 1.1.2d changes for DOS
  172. +  *
  173. +  * Revision 1.1  1992/12/05  22:38:41  mike
  174. +  * Initial revision
  175. +  *
  176. + */
  177. + /***********************************************************/
  178. + /*                                                         */
  179. + /* prototypes for reargv                                   */
  180. + /*                                                         */
  181. + /***********************************************************/
  182. + void *malloc(unsigned) ;
  183. + char * basename ( char * );
  184. + char *strcpy(char* , char*) ;
  185. + /***********************************************************/
  186. + /*                                                         */
  187. + /* reargv reset argc/argv from environment for MKS shell   */
  188. + /*                                                         */
  189. + /***********************************************************/
  190. + void reargv ( int *argcp, char *** argvp ) {
  191. +     int i = 0;
  192. +     int cnt ;
  193. +     char ** v;
  194. +     extern char **environ ;
  195. +     register char **pe = environ;
  196. + /* MKS Command line args are in the first n lines of the environment */
  197. + /* each arg is preceded with a tilde (~)*/
  198. +     while ( **(pe++) == '~' )
  199. +         i++;
  200. + /* if no tilde found then not running under MKS */
  201. +     if ( ! i )  return ;
  202. + /* malloc space for array of char pointers */
  203. +     if ( ! ( v = ( char ** ) malloc (( i + 1 ) * sizeof ( char* ))) )
  204. +         return 1;
  205. + /* set argc to number of args in environ */
  206. +     *argcp = cnt = i;
  207. + /* set char pointers to each command line arg */
  208. + /* jump over the tilde which is the first char in each string */
  209. +     for ( i = 0; i < cnt ; i++ )
  210. +         v[i] = environ[i]+1;
  211. +     /*set last arg to null*/
  212. +     v[cnt] = (char *) 0 ;
  213. +     
  214. +     /*strip leading directory stuff from argv[0] */
  215. +     v[0] = basename(v[0]);
  216. +     *argvp = v;
  217. + }
  218. + /***********************************************************/
  219. + /*                                                         */
  220. + /* basename                                                */
  221. + /*                                                         */
  222. + /***********************************************************/
  223. + static char * basename ( char * s ) {
  224. +     register char * p ;
  225. +     char *last ;
  226. +     
  227. +     /* find the last occurrence of ':' '\\' or '/' */
  228. +     p = s ;  last = (char *) 0 ;
  229. +     while ( *p ) {
  230. +     if ( *p == ':' || *p == '\\' || *p == '/' ) last = p ;
  231. +     p++ ;
  232. +     }
  233. +     return last ? last+1 : s ;
  234. + }
  235. *** /dev/null    Sat Feb  6 02:07:00 1993
  236. --- vargs.h    Fri Oct  2 16:23:41 1992
  237. ***************
  238. *** 0 ****
  239. --- 1,56 ----
  240. + /********************************************
  241. + vargs.h
  242. + copyright 1992 Michael D. Brennan
  243. + This is a source file for mawk, an implementation of
  244. + the AWK programming language.
  245. + Mawk is distributed without warranty under the terms of
  246. + the GNU General Public License, version 2, 1991.
  247. + ********************************************/
  248. + /*
  249. + $Log: vargs.h,v $
  250. +  * Revision 1.1  1992/10/02  23:23:41  mike
  251. +  * Initial revision
  252. +  *
  253. + */
  254. + /* provides common interface to <stdarg.h> or <varargs.h> 
  255. +    only used for error messages
  256. + */
  257. + #if   HAVE_STDARG_H == 0
  258. + #include <varargs.h>
  259. + #ifndef  VA_ALIST
  260. + #define  VA_ALIST(type, arg)  (va_alist) va_dcl { type arg ;
  261. + #define  VA_ALIST2(t1,a1,t2,a2) (va_alist) va_dcl { t1 a1 ; t2 a2 ;
  262. + #endif
  263. + #define  VA_START(p,type, last)  va_start(p) ;\
  264. +                                  last = va_arg(p,type)
  265. + #define  VA_START2(p,t1,a1,t2,a2)  va_start(p) ;\
  266. +                                   a1 = va_arg(p,t1);\
  267. +                                   a2 = va_arg(p,t2)
  268. + #else  /* HAVE_STDARG_H  */
  269. + #include <stdarg.h>
  270. + #ifndef  VA_ALIST
  271. + #define  VA_ALIST(type, arg)  (type arg, ...) {
  272. + #define  VA_ALIST2(t1,a1,t2,a2)  (t1 a1,t2 a2,...) {
  273. + #endif
  274. + #define  VA_START(p,type,last)   va_start(p,last)
  275. + #define  VA_START2(p,t1,a1,t2,a2)  va_start(p,a2)
  276. + #endif
  277. *** /dev/null    Sat Feb  6 02:07:00 1993
  278. --- msdos/examples/srcstat2.awk    Sat Dec  5 13:57:14 1992
  279. ***************
  280. *** 0 ****
  281. --- 1,28 ----
  282. + # Ben Myers <0003571400@mcimail.com>
  283. + # Sum up number, line count, and sizes of SOURCE files in current directory
  284. + # run with 
  285. + #       bmawk -fsrcsize.awk workfile
  286. + # or similar command syntax with your awk program
  287. + # where workfile is a work file
  288. + BEGIN {
  289. + # redirection done by shelled command
  290. + system("dir *.* >workfile")
  291. + ssize = 0   # size accumulator
  292. + slines = 0  # line counter
  293. + scount = 0  # obj counter
  294. + exit
  295. + }
  296. + END {
  297. + # Now read workfile back in
  298. +     while (getline < "workfile" > 0) {
  299. +     if ($2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP")  {
  300. +     filename = sprintf("%s.%s", $1, $2)
  301. +     ssize += $3
  302. +     while (getline < filename > 0) {slines++}
  303. +     scount++
  304. +     }
  305. +     }
  306. + print scount " files, " slines " lines, total size " ssize " bytes"
  307. + system("del workfile")
  308. + }
  309. *** /dev/null    Sat Feb  6 02:07:00 1993
  310. --- msdos/argvpoly.c    Thu Dec 17 20:09:43 1992
  311. ***************
  312. *** 0 ****
  313. --- 1,80 ----
  314. + /*  argvpoly.c
  315. +     --  set arguments via POLYSHELL (now Thompson Shell??)
  316. +     --  no errors, don't change anything if
  317. +     --  it seems shell is not activated   */
  318. + /* POLYSHELL puts the shell expanded command line
  319. +    in the environment variable CMDLINE.  Ascii 0 is
  320. +    replaced by \xff.
  321. + */
  322. + char *strchr(char *, int), *getenv(char *) ;
  323. + char *basename(char *) ;
  324. + void *malloc(unsigned) ;
  325. + int  strcmp(char *, char *) ;
  326. + static  char *basename(char *s)
  327. + /* strip path and extension , upcase the rest */
  328. + { 
  329. +   register char *p ;
  330. +   for ( p = strchr(s,0) ; p > s ; p-- )
  331. +     switch( p[-1] )
  332. +      { case '\\' :
  333. +        case ':'  :
  334. +        case '/'  :  return p ;
  335. +        case '.'  :  p[-1] = 0 ;  break ;
  336. +        default   :
  337. +         if ( p[-1] >= 'a' && p[-1] <= 'z' )   p[-1] -= 32 ;
  338. +         break ;
  339. +      }
  340. +   return  p ;
  341. + }
  342. + /*---------------------
  343. +   reargv  --  recompute  argc and argv for PolyShell
  344. +     if not under shell do nothing
  345. +  *-------------------------------  */
  346. + extern  char *progname ;
  347. + extern  unsigned char _osmajor ;
  348. + void  reargv(int *argcp , char ***argvp)
  349. + { register char *p ;
  350. +   char **v , *q, *cmdline, **vx ;
  351. +   int cnt, cntx ;
  352. +   if ( _osmajor == 2 )  /* ugh */
  353. +      (*argvp)[0] = progname ;
  354. +   else  (*argvp)[0] = basename( (*argvp)[0] ) ;
  355. +   if ( ! (cmdline = getenv("CMDLINE")) )  return ;
  356. +   if ( *(q = strchr(cmdline,0) - 1) != 0xff )
  357. +       return ;  /*  shexpand set wrong */
  358. +   for ( *q = 0, cnt = 1 , p = cmdline ; p < q ; p++ )
  359. +      if ( *p == 0xff ) { cnt++ ; *p = 0 ; }
  360. +   if ( ! (v = (char **) malloc((cnt+1)*sizeof(char*))) )
  361. +        return ;  /* shouldn't happen */
  362. +   p = cmdline ;
  363. +   vx = v ; cntx = cnt ;
  364. +   while ( cnt )
  365. +    { *v++ = p ;
  366. +      cnt-- ;
  367. +      while ( *p )  p++ ;
  368. +      p++ ;
  369. +    }
  370. +   *v = (char *) 0 ;
  371. +   v = vx ;
  372. +   v[0] = basename( v[0] ) ;
  373. +   if ( strcmp(v[0], (*argvp)[0]) )  return  ;/* running under command
  374. +     and sh earlier  */
  375. +   /* running under PolyShell  */
  376. +   *argcp = cntx ;  *argvp = v ;
  377. + }
  378. *** /dev/null    Sat Feb  6 02:07:00 1993
  379. --- config/ztc_dos.h    Sat Dec 26 17:42:50 1992
  380. ***************
  381. *** 0 ****
  382. --- 1,58 ----
  383. + /********************************************
  384. + ztc_dos.h
  385. + copyright 1992, Michael D. Brennan
  386. + This is a source file for mawk, an implementation of
  387. + the AWK programming language.
  388. + Mawk is distributed without warranty under the terms of
  389. + the GNU General Public License, version 2, 1991.
  390. + ********************************************/
  391. + /* Zortech C++ under MSDOS */
  392. + /* $Log: ztc_dos.h,v $
  393. +  * Revision 1.1  1992/12/27  01:42:50  mike
  394. +  * Initial revision
  395. +  *
  396. +  * Revision 4.2.1  92/06/01  00:00:00  bmyers
  397. +  * create Zortech C++ version from Borland C++ version
  398. +  * ZTC has matherr function and no info for floating point exceptions.
  399. +  *
  400. + */
  401. + #ifndef   CONFIG_H
  402. + #define   CONFIG_H      1
  403. + #define   MSDOS                 1
  404. + #define   HAVE_PROTOS           1
  405. + #define   HAVE_STDARG_H         1
  406. + #define   HAVE_STDLIB_H        1
  407. + #define   HAVE_TIME_H        1
  408. + #define   HAVE_STRERROR        1
  409. + #define   HAVE_MATHERR          0
  410. + #define  FPE_TRAPS_ON        1
  411. + #define  NOINFO_SIGFPE          1
  412. + #ifndef   HAVE_SMALL_MEMORY   /* allow large model override */
  413. + #define   HAVE_SMALL_MEMORY     1
  414. + #endif
  415. + #if  HAVE_SMALL_MEMORY==0
  416. + /* how to test far pointers have the same segment */
  417. + #include <dos.h>
  418. + #define  SAMESEG(p,q)    (FP_SEG(p)==FP_SEG(q))
  419. + #endif
  420. + #include "config/Idefault.h"
  421. + #endif  /* CONFIG_H  */
  422. *** /dev/null    Sat Feb  6 02:07:00 1993
  423. --- msdos/examples/objstat.awk    Sat Dec  5 13:57:12 1992
  424. ***************
  425. *** 0 ****
  426. --- 1,20 ----
  427. + # Ben Myers <0003571400@mcimail.com>
  428. + # Sum up sizes of OBJ files in current directory
  429. + # A clumsy script to count OBJs and sum up their sizes
  430. + # run with 
  431. + #       bmawk -fobjsize.awk workfile
  432. + # or similar command syntax with your awk program
  433. + # where workfile is a work file
  434. + BEGIN {
  435. + # redirection done by shelled command
  436. + system("dir *.obj >" ARGV[1])
  437. + osize = 0   # size accumulator
  438. + ocount = 0  # obj counter
  439. + }
  440. + # Now read workfile back, skipping lines that are not files
  441. + $2 == "OBJ" { osize += $3 ; ocount++ }
  442. + END {
  443. + print ocount " OBJs, total size " osize " bytes"
  444. + system("del "ARGV[1])
  445. + }
  446. *** /dev/null    Sat Feb  6 02:07:00 1993
  447. --- msdos/examples/add_cr.awk    Sat Dec  5 13:57:11 1992
  448. ***************
  449. *** 0 ****
  450. --- 1,93 ----
  451. + # add_cr.awk
  452. + # converts from Unix (LF only) text files to
  453. + # DOS (CRLF) text files
  454. + #
  455. + # works on both unix and dos 
  456. + # if used on unix change COPY and DEL in BEGIN section
  457. + #
  458. + # mawk -f add_cr.awk  [files]
  459. + # with no files reads stdin writes stdout
  460. + # otherwise the original is overwritten
  461. + #
  462. + # If a file of the form `@file', then arguments are read from
  463. + # `file', one per line
  464. + #
  465. + # To add cr's to the whole distribution
  466. + #
  467. + # mawk -f doslist.awk packing.lis | mawk "{print $2}" > list
  468. + # mawk -f add_cr.awk  @list
  469. + #
  470. + # read arguments for @file into ARGV[]
  471. + function reset_argv(T, i, j, flag, file) #all args local
  472. + {
  473. +   for( i = 1 ; i < ARGC ; i++ ) 
  474. +   {
  475. +     T[i] = ARGV[i]
  476. +     if ( T[i] ~ /^@/ ) flag = 1
  477. +   }
  478. +   if ( ! flag )  return
  479. +   # need to read from a @file into ARGV
  480. +   j = 1
  481. +   for( i = 1 ; i < ARGC ; i++ )
  482. +   {
  483. +     if ( T[i] !~ /^@/ ) ARGV[j++] = T[i]
  484. +     else
  485. +     {
  486. +       T[i] = substr(T[i],2)
  487. +       # read arguments from T[i]
  488. +       while ( (getline file < T[i]) > 0 ) ARGV[j++] = file
  489. +     }
  490. +   }
  491. +   ARGC = j
  492. + }
  493. +    
  494. +   
  495. + BEGIN {
  496. +   COPY = "copy"    # unix: "cp"
  497. +   DEL = "del"      # unix: "rm"
  498. +   tmpfile = ENVIRON["MAWKTMPDIR"] "MAWK.TMP"
  499. +   reset_argv()
  500. + }
  501. + FILENAME == "-" {
  502. +    # just write to stdout
  503. +    printf "%s\r\n" , $0
  504. +    next
  505. + }
  506. + FILENAME != filename {
  507. +    
  508. +    if ( filename )
  509. +    {
  510. +      close(tmpfile)
  511. +      syscmd = sprintf( "%s %s %s", COPY, tmpfile, filename )
  512. +      system(syscmd)
  513. +    }
  514. +    filename = FILENAME
  515. + }
  516. + { printf "%s\r\n" , $0 > tmpfile }
  517. + END {
  518. +   if ( filename )  
  519. +   {
  520. +     close(tmpfile)
  521. +     syscmd = sprintf( "%s %s %s", COPY, tmpfile, filename )
  522. +     system(syscmd)
  523. +     system(DEL " " tmpfile)
  524. +   }
  525. + }
  526. +    
  527. *** /dev/null    Sat Feb  6 02:07:00 1993
  528. --- msdos/examples/texttest.awk    Sat Dec  5 13:57:15 1992
  529. ***************
  530. *** 0 ****
  531. --- 1,11 ----
  532. + # Ben Myers <0003571400@mcimail.com>
  533. + /^#include/ {
  534. + # got #include, see if it has at least one quote. We don't want #include <>        
  535. +         z = gsub(/"/, "", $2)
  536. +         while ((z > 0) && (getline x <$2 > 0)) 
  537. + #        while (getline x <$2 > 0) 
  538. +                 print x
  539. +         next
  540. + }
  541. + { print }
  542. *** /dev/null    Sat Feb  6 02:07:00 1993
  543. --- msdos/makefile.ztc    Sat Dec 26 17:44:54 1992
  544. ***************
  545. *** 0 ****
  546. --- 1,28 ----
  547. + # Makefile for Zortech C
  548. + OBJ1=parse.obj scan.obj memory.obj main.obj hash.obj execute.obj code.obj\
  549. +   da.obj error.obj init.obj bi_vars.obj cast.obj print.obj bi_funct.obj\
  550. +   kw.obj jmp.obj array.obj field.obj  split.obj re_cmpl.obj zmalloc.obj\
  551. +   fin.obj files.obj  scancode.obj matherr.obj fcall.obj version.obj\
  552. +   dosexec.obj
  553. + #OBJ2=rexp\rexp.obj rexp\rexp0.obj rexp\rexp1.obj rexp\rexp2.obj\
  554. + #  rexp\rexp3.obj  rexp\rexpdb.obj
  555. + OBJ2=rexp.obj rexp0.obj rexp1.obj rexp2.obj\
  556. +   rexp3.obj rexpdb.obj
  557. + CFLAGS=-ml -bx -o -A- -DLARGE -DMAWK -DHAVE_SMALL_MEMORY=0
  558. + LFLAGS = -L/ST:32768
  559. + .c.obj:
  560. +     ztc -c $(CFLAGS) $<
  561. + bmawkztc.exe:    $(OBJ1) $(OBJ2)
  562. +     ztc $(LFLAGS) -obmawkztc $(OBJ1) $(OBJ2)
  563. + $(OBJ1): BI_FUNCT.H BI_VARS.H CODE.H FIELD.H FILES.H INIT.H JMP.H MEMORY.H\
  564. +   PARSE.H PATCHLEV.H REGEXP.H REPL.H SCAN.H SIZES.H SYMTYPE.H TYPES.H\
  565. +   ZMALLOC.H CONFIG.H FIN.H MAWK.H
  566. + $(OBJ2):    rexp.h
  567. *** /dev/null    Sat Feb  6 02:07:00 1993
  568. --- msdos/examples/doslist.awk    Sat Dec  5 13:57:11 1992
  569. ***************
  570. *** 0 ****
  571. --- 1,34 ----
  572. + # print truncated DOS file names
  573. + # from packing.list (packing.lis)
  574. + #
  575. + #  mawk -f doslist.awk packing.lis
  576. + # discard blanks and comments
  577. + /^#/ || /^[ \t]*$/ {next}
  578. + function dos_name(s,    n, front, X)
  579. + {
  580. +   #lowercase, split on extension and truncate pieces
  581. +   s = tolower(s)
  582. +   n = split(s, X, ".")
  583. +   front = substr(X[1],1,8)
  584. +   if ( n == 1 )  return front
  585. +   else return front "." substr(X[2], 1, 3)
  586. + }
  587. + {
  588. +   n = split($1, X, "/")
  589. +   new = dos_name(X[1])
  590. +   for( i = 2 ; i <= n ; i++ )
  591. +     new = new "\\" dos_name(X[i])
  592. +   printf "%-30s%s\n", $1, new
  593. + }
  594. *** /dev/null    Sat Feb  6 02:07:00 1993
  595. --- config/linux.h    Wed Jan 27 19:52:22 1993
  596. ***************
  597. *** 0 ****
  598. --- 1,24 ----
  599. + /*
  600. + linux.h
  601. + Sorta tested with Linux 0.98pl4 & gcc 2.2d7
  602. + Slapped together by Bob Hutchinson
  603. + Standard disclaimer: "Well, it worked for me..."
  604. + */
  605. + #ifndef   CONFIG_H
  606. + #define   CONFIG_H          1
  607. + #define HAVE_MATHERR        0
  608. + #define HAVE_STDLIB_H        1
  609. + #define  DONT_PROTO_OPEN
  610. + #define FPE_TRAPS_ON        1
  611. + #define NOINFO_SIGFPE        1
  612. + #include "config/Idefault.h"
  613. + #endif  /* CONFIG_H  */
  614. *** /dev/null    Sat Feb  6 02:07:00 1993
  615. --- config/coherent.h    Sun Nov 22 10:35:43 1992
  616. ***************
  617. *** 0 ****
  618. --- 1,58 ----
  619. + /********************************************
  620. + coherent.h
  621. + copyright 1992.  Michael D. Brennan
  622. + This is a source file for mawk, an implementation of
  623. + the AWK programming language.
  624. + Mawk is distributed without warranty under the terms of
  625. + the GNU General Public License, version 2, 1991.
  626. + ********************************************/
  627. + /* This is for COHERENT 4.0 */
  628. + /*
  629. + $Log: coherent.h,v $
  630. +  * Revision 1.1  1992/11/22  18:35:43  mike
  631. +  * Initial revision
  632. +  *
  633. + */
  634. + #ifndef  CONFIG_H
  635. + #define  CONFIG_H       1
  636. + #define HAVE_VOID_PTR   0
  637. + #define HAVE_MATHERR    0
  638. + #define HAVE_FMOD       0
  639. + #define HAVE_STDLIB_H   1
  640. + #define HAVE_STRERROR    1
  641. + #define USE_SIMPLE_VFPRINTF  /* no vfprintf() */
  642. + #define HAVE_STDARG_H   1
  643. +    /* but it not standard ! 
  644. +       so add  */
  645. + #define  VA_ALIST(type, arg) (arg) type arg; {
  646. + #define  VA_ALIST2(t1,a1,t2,a2)  (a1,a2) t1 a1; t2 a2; {
  647. + /* Until MWC improves floating point (December 1992, they tell me),
  648. +    or fixes the math library (log(-8) gives 0, for example), we'll
  649. +    have to put up with inconsistent handling. 
  650. +    
  651. +    Coherent 4.0 cannot be set up to pass fpe_test
  652. + */
  653. + #define FPE_TRAPS_ON    1
  654. + #define NOINFO_SIGFPE   1
  655. + int printf();
  656. + int sprintf();
  657. + #include "config/Idefault.h"
  658. + #endif
  659. *** /dev/null    Sat Feb  6 02:07:00 1993
  660. --- msdos/examples/shell.awk    Sat Dec  5 13:57:13 1992
  661. ***************
  662. *** 0 ****
  663. --- 1,16 ----
  664. + # Ben Myers <0003571400@mcimail.com>
  665. + # Test pipes under DOS. comment/uncomment print statements below
  666. + BEGIN {
  667. + # redirection done by shelled command
  668. + system("dir *.* /b >pippo.")
  669. + lcount = 0
  670. + }
  671. + {
  672. + # print
  673. + # Below is redirection done by mawk
  674. + # print >"pippo2."
  675. + print $0 | "sort"
  676. + lcount++
  677. + }
  678. + END { print "mawk NR line count=" NR " our line count=" lcount " lines in pippo"}
  679. *** /dev/null    Sat Feb  6 02:07:00 1993
  680. --- config/386bsd.h    Thu Feb  4 18:20:10 1993
  681. ***************
  682. *** 0 ****
  683. --- 1,36 ----
  684. + /********************************************
  685. + 386bsd.h
  686. + copyright 1993, Michael D. Brennan
  687. + This is a source file for mawk, an implementation of
  688. + the AWK programming language.
  689. + Mawk is distributed without warranty under the terms of
  690. + the GNU General Public License, version 2, 1991.
  691. + ********************************************/
  692. + /*
  693. + $Log: 386bsd.h,v $
  694. +  * Revision 1.1  1993/02/05  02:20:10  mike
  695. +  * Initial revision
  696. +  *
  697. + */
  698. + #ifndef   CONFIG_H
  699. + #define   CONFIG_H    1
  700. + #define   FPE_TRAPS_ON                1
  701. + #define   FPE_ZERODIVIDE   FPE_FLTDIV_TRAP
  702. + #define   FPE_OVERFLOW     FPE_FLTOVF_TRAP
  703. + #define   HAVE_STRTOD         0
  704. + #define   HAVE_MATHERR                0
  705. + #define   DONT_PROTO_OPEN
  706. + #include "config/Idefault.h"
  707. + #endif  /* CONFIG_H  */
  708. *** /dev/null    Sat Feb  6 02:07:00 1993
  709. --- msdos/examples/winexe.awk    Sat Dec  5 13:57:15 1992
  710. ***************
  711. *** 0 ****
  712. --- 1,106 ----
  713. + # Ben Myers <0003571400@mcimail.com>
  714. + # Sum up segment sizes of all Windows EXEs in current directory
  715. + # requires DOS 5.0 and Borland TDUMP
  716. + # run with
  717. + #       awk -fwinexe.awk work1
  718. + # where work1 is a work file
  719. + # You must have at least one filename as an arg, else awk will want to read
  720. + # from con:, hence the requirement for work1
  721. + BEGIN {
  722. + # redirection done by shelled command
  723. + system("del workfile.$%$") # Will probably cause a File Not Found message
  724. + # Generate a list of EXEs
  725. + system("dir *.exe /b > workfile.$%$")
  726. + while (getline < "workfile.$%$" > 0) {
  727. + # TDUMP keeps on piping to the workfile
  728. + system("tdump " $1 ">> " ARGV[1])
  729. + }
  730. + module_name = "" # initialize
  731. + # Now read workfile back, processing lines that:
  732. + # 1. contain EXE file name
  733. + # 2. contain segment type
  734. + # Print EXE name and stats for each segment type processed
  735. + # When there is a new EXE name, print summary for EXE just processed
  736. + j = 1
  737. + while (getline < ARGV[1] > 0) {
  738. + # module name
  739. + if($1 == "Display" && $2 == "of" && $3 == "File") {
  740. + # Print program summary for all but last program
  741. + if(module_name != "") { Print_Summary() }
  742. + otcount = 0 # text segment counter
  743. + odcount = 0 # data segment counter
  744. + otsize = 0  # text size accumulator
  745. + odsize = 0  # data size accumulator
  746. + module_name = $4 }
  747. + # File Size
  748. + if($1 == "DOS" && $2 == "File" && $3 == "Size") {
  749. + # 6+ digit file size with leading left paren
  750. + DOS_Size = substr($5,2,7)
  751. + # file size < 6 digits
  752. + if(DOS_Size == 0 || DOS_Size == "") { DOS_Size = $6 }
  753. + }
  754. + # CODE segment
  755. + if($1 == "Segment" && $2 == "Type:" && $3 =="CODE") {
  756. + decval = hexdec(substr($7,1,4))
  757. + otsize += decval
  758. + # printf ("%12s CODE %4s %7u\n", module_name, $7, decval)
  759. + otcount++ }
  760. + # DATA segment
  761. + if($1 == "Segment" && $2 == "Type:" && $3 =="DATA") {
  762. + decval = hexdec(substr($7,1,4))
  763. + odsize += decval
  764. + # printf ("%12s DATA %4s %7u\n", module_name, $7, decval)
  765. + odcount++ }
  766. + } # while
  767. + } # end of BEGIN section
  768. + # no main loop at all!
  769. + END {
  770. + # print record for last program
  771. + Print_Summary()
  772. + # delete work files
  773. + system("del "ARGV[1])
  774. + system("del workfile.$%$")
  775. + }  # end of END section
  776. + # No scanf in awk, so convert hex string x to decimal the hard way
  777. + function hexdec (x) {
  778. + result = 0
  779. + for (i=1; i<=length(x); i++) {
  780. + thechar = substr(x,i,1)
  781. + # digits 0-9 and lower case hex produced by TDUMP
  782. + # use brute force
  783. + if (thechar == "0") {result = result*16}
  784. + if (thechar == "1") {result = result*16 + 1}
  785. + if (thechar == "2") {result = result*16 + 2}
  786. + if (thechar == "3") {result = result*16 + 3}
  787. + if (thechar == "4") {result = result*16 + 4}
  788. + if (thechar == "5") {result = result*16 + 5}
  789. + if (thechar == "6") {result = result*16 + 6}
  790. + if (thechar == "7") {result = result*16 + 7}
  791. + if (thechar == "8") {result = result*16 + 8}
  792. + if (thechar == "9") {result = result*16 + 9}
  793. + if (thechar == "a") {result = result*16 + 10}
  794. + if (thechar == "b") {result = result*16 + 11}
  795. + if (thechar == "c") {result = result*16 + 12}
  796. + if (thechar == "d") {result = result*16 + 13}
  797. + if (thechar == "e") {result = result*16 + 14}
  798. + if (thechar == "f") {result = result*16 + 15}
  799. + if (thechar == "A") {result = result*16 + 10}
  800. + if (thechar == "B") {result = result*16 + 11}
  801. + if (thechar == "C") {result = result*16 + 12}
  802. + if (thechar == "D") {result = result*16 + 13}
  803. + if (thechar == "E") {result = result*16 + 14}
  804. + if (thechar == "F") {result = result*16 + 15}
  805. + } # for (i=1;i<length(x);i++)
  806. + return result
  807. + } # function hexdec (x)
  808. + function Print_Summary () {
  809. + # zero segment counts mean non-Windows EXE, so don't print
  810. + if (otcount+otcount != 0) {
  811. + printf ("%12s - %10.0f bytes\n", module_name, DOS_Size)
  812. + printf ("%5.0f TEXT segments with %10.0f bytes\n", otcount, otsize)
  813. + printf ("%5.0f DATA segments with %10.0f bytes\n", odcount, odsize)
  814. + }
  815. + }
  816. *** /dev/null    Sat Feb  6 02:07:00 1993
  817. --- msdos/examples/srcstat.awk    Sat Dec  5 13:57:14 1992
  818. ***************
  819. *** 0 ****
  820. --- 1,26 ----
  821. + # Ben Myers <0003571400@mcimail.com>
  822. + # Sum up number, line count, and sizes of SOURCE files in current directory
  823. + # run with 
  824. + #       bmawk -fsrcsize.awk workfile
  825. + # or similar command syntax with your awk program
  826. + # where workfile is a work file
  827. + BEGIN {
  828. + # redirection done by shelled command
  829. + # system("dir *.* >workfile")
  830. + system("dir *.* >" ARGV[1])
  831. + ssize = 0   # size accumulator
  832. + slines = 0  # line counter
  833. + scount = 0  # obj counter
  834. + }
  835. + # Now read workfile back in
  836. + $2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP" {
  837. +     filename = sprintf("%s.%s", $1, $2)
  838. +     ssize += $3
  839. +     while (getline < filename > 0) {slines++}
  840. +     scount++
  841. +     }
  842. + END {
  843. + print scount " files, " slines " lines, total size " ssize " bytes"
  844. + system("del " ARGV[1])
  845. + }
  846. Index: rexp/rexp2.c
  847. *** 3.7    1992/01/21 17:33:15
  848. --- 3.8    1992/12/24 00:36:44
  849. ***************
  850. *** 12,18 ****
  851. X  
  852. X  /*$Log: rexp2.c,v $
  853. !  * Revision 3.7  1992/01/21  17:33:15  brennan
  854. !  * added some casts so that character classes work with signed chars
  855. X   *
  856. X   * Revision 3.6  91/10/29  10:54:03  brennan
  857. X   * SIZE_T
  858. --- 12,23 ----
  859. X  
  860. X  /*$Log: rexp2.c,v $
  861. !  * Revision 3.8  1992/12/24  00:36:44  mike
  862. !  * fixed major bozo for LMDOS when growing stack
  863. !  * fixed potential LMDOS bozo with M_STR+U_ON+END_ON
  864. !  * fixed minor bug in M_CLASS+U_ON+END_ON
  865. X   *
  866. +  * Revision 3.7  92/01/21  17:33:15  brennan
  867. +  * added some casts so that character classes work with signed chars
  868. +  * 
  869. X   * Revision 3.6  91/10/29  10:54:03  brennan
  870. X   * SIZE_T
  871. ***************
  872. *** 52,58 ****
  873. X  #define  STACKGROWTH    16
  874. X  
  875. ! /* statics */
  876. X  static RT_STATE *PROTO(slow_push,(RT_STATE *,STATE*,char*,int)); 
  877. X  
  878. X  
  879. --- 57,63 ----
  880. X  #define  STACKGROWTH    16
  881. X  
  882. ! #ifdef  DEBUG
  883. X  static RT_STATE *PROTO(slow_push,(RT_STATE *,STATE*,char*,int)); 
  884. ! #endif
  885. X  
  886. X  
  887. ***************
  888. *** 64,72 ****
  889. X  RT_STATE *RE_run_stack_empty ;
  890. X  
  891. - /* for statistics and debug */
  892. - static RT_STATE *stack_max ; 
  893. X  void RE_run_stack_init()
  894. ! { if ( !RE_run_stack_base )
  895. X    {
  896. X      RE_run_stack_base = (RT_STATE *)
  897. --- 69,75 ----
  898. X  RT_STATE *RE_run_stack_empty ;
  899. X  
  900. X  void RE_run_stack_init()
  901. ! { 
  902. !   if ( !RE_run_stack_base )
  903. X    {
  904. X      RE_run_stack_base = (RT_STATE *)
  905. ***************
  906. *** 73,77 ****
  907. X                   RE_malloc(sizeof(RT_STATE) * STACKGROWTH ) ;
  908. X      RE_run_stack_limit = RE_run_stack_base + STACKGROWTH ;
  909. !     RE_run_stack_empty = stack_max = RE_run_stack_base-1 ;
  910. X    }
  911. X  }
  912. --- 76,80 ----
  913. X                   RE_malloc(sizeof(RT_STATE) * STACKGROWTH ) ;
  914. X      RE_run_stack_limit = RE_run_stack_base + STACKGROWTH ;
  915. !     RE_run_stack_empty = RE_run_stack_base-1 ;
  916. X    }
  917. X  }
  918. ***************
  919. *** 84,88 ****
  920. X  
  921. X  RT_STATE  *RE_new_run_stack()
  922. ! { int newsize = (RE_run_stack_limit - RE_run_stack_base) + STACKGROWTH ;
  923. X  
  924. X  #ifdef  LMDOS   /* large model DOS */
  925. --- 87,93 ----
  926. X  
  927. X  RT_STATE  *RE_new_run_stack()
  928. ! { 
  929. !   int oldsize = RE_run_stack_limit - RE_run_stack_base ;
  930. !   int newsize = oldsize + STACKGROWTH ;
  931. X  
  932. X  #ifdef  LMDOS   /* large model DOS */
  933. ***************
  934. *** 92,107 ****
  935. X  #endif
  936. X  
  937. - #ifdef  __TURBOC__  
  938. - /* turbo C's realloc() screws up when running out of mem  */
  939. -   { RT_STATE *temp = (RT_STATE*)malloc(SIZE_T(newsize*sizeof(RT_STATE))) ;
  940. -     if ( temp ) (void)memcpy(temp,RE_run_stack_base,
  941. -         SIZE_T((newsize-STACKGROWTH)*sizeof(RT_STATE))) ;
  942. -     free(RE_run_stack_base) ;
  943. -     RE_run_stack_base = temp ;
  944. -   }
  945. - #else  /* normal case */
  946. X    RE_run_stack_base = (RT_STATE *) realloc( RE_run_stack_base ,
  947. X            SIZE_T(newsize * sizeof(RT_STATE)) ) ;
  948. - #endif
  949. X  
  950. X    if ( ! RE_run_stack_base )
  951. --- 97,102 ----
  952. ***************
  953. *** 115,121 ****
  954. X    RE_run_stack_limit = RE_run_stack_base + newsize ;
  955. X    RE_run_stack_empty = RE_run_stack_base - 1 ;
  956. !   return  stack_max = RE_run_stack_base + newsize - STACKGROWTH ;
  957. X  }
  958. X  
  959. X  static RT_STATE *slow_push(sp, m, s, u)
  960. X    RT_STATE *sp ;
  961. --- 110,119 ----
  962. X    RE_run_stack_limit = RE_run_stack_base + newsize ;
  963. X    RE_run_stack_empty = RE_run_stack_base - 1 ;
  964. !   /* return the new stackp */
  965. !   return  RE_run_stack_base + oldsize ;
  966. X  }
  967. X  
  968. + #ifdef  DEBUG
  969. X  static RT_STATE *slow_push(sp, m, s, u)
  970. X    RT_STATE *sp ;
  971. ***************
  972. *** 124,139 ****
  973. X    int   u ;
  974. X  { 
  975. !   if ( sp > stack_max )
  976. !      if ( (stack_max = sp) == RE_run_stack_limit )
  977. !              sp = RE_new_run_stack() ;
  978. X    sp->m = m ; sp->s = s ; sp->u = u ;
  979. X    return sp ;
  980. X  }
  981. - #ifdef   DEBUG
  982. - void  print_max_stack(f)
  983. -   FILE *f ;
  984. - { fprintf(f, "stack_max = %d\n", stack_max-RE_run_stack_base+1) ; }
  985. X  #endif
  986. X  
  987. --- 122,129 ----
  988. X    int   u ;
  989. X  { 
  990. !   if ( sp == RE_run_stack_limit ) sp = RE_new_run_stack() ;
  991. X    sp->m = m ; sp->s = s ; sp->u = u ;
  992. X    return sp ;
  993. X  }
  994. X  #endif
  995. X  
  996. ***************
  997. *** 142,148 ****
  998. X  #else
  999. X  #define  push(mx,sx,ux)   if (++stackp == RE_run_stack_limit)\
  1000. !                                 stackp = slow_push(stackp,mx,sx,ux) ;\
  1001. !                           else\
  1002. !                           { stackp->m=mx;stackp->s=sx;stackp->u=ux;}
  1003. X  #endif
  1004. X  
  1005. --- 132,137 ----
  1006. X  #else
  1007. X  #define  push(mx,sx,ux)   if (++stackp == RE_run_stack_limit)\
  1008. !                                 stackp = RE_new_run_stack() ;\
  1009. !                           stackp->m=(mx);stackp->s=(sx);stackp->u=(ux)
  1010. X  #endif
  1011. X  
  1012. ***************
  1013. *** 161,165 ****
  1014. X    int u_flag ;
  1015. X    char *str_end ;
  1016. !   char *ts ; /*convenient temps */
  1017. X    STATE *tm ;
  1018. X  
  1019. --- 150,154 ----
  1020. X    int u_flag ;
  1021. X    char *str_end ;
  1022. !   int t ; /*convenient temps */
  1023. X    STATE *tm ;
  1024. X  
  1025. ***************
  1026. *** 166,170 ****
  1027. X    /* handle the easy case quickly */
  1028. X    if ( (m+1)->type == M_ACCEPT && m->type == M_STR )
  1029. !         return  (int ) str_str(s, m->data.str, m->len) ;
  1030. X    else
  1031. X    { u_flag = U_ON ; str_end = (char *) 0 ;
  1032. --- 155,159 ----
  1033. X    /* handle the easy case quickly */
  1034. X    if ( (m+1)->type == M_ACCEPT && m->type == M_STR )
  1035. !         return  str_str(s, m->data.str, m->len) != (char *) 0 ;
  1036. X    else
  1037. X    { u_flag = U_ON ; str_end = (char *) 0 ;
  1038. ***************
  1039. *** 202,207 ****
  1040. X      case M_STR + U_ON + END_ON :
  1041. X              if ( !str_end )  str_end = s + strlen(s) ;
  1042. !             ts = str_end - m->len ;
  1043. !             if (ts < s || memcmp(ts,m->data.str,SIZE_T(m->len+1))) goto refill ;
  1044. X              s = str_end ; m++ ; u_flag = U_OFF ;
  1045. X              goto reswitch ;
  1046. --- 191,197 ----
  1047. X      case M_STR + U_ON + END_ON :
  1048. X              if ( !str_end )  str_end = s + strlen(s) ;
  1049. !         t = (str_end - s) - m->len ;
  1050. !             if (t < 0 || memcmp(s+t,m->data.str,SIZE_T(m->len)))
  1051. !             goto refill ;
  1052. X              s = str_end ; m++ ; u_flag = U_OFF ;
  1053. X              goto reswitch ;
  1054. ***************
  1055. *** 216,220 ****
  1056. X              s++ ; m++ ;
  1057. X              goto reswitch ;
  1058. X      case M_CLASS + U_ON + END_OFF :
  1059. X              while ( !ison(*m->data.bvp,s[0]) )
  1060. --- 206,209 ----
  1061. ***************
  1062. *** 228,232 ****
  1063. X      case M_CLASS + U_ON + END_ON :
  1064. X              if ( ! str_end )  str_end = s + strlen(s) ;
  1065. !             if ( ! ison(*m->data.bvp, str_end[-1]) ) goto refill ;
  1066. X              s = str_end ; m++ ; u_flag = U_OFF ;
  1067. X              goto reswitch ;
  1068. --- 217,222 ----
  1069. X      case M_CLASS + U_ON + END_ON :
  1070. X              if ( ! str_end )  str_end = s + strlen(s) ;
  1071. !             if ( s[0] == 0 || ! ison(*m->data.bvp, str_end[-1]) )
  1072. !                 goto refill ;
  1073. X              s = str_end ; m++ ; u_flag = U_OFF ;
  1074. X              goto reswitch ;
  1075. Index: sizes.h
  1076. *** 5.2    1992/08/27 03:20:08
  1077. --- 5.3    1992/12/17 02:48:01
  1078. ***************
  1079. *** 12,15 ****
  1080. --- 12,18 ----
  1081. X  
  1082. X  /* $Log: sizes.h,v $
  1083. +  * Revision 5.3  1992/12/17  02:48:01  mike
  1084. +  * 1.1.2d changes for DOS
  1085. +  *
  1086. X   * Revision 5.2  1992/08/27  03:20:08  mike
  1087. X   * patch2: increase A_HASH_PRIME
  1088. ***************
  1089. *** 51,54 ****
  1090. --- 54,65 ----
  1091. X    /* starting buffer size for input files, grows if 
  1092. X       necessary */
  1093. + #if      LM_DOS
  1094. + /* trade some space for IO speed */
  1095. + #undef  BUFFSZ
  1096. + #define BUFFSZ        8192
  1097. + /* maximum input buffers that will fit in 64K */
  1098. + #define  MAX_BUFFS    ((int)(0x10000L/BUFFSZ) - 1)
  1099. + #endif
  1100. X  
  1101. X  #define  HASH_PRIME  53
  1102. Index: rexp/rexp3.c
  1103. *** 3.5    1992/01/21 17:33:20
  1104. --- 3.6    1992/12/24 00:44:53
  1105. ***************
  1106. *** 12,15 ****
  1107. --- 12,19 ----
  1108. X  
  1109. X  /*$Log: rexp3.c,v $
  1110. +  * Revision 3.6  1992/12/24  00:44:53  mike
  1111. +  * fixed potential LMDOS bozo with M_STR+U_ON+END_ON
  1112. +  * fixed minor bug in M_CLASS+U_ON+END_ON
  1113. +  *
  1114. X   * Revision 3.5  1992/01/21  17:33:20  brennan
  1115. X   * added some casts so that character classes work with signed chars
  1116. ***************
  1117. *** 47,51 ****
  1118. X  #define  push(mx,sx,ssx,ux)   if (++stackp == RE_run_stack_limit)\
  1119. X                                  stackp = RE_new_run_stack() ;\
  1120. !                stackp->m=mx;stackp->s=sx;stackp->ss=ssx;stackp->u=ux;
  1121. X  
  1122. X  
  1123. --- 51,56 ----
  1124. X  #define  push(mx,sx,ssx,ux)   if (++stackp == RE_run_stack_limit)\
  1125. X                                  stackp = RE_new_run_stack() ;\
  1126. !                stackp->m=(mx);stackp->s=(sx);stackp->ss=(ssx);\
  1127. !            stackp->u=(ux)
  1128. X  
  1129. X  
  1130. ***************
  1131. *** 63,67 ****
  1132. X    char *ss ;
  1133. X    register RT_STATE *stackp ;
  1134. !   int u_flag ;
  1135. X    char *str_end, *ts ;
  1136. X  
  1137. --- 68,72 ----
  1138. X    char *ss ;
  1139. X    register RT_STATE *stackp ;
  1140. !   int u_flag, t ;
  1141. X    char *str_end, *ts ;
  1142. X  
  1143. ***************
  1144. *** 130,135 ****
  1145. X      case M_STR + U_ON + END_ON :
  1146. X              if ( !str_end )  str_end = s + strlen(s) ;
  1147. !             ts = str_end - m->len ;
  1148. !             if (ts < s || memcmp(ts,m->data.str,SIZE_T(m->len+1))) goto refill ;
  1149. X          if ( !ss )  
  1150. X          if ( cb_ss && ts > cb_ss )  goto refill ;
  1151. --- 135,141 ----
  1152. X      case M_STR + U_ON + END_ON :
  1153. X              if ( !str_end )  str_end = s + strlen(s) ;
  1154. !             t  = (str_end - s) - m->len ;
  1155. !             if (t < 0 || memcmp(ts=s+t,m->data.str,SIZE_T(m->len)))
  1156. !                     goto refill ;
  1157. X          if ( !ss )  
  1158. X          if ( cb_ss && ts > cb_ss )  goto refill ;
  1159. ***************
  1160. *** 169,173 ****
  1161. X      case M_CLASS + U_ON + END_ON :
  1162. X              if ( ! str_end )  str_end = s + strlen(s) ;
  1163. !             if ( ! ison(*m->data.bvp, str_end[-1]) ) goto refill ;
  1164. X          if ( !ss )
  1165. X          if ( cb_ss && str_end-1 > cb_ss )  goto refill ;
  1166. --- 175,180 ----
  1167. X      case M_CLASS + U_ON + END_ON :
  1168. X              if ( ! str_end )  str_end = s + strlen(s) ;
  1169. !             if ( s[0] == 0 || ! ison(*m->data.bvp, str_end[-1]) )
  1170. !                     goto refill ;
  1171. X          if ( !ss )
  1172. X          if ( cb_ss && str_end-1 > cb_ss )  goto refill ;
  1173. Index: bi_funct.c
  1174. *** 5.2    1992/07/08 15:43:41
  1175. --- 5.3.1.2    1993/01/27 01:04:06
  1176. ***************
  1177. *** 12,15 ****
  1178. --- 12,24 ----
  1179. X  
  1180. X  /* $Log: bi_funct.c,v $
  1181. +  * Revision 5.3.1.2  1993/01/27  01:04:06  mike
  1182. +  * minor tuning to str_str()
  1183. +  *
  1184. +  * Revision 5.3.1.1  1993/01/15  03:33:35  mike
  1185. +  * patch3: safer double to int conversion
  1186. +  *
  1187. +  * Revision 5.3  1992/12/17  02:48:01  mike
  1188. +  * 1.1.2d changes for DOS
  1189. +  *
  1190. X   * Revision 5.2  1992/07/08  15:43:41  brennan
  1191. X   * patch2: length returns.  I am a wimp
  1192. ***************
  1193. *** 109,129 ****
  1194. X  
  1195. X  char *str_str(target, key , key_len)
  1196. !   register char *target, *key ;
  1197. X    unsigned key_len ;
  1198. X  { 
  1199. X    switch( key_len )
  1200. !   { case 0 :  return (char *) 0 ;
  1201. !     case 1 :  return strchr( target, *key) ;
  1202. X      case 2 :
  1203. !         while ( target = strchr(target, *key) )
  1204. !           if ( target[1] == key[1] )  return  target ;
  1205. !           else target++ ;
  1206. !         /*failed*/
  1207. !         return (char *) 0 ;
  1208. X    }
  1209. X    key_len-- ;
  1210. !   while ( target = strchr(target, *key) )
  1211. !         if ( memcmp(target+1, key+1, SIZE_T(key_len)) == 0 ) return target ;
  1212. X          else target++ ;
  1213. X    /*failed*/
  1214. X    return (char *) 0 ;
  1215. --- 118,148 ----
  1216. X  
  1217. X  char *str_str(target, key , key_len)
  1218. !   register char *target;
  1219. !   char *key ;
  1220. X    unsigned key_len ;
  1221. X  { 
  1222. +   register int k = key[0] ;
  1223. X    switch( key_len )
  1224. !   {
  1225. !     case 0 :  return (char *) 0 ;
  1226. !     case 1 :  return strchr( target, k) ;
  1227. X      case 2 :
  1228. !     { int k1 = key[1] ;
  1229. !         while ( target = strchr(target, k) )
  1230. !           if ( target[1] == k1 )  return  target ;
  1231. !           else target++ ;
  1232. !         /*failed*/
  1233. !         return (char *) 0 ;
  1234. !     }
  1235. X    }
  1236. X    key_len-- ;
  1237. !   while ( target = strchr(target, k) )
  1238. !   {
  1239. !         if ( memcmp(target+1, key+1, SIZE_T(key_len)) == 0 )
  1240. !          return target ;
  1241. X          else target++ ;
  1242. +   }
  1243. X    /*failed*/
  1244. X    return (char *) 0 ;
  1245. ***************
  1246. *** 185,191 ****
  1247. X    else
  1248. X    { if ( TEST2(sp+1) != TWO_DOUBLES ) cast2_to_d(sp+1) ;
  1249. !     n = (int) sp[2].dval ;
  1250. X    }
  1251. !   i = (int) sp[1].dval - 1 ; /* i now indexes into string */
  1252. X  
  1253. X    if ( i < 0 ) { n += i ; i = 0 ; }
  1254. --- 204,210 ----
  1255. X    else
  1256. X    { if ( TEST2(sp+1) != TWO_DOUBLES ) cast2_to_d(sp+1) ;
  1257. !     n = d_to_i(sp[2].dval) ;
  1258. X    }
  1259. !   i = d_to_i(sp[1].dval) - 1 ; /* i now indexes into string */
  1260. X  
  1261. X    if ( i < 0 ) { n += i ; i = 0 ; }
  1262. ***************
  1263. *** 423,431 ****
  1264. X  }
  1265. X  
  1266. ! #ifdef  __TURBOC__
  1267. ! long  biostime(int, long) ;
  1268. ! #define  time(x)  biostime(0,0L)
  1269. ! #else
  1270. ! #ifdef THINK_C
  1271. X  #include <time.h>
  1272. X  #else
  1273. --- 442,446 ----
  1274. X  }
  1275. X  
  1276. ! #ifdef  HAVE_TIME_H
  1277. X  #include <time.h>
  1278. X  #else
  1279. ***************
  1280. *** 432,436 ****
  1281. X  #include <sys/types.h>
  1282. X  #endif
  1283. - #endif
  1284. X  
  1285. X  
  1286. --- 447,450 ----
  1287. ***************
  1288. *** 467,471 ****
  1289. X    if ( c.type == C_NOINIT )  cast1_to_d(&c) ;
  1290. X  
  1291. !   seed =  c.type == C_DOUBLE ? ((int)c.dval & M) % M + 1 :
  1292. X                          hash(string(&c)->str) % M + 1 ;
  1293. X  
  1294. --- 481,485 ----
  1295. X    if ( c.type == C_NOINIT )  cast1_to_d(&c) ;
  1296. X  
  1297. !   seed =  c.type == C_DOUBLE ? (d_to_i(c.dval) & M) % M + 1 :
  1298. X                          hash(string(&c)->str) % M + 1 ;
  1299. X  
  1300. Index: test/fpe_test.bat
  1301. *** 1.1    1991/11/16 15:32:43
  1302. --- 1.2    1992/12/30 22:03:04
  1303. ***************
  1304. *** 127,129 ****
  1305. --- 127,139 ----
  1306. X  
  1307. X  :done
  1308. + set ret1=
  1309. + set ret2=
  1310. + set ret3=
  1311. + set same=
  1312. + if %exception% == 1 goto :done1
  1313. + set exception=
  1314. + exit 0
  1315. + :done1
  1316. + set exception=
  1317. + exit 1
  1318. X  exit %exception%
  1319. Index: UCONFIG
  1320. *** 1.7    1992/08/27 11:45:48
  1321. --- 1.9    1993/02/05 01:40:59
  1322. ***************
  1323. *** 28,32 ****
  1324. X  stardentVr3
  1325. X  
  1326. - apolloSR10.3
  1327. X  dynix
  1328. X  mips
  1329. --- 28,31 ----
  1330. ***************
  1331. *** 35,39 ****
  1332. --- 34,42 ----
  1333. X  aix
  1334. X  convex
  1335. + coherent
  1336. X  
  1337. + 386bsd
  1338. + linux
  1339. X  atarist                cross compile with gcc
  1340. X  
  1341. ***************
  1342. *** 47,50 ****
  1343. --- 50,58 ----
  1344. X  V7:  This port is the work of Carl Mascott.  You'll need to read
  1345. X  his notes and use the .v7 Makefiles
  1346. + Apollo SR10.3: This used to work, but they changed compilers and
  1347. + mawk will no longer compile because  p++->f does not compile
  1348. + correctly.  The offending compiler is CC6.8.
  1349. X  
  1350. X  
  1351. Index: field.c
  1352. *** 5.3    1992/08/17 14:21:10
  1353. --- 5.4.1.2    1993/01/20 12:53:08
  1354. ***************
  1355. *** 12,15 ****
  1356. --- 12,26 ----
  1357. X  
  1358. X  /* $Log: field.c,v $
  1359. +  * Revision 5.4.1.2  1993/01/20  12:53:08  mike
  1360. +  * d_to_l()
  1361. +  *
  1362. +  * Revision 5.4.1.1  1993/01/15  03:33:42  mike
  1363. +  * patch3: safer double to int conversion
  1364. +  *
  1365. +  * Revision 5.4  1992/11/29  22:52:11  mike
  1366. +  * double->string conversions uses long ints for 16/32 bit
  1367. +  * compatibility.
  1368. +  * Fixed small LM_DOS bozo.
  1369. +  *
  1370. X   * Revision 5.3  1992/08/17  14:21:10  brennan
  1371. X   * patch2: After parsing, only bi_sprintf() uses string_buff.
  1372. ***************
  1373. *** 258,262 ****
  1374. X  
  1375. X  #if  LM_DOS
  1376. !   if ( !SAMESEG(fp,field) )  goto lm_dos_label ;
  1377. X  #endif
  1378. X  
  1379. --- 269,277 ----
  1380. X  
  1381. X  #if  LM_DOS
  1382. !   if ( !SAMESEG(fp,field) )
  1383. !   { 
  1384. !     i = -1 ;
  1385. !     goto lm_dos_label ;
  1386. !   }
  1387. X  #endif
  1388. X  
  1389. ***************
  1390. *** 270,274 ****
  1391. X          if ( c.type != C_DOUBLE )  cast1_to_d(&c) ;
  1392. X  
  1393. !         if ( (j = (int) c.dval) < 0 )
  1394. X              rt_error("negative value assigned to NF") ;
  1395. X  
  1396. --- 285,289 ----
  1397. X          if ( c.type != C_DOUBLE )  cast1_to_d(&c) ;
  1398. X  
  1399. !         if ( (j = d_to_i(c.dval)) < 0 )
  1400. X              rt_error("negative value assigned to NF") ;
  1401. X  
  1402. ***************
  1403. *** 408,420 ****
  1404. X        { /* use the string field temporarily */
  1405. X          if ( cp->type == C_NOINIT )
  1406. !     { cp->ptr = (PTR) &null_str ;
  1407. X        null_str.ref_cnt++ ;
  1408. X          }
  1409. X      else /* its a double */
  1410. !     { int ival ;
  1411. X        char xbuff[260] ;
  1412. X  
  1413. !       if ( (double)(ival = (int)cp->dval) == cp->dval )
  1414. !         (void) sprintf(xbuff, "%d", ival) ;
  1415. X        else
  1416. X          (void) sprintf(xbuff, string(CONVFMT)->str, cp->dval) ;
  1417. --- 423,438 ----
  1418. X        { /* use the string field temporarily */
  1419. X          if ( cp->type == C_NOINIT )
  1420. !     { 
  1421. !       cp->ptr = (PTR) &null_str ;
  1422. X        null_str.ref_cnt++ ;
  1423. X          }
  1424. X      else /* its a double */
  1425. !     { 
  1426. !       long ival ;
  1427. X        char xbuff[260] ;
  1428. X  
  1429. !       ival = d_to_l(cp->dval) ;
  1430. !       if ( ival == cp->dval )
  1431. !         (void) sprintf(xbuff, INT_FMT, ival) ;
  1432. X        else
  1433. X          (void) sprintf(xbuff, string(CONVFMT)->str, cp->dval) ;
  1434. ***************
  1435. *** 583,587 ****
  1436. X    
  1437. X    cast1_to_d(cellcpy(&c, BINMODE)) ;
  1438. !   return  (int) c.dval ;
  1439. X  }
  1440. X  
  1441. --- 601,605 ----
  1442. X    
  1443. X    cast1_to_d(cellcpy(&c, BINMODE)) ;
  1444. !   return  d_to_i(c.dval) ;
  1445. X  }
  1446. X  
  1447. Index: config/generic.h
  1448. *** 4.4    1992/03/03 16:40:54
  1449. --- 4.5    1992/11/22 18:30:29
  1450. ***************
  1451. *** 13,16 ****
  1452. --- 13,19 ----
  1453. X  
  1454. X  /* $Log: generic.h,v $
  1455. +  * Revision 4.5  1992/11/22  18:30:29  mike
  1456. +  * strerror()
  1457. +  *
  1458. X   * Revision 4.4  1992/03/03  16:40:54  brennan
  1459. X   * remove HAVE_PRINTF_HD
  1460. ***************
  1461. *** 54,57 ****
  1462. --- 57,61 ----
  1463. X     have strtod()
  1464. X     have fmod()
  1465. +    do not have strerror()
  1466. X  
  1467. X  
  1468. ***************
  1469. *** 70,82 ****
  1470. X  /*
  1471. X  
  1472. - /* tested and works on:
  1473. - SunOS4.1  (sun 4.0.3 has a bug in strtod(), use sun_os40.h)
  1474. - Ultrix4.1  on a MIPS
  1475. - Ultrix4.2  on a MIPS
  1476. - SysV3.02beta on a Stardent 3000
  1477. - */
  1478. X  
  1479. X  #ifndef  CONFIG_H
  1480. --- 74,77 ----
  1481. Index: PATCHES
  1482. *** 1.5    1992/08/27 04:06:44
  1483. --- 1.6    1993/02/05 01:43:06
  1484. ***************
  1485. *** 1,2 ****
  1486. --- 1,25 ----
  1487. + patch3:  mawk1.1.2 -> mawk1.1.3   Jan 93
  1488. + 1) New configurations:
  1489. +    hpux coherent 386bsd linux
  1490. + 2) Changed some ints to longs so that Unix and Dos versions
  1491. +    give same output.  E.g.,
  1492. +    printf "%d" and printf "%ld" are now the same on Dos.
  1493. +    msdos/examples directory with scripts by Ben Myers
  1494. +    Infinity+1 large model pointer bug caused by modulo 2^16
  1495. +    arithmetic fixed.
  1496. + 3) Grossly surprised to discover  (int) d causes a floating
  1497. +    point exception on hpux when d is a large double.
  1498. +    Integer casts are now done more carefully.  Thanks to
  1499. +    Ken Poulton for finding this bug.
  1500. + 4) Removed ApolloSR10.3 from working configurations. Mawk will
  1501. +    not work if compiled with CC6.8.
  1502. X  
  1503. X  patch2:  mawk1.1.1 -> mawk1.1.2   26 Aug 92
  1504. Index: patchlev.h
  1505. *** 1.7    1992/08/27 11:50:38
  1506. --- 1.13    1993/02/03 09:25:40
  1507. ***************
  1508. *** 1,3 ****
  1509. X  /* mawk 1.1 */
  1510. ! #define  PATCHLEVEL    2
  1511. ! #define  PATCH_STRING    ".2"
  1512. --- 1,4 ----
  1513. X  /* mawk 1.1 */
  1514. ! #define  PATCHLEVEL    3
  1515. ! #define  PATCH_STRING    ".3"  
  1516. ! #define  DATE_STRING    "Jan 1993"
  1517. Index: init.c
  1518. *** 5.3    1992/07/10 16:17:10
  1519. --- 5.4    1992/12/24 01:58:19
  1520. ***************
  1521. *** 13,16 ****
  1522. --- 13,19 ----
  1523. X  
  1524. X  /* $Log: init.c,v $
  1525. +  * Revision 5.4  1992/12/24  01:58:19  mike
  1526. +  * 1.1.2d changes for MsDOS
  1527. +  *
  1528. X   * Revision 5.3  1992/07/10  16:17:10  brennan
  1529. X   * MsDOS: remove NO_BINMODE macro
  1530. ***************
  1531. *** 38,41 ****
  1532. --- 41,47 ----
  1533. X  #endif
  1534. X  
  1535. + #if MSDOS
  1536. + #include <fcntl.h>
  1537. + #endif
  1538. X  
  1539. X  static void PROTO( process_cmdline , (int, char **) ) ;
  1540. ***************
  1541. *** 46,56 ****
  1542. X  extern  int  PROTO( is_cmdline_assign, (char*)) ;
  1543. X  
  1544. ! #if 0
  1545. ! #if  MSDOS  &&  ! HAVE_REARGV
  1546. ! #include <fcntl.h>
  1547. ! static  void  PROTO(emit_prompt, (void) ) ;
  1548. X  #endif
  1549. X  #endif
  1550. X  
  1551. X  
  1552. X  void initialize(argc, argv)
  1553. --- 52,63 ----
  1554. X  extern  int  PROTO( is_cmdline_assign, (char*)) ;
  1555. X  
  1556. ! #if  MSDOS
  1557. ! void PROTO(stdout_init,(void)) ;
  1558. ! #if  HAVE_REARGV
  1559. ! void PROTO(reargv, (int*,char***)) ;
  1560. X  #endif
  1561. X  #endif
  1562. X  
  1563. + char *progname ;
  1564. X  
  1565. X  void initialize(argc, argv)
  1566. ***************
  1567. *** 57,60 ****
  1568. --- 64,69 ----
  1569. X    int argc ; char **argv ;
  1570. X  {
  1571. +   SET_PROGNAME() ;
  1572. X    bi_vars_init() ; /* load the builtin variables */
  1573. X    bi_funct_init() ; /* load the builtin functions */
  1574. ***************
  1575. *** 81,84 ****
  1576. --- 90,97 ----
  1577. X    fpe_init() ;
  1578. X    set_stderr() ;
  1579. + #if  MSDOS
  1580. +   stdout_init() ;
  1581. + #endif
  1582. X  }
  1583. X  
  1584. Index: mawk.h
  1585. *** 5.5    1992/07/06 20:15:49
  1586. --- 5.5.1.3    1993/01/22 15:04:50
  1587. ***************
  1588. *** 13,16 ****
  1589. --- 13,25 ----
  1590. X  
  1591. X  /*   $Log: mawk.h,v $
  1592. +  * Revision 5.5.1.3  1993/01/22  15:04:50  mike
  1593. +  * pow2->mpow2 for linux
  1594. +  *
  1595. +  * Revision 5.5.1.2  1993/01/20  12:53:10  mike
  1596. +  * d_to_l()
  1597. +  *
  1598. +  * Revision 5.5.1.1  1993/01/15  03:33:46  mike
  1599. +  * patch3: safer double to int conversion
  1600. +  *
  1601. X   * Revision 5.5  1992/07/06  20:15:49  brennan
  1602. X   * DONT_PROTO_OPEN macro
  1603. ***************
  1604. *** 63,66 ****
  1605. --- 72,77 ----
  1606. X  
  1607. X  
  1608. X  /*----------------
  1609. X   *  GLOBAL VARIABLES
  1610. ***************
  1611. *** 89,93 ****
  1612. X  
  1613. X  /* help with casts */
  1614. ! extern int pow2[] ;
  1615. X  
  1616. X  
  1617. --- 100,104 ----
  1618. X  
  1619. X  /* help with casts */
  1620. ! extern int mpow2[] ;
  1621. X  
  1622. X  
  1623. ***************
  1624. *** 112,116 ****
  1625. X  
  1626. X  /* macro to test the type of two adjacent cells */
  1627. ! #define TEST2(cp)  (pow2[(cp)->type]+pow2[((cp)+1)->type])
  1628. X  
  1629. X  /* macro to get at the string part of a CELL */
  1630. --- 123,127 ----
  1631. X  
  1632. X  /* macro to test the type of two adjacent cells */
  1633. ! #define TEST2(cp)  (mpow2[(cp)->type]+mpow2[((cp)+1)->type])
  1634. X  
  1635. X  /* macro to get at the string part of a CELL */
  1636. ***************
  1637. *** 136,139 ****
  1638. --- 147,153 ----
  1639. X  void  PROTO( check_strnum, (CELL *) ) ;
  1640. X  void  PROTO( cast_to_REPL, (CELL *) ) ;
  1641. + long  PROTO( d_to_l, (double)) ;
  1642. + #define d_to_i(d)    ((int)d_to_l(d))
  1643. X  
  1644. X  int   PROTO( test, (CELL *) ) ; /* test for null non-null */
  1645. ***************
  1646. *** 183,190 ****
  1647. X  char *PROTO( find_kw_str, (int) ) ;
  1648. X  
  1649. - #if ! HAVE_STDLIB_H
  1650. X  double strtod() ;
  1651. - #endif
  1652. X  double fmod() ;
  1653. X  
  1654. --- 197,201 ----
  1655. Index: config/Idefault.h
  1656. *** 3.15    1992/07/08 16:16:08
  1657. --- 3.18.1.1    1993/01/15 03:33:52
  1658. ***************
  1659. *** 13,68 ****
  1660. X  
  1661. X  /* $Log: Idefault.h,v $
  1662. !  * Revision 3.15  1992/07/08  16:16:08  brennan
  1663. !  * don't attempt any #def or #undef with __STDC__
  1664. X   *
  1665. !  * Revision 3.14  1992/03/31  13:39:00  brennan
  1666. !  * TURN_ON_FPE_TRAPS() macro
  1667. X   *
  1668. !  * Revision 3.13  92/03/03  16:40:56  brennan
  1669. !  * remove HAVE_PRINTF_HD
  1670. !  * 
  1671. !  * Revision 3.12  91/11/16  15:37:29  brennan
  1672. !  * add NO_BINMODE
  1673. !  * 
  1674. !  * Revision 3.11  91/10/29  10:48:40  brennan
  1675. !  * version 1.09
  1676. !  * 
  1677. !  * Revision 3.10  91/10/23  10:46:34  brennan
  1678. !  * MSDOS LM and SM
  1679. !  * 
  1680. !  * Revision 3.9  91/10/14  09:52:48  brennan
  1681. !  * added HAVE_PRINTF_HD
  1682. !  * 
  1683. !  * Revision 3.8  91/09/30  08:11:22  brennan
  1684. !  * added MAX__INT
  1685. !  * 
  1686. !  * Revision 3.7  91/08/16  08:49:51  brennan
  1687. !  * Carl's addition of SW_FP_CHECK for XNX23A
  1688. !  * 
  1689. !  * Revision 3.6  91/08/13  09:04:05  brennan
  1690. !  * VERSION .9994
  1691. !  * 
  1692. !  * Revision 3.5  91/08/03  06:10:46  brennan
  1693. !  * changed CHECK_DIVZERO macro
  1694. !  * 
  1695. !  * Revision 3.4  91/08/03  05:35:59  brennan
  1696. !  * changed name to Idefault.h 
  1697. !  * 
  1698. !  * Revision 3.3  91/06/28  04:36:28  brennan
  1699. !  * adjustments with __STDC__
  1700. !  * 
  1701. !  * Revision 3.3  91/06/19  10:21:37  brennan
  1702. !  * changes for xenix_r2.h and gcc
  1703. !  * 
  1704. !  * Revision 3.2  91/06/15  09:24:34  brennan
  1705. !  * Carl's diffs for V7
  1706. !  * 
  1707. !  * 06/11/91  C. Mascott        add default D2BOOL
  1708. X   *
  1709. -  * Revision 3.1  91/06/07  10:38:46  brennan
  1710. -  * VERSION 0.995
  1711. -  * 
  1712. X  */
  1713. X  
  1714. X  /* The most common configuration is defined here:
  1715. X   
  1716. --- 13,92 ----
  1717. X  
  1718. X  /* $Log: Idefault.h,v $
  1719. !  * Revision 3.18.1.1  1993/01/15  03:33:52  mike
  1720. !  * patch3: safer double to int conversion
  1721. !  *
  1722. !  * Revision 3.18  1992/12/17  02:48:01  mike
  1723. !  * 1.1.2d changes for DOS
  1724. !  *
  1725. !  * Revision 3.17  1992/11/26  15:35:52  mike
  1726. !  * don't assume __STDC__ implies HAVE_STRERROR
  1727. X   *
  1728. !  * Revision 3.16  1992/11/22  19:00:43  mike
  1729. !  * allow STDC assumptions to be overridden
  1730. X   *
  1731. !  * Revision 3.15  1992/07/08  16:16:08  brennan
  1732. !  * don't attempt any #def or #undef with __STDC__
  1733. X   *
  1734. X  */
  1735. X  
  1736. + #ifdef __STDC__
  1737. + #if   __STDC__  
  1738. + #undef  HAVE_PROTOS
  1739. + #define HAVE_PROTOS        1
  1740. + #undef  HAVE_VOID_PTR
  1741. + #define HAVE_VOID_PTR        1
  1742. + /* these can be overidden */
  1743. + #ifndef  HAVE_STDARG_H
  1744. + #define HAVE_STDARG_H        1
  1745. + #endif
  1746. + #ifndef  HAVE_STRING_H
  1747. + #define HAVE_STRING_H        1
  1748. + #endif
  1749. + #ifndef  HAVE_STDLIB_H
  1750. + #define HAVE_STDLIB_H        1
  1751. + #endif
  1752. + #endif  
  1753. + #endif
  1754. + #ifdef    MSDOS
  1755. + #ifndef  HAVE_REARGV
  1756. + #define  HAVE_REARGV    0
  1757. + #endif
  1758. + #if HAVE_REARGV
  1759. + #define  SET_PROGNAME()  reargv(&argc,&argv) ; progname = argv[0]
  1760. + #else
  1761. + #define  SET_PROGNAME()  progname = "mawk"
  1762. + #endif
  1763. + #define  MAX__INT    0x7fff
  1764. + #if  HAVE_SMALL_MEMORY==0
  1765. + #define  LM_DOS        1
  1766. + #else
  1767. + #define  LM_DOS        0
  1768. + #endif
  1769. + #define   SM_DOS    (!LM_DOS)
  1770. + #define HAVE_REAL_PIPES        0
  1771. + #define HAVE_FAKE_PIPES        1
  1772. + #else /* not defined MSDOS */
  1773. + #define   MSDOS        0
  1774. + #define   LM_DOS    0
  1775. + #define   SM_DOS    0
  1776. + #endif /* MSDOS */
  1777. X  /* The most common configuration is defined here:
  1778. X   
  1779. ***************
  1780. *** 121,124 ****
  1781. --- 145,152 ----
  1782. X  #endif
  1783. X  
  1784. + #ifndef  HAVE_STRERROR
  1785. + #define  HAVE_STRERROR        0
  1786. + #endif
  1787. X  /* uses <varargs.h> instead of <stdarg.h> */
  1788. X  #ifndef  HAVE_STDARG_H    
  1789. ***************
  1790. *** 152,155 ****
  1791. --- 180,196 ----
  1792. X  #endif
  1793. X  
  1794. + /* don't have strerror() */
  1795. + #ifndef  HAVE_STRERROR
  1796. + #define  HAVE_STRERROR        0
  1797. + #endif
  1798. + #ifndef  SET_PROGNAME
  1799. + #define  SET_PROGNAME()        { char *strrchr() , *p ;\
  1800. +                                   p = strrchr(argv[0],'/') ;\
  1801. +                   progname = p ? p+1 : argv[0] ; }
  1802. + #endif
  1803. +                   
  1804. +                   
  1805. X  /*------------- machine ------------------------*/
  1806. X  
  1807. ***************
  1808. *** 157,162 ****
  1809. --- 198,214 ----
  1810. X  #ifndef  MAX__INT     
  1811. X  #define  MAX__INT    0x7fffffff
  1812. + #define  INT_FMT    "%d"
  1813. + #endif
  1814. + #ifndef  MAX__LONG
  1815. + #define  MAX__LONG    0x7fffffff
  1816. X  #endif
  1817. X  
  1818. + #if  MAX__INT <= 0x7fff
  1819. + #define  SHORT_INTS
  1820. + #define  INT_FMT    "%ld"
  1821. + #endif
  1822. X  /* default is IEEE754 and data space is not scarce */
  1823. X  
  1824. ***************
  1825. *** 204,224 ****
  1826. X  
  1827. X  
  1828. - #ifdef __STDC__
  1829. - #if   __STDC__  
  1830. - #undef  HAVE_PROTOS
  1831. - #define HAVE_PROTOS        1
  1832. - #undef  HAVE_VOID_PTR
  1833. - #define HAVE_VOID_PTR        1
  1834. - #undef  HAVE_STDARG_H
  1835. - #define HAVE_STDARG_H        1
  1836. - #undef  HAVE_STRING_H
  1837. - #define HAVE_STRING_H        1
  1838. - #undef  HAVE_STDLIB_H
  1839. - #define HAVE_STDLIB_H        1
  1840. - #endif  
  1841. - #endif
  1842. X  
  1843. X  
  1844. X  /* the painfull case: we need to catch fpe's and look at errno
  1845. X     after lib calls */
  1846. --- 256,261 ----
  1847. ***************
  1848. *** 226,272 ****
  1849. X  #define  STDC_MATHERR    ((SW_FP_CHECK || FPE_TRAPS_ON) && HAVE_MATHERR==0)
  1850. X  
  1851. - /*-------------------MSDOS---------------------------------*/
  1852. - #ifdef    MSDOS
  1853. - #ifndef  HAVE_REARGV
  1854. - #define  HAVE_REARGV    0
  1855. - #endif
  1856. - #undef   MAX__INT
  1857. - #define  MAX__INT    0x7fff
  1858. - #if  HAVE_SMALL_MEMORY==0
  1859. - #define  LM_DOS        1
  1860. - #else
  1861. - #define  LM_DOS        0
  1862. - #endif
  1863. - #define   SM_DOS    (!LM_DOS)
  1864. - #undef  HAVE_REAL_PIPES
  1865. - #define HAVE_REAL_PIPES        0
  1866. - #undef  HAVE_FAKE_PIPES
  1867. - #define HAVE_FAKE_PIPES        1
  1868. - #if  SM_DOS 
  1869. - #ifdef  NO_BINMODE
  1870. - #undef  NO_BINMODE
  1871. - #define NO_BINMODE    1   /* hopefully no one needs this */
  1872. - #else
  1873. - #define NO_BINMODE    0
  1874. - #endif
  1875. - #else 
  1876. - #define NO_BINMODE    0
  1877. - #endif /* SM_DOS */
  1878. - #else /* not defined MSDOS */
  1879. - #define   MSDOS        0
  1880. - #define   LM_DOS    0
  1881. - #define   SM_DOS    0
  1882. - #endif /* MSDOS */
  1883. - /*----------------------------------------------------------*/
  1884. X  
  1885. X  
  1886. --- 263,266 ----
  1887. Index: msdos/dosexec.c
  1888. *** 1.3    1992/07/10 16:21:57
  1889. --- 1.4    1992/12/05 22:29:43
  1890. ***************
  1891. *** 12,15 ****
  1892. --- 12,20 ----
  1893. X  
  1894. X  /*$Log: dosexec.c,v $
  1895. +  * Revision 1.4  1992/12/05  22:29:43  mike
  1896. +  * dos patch 112d:
  1897. +  * don't use string_buff
  1898. +  * check COMSPEC
  1899. +  *
  1900. X   * Revision 1.3  1992/07/10  16:21:57  brennan
  1901. X   * store exit code of input pipes
  1902. ***************
  1903. *** 43,56 ****
  1904. X    int len ;
  1905. X  
  1906. !   if ( !(s = getenv("MAWKSHELL")) )
  1907. X    {
  1908. !     errmsg(0, "MAWKSHELL not set in environment") ; exit(1) ;
  1909. X    }
  1910. -   p = s ;
  1911. -   while ( *p != ' ' && *p != '\t' ) p++ ;
  1912. -   len = p - s ;
  1913. -   shell = (char *) zmalloc( len + 1 ) ;
  1914. -   (void) memcpy(shell, s, len) ;  shell[len] = 0 ;
  1915. -   command_opt = p ;
  1916. X  }
  1917. X  
  1918. --- 48,74 ----
  1919. X    int len ;
  1920. X  
  1921. !   if ( s = getenv("MAWKSHELL") )
  1922. !   {
  1923. !     /* break into shell part and option part */
  1924. !     p = s ;
  1925. !     while ( *p != ' ' && *p != '\t' ) p++ ;
  1926. !     len = p - s ;
  1927. !     shell = (char *) zmalloc(len+1) ;
  1928. !     memcpy(shell, s, len) ; shell[len] = 0 ;
  1929. !     command_opt = p ;
  1930. !   }
  1931. !   else
  1932. !   if ( s = getenv("COMSPEC") )
  1933. !   {
  1934. !     shell = s ;
  1935. !     command_opt = " /c" ;
  1936. !     /* leading space needed because of bug in command.com */
  1937. !   }
  1938. !   else
  1939. X    {
  1940. !     errmsg(0,
  1941. !     "cannot exec(), must set MAWKSHELL or COMSPEC in environment" ) ;
  1942. !     exit(1) ;
  1943. X    }
  1944. X  }
  1945. X  
  1946. ***************
  1947. *** 104,117 ****
  1948. X  static int next_tmp ;  /* index for naming temp files */
  1949. X  static char *tmpdir ;  /* directory to hold temp files */
  1950. X  
  1951. X  
  1952. ! /* put the name of a temp file in string buff */
  1953. ! char *tmp_file_name( id )
  1954. X    int id ;
  1955. X  {
  1956. !   (void) sprintf(string_buff, "%sMAWK%04X.TMP", tmpdir, id) ;
  1957. !   return string_buff ;
  1958. X  }
  1959. X  
  1960. X  PTR  get_pipe( command, type, tmp_idp)
  1961. X    char *command ;
  1962. --- 122,156 ----
  1963. X  static int next_tmp ;  /* index for naming temp files */
  1964. X  static char *tmpdir ;  /* directory to hold temp files */
  1965. + static unsigned mawkid ; /* unique to this mawk process */
  1966. X  
  1967. X  
  1968. ! /* compute the unique temp file name associated with id */
  1969. ! char *tmp_file_name(id, buffer )
  1970. X    int id ;
  1971. +   char *buffer ;
  1972. X  {
  1973. !   if ( mawkid == 0 )
  1974. !   {
  1975. !     /* first time */
  1976. !     union {
  1977. !     void far *ptr ;
  1978. !     unsigned w[2] ;
  1979. !     } xptr ;
  1980. !     xptr.ptr = (void far*)&mawkid ;
  1981. !     mawkid = xptr.w[1] ;
  1982. !     tmpdir = getenv("MAWKTMPDIR") ;
  1983. !     if ( ! tmpdir || strlen(tmpdir) > 80 ) tmpdir = "" ;
  1984. !   }
  1985. !   (void) sprintf(buffer, "%sMAWK%04X.%03X",tmpdir, mawkid, id) ;
  1986. !   return buffer ;
  1987. X  }
  1988. X  
  1989. + /* open a pipe, returning a temp file identifier by
  1990. +    reference
  1991. + */
  1992. X  PTR  get_pipe( command, type, tmp_idp)
  1993. X    char *command ;
  1994. ***************
  1995. *** 119,141 ****
  1996. X  {
  1997. X    PTR  retval ;
  1998. !   char *tmpfile ;
  1999. X  
  2000. -   if ( ! tmpdir )
  2001. -   {
  2002. -     tmpdir = getenv("MAWKTMPDIR") ;
  2003. -     if ( ! tmpdir )  tmpdir = "" ;
  2004. -   }
  2005. X  
  2006. X    *tmp_idp = next_tmp ;
  2007. !   tmpfile = tmp_file_name(next_tmp) ;
  2008. X  
  2009. X    if ( type == PIPE_OUT )  
  2010. !       retval = (PTR) fopen(tmpfile, (binmode()&2)? "wb":"w") ;
  2011. X    else
  2012. !   { char xbuff[256] ;
  2013. !     
  2014. !     sprintf(xbuff, "%s > %s" , command, tmpfile) ;
  2015. X      tmp_idp[1] = DOSexec(xbuff) ;
  2016. !     retval = (PTR) FINopen(tmpfile, 0) ;
  2017. X    }
  2018. X  
  2019. --- 158,177 ----
  2020. X  {
  2021. X    PTR  retval ;
  2022. !   char xbuff[256] ;
  2023. !   char *tmpname ;
  2024. X  
  2025. X  
  2026. X    *tmp_idp = next_tmp ;
  2027. !   tmpname = tmp_file_name(next_tmp, xbuff+163) ;
  2028. X  
  2029. X    if ( type == PIPE_OUT )  
  2030. !   {
  2031. !     retval = (PTR) fopen(tmpname, (binmode()&2)? "wb":"w") ;
  2032. !   }
  2033. X    else
  2034. !   { 
  2035. !     sprintf(xbuff, "%s > %s" , command, tmpname) ;
  2036. X      tmp_idp[1] = DOSexec(xbuff) ;
  2037. !     retval = (PTR) FINopen(tmpname, 0) ;
  2038. X    }
  2039. X  
  2040. ***************
  2041. *** 152,157 ****
  2042. X    int tid ; /* identifies the temp file */
  2043. X  {
  2044. -   char *tmpname = tmp_file_name(tid) ;
  2045. X    char xbuff[256] ;
  2046. X    int retval ;
  2047. X  
  2048. --- 188,193 ----
  2049. X    int tid ; /* identifies the temp file */
  2050. X  {
  2051. X    char xbuff[256] ;
  2052. +   char *tmpname = tmp_file_name(tid, xbuff+163) ;
  2053. X    int retval ;
  2054. X  
  2055. Index: print.c
  2056. *** 5.3    1992/08/17 14:23:21
  2057. --- 5.4.1.2    1993/01/20 12:53:11
  2058. ***************
  2059. *** 12,15 ****
  2060. --- 12,25 ----
  2061. X  
  2062. X  /* $Log: print.c,v $
  2063. +  * Revision 5.4.1.2  1993/01/20  12:53:11  mike
  2064. +  * d_to_l()
  2065. +  *
  2066. +  * Revision 5.4.1.1  1993/01/15  03:33:47  mike
  2067. +  * patch3: safer double to int conversion
  2068. +  *
  2069. +  * Revision 5.4  1992/11/29  18:03:11  mike
  2070. +  * when printing integers, convert doubles to
  2071. +  * longs so output is the same on 16bit systems as 32bit systems
  2072. +  *
  2073. X   * Revision 5.3  1992/08/17  14:23:21  brennan
  2074. X   * patch2: After parsing, only bi_sprintf() uses string_buff.
  2075. ***************
  2076. *** 48,52 ****
  2077. X    register CELL *p ;
  2078. X    register FILE *fp ;
  2079. ! { register int len ;
  2080. X    
  2081. X    switch( p->type )
  2082. --- 58,63 ----
  2083. X    register CELL *p ;
  2084. X    register FILE *fp ;
  2085. ! { 
  2086. !   int len ;
  2087. X    
  2088. X    switch( p->type )
  2089. ***************
  2090. *** 69,76 ****
  2091. X  
  2092. X      case C_DOUBLE :
  2093. !     if ( (double)(len = (int) p->dval) == p->dval )
  2094. !         fprintf(fp, "%d", len) ;
  2095. !     else
  2096. !         fprintf(fp, string(OFMT)->str, p->dval) ;
  2097. X          break ;
  2098. X  
  2099. --- 80,92 ----
  2100. X  
  2101. X      case C_DOUBLE :
  2102. !     {
  2103. !       long ival = d_to_l(p->dval) ;
  2104. !       /* integers print as "%[l]d" */ 
  2105. !       if ( (double) ival == p->dval )
  2106. !             fprintf(fp, INT_FMT, ival) ;
  2107. !       else
  2108. !           fprintf(fp, string(OFMT)->str, p->dval) ;
  2109. !     }
  2110. X          break ;
  2111. X  
  2112. ***************
  2113. *** 92,104 ****
  2114. X  CELL *bi_print(sp)
  2115. X    CELL *sp ; /* stack ptr passed in */
  2116. ! { register CELL *p ;
  2117. X    register int k ;
  2118. X    FILE *fp ;
  2119. X  
  2120. !   if ( (k = sp->type) < 0 )
  2121. !   { if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ;
  2122. X      fp = (FILE *) file_find( string(sp), k ) ;
  2123. X      free_STRING(string(sp)) ;
  2124. X      k = (--sp)->type ;
  2125. X    }
  2126. X    else  fp = stdout ;
  2127. --- 108,125 ----
  2128. X  CELL *bi_print(sp)
  2129. X    CELL *sp ; /* stack ptr passed in */
  2130. ! { 
  2131. !   register CELL *p ;
  2132. X    register int k ;
  2133. X    FILE *fp ;
  2134. X  
  2135. !   k = sp->type ;
  2136. !   if ( k < 0 )
  2137. !   { 
  2138. !     /* k holds redirection */
  2139. !     if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ;
  2140. X      fp = (FILE *) file_find( string(sp), k ) ;
  2141. X      free_STRING(string(sp)) ;
  2142. X      k = (--sp)->type ;
  2143. +     /* k now has number of arguments */
  2144. X    }
  2145. X    else  fp = stdout ;
  2146. ***************
  2147. *** 105,113 ****
  2148. X  
  2149. X    if ( k )  
  2150. !   { p = sp - k ; /* clear k variables off the stack */
  2151. X      sp = p - 1 ;
  2152. !     while ( k-- > 1 ) 
  2153. !     { print_cell(p,fp) ; print_cell(OFS,fp) ;
  2154. !       cell_destroy(p) ; p++ ; }
  2155. X      
  2156. X      print_cell(p, fp) ;  cell_destroy(p) ;
  2157. --- 126,140 ----
  2158. X  
  2159. X    if ( k )  
  2160. !   { 
  2161. !     p = sp - k ; /* clear k variables off the stack */
  2162. X      sp = p - 1 ;
  2163. !     k-- ;
  2164. !     while ( k > 0 ) 
  2165. !     { 
  2166. !       print_cell(p,fp) ; print_cell(OFS,fp) ;
  2167. !       cell_destroy(p) ; 
  2168. !       p++ ; k-- ;
  2169. !     }
  2170. X      
  2171. X      print_cell(p, fp) ;  cell_destroy(p) ;
  2172. ***************
  2173. *** 114,119 ****
  2174. X    }
  2175. X    else  
  2176. !   { sp-- ;
  2177. !     print_cell( &field[0], fp )  ; }
  2178. X  
  2179. X    print_cell(ORS , fp) ;
  2180. --- 141,148 ----
  2181. X    }
  2182. X    else  
  2183. !   { /* print $0 */
  2184. !     sp-- ;
  2185. !     print_cell( &field[0], fp )  ;
  2186. !   }
  2187. X  
  2188. X    print_cell(ORS , fp) ;
  2189. ***************
  2190. *** 122,133 ****
  2191. X    
  2192. X  /*---------- types and defs for doing printf and sprintf----*/
  2193. ! #define  PF_C        0
  2194. ! #define  PF_S        1
  2195. X  #define  PF_D        2   /* int conversion */
  2196. ! #define  PF_LD        3   /* long int */
  2197. ! #define  PF_F        4   /* float conversion */
  2198. X  
  2199. X  /* for switch on number of '*' and type */
  2200. ! #define  AST(num,type)  (5*(num)+(type))
  2201. X  
  2202. X  /* some picky ANSI compilers go berserk without this */
  2203. SHAR_EOF
  2204. true || echo 'restore of patch3 failed'
  2205. fi
  2206. echo 'End of  part 1'
  2207. echo 'File patch3 is continued in part 2'
  2208. echo 2 > _shar_seq_.tmp
  2209. exit 0
  2210.  
  2211.