home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume03 / mawkpch3 / 2 < prev    next >
Encoding:
Internet Message Format  |  1993-03-13  |  52.9 KB

  1. From: Michael Brennan <brennan@atc.boeing.com>
  2.  
  3. #!/bin/sh
  4. # this is xxx.02 (part 2 of a multipart archive)
  5. # do not concatenate these parts, unpack them in order with /bin/sh
  6. # file patch3 continued
  7. #
  8. if test ! -r _shar_seq_.tmp; then
  9.     echo 'Please unpack part 1 first!'
  10.     exit 1
  11. fi
  12. (read Scheck
  13.  if test "$Scheck" != 2; then
  14.     echo Please unpack part "$Scheck" next!
  15.     exit 1
  16.  else
  17.     exit 0
  18.  fi
  19. ) < _shar_seq_.tmp || exit 1
  20. if test ! -f _shar_wnt_.tmp; then
  21.     echo 'x - still skipping patch3'
  22. else
  23. echo 'x - continuing file patch3'
  24. sed 's/^X//' << 'SHAR_EOF' >> 'patch3' &&
  25. --- 151,161 ----
  26. X    
  27. X  /*---------- types and defs for doing printf and sprintf----*/
  28. ! #define  PF_C        0   /* %c */
  29. ! #define  PF_S        1   /* %s */
  30. X  #define  PF_D        2   /* int conversion */
  31. ! #define  PF_F        3   /* float conversion */
  32. X  
  33. X  /* for switch on number of '*' and type */
  34. ! #define  AST(num,type)  ((PF_F+1)*(num)+(type))
  35. X  
  36. X  /* some picky ANSI compilers go berserk without this */
  37. ***************
  38. *** 166,171 ****
  39. X    int ast_cnt ;
  40. X    int ast[2] ;
  41. !   long lval ;
  42. !   int ival ;  /* caters to MSDOS */
  43. X    int num_conversion = 0 ; /* for error messages */
  44. X    char *who ; /*ditto*/
  45. --- 194,198 ----
  46. X    int ast_cnt ;
  47. X    int ast[2] ;
  48. !   long lval ;  /* hold integer values */
  49. X    int num_conversion = 0 ; /* for error messages */
  50. X    char *who ; /*ditto*/
  51. ***************
  52. *** 173,176 ****
  53. --- 200,207 ----
  54. X    PRINTER printer ; /* pts at fprintf() or sprintf() */
  55. X  
  56. + #ifdef   SHORT_INTS
  57. +   char xbuff[256] ; /* splice in l qualifier here */
  58. + #endif
  59. X    if ( fp == (FILE *) 0 ) /* doing sprintf */
  60. X    {
  61. ***************
  62. *** 220,223 ****
  63. --- 251,255 ----
  64. X         
  65. X  
  66. +     /* *q == '%' */
  67. X      num_conversion++ ;
  68. X    
  69. ***************
  70. *** 241,245 ****
  71. X      { 
  72. X        if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  73. !       ast[ast_cnt++] = (int) cp++ ->dval ;
  74. X        argcnt-- ; q++ ;
  75. X      }
  76. --- 273,277 ----
  77. X      { 
  78. X        if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  79. !       ast[ast_cnt++] = d_to_i(cp++ ->dval) ;
  80. X        argcnt-- ; q++ ;
  81. X      }
  82. ***************
  83. *** 253,257 ****
  84. X        {
  85. X      if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  86. !         ast[ast_cnt++] = (int) cp++ ->dval ;
  87. X          argcnt-- ; q++ ;
  88. X        }
  89. --- 285,289 ----
  90. X        {
  91. X      if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  92. !         ast[ast_cnt++] = d_to_i(cp++ ->dval) ;
  93. X          argcnt-- ; q++ ;
  94. X        }
  95. ***************
  96. *** 286,290 ****
  97. X          {
  98. X            case C_NOINIT :
  99. !             ival = 0 ;
  100. X              break ;
  101. X  
  102. --- 318,322 ----
  103. X          {
  104. X            case C_NOINIT :
  105. !             lval = 0 ;
  106. X              break ;
  107. X  
  108. ***************
  109. *** 291,299 ****
  110. X            case C_STRNUM :
  111. X            case C_DOUBLE :
  112. !             ival = (int) cp->dval ;
  113. X              break ;
  114. X  
  115. X            case  C_STRING :
  116. !             ival = string(cp)->str[0] ;
  117. X              break ;
  118. X  
  119. --- 323,331 ----
  120. X            case C_STRNUM :
  121. X            case C_DOUBLE :
  122. !             lval = (long) d_to_i(cp->dval) ;
  123. X              break ;
  124. X  
  125. X            case  C_STRING :
  126. !             lval = string(cp)->str[0] ;
  127. X              break ;
  128. X  
  129. ***************
  130. *** 300,305 ****
  131. X            case  C_MBSTRN :
  132. X              check_strnum(cp) ;
  133. !             ival = cp->type == C_STRING ?
  134. !             string(cp)->str[0] : (int) cp->dval ;
  135. X              break ;
  136. X            
  137. --- 332,337 ----
  138. X            case  C_MBSTRN :
  139. X              check_strnum(cp) ;
  140. !             lval = cp->type == C_STRING ?
  141. !             string(cp)->str[0] : (long) d_to_i(cp->dval) ;
  142. X              break ;
  143. X            
  144. ***************
  145. *** 318,325 ****
  146. X        case 'u' :
  147. X              if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  148. !             lval = (long) cp->dval ;
  149. !         if ( h_flag ) lval &= 0xffff ;
  150. X  
  151. !             pf_type = l_flag ? PF_LD : PF_D ;
  152. X              break ;
  153. X      
  154. --- 350,359 ----
  155. X        case 'u' :
  156. X              if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ;
  157. !         if ( cp->dval > MAX__LONG ) lval = MAX__LONG ;
  158. !         else
  159. !         if ( cp->dval > -MAX__LONG ) lval = (long) cp->dval ;
  160. !         else lval = -MAX__LONG ;
  161. X  
  162. !             pf_type = PF_D ;
  163. X              break ;
  164. X      
  165. ***************
  166. *** 341,344 ****
  167. --- 375,407 ----
  168. X      *q = 0 ;
  169. X  
  170. + #ifdef  SHORT_INTS
  171. +     if ( pf_type == PF_D )
  172. +     {
  173. +       /* need to splice in long modifier */
  174. +       strcpy(xbuff, p) ;
  175. +       if ( l_flag ) /* do nothing */ ;
  176. +       else
  177. +       {
  178. +     int k = q - p ;
  179. +     if ( h_flag )
  180. +     {
  181. +       lval = (short) lval ;
  182. +       /* replace the 'h' with 'l' (really!) */
  183. +       xbuff[k-2] = 'l' ;
  184. +       if ( xbuff[k-1] != 'd' && xbuff[k-1] != 'i' ) lval &= 0xffff ;
  185. +     }
  186. +     else
  187. +     {
  188. +       /* the usual case */
  189. +       xbuff[k] = xbuff[k-1] ;
  190. +       xbuff[k-1] = 'l' ;
  191. +       xbuff[k+1] = 0 ;
  192. +     }
  193. +       }
  194. +     }
  195. + #endif
  196. X      /* ready to call printf() */
  197. X      switch( AST(ast_cnt, pf_type ) )
  198. ***************
  199. *** 345,357 ****
  200. X      {
  201. X        case AST(0, PF_C )  :
  202. !             (*printer)((PTR) target, p, ival) ;
  203. X              break ;
  204. X  
  205. X        case AST(1, PF_C ) :
  206. !             (*printer)((PTR) target, p, ast[0], ival) ;
  207. X              break ;
  208. X  
  209. X        case AST(2, PF_C ) :
  210. !             (*printer)((PTR) target, p, ast[0], ast[1], ival) ;
  211. X              break ;
  212. X  
  213. --- 408,420 ----
  214. X      {
  215. X        case AST(0, PF_C )  :
  216. !             (*printer)((PTR) target, p, (int) lval) ;
  217. X              break ;
  218. X  
  219. X        case AST(1, PF_C ) :
  220. !             (*printer)((PTR) target, p, ast[0], (int) lval) ;
  221. X              break ;
  222. X  
  223. X        case AST(2, PF_C ) :
  224. !             (*printer)((PTR) target, p, ast[0], ast[1], (int)lval) ;
  225. X              break ;
  226. X  
  227. ***************
  228. *** 365,394 ****
  229. X  
  230. X        case AST(2, PF_S) :
  231. !             (*printer)((PTR) target, p, ast[0], ast[1], string(cp)->str) ;
  232. X              break ;
  233. X  
  234. X        case AST(0, PF_D) :
  235. !             (*printer)((PTR) target, p, (int) lval) ;
  236. X              break ;
  237. X  
  238. X        case AST(1, PF_D) :
  239. !             (*printer)((PTR) target, p, ast[0], (int) lval) ;
  240. X              break ;
  241. X  
  242. X        case AST(2, PF_D) :
  243. !             (*printer)((PTR) target, p, ast[0], ast[1], (int) lval) ;
  244. !             break ;
  245. !       case AST(0, PF_LD) :
  246. !             (*printer)((PTR) target, p,  lval) ;
  247. X              break ;
  248. X  
  249. !       case AST(1, PF_LD) :
  250. !             (*printer)((PTR) target, p, ast[0],  lval) ;
  251. !             break ;
  252. X  
  253. -       case AST(2, PF_LD) :
  254. -             (*printer)((PTR) target, p, ast[0], ast[1],  lval) ;
  255. -             break ;
  256. X  
  257. X        case AST(0, PF_F) :
  258. --- 428,453 ----
  259. X  
  260. X        case AST(2, PF_S) :
  261. !             (*printer)((PTR) target,p,ast[0],ast[1],string(cp)->str) ;
  262. X              break ;
  263. X  
  264. + #ifdef  SHORT_INTS
  265. + #define    FMT    xbuff     /* format in xbuff */
  266. + #else
  267. + #define FMT     p         /* p -> format */
  268. + #endif
  269. X        case AST(0, PF_D) :
  270. !             (*printer)((PTR) target, FMT, lval) ;
  271. X              break ;
  272. X  
  273. X        case AST(1, PF_D) :
  274. !             (*printer)((PTR) target, FMT, ast[0], lval) ;
  275. X              break ;
  276. X  
  277. X        case AST(2, PF_D) :
  278. !             (*printer)((PTR) target, FMT, ast[0], ast[1], lval) ;
  279. X              break ;
  280. X  
  281. ! #undef  FMT
  282. X  
  283. X  
  284. X        case AST(0, PF_F) :
  285. ***************
  286. *** 415,432 ****
  287. X    FILE *fp ;
  288. X  
  289. !   if ( (k = sp->type) < 0 )
  290. !   { if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ;
  291. X      fp = (FILE *) file_find( string(sp), k ) ;
  292. X      free_STRING(string(sp)) ;
  293. X      k = (--sp)->type ;
  294. X    }
  295. X    else  fp = stdout ;
  296. X  
  297. !   sp -= k-- ; /* sp points at the format string */
  298. X    if ( sp->type < C_STRING )  cast1_to_s(sp) ;
  299. X    do_printf(fp, string(sp)->str, k, sp+1) ;
  300. X    free_STRING(string(sp)) ;
  301. !   for ( p = sp+1 ; k-- ; p++ )  cell_destroy(p) ;
  302. X    return --sp ;
  303. X  }
  304. --- 474,498 ----
  305. X    FILE *fp ;
  306. X  
  307. !   k = sp->type ;
  308. !   if ( k  < 0 )
  309. !   { 
  310. !     /* k has redirection */
  311. !     if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ;
  312. X      fp = (FILE *) file_find( string(sp), k ) ;
  313. X      free_STRING(string(sp)) ;
  314. X      k = (--sp)->type ;
  315. +     /* k is now number of args including format */
  316. X    }
  317. X    else  fp = stdout ;
  318. X  
  319. !   sp -= k ; /* sp points at the format string */
  320. !   k-- ;
  321. X    if ( sp->type < C_STRING )  cast1_to_s(sp) ;
  322. X    do_printf(fp, string(sp)->str, k, sp+1) ;
  323. X    free_STRING(string(sp)) ;
  324. !   /* cleanup arguments on eval stack */
  325. !   for ( p = sp+1 ; k ; k--, p++ )  cell_destroy(p) ;
  326. X    return --sp ;
  327. X  }
  328. ***************
  329. *** 438,444 ****
  330. X    STRING *sval ;
  331. X  
  332. !   sp -= argcnt-- ; /* sp points at the format string */
  333. !   if ( sp->type != C_STRING )  cast1_to_s(sp) ;
  334. X  
  335. X    sval = do_printf((FILE *)0, string(sp)->str, argcnt, sp+1) ;
  336. X    free_STRING(string(sp)) ;
  337. --- 504,511 ----
  338. X    STRING *sval ;
  339. X  
  340. !   sp -= argcnt ; /* sp points at the format string */
  341. !   argcnt-- ;
  342. X  
  343. +   if ( sp->type != C_STRING )  cast1_to_s(sp) ;
  344. X    sval = do_printf((FILE *)0, string(sp)->str, argcnt, sp+1) ;
  345. X    free_STRING(string(sp)) ;
  346. ***************
  347. *** 445,449 ****
  348. X    sp->ptr = (PTR) sval ;
  349. X  
  350. !   for ( p = sp+1 ; argcnt-- ; p++ )  cell_destroy(p) ;
  351. X  
  352. X    return sp ;
  353. --- 512,517 ----
  354. X    sp->ptr = (PTR) sval ;
  355. X  
  356. !   /* cleanup */
  357. !   for (p = sp+1 ; argcnt ; argcnt--, p++ )  cell_destroy(p) ;
  358. X  
  359. X    return sp ;
  360. Index: packing.list
  361. *** 1.27    1992/08/27 04:06:08
  362. --- 1.32    1993/02/06 02:12:51
  363. ***************
  364. *** 1,5 ****
  365. X  
  366. X  ################################################
  367. ! # These files form the mawk distribution 1.1.2
  368. X  #
  369. X  # Mawk is an implementation of the AWK Programming Language as
  370. --- 1,7 ----
  371. X  
  372. + #$Id: packing.list,v 1.32 1993/02/06 02:12:51 mike Exp $
  373. X  ################################################
  374. ! # These files form the mawk distribution 1.1.2d
  375. X  #
  376. X  # Mawk is an implementation of the AWK Programming Language as
  377. ***************
  378. *** 69,72 ****
  379. --- 71,75 ----
  380. X  symtype.h
  381. X  types.h
  382. + vargs.h
  383. X  version.c
  384. X  zmalloc.c
  385. ***************
  386. *** 74,78 ****
  387. X  ########################
  388. X  # directory:  man
  389. ! man/mawk.1        troff input for unix style man pages
  390. X  man/mawk.doc        ascii man pages
  391. X  ########################
  392. --- 77,81 ----
  393. X  ########################
  394. X  # directory:  man
  395. ! man/mawk.1        troff source for unix style man pages
  396. X  man/mawk.doc        ascii man pages
  397. X  ########################
  398. ***************
  399. *** 114,117 ****
  400. --- 117,124 ----
  401. X  config/convex.h
  402. X  config/aix.h
  403. + config/coherent.h
  404. + config/linux.h
  405. + config/386bsd.h
  406. + config/ztc_dos.h
  407. X  #######################
  408. X  # directory:  test      testing and benchmarking directory
  409. ***************
  410. *** 154,162 ****
  411. X  msdos/xdosexec.see        hex dump of xdosexec.obj
  412. X  msdos/see2obj.c            recovers xdosexec.obj 
  413. ! msdos/reargv.c            example (works with PolyShell)
  414. ! msdos/Makefile.tcc        for TCC and Borland make
  415. X  msdos/Makefile.MSC        nmake and MSC 6.0A
  416. X  msdos/mawkmsc.lnk
  417. X  msdos/bmawkmsc.lnk
  418. X  #####################
  419. X  # directory macintosh
  420. --- 161,182 ----
  421. X  msdos/xdosexec.see        hex dump of xdosexec.obj
  422. X  msdos/see2obj.c            recovers xdosexec.obj 
  423. ! msdos/argvpoly.c        for polyshell
  424. ! msdos/argvmks.c            for MKS Korn Shell
  425. ! msdos/Makefile.tcc        for [TB]CC and Borland make
  426. X  msdos/Makefile.MSC        nmake and MSC 6.0A
  427. + msdos/makefile.ztc            
  428. X  msdos/mawkmsc.lnk
  429. X  msdos/bmawkmsc.lnk
  430. + #####################
  431. + # directory msdos/examples    awk programs for msdos
  432. + msdos/examples/add_cr.awk
  433. + msdos/examples/doslist.awk
  434. + msdos/examples/objstat.awk
  435. + msdos/examples/shell.awk
  436. + msdos/examples/srcstat.awk
  437. + msdos/examples/srcstat2.awk
  438. + msdos/examples/texttest.awk
  439. + msdos/examples/winexe.awk
  440. + msdos/examples/winobj.awk
  441. X  #####################
  442. X  # directory macintosh
  443. Index: scan.c
  444. *** 5.3    1992/07/08 15:43:41
  445. --- 5.4.1.1    1993/01/15 03:33:50
  446. ***************
  447. *** 13,16 ****
  448. --- 13,23 ----
  449. X  
  450. X  /* $Log: scan.c,v $
  451. +  * Revision 5.4.1.1  1993/01/15  03:33:50  mike
  452. +  * patch3: safer double to int conversion
  453. +  *
  454. +  * Revision 5.4  1992/11/29  18:57:50  mike
  455. +  * field expressions convert to long so 16 bit and 32 bit
  456. +  * systems behave the same
  457. +  *
  458. X   * Revision 5.3  1992/07/08  15:43:41  brennan
  459. X   * patch2: length returns.  I am a wimp
  460. ***************
  461. *** 471,482 ****
  462. X                  else  yylval.cp = &field[0] ;
  463. X              else
  464. !             { int k = (int) d ;
  465. !               if ( k > MAX_FIELD )
  466. X                { compile_error(
  467. X                     "$%g exceeds maximum field(%d)" , d, MAX_FIELD) ;
  468. !                 k = MAX_FIELD ;
  469. X                }
  470. !               yylval.cp = field_ptr(k) ;
  471. X              }
  472. X  
  473. --- 478,488 ----
  474. X                  else  yylval.cp = &field[0] ;
  475. X              else
  476. !             { 
  477. !               if ( d > MAX_FIELD )
  478. X                { compile_error(
  479. X                     "$%g exceeds maximum field(%d)" , d, MAX_FIELD) ;
  480. !                 d = MAX_FIELD ;
  481. X                }
  482. !               yylval.cp = field_ptr((int)d) ;
  483. X              }
  484. X  
  485. Index: config/tcc_dos.h
  486. *** 4.2    1991/10/29 09:37:54
  487. --- 4.3    1992/12/17 02:48:01
  488. ***************
  489. *** 14,17 ****
  490. --- 14,20 ----
  491. X  
  492. X  /* $Log: tcc_dos.h,v $
  493. +  * Revision 4.3  1992/12/17  02:48:01  mike
  494. +  * 1.1.2d changes for DOS
  495. +  *
  496. X   * Revision 4.2  1991/10/29  09:37:54  brennan
  497. X   * changes for 1.09
  498. ***************
  499. *** 36,39 ****
  500. --- 39,43 ----
  501. X  #define   HAVE_STDARG_H         1
  502. X  #define   HAVE_STDLIB_H        1
  503. + #define   HAVE_TIME_H        1
  504. X  
  505. X  
  506. Index: execute.c
  507. *** 5.5    1992/08/11 15:24:55
  508. --- 5.7.1.1    1993/01/15 03:33:39
  509. ***************
  510. *** 12,15 ****
  511. --- 12,25 ----
  512. X  
  513. X  /* $Log: execute.c,v $
  514. +  * Revision 5.7.1.1  1993/01/15  03:33:39  mike
  515. +  * patch3: safer double to int conversion
  516. +  *
  517. +  * Revision 5.7  1992/12/17  02:48:01  mike
  518. +  * 1.1.2d changes for DOS
  519. +  *
  520. +  * Revision 5.6  1992/11/29  18:57:50  mike
  521. +  * field expressions convert to long so 16 bit and 32 bit
  522. +  * systems behave the same
  523. +  *
  524. X   * Revision 5.5  1992/08/11  15:24:55  brennan
  525. X   * patch2: F_PUSHA and FE_PUSHA
  526. ***************
  527. *** 48,56 ****
  528. X  #include <math.h>
  529. X  
  530. - /* static functions */
  531. X  static int PROTO( compare, (CELL *) ) ;
  532. ! static void PROTO( eval_overflow, (void) ) ;
  533. X  
  534. X  #if   NOINFO_SIGFPE
  535. X  static char dz_msg[] = "division by zero" ;
  536. --- 58,64 ----
  537. X  #include <math.h>
  538. X  
  539. X  static int PROTO( compare, (CELL *) ) ;
  540. ! static int PROTO( d_to_index, (double)) ;
  541. X  
  542. X  #if   NOINFO_SIGFPE
  543. X  static char dz_msg[] = "division by zero" ;
  544. ***************
  545. *** 58,61 ****
  546. --- 66,71 ----
  547. X  
  548. X  #ifdef   DEBUG
  549. + static void PROTO( eval_overflow, (void) ) ;
  550. X  #define  inc_sp()   if( ++sp == eval_stack+EVAL_STACK_SIZE )\
  551. X                           eval_overflow()
  552. ***************
  553. *** 235,241 ****
  554. X  
  555. X          case  FE_PUSHA :
  556. X              if ( sp->type != C_DOUBLE )  cast1_to_d(sp) ;
  557. !             if ( (t = (int) sp->dval) < 0 )
  558. !                 rt_error( "negative field index $%d", t) ;
  559. X              if ( t && nf < 0 )  split_field0() ;
  560. X              sp->ptr = (PTR) field_ptr(t) ;
  561. --- 245,252 ----
  562. X  
  563. X          case  FE_PUSHA :
  564. X              if ( sp->type != C_DOUBLE )  cast1_to_d(sp) ;
  565. !         t = d_to_index(sp->dval) ;
  566. X              if ( t && nf < 0 )  split_field0() ;
  567. X              sp->ptr = (PTR) field_ptr(t) ;
  568. ***************
  569. *** 252,259 ****
  570. X  
  571. X          case  FE_PUSHI :
  572. X              if ( sp->type != C_DOUBLE )  cast1_to_d(sp) ;
  573. X  
  574. !             if ( (t = (int) sp->dval) < 0 )
  575. !                   rt_error( "negative field index $%d", t) ;
  576. X  
  577. X              if ( nf < 0)  split_field0() ;
  578. --- 263,270 ----
  579. X  
  580. X          case  FE_PUSHI :
  581. X              if ( sp->type != C_DOUBLE )  cast1_to_d(sp) ;
  582. X  
  583. !         t = d_to_index(sp->dval) ;
  584. X  
  585. X              if ( nf < 0)  split_field0() ;
  586. ***************
  587. *** 915,919 ****
  588. X          case  _EXIT  :
  589. X              if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ;
  590. !             exit_code = (int) sp-- -> dval ;
  591. X              /* fall thru */
  592. X  
  593. --- 926,931 ----
  594. X          case  _EXIT  :
  595. X              if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ;
  596. !             exit_code = d_to_i(sp->dval) ;
  597. !         sp-- ;
  598. X              /* fall thru */
  599. X  
  600. ***************
  601. *** 1112,1115 ****
  602. --- 1124,1128 ----
  603. X        bozo("bad cell type in call to test") ;
  604. X    }
  605. +   return 0 ; /*can't get here: shutup */
  606. X  }
  607. X  
  608. ***************
  609. *** 1163,1166 ****
  610. --- 1176,1180 ----
  611. X              bozo("bad cell type passed to compare") ;
  612. X    }
  613. +   return 0 ; /* shut up */
  614. X  }
  615. X  
  616. ***************
  617. *** 1230,1231 ****
  618. --- 1244,1263 ----
  619. X  
  620. X  #endif
  621. + /* convert a double d to a field index  $d -> $i */
  622. + static int
  623. + d_to_index( d ) 
  624. +   double d ;
  625. + {
  626. +   if ( d > MAX_FIELD ) 
  627. +         rt_overflow("maximum number of fields", MAX_FIELD) ;
  628. +   
  629. +   if ( d >= 0.0 )  return (int) d ;
  630. +   
  631. +   /* might include nan */
  632. +   rt_error("negative field index $%.6g", d) ;
  633. +   return 0 ; /* shutup */
  634. + }
  635. Index: msdos/NOTES
  636. *** 1.5    1992/07/10 16:32:02
  637. --- 1.6    1992/12/17 02:48:01
  638. ***************
  639. *** 1,3 ****
  640. --- 1,29 ----
  641. + Notes for 1.1.2d
  642. X  
  643. +   Three changes specific to DOS.
  644. +   (1) Internal conversions from doubles to strings that are integers
  645. +   use internal conversion to long so DOS and unix now give the same
  646. +   output.  E.g.
  647. +       '{ print 2^30 }'
  648. +            1073741824  (instead of  ).
  649. +   (2) Large model uses 8K as opposed to 4K I/O buffers.
  650. +   (3) MAWKSHELL is no longer required.  If not set in the 
  651. +   environment, MAWKSHELL defaults to %COMSPEC% /c, e.g., if
  652. +   comspec is
  653. +        c:\system\command.com
  654. +   then this has the effect of setting MAWKSHELL to
  655. +        c:\system\command.com /c
  656. +   Comspec should give a full drive-path specification.
  657. X  Notes for MsDOS (mawk 1.1)
  658. X  ---------------
  659. ***************
  660. *** 38,41 ****
  661. --- 64,68 ----
  662. X  The trailing backslash is required.  You have to set MAWKSHELL,
  663. X  MAWKTMPDIR is optional -- defaulting to the current directory.
  664. X  
  665. X  For compatibility with Unix, CR are silently stripped from input and LF 
  666. Index: fin.c
  667. *** 5.5    1992/07/28 15:11:30
  668. --- 5.6    1992/12/17 02:48:01
  669. ***************
  670. *** 12,15 ****
  671. --- 12,18 ----
  672. X  
  673. X  /*$Log: fin.c,v $
  674. +  * Revision 5.6  1992/12/17  02:48:01  mike
  675. +  * 1.1.2d changes for DOS
  676. +  *
  677. X   * Revision 5.5  1992/07/28  15:11:30  brennan
  678. X   * minor change in finding eol, needed for MsDOS
  679. ***************
  680. *** 284,287 ****
  681. --- 287,300 ----
  682. X    unsigned r ;
  683. X    unsigned oldsize = fin->nbuffs*BUFFSZ+1 ;
  684. + #if  LM_DOS
  685. +   /* I'm not sure this can really happen:
  686. +      avoid "16bit wrap" */
  687. +   if ( fin->nbuffs == MAX_BUFFS )
  688. +   {
  689. +     errmsg(0, "out of input buffer space") ;
  690. +     mawk_exit(1) ;
  691. +   }
  692. + #endif
  693. X  
  694. X    fin->buffp = 
  695. Index: cast.c
  696. *** 5.2    1992/08/17 14:19:45
  697. --- 5.3.1.4    1993/01/22 15:05:19
  698. ***************
  699. *** 13,16 ****
  700. --- 13,33 ----
  701. X  
  702. X  /*   $Log: cast.c,v $
  703. +  * Revision 5.3.1.4  1993/01/22  15:05:19  mike
  704. +  * pow2->mpow2 for linux
  705. +  *
  706. +  * Revision 5.3.1.3  1993/01/22  14:18:33  mike
  707. +  * const for strtod and ansi picky compilers
  708. +  *
  709. +  * Revision 5.3.1.2  1993/01/20  12:53:06  mike
  710. +  * d_to_l()
  711. +  *
  712. +  * Revision 5.3.1.1  1993/01/15  03:33:37  mike
  713. +  * patch3: safer double to int conversion
  714. +  *
  715. +  * Revision 5.3  1992/11/28  23:48:42  mike
  716. +  * For internal conversion numeric->string, when testing
  717. +  * if integer, use longs instead of ints so 16 and 32 bit
  718. +  * systems behave the same
  719. +  *
  720. X   * Revision 5.2  1992/08/17  14:19:45  brennan
  721. X   * patch2: After parsing, only bi_sprintf() uses string_buff.
  722. ***************
  723. *** 30,34 ****
  724. X  #include "repl.h"
  725. X  
  726. ! int pow2[NUM_CELL_TYPES] = {1,2,4,8,16,32,64,128,256,512} ;
  727. X  
  728. X  void cast1_to_d( cp )
  729. --- 47,51 ----
  730. X  #include "repl.h"
  731. X  
  732. ! int mpow2[NUM_CELL_TYPES] = {1,2,4,8,16,32,64,128,256,512} ;
  733. X  
  734. X  void cast1_to_d( cp )
  735. ***************
  736. *** 133,137 ****
  737. X    register CELL *cp ;
  738. X  { 
  739. !   register int ival ;
  740. X    char xbuff[260] ;
  741. X  
  742. --- 150,154 ----
  743. X    register CELL *cp ;
  744. X  { 
  745. !   register long lval ;
  746. X    char xbuff[260] ;
  747. X  
  748. ***************
  749. *** 144,149 ****
  750. X      case C_DOUBLE  :
  751. X      
  752. !     if ( (double) (ival = (int) cp->dval) == cp->dval )
  753. !         (void) sprintf(xbuff, "%d", ival) ;
  754. X      else
  755. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  756. --- 161,167 ----
  757. X      case C_DOUBLE  :
  758. X      
  759. !     lval = d_to_l(cp->dval) ;
  760. !     if ( lval == cp->dval )
  761. !         (void) sprintf(xbuff, INT_FMT, lval) ;
  762. X      else
  763. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  764. ***************
  765. *** 165,169 ****
  766. X    register CELL *cp ;
  767. X  { 
  768. !   register int ival ;
  769. X    char xbuff[260] ;
  770. X  
  771. --- 183,187 ----
  772. X    register CELL *cp ;
  773. X  { 
  774. !   register long lval ;
  775. X    char xbuff[260] ;
  776. X  
  777. ***************
  778. *** 175,180 ****
  779. X  
  780. X      case C_DOUBLE  :
  781. !     if ( (double) (ival = (int) cp->dval) == cp->dval )
  782. !         (void) sprintf(xbuff, "%d", ival) ;
  783. X      else
  784. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  785. --- 193,200 ----
  786. X  
  787. X      case C_DOUBLE  :
  788. !     lval = d_to_l(cp->dval) ;
  789. !     if ( lval == cp->dval )
  790. !         (void) sprintf(xbuff, INT_FMT, lval) ;
  791. X      else
  792. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  793. ***************
  794. *** 202,207 ****
  795. X  
  796. X      case C_DOUBLE  :
  797. !     if ( (double) (ival = (int) cp->dval) == cp->dval )
  798. !         (void) sprintf(xbuff, "%d", ival) ;
  799. X      else
  800. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  801. --- 222,229 ----
  802. X  
  803. X      case C_DOUBLE  :
  804. !     lval = d_to_l(cp->dval) ;
  805. !     if ( lval == cp->dval )
  806. !         (void) sprintf(xbuff, INT_FMT, lval) ;
  807. X      else
  808. X              (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ;
  809. ***************
  810. *** 324,327 ****
  811. --- 346,364 ----
  812. X  
  813. X  
  814. + /* convert a double to long (this is not as simple as a
  815. +    cast because the results are undefined if it won't fit).
  816. +    Truncate large values to +MAX__LONG or -MAX__LONG
  817. +    Send nans to -MAX__LONG
  818. + */
  819. + long
  820. + d_to_l(d)
  821. +   double d ;
  822. + {
  823. +   if ( d >= MAX__LONG )  return MAX__LONG ;
  824. +   if ( d >  -MAX__LONG ) return (int) d ;
  825. +   return -MAX__LONG ;
  826. + }
  827. X  #if   HAVE_STRTOD==0
  828. X  
  829. ***************
  830. *** 331,336 ****
  831. X  */
  832. X  
  833. X  double strtod(s, endptr)
  834. !   char *s , **endptr ;
  835. X  {
  836. X    register unsigned char *p ; 
  837. --- 368,378 ----
  838. X  */
  839. X  
  840. + #if __STDC__ == 0
  841. + #define const
  842. + #endif
  843. X  double strtod(s, endptr)
  844. !   const char *s ;
  845. !   char  **endptr ;
  846. X  {
  847. X    register unsigned char *p ; 
  848. Index: ACKNOWLEDGMENT
  849. *** 1.6    1992/08/27 03:47:37
  850. --- 1.9    1993/02/05 02:09:25
  851. ***************
  852. *** 11,26 ****
  853. X  
  854. X  Ports to new systems:
  855. -     Layne Lommen        ApolloSR10.3
  856. X      Ed Ferguson        MIPS M2000 C2.20 OS4.52
  857. X      Jwahar R. Bammi        Atari ST
  858. X      Berry Kercheval        SGI IRIX 4.0.1
  859. !     Andy Mason        Next 2.1
  860. X      Mike Carlton        Next 2.1
  861. X      Elliot Jaffe        AIX 3.1
  862. X      Jeremy Martin        Convex 9.1
  863. X  
  864. X  The DOS version is a lot better thanks to suggestions and testing
  865. X  from Ed Ferguson, Jack Fitts, Nadav Horesh, Michael Golan and
  866. ! Conny Ohstrom.
  867. X  
  868. X  Arnold Robbins kept me current on POSIX standards for AWK, and
  869. --- 11,30 ----
  870. X  
  871. X  Ports to new systems:
  872. X      Ed Ferguson        MIPS M2000 C2.20 OS4.52
  873. X      Jwahar R. Bammi        Atari ST
  874. X      Berry Kercheval        SGI IRIX 4.0.1
  875. !     Andy Newman        Next 2.1
  876. X      Mike Carlton        Next 2.1
  877. X      Elliot Jaffe        AIX 3.1
  878. X      Jeremy Martin        Convex 9.1
  879. +     Scott Hunziker        Coherent 4.0
  880. +     Ken Poulton        Hpux
  881. +     Onno van der Linden    386bsd 0.1
  882. +     Bob Hutchinson        Linux 0.98p14
  883. X  
  884. X  The DOS version is a lot better thanks to suggestions and testing
  885. X  from Ed Ferguson, Jack Fitts, Nadav Horesh, Michael Golan and
  886. ! Conny Ohstrom. The DOS additions for 1.1.2d are all ideas of
  887. ! Ben Myers; much of the code is his too.
  888. X  
  889. X  Arnold Robbins kept me current on POSIX standards for AWK, and
  890. Index: config/think_c.h
  891. *** 4.1    1991/09/25 11:42:00
  892. --- 4.2    1992/12/17 02:48:01
  893. ***************
  894. *** 20,23 ****
  895. --- 20,25 ----
  896. X  #define   HAVE_STDARG_H         1
  897. X  #define   HAVE_STDLIB_H        1
  898. + #define   HAVE_TIME_H        1
  899. + #define   HAVE_STRERROR        1
  900. X  
  901. X  #define   HAVE_MATHERR        0
  902. ***************
  903. *** 26,29 ****
  904. --- 28,33 ----
  905. X  
  906. X  #define   SIZE_T(x)        (size_t)(x)
  907. + #define   SET_PROGNAME()  progname = "MacMAWK"
  908. X  
  909. X  #include ":config:Idefault.h"
  910. Index: error.c
  911. *** 5.1    1991/12/05 07:55:48
  912. --- 5.3    1993/01/22 14:55:46
  913. ***************
  914. *** 2,6 ****
  915. X  /********************************************
  916. X  error.c
  917. ! copyright 1991, Michael D. Brennan
  918. X  
  919. X  This is a source file for mawk, an implementation of
  920. --- 2,6 ----
  921. X  /********************************************
  922. X  error.c
  923. ! copyright 1991, 1992 Michael D. Brennan
  924. X  
  925. X  This is a source file for mawk, an implementation of
  926. ***************
  927. *** 13,16 ****
  928. --- 13,22 ----
  929. X  
  930. X  /* $Log: error.c,v $
  931. +  * Revision 5.3  1993/01/22  14:55:46  mike
  932. +  * trivial change for unexpected_char()
  933. +  *
  934. +  * Revision 5.2  1992/10/02  23:26:04  mike
  935. +  * using vargs.h
  936. +  *
  937. X   * Revision 5.1  1991/12/05  07:55:48  brennan
  938. X   * 1.1 pre-release
  939. ***************
  940. *** 22,26 ****
  941. --- 28,34 ----
  942. X  #include  "scan.h"
  943. X  #include  "bi_vars.h"
  944. + #include  "vargs.h"
  945. X  
  946. X  #ifndef  EOF
  947. X  #define  EOF  (-1)
  948. ***************
  949. *** 27,31 ****
  950. X  #endif
  951. X  
  952. - /* statics */
  953. X  static void  PROTO( rt_where, (void) ) ;
  954. X  static void  PROTO( unexpected_char, (void) ) ;
  955. --- 35,38 ----
  956. ***************
  957. *** 33,36 ****
  958. --- 40,55 ----
  959. X  static char *PROTO( type_to_str, (int) ) ;
  960. X  
  961. + #if HAVE_STRERROR == 0
  962. + #define strerror(n) ((n)>0&&(n)<sys_nerr?sys_errlist[n]:(char*)0)
  963. + extern int sys_nerr ;
  964. + extern char *sys_errlist[];
  965. + #endif
  966. + #ifdef  USE_SIMPLE_VFPRINTF
  967. + #define  vfprintf  simple_vfprintf
  968. + #endif
  969. X  extern int NR_flag ; /* on if tracking NR */
  970. X  
  971. ***************
  972. *** 176,189 ****
  973. X  }
  974. X  
  975. - /* system provided errnos and messages */
  976. - #ifndef MSDOS_MSC       /* don't need the declarations */
  977. - #ifndef THINK_C         /* don't WANT the declarations */
  978. - extern int sys_nerr ;
  979. - extern char *sys_errlist[] ;
  980. - #endif
  981. - #endif
  982. - #if  HAVE_STDARG_H
  983. - #include <stdarg.h>
  984. X  
  985. X  /* generic error message with a hook into the system error 
  986. --- 195,198 ----
  987. ***************
  988. *** 190,212 ****
  989. X     messages if errnum > 0 */
  990. X  
  991. ! void  errmsg(int errnum, char *format, ...)
  992. ! { va_list args ;
  993. X  
  994. X    fprintf(stderr, "%s: " , progname) ;
  995. !   va_start(args, format) ;
  996. X    (void) vfprintf(stderr, format, args) ;
  997. X    va_end(args) ;
  998. ! #ifdef THINK_C
  999. !   if ( errnum > 0 )
  1000. !     fprintf(stderr, " (%s)" , strerror(errnum) ) ;
  1001. ! #else
  1002. !   if ( errnum > 0 && errnum < sys_nerr )
  1003. !     fprintf(stderr, " (%s)" , sys_errlist[errnum]) ;
  1004. ! #endif
  1005. X    fprintf( stderr, "\n") ;
  1006. X  }
  1007. X  
  1008. ! void  compile_error(char *format, ...)
  1009. ! { va_list args ;
  1010. X    char *s0, *s1 ;
  1011. X  
  1012. --- 199,218 ----
  1013. X     messages if errnum > 0 */
  1014. X  
  1015. ! void  errmsg VA_ALIST2(int , errnum, char *, format)
  1016. !   va_list args ;
  1017. X  
  1018. X    fprintf(stderr, "%s: " , progname) ;
  1019. !   VA_START2(args, int, errnum, char *, format) ;
  1020. X    (void) vfprintf(stderr, format, args) ;
  1021. X    va_end(args) ;
  1022. !   if ( errnum > 0 ) fprintf(stderr, " (%s)" , strerror(errnum) ) ;
  1023. X    fprintf( stderr, "\n") ;
  1024. X  }
  1025. X  
  1026. ! void  compile_error  VA_ALIST(char *, format)
  1027. !   va_list args ;
  1028. X    char *s0, *s1 ;
  1029. X  
  1030. ***************
  1031. *** 219,281 ****
  1032. X  
  1033. X    fprintf(stderr, "%s: %s%sline %u: " , progname, s0, s1,token_lineno) ;
  1034. !   va_start(args, format) ;
  1035. !   vfprintf(stderr, format, args) ;
  1036. !   va_end(args) ;
  1037. !   fprintf(stderr, "\n") ;
  1038. !   if ( ++compile_error_count == MAX_COMPILE_ERRORS ) mawk_exit(1) ;
  1039. ! }
  1040. ! void  rt_error( char *format, ...)
  1041. ! { va_list args ;
  1042. !   fprintf(stderr, "%s: run time error: " , progname ) ;
  1043. !   va_start(args, format) ;
  1044. !   vfprintf(stderr, format, args) ;
  1045. !   va_end(args) ;
  1046. !   putc('\n',stderr) ;
  1047. !   rt_where() ;
  1048. !   mawk_exit(1) ;
  1049. ! }
  1050. ! #else
  1051. ! #include <varargs.h>
  1052. ! /*  void errmsg(errnum, format, ...) */
  1053. ! void  errmsg( va_alist)
  1054. !   va_dcl
  1055. ! { va_list ap ;
  1056. !   int errnum ;
  1057. !   char *format ;
  1058. !   fprintf(stderr, "%s: " , progname) ;
  1059. !   va_start(ap) ;
  1060. !   errnum = va_arg(ap, int) ;
  1061. !   format = va_arg(ap, char *) ;
  1062. !   (void) vfprintf(stderr, format, ap) ;
  1063. ! #ifdef THINK_C
  1064. !   if ( errnum > 0 )
  1065. !     fprintf(stderr, " (%s)" , strerror(errnum) ) ;
  1066. ! #else
  1067. !   if ( errnum > 0 && errnum < sys_nerr )
  1068. !     fprintf(stderr, " (%s)" , sys_errlist[errnum]) ;
  1069. ! #endif
  1070. !   fprintf( stderr, "\n") ;
  1071. ! }
  1072. ! void compile_error( va_alist )
  1073. !   va_dcl
  1074. ! { va_list args ;
  1075. !   char *format ;
  1076. !   char *s0, *s1 ;
  1077. !   if ( pfile_name ) /* print program filename too */
  1078. !   { s0 = pfile_name ; s1 = ": " ; }
  1079. !   else s0 = s1 = "" ;
  1080. !   fprintf(stderr, "%s: %s%sline %u: " , progname, s0, s1,token_lineno) ;
  1081. !   va_start(args) ;
  1082. !   format = va_arg(args, char *) ;
  1083. X    vfprintf(stderr, format, args) ;
  1084. X    va_end(args) ;
  1085. --- 225,229 ----
  1086. X  
  1087. X    fprintf(stderr, "%s: %s%sline %u: " , progname, s0, s1,token_lineno) ;
  1088. !   VA_START(args, char *, format) ;
  1089. X    vfprintf(stderr, format, args) ;
  1090. X    va_end(args) ;
  1091. ***************
  1092. *** 284,295 ****
  1093. X  }
  1094. X  
  1095. ! void  rt_error( va_alist )
  1096. !   va_dcl
  1097. ! { va_list args ;
  1098. !   char *format ;
  1099. X  
  1100. X    fprintf(stderr, "%s: run time error: " , progname ) ;
  1101. !   va_start(args) ;
  1102. !   format = va_arg(args, char *) ;
  1103. X    vfprintf(stderr, format, args) ;
  1104. X    va_end(args) ;
  1105. --- 232,240 ----
  1106. X  }
  1107. X  
  1108. ! void  rt_error VA_ALIST( char *, format)
  1109. !   va_list args ;
  1110. X  
  1111. X    fprintf(stderr, "%s: run time error: " , progname ) ;
  1112. !   VA_START(args, char *, format) ;
  1113. X    vfprintf(stderr, format, args) ;
  1114. X    va_end(args) ;
  1115. ***************
  1116. *** 299,312 ****
  1117. X  }
  1118. X  
  1119. - #endif
  1120. X  
  1121. X  void bozo(s)
  1122. X    char *s ;
  1123. ! { errmsg(0, "bozo: %s" , s) ; mawk_exit(1) ; }
  1124. X  
  1125. X  void overflow(s, size)
  1126. X    char *s ; unsigned size ;
  1127. ! { errmsg(0 , "program limit exceeded: %s size=%u", s, size) ;
  1128. !   mawk_exit(1) ; }
  1129. X  
  1130. X  
  1131. --- 244,261 ----
  1132. X  }
  1133. X  
  1134. X  
  1135. X  void bozo(s)
  1136. X    char *s ;
  1137. ! { 
  1138. !   errmsg(0, "bozo: %s" , s) ; 
  1139. !   mawk_exit(1) ;
  1140. ! }
  1141. X  
  1142. X  void overflow(s, size)
  1143. X    char *s ; unsigned size ;
  1144. ! { 
  1145. !   errmsg(0 , "program limit exceeded: %s size=%u", s, size) ;
  1146. !   mawk_exit(1) ; 
  1147. ! }
  1148. X  
  1149. X  
  1150. ***************
  1151. *** 338,342 ****
  1152. X  
  1153. X    fprintf(stderr, "%s: %u: ", progname, token_lineno) ;
  1154. !   if ( c > ' ')
  1155. X        fprintf(stderr, "unexpected character '%c'\n" , c) ;
  1156. X    else
  1157. --- 287,291 ----
  1158. X  
  1159. X    fprintf(stderr, "%s: %u: ", progname, token_lineno) ;
  1160. !   if ( c > ' ' && c < 127 )
  1161. X        fprintf(stderr, "unexpected character '%c'\n" , c) ;
  1162. X    else
  1163. ***************
  1164. *** 366,369 ****
  1165. --- 315,390 ----
  1166. X      type_to_str(p->type) , p->name) ;
  1167. X  }
  1168. + #ifdef  USE_SIMPLE_VFPRINTF
  1169. + /* a minimal vfprintf  */
  1170. + int simple_vfprintf( fp, format, argp)
  1171. +   FILE *fp ;
  1172. +   char *format ; 
  1173. +   va_list  argp ;
  1174. + { 
  1175. +   char *q , *p, *t ;
  1176. +   int l_flag ;
  1177. +   char xbuff[64] ;
  1178. +   q = format ;
  1179. +   xbuff[0] = '%' ;
  1180. +   while ( *q != 0 )
  1181. +   { 
  1182. +     if ( *q != '%' )
  1183. +     {
  1184. +       putc(*q, fp) ; q++ ; continue ;
  1185. +     }
  1186. +     /* mark the start with p */
  1187. +     p = ++q ;  t = xbuff + 1 ;
  1188. +     if ( *q == '-' )  *t++ = *q++ ;
  1189. +     while ( scan_code[*(unsigned char*)q] == SC_DIGIT ) *t++ = *q++ ;
  1190. +     if ( *q == '.' )
  1191. +     { *t++ = *q++ ;
  1192. +       while ( scan_code[*(unsigned char*)q] == SC_DIGIT ) *t++ = *q++ ;
  1193. +     }
  1194. +     if ( *q == 'l' )  { l_flag = 1 ; *t++ = *q++ ; }
  1195. +     else l_flag = 0 ;
  1196. +     
  1197. +     *t = *q++ ; t[1] = 0 ;
  1198. +     switch( *t )
  1199. +     {
  1200. +       case 'c' :  
  1201. +       case 'd' :
  1202. +       case 'o' :
  1203. +       case 'x' :
  1204. +       case 'u' :
  1205. +            if ( l_flag )  fprintf(fp, xbuff, va_arg(argp,long) ) ;
  1206. +            else  fprintf(fp, xbuff, va_arg(argp, int)) ;
  1207. +            break ;
  1208. +       case  's' :
  1209. +            fprintf(fp, xbuff, va_arg(argp, char*)) ;
  1210. +            break ;
  1211. +       case  'g' :
  1212. +       case  'f' :
  1213. +            fprintf(fp, xbuff, va_arg(argp, double)) ;
  1214. +            break ;
  1215. +       default:
  1216. +            putc('%', fp) ; 
  1217. +            q = p ;
  1218. +            break ;
  1219. +     }
  1220. +   }
  1221. +   return 0 ; /* shut up */
  1222. + }
  1223. + #endif  /* USE_SIMPLE_VFPRINTF */
  1224. X  
  1225. X  
  1226. Index: files.c
  1227. *** 5.4    1992/07/10 16:10:30
  1228. --- 5.5    1992/12/17 02:48:01
  1229. ***************
  1230. *** 12,15 ****
  1231. --- 12,18 ----
  1232. X  
  1233. X  /*$Log: files.c,v $
  1234. +  * Revision 5.5  1992/12/17  02:48:01  mike
  1235. +  * 1.1.2d changes for DOS
  1236. +  *
  1237. X   * Revision 5.4  1992/07/10  16:10:30  brennan
  1238. X   * patch2
  1239. ***************
  1240. *** 77,98 ****
  1241. X  static FILE_NODE *file_list ;
  1242. X  
  1243. - void set_stderr()
  1244. - {
  1245. -   file_list = ZMALLOC(FILE_NODE) ;
  1246. -   file_list->link = (FILE_NODE*) 0 ;
  1247. -   file_list->type = F_TRUNC ;
  1248. -   file_list->name = new_STRING("/dev/stderr") ;
  1249. -   file_list->ptr = (PTR) stderr ;
  1250. - }
  1251. - /* fopen() but no buffering to ttys */
  1252. - static FILE *tfopen(name, mode)
  1253. -   char *name, *mode ;
  1254. - {
  1255. -   FILE *retval = fopen(name,mode) ;
  1256. -   if ( retval && isatty(fileno(retval)) )  setbuf(retval, (char*)0) ;
  1257. -   return retval ;
  1258. - }
  1259. X  
  1260. X  /* find a file on file_list */
  1261. --- 80,83 ----
  1262. ***************
  1263. *** 238,243 ****
  1264. X  #endif
  1265. X  #if  HAVE_FAKE_PIPES
  1266. !                 (void) unlink(tmp_file_name(p->pid)) ;
  1267. X          retval = p->inpipe_exit ;
  1268. X  #endif
  1269. X                  break ;
  1270. --- 223,231 ----
  1271. X  #endif
  1272. X  #if  HAVE_FAKE_PIPES
  1273. !           { 
  1274. !         char xbuff[100] ;
  1275. !                 (void) unlink(tmp_file_name(p->pid,xbuff)) ;
  1276. X          retval = p->inpipe_exit ;
  1277. +           }
  1278. X  #endif
  1279. X                  break ;
  1280. ***************
  1281. *** 276,279 ****
  1282. --- 264,268 ----
  1283. X  void  close_fake_pipes()
  1284. X  { register FILE_NODE *p = file_list ;
  1285. +   char xbuff[100] ;
  1286. X  
  1287. X    /* close input pipes first to free descriptors for children */
  1288. ***************
  1289. *** 282,286 ****
  1290. X      if ( p->type == PIPE_IN )
  1291. X      { FINclose((FIN *) p->ptr) ;
  1292. !       (void) unlink(tmp_file_name(p->pid)) ; 
  1293. X      }
  1294. X      p = p->link ;
  1295. --- 271,275 ----
  1296. X      if ( p->type == PIPE_IN )
  1297. X      { FINclose((FIN *) p->ptr) ;
  1298. !       (void) unlink(tmp_file_name(p->pid,xbuff)) ; 
  1299. X      }
  1300. X      p = p->link ;
  1301. ***************
  1302. *** 298,303 ****
  1303. X    }
  1304. X  }
  1305. ! #endif
  1306. ! #endif
  1307. X  
  1308. X  /* hardwire to /bin/sh for portability of programs */
  1309. --- 287,292 ----
  1310. X    }
  1311. X  }
  1312. ! #endif /* HAVE_FAKE_PIPES */
  1313. ! #endif /* ! HAVE_REAL_PIPES */
  1314. X  
  1315. X  /* hardwire to /bin/sh for portability of programs */
  1316. ***************
  1317. *** 428,429 ****
  1318. --- 417,468 ----
  1319. X          
  1320. X  #endif  /* HAVE_REAL_PIPES */
  1321. + void set_stderr()
  1322. + {
  1323. +   file_list = ZMALLOC(FILE_NODE) ;
  1324. +   file_list->link = (FILE_NODE*) 0 ;
  1325. +   file_list->type = F_TRUNC ;
  1326. +   file_list->name = new_STRING("/dev/stderr") ;
  1327. +   file_list->ptr = (PTR) stderr ;
  1328. + }
  1329. + /* fopen() but no buffering to ttys */
  1330. + static FILE *tfopen(name, mode)
  1331. +   char *name, *mode ;
  1332. + {
  1333. +   FILE *retval = fopen(name,mode) ;
  1334. +   if ( retval )
  1335. +   {
  1336. +     if ( isatty(fileno(retval)) )  setbuf(retval, (char*)0) ;
  1337. +     else
  1338. +     {
  1339. + #if  LM_DOS
  1340. +        enlarge_output_buffer(retval) ;
  1341. + #endif
  1342. +     }
  1343. +   }
  1344. +   return retval ;
  1345. + }
  1346. + #if  LM_DOS
  1347. + void enlarge_output_buffer( fp )
  1348. +   FILE *fp ;
  1349. + {
  1350. +   if ( setvbuf(fp, (char*) 0, _IOFBF, BUFFSZ) < 0 )
  1351. +   {
  1352. +     errmsg(errno, "setvbuf failed on fileno %d", fileno(fp)) ;
  1353. +     mawk_exit(1) ;
  1354. +   }
  1355. + }
  1356. + #endif
  1357. + #if  MSDOS
  1358. + void
  1359. + stdout_init()
  1360. + {
  1361. + #if  LM_DOS
  1362. +    if ( ! isatty(1) )  enlarge_output_buffer(stdout) ;
  1363. + #endif
  1364. +    if ( binmode() & 2 ) { setmode(1,O_BINARY) ; setmode(2,O_BINARY) ; }
  1365. + }
  1366. + #endif /* MSDOS */
  1367. Index: build_mawk
  1368. *** 1.13    1992/07/08 16:41:06
  1369. --- 1.16    1993/02/05 01:56:33
  1370. ***************
  1371. *** 11,14 ****
  1372. --- 11,15 ----
  1373. X  #
  1374. X  
  1375. + #$Id: build_mawk,v 1.16 1993/02/05 01:56:33 mike Exp $
  1376. X  
  1377. X  progname=`basename $0`
  1378. ***************
  1379. *** 59,62 ****
  1380. --- 60,66 ----
  1381. X      config=bsd43_vax.h ;;
  1382. X  
  1383. + 386bsd)
  1384. +     config=386bsd.h ;;
  1385. X  ultrix41_mips)
  1386. X      config=generic.h  ;;
  1387. ***************
  1388. *** 94,99 ****
  1389. X      ranlib=: ;;
  1390. X  
  1391. ! apolloSR10.3)
  1392. !     config=apollo.h  ;;
  1393. X  
  1394. X  dynix)
  1395. --- 98,103 ----
  1396. X      ranlib=: ;;
  1397. X  
  1398. ! #apolloSR10.3)  #does not work anymore
  1399. ! #    config=apollo.h  ;;
  1400. X  
  1401. X  dynix)
  1402. ***************
  1403. *** 125,128 ****
  1404. --- 129,145 ----
  1405. X      cflags='-O2 -std' ;;
  1406. X  
  1407. + hpux)
  1408. +     config=generic.h ;;
  1409. + coherent)
  1410. +     echo Coherent will not pass fpe_test
  1411. +     echo overflow cannot be detected
  1412. +     echo
  1413. +         config=coherent.h
  1414. +         cflags='-O -f' ;;
  1415. + linux)
  1416. +     config=linux.h
  1417. +     CC=gcc ;;
  1418. X  
  1419. X  MF)  ;;
  1420. ***************
  1421. *** 165,169 ****
  1422. X     echo touching parse.c  ; touch parse.c
  1423. X  fi
  1424. - rm -f  config.h
  1425. X  
  1426. X  
  1427. --- 182,185 ----
  1428. ***************
  1429. *** 171,174 ****
  1430. --- 187,195 ----
  1431. X  
  1432. X  
  1433. + if [ -f config.h ]
  1434. +   then
  1435. +      echo moving config.h to config.h.old
  1436. +      mv  config.h  config.h.old
  1437. + fi
  1438. X  echo linking config/$config to config.h
  1439. X  ln   config/$config  config.h
  1440. Index: zmalloc.c
  1441. *** 5.1    1991/12/05 07:56:35
  1442. --- 5.1.1.1    1993/02/06 11:12:19
  1443. ***************
  1444. *** 12,15 ****
  1445. --- 12,19 ----
  1446. X  
  1447. X  /*$Log: zmalloc.c,v $
  1448. +  * Revision 5.1.1.1  1993/02/06  11:12:19  mike
  1449. +  * fix bug in reuse of parser table memory
  1450. +  * for most users ifdef the mess out
  1451. +  *
  1452. X   * Revision 5.1  1991/12/05  07:56:35  brennan
  1453. X   * 1.1 pre-release
  1454. ***************
  1455. *** 84,101 ****
  1456. X  
  1457. X    if ( blocks > amt_avail )
  1458. !   { if ( amt_avail ) /* free avail */
  1459. !     { avail->link = pool[--amt_avail] ; pool[amt_avail] = avail ; }
  1460. X  
  1461. X      /* use parser tables first */
  1462. !     if ( yacc_memp->zblocks >= blocks )
  1463. !     { avail = (ZBLOCK *) yacc_memp->mem ;
  1464. X        amt_avail = yacc_memp++ -> zblocks ;
  1465. X        /* make sure its -- aligned */
  1466. !       if ( (int) avail & 7 )
  1467. !       { avail = (ZBLOCK*)((char *)avail + 8 - ((int)avail&7)) ;
  1468. !     amt_avail-- ;
  1469. X        }
  1470. X      }
  1471. X      else
  1472. X      if ( !(avail = (ZBLOCK *) malloc(SIZE_T(CHUNK*ZBLOCKSZ))) )
  1473. X      { /* if we get here, almost out of memory */
  1474. --- 88,121 ----
  1475. X  
  1476. X    if ( blocks > amt_avail )
  1477. !   { 
  1478. !     if ( amt_avail != 0 ) /* free avail */
  1479. !     { 
  1480. !       avail->link = pool[--amt_avail] ;
  1481. !       pool[amt_avail] = avail ;
  1482. !     }
  1483. X  
  1484. + #if MSDOS || HAVE_SMALL_MEMORY
  1485. + /* this hack is dangerous (I've blown it twice), not portable,
  1486. +    and counts on byacc not changing, but it is a big win on
  1487. +    DOS.  On paged vmem systems it is a nop so ifdef it out.
  1488. + */
  1489. X      /* use parser tables first */
  1490. !     if ( yacc_memp->zblocks > blocks )
  1491. !     { 
  1492. !       avail = (ZBLOCK *) yacc_memp->mem ;
  1493. X        amt_avail = yacc_memp++ -> zblocks ;
  1494. X        /* make sure its -- aligned */
  1495. !       {
  1496. !     int k = (int) avail & 7 ;
  1497. !         if ( k )
  1498. !         { 
  1499. !       avail = (ZBLOCK*)((char *)avail + (8-k)) ;
  1500. !       amt_avail-- ;
  1501. !     }
  1502. X        }
  1503. X      }
  1504. X      else
  1505. + #endif
  1506. X      if ( !(avail = (ZBLOCK *) malloc(SIZE_T(CHUNK*ZBLOCKSZ))) )
  1507. X      { /* if we get here, almost out of memory */
  1508. Index: main.c
  1509. *** 5.1    1991/12/05 07:56:14
  1510. --- 5.2.1.1    1993/01/15 03:33:44
  1511. ***************
  1512. *** 12,15 ****
  1513. --- 12,21 ----
  1514. X  
  1515. X  /* $Log: main.c,v $
  1516. +  * Revision 5.2.1.1  1993/01/15  03:33:44  mike
  1517. +  * patch3: safer double to int conversion
  1518. +  *
  1519. +  * Revision 5.2  1992/12/17  02:48:01  mike
  1520. +  * 1.1.2d changes for DOS
  1521. +  *
  1522. X   * Revision 5.1  1991/12/05  07:56:14  brennan
  1523. X   * 1.1 pre-release
  1524. ***************
  1525. *** 30,69 ****
  1526. X  #include <stdio.h>
  1527. X  
  1528. - #if  MSDOS 
  1529. - void  reargv(int *, char ***) ;
  1530. - #endif
  1531. - #if LM_DOS && __TURBOC__
  1532. - extern unsigned  _stklen = 16 * 1024U ;
  1533. -    /*  4K of stack is enough for a user function call 
  1534. -        nesting depth of 75 so this is enough for 300 */
  1535. - #endif
  1536. X  
  1537. - extern int program_fd ;
  1538. - char *progname ;
  1539. X  short mawk_state ; /* 0 is compiling */
  1540. X  int  exit_code ;
  1541. X  
  1542. X  main(argc , argv )
  1543. X    int argc ; char **argv ;
  1544. X  { 
  1545. - #if   MSDOS
  1546. -   progname = "mawk" ;
  1547. - #if      HAVE_REARGV
  1548. -   reargv(&argc, &argv) ;
  1549. - #endif
  1550. - #else    /* MSDOS */
  1551. - #ifdef THINK_C
  1552. -   progname = "MacMAWK";
  1553. - #else    /* THINK_C */
  1554. -   { char *strrchr() ;
  1555. -     char *p = strrchr(argv[0], '/') ;
  1556. -     progname = p ? p+1 : argv[0] ; }
  1557. - #endif
  1558. - #endif
  1559. X  
  1560. X    initialize(argc, argv) ;
  1561. --- 36,47 ----
  1562. X  #include <stdio.h>
  1563. X  
  1564. X  
  1565. X  short mawk_state ; /* 0 is compiling */
  1566. X  int  exit_code ;
  1567. X  
  1568. ! int
  1569. X  main(argc , argv )
  1570. X    int argc ; char **argv ;
  1571. X  { 
  1572. X  
  1573. X    initialize(argc, argv) ;
  1574. Index: msdos/Makefile.tcc
  1575. *** 1.2    1991/11/12 09:59:26
  1576. --- 1.4    1993/01/14 13:07:48
  1577. ***************
  1578. *** 3,12 ****
  1579. X  #  with Borland make
  1580. X  #
  1581. ! #   make    --  mawk.exe   DOS command line
  1582. ! #   make  -DLARGE   -- bmawk.exe   DOS  command line
  1583. ! #   make  -DREARGV  --  mawk.exe   unix command line
  1584. ! #   make  -DLARGE -DREARGV  -- bmawk.exe   unix  command line
  1585. X  
  1586. X  #$Log: Makefile.tcc,v $
  1587. X  #Revision 1.2  1991/11/12  09:59:26  brennan
  1588. X  #changed tcc to $(CC) and .o to .obj
  1589. --- 3,22 ----
  1590. X  #  with Borland make
  1591. X  #
  1592. ! #   make    --  mawk.exe
  1593. ! #   make  -DLARGE   -- bmawk.exe
  1594. X  
  1595. + #  for a unix style command line add
  1596. + #  -DREARV=your_reargv_file without the extension
  1597. + #
  1598. + #  e.g. -DREARGV=argvmks
  1599. X  #$Log: Makefile.tcc,v $
  1600. + #Revision 1.4  1993/01/14  13:07:48  mike
  1601. + #RM macro
  1602. + #
  1603. + #Revision 1.3  1992/12/27  01:44:11  mike
  1604. + #have to use -G- to fit small model
  1605. + #a bunch of small changes
  1606. + #
  1607. X  #Revision 1.2  1991/11/12  09:59:26  brennan
  1608. X  #changed tcc to $(CC) and .o to .obj
  1609. ***************
  1610. *** 19,26 ****
  1611. X  
  1612. X  # user settable
  1613. X  CC=tcc   # bcc or ? 
  1614. ! TCCLIB =c:\lib
  1615. ! FLOATLIB=emu   #  or  fp87
  1616. ! WILDCARD=c:\lib\wildargs.obj
  1617. X  
  1618. X  # compiler flags
  1619. --- 29,49 ----
  1620. X  
  1621. X  # user settable
  1622. + # change here or override from command line e.g. -DCC=bcc
  1623. + !if ! $d(CC)
  1624. X  CC=tcc   # bcc or ? 
  1625. ! !endif
  1626. ! !if ! $d(LIBDIR)
  1627. ! LIBDIR =c:\lib    # where are your Borland C libraries ?
  1628. ! !endif  
  1629. ! !if !  $d(FLOATLIB)
  1630. ! FLOATLIB=emu   #  or  fp87 if you have fp87 hardware
  1631. ! !endif
  1632. ! !if ! $d(WILDCARD)
  1633. ! WILDCARD=$(LIBDIR)\wildargs.obj
  1634. ! !endif
  1635. X  
  1636. X  # compiler flags
  1637. ***************
  1638. *** 29,35 ****
  1639. X  # -v- symbolic debugging off
  1640. X  # -O  optimize
  1641. ! CFLAGS = -c -d -v- -O -G
  1642. X  LFLAGS = /c  #case sensitive linking
  1643. X  
  1644. X  ##############################
  1645. X  # end of user settable
  1646. --- 52,76 ----
  1647. X  # -v- symbolic debugging off
  1648. X  # -O  optimize
  1649. ! CFLAGS = -c -d -v- -O 
  1650. ! !if $d(LARGE)
  1651. ! OPT = -G
  1652. ! !else
  1653. ! OPT = -G-  # opt for size (getting too big)
  1654. ! !endif
  1655. X  LFLAGS = /c  #case sensitive linking
  1656. X  
  1657. + # how to delete a file
  1658. + !if ! $d(RM)
  1659. + RM = del    # rm
  1660. + !endif
  1661. + # how to rename a file
  1662. + !if ! $d(RENAME)
  1663. + RENAME = rename  # mv
  1664. + !endif
  1665. X  ##############################
  1666. X  # end of user settable
  1667. ***************
  1668. *** 45,49 ****
  1669. X  !endif
  1670. X  
  1671. ! CFLAGS=-m$(MODEL) $(CFLAGS)
  1672. X  
  1673. X  
  1674. --- 86,90 ----
  1675. X  !endif
  1676. X  
  1677. ! CFLAGS=-m$(MODEL) $(OPT) $(CFLAGS)
  1678. X  
  1679. X  
  1680. ***************
  1681. *** 82,86 ****
  1682. X  
  1683. X  !if  $d(REARGV)  
  1684. ! OBS = $(OBS) reargv.obj
  1685. X  !endif
  1686. X  
  1687. --- 123,127 ----
  1688. X  
  1689. X  !if  $d(REARGV)  
  1690. ! OBS = $(OBS) $(REARGV).obj
  1691. X  !endif
  1692. X  
  1693. ***************
  1694. *** 95,104 ****
  1695. X  rexp3.obj
  1696. X  
  1697. ! LIBS = $(TCCLIB)\$(FLOATLIB) \
  1698. ! $(TCCLIB)\math$(MODEL) $(TCCLIB)\c$(MODEL)
  1699. X  
  1700. X  $(TARGET).exe : $(OBS)  $(REXP_OBS)
  1701. X      tlink $(LFLAGS) @&&!
  1702. !     $(TCCLIB)\c0$(MODEL) $(WILDCARD) $(OBS) $(REXP_OBS)
  1703. X      $(TARGET),$(TARGET)
  1704. X      $(LIBS)
  1705. --- 136,145 ----
  1706. X  rexp3.obj
  1707. X  
  1708. ! LIBS = $(LIBDIR)\$(FLOATLIB) \
  1709. ! $(LIBDIR)\math$(MODEL) $(LIBDIR)\c$(MODEL)
  1710. X  
  1711. X  $(TARGET).exe : $(OBS)  $(REXP_OBS)
  1712. X      tlink $(LFLAGS) @&&!
  1713. !     $(LIBDIR)\c0$(MODEL) $(WILDCARD) $(OBS) $(REXP_OBS)
  1714. X      $(TARGET),$(TARGET)
  1715. X      $(LIBS)
  1716. ***************
  1717. *** 112,117 ****
  1718. X      $(CC) makescan.c
  1719. X      makescan.exe > scancode.c
  1720. !     del makescan.obj  
  1721. !     del makescan.exe
  1722. X  
  1723. X  xdosexec.obj  :  msdos\xdosexec.see
  1724. --- 153,158 ----
  1725. X      $(CC) makescan.c
  1726. X      makescan.exe > scancode.c
  1727. !     $(RM) makescan.obj  
  1728. !     $(RM) makescan.exe
  1729. X  
  1730. X  xdosexec.obj  :  msdos\xdosexec.see
  1731. ***************
  1732. *** 118,122 ****
  1733. X      $(CC) msdos\see2obj.c
  1734. X      see2obj < msdos\xdosexec.see > xdosexec.obj
  1735. !     del see2obj.exe
  1736. X  
  1737. X  #xdosexec.obj  :  xdosexec.asm
  1738. --- 159,163 ----
  1739. X      $(CC) msdos\see2obj.c
  1740. X      see2obj < msdos\xdosexec.see > xdosexec.obj
  1741. !     $(RM) see2obj.exe
  1742. X  
  1743. X  #xdosexec.obj  :  xdosexec.asm
  1744. ***************
  1745. *** 132,137 ****
  1746. X  #    bison -dy parse.y
  1747. X  #    bmawk -f modbison.awk y_tab.c parse2.xc > parse.c
  1748. ! #    rename y_tab.h parse.h
  1749. ! #    del y_tab.c
  1750. X  ########################################
  1751. X  
  1752. --- 173,178 ----
  1753. X  #    bison -dy parse.y
  1754. X  #    bmawk -f modbison.awk y_tab.c parse2.xc > parse.c
  1755. ! #    $(RENAME) y_tab.h parse.h
  1756. ! #    $(RM) y_tab.c
  1757. X  ########################################
  1758. X  
  1759. ***************
  1760. *** 138,142 ****
  1761. X  
  1762. X  clean  :
  1763. !     del  *.obj
  1764. X  
  1765. X  
  1766. --- 179,183 ----
  1767. X  
  1768. X  clean  :
  1769. !     $(RM)  *.obj
  1770. X  
  1771. X  
  1772. Index: symtype.h
  1773. *** 5.2    1992/07/08 15:44:44
  1774. --- 5.3    1992/12/17 02:48:01
  1775. ***************
  1776. *** 12,15 ****
  1777. --- 12,18 ----
  1778. X  
  1779. X  /*$Log: symtype.h,v $
  1780. +  * Revision 5.3  1992/12/17  02:48:01  mike
  1781. +  * 1.1.2d changes for DOS
  1782. +  *
  1783. X   * Revision 5.2  1992/07/08  15:44:44  brennan
  1784. X   * patch2: length returns.  I am a wimp
  1785. ***************
  1786. *** 44,48 ****
  1787. X  struct anode *link , *ilink ;
  1788. X  STRING *sval ;
  1789. ! int     ival ;
  1790. X  CELL   *cp ;
  1791. X  }  ANODE ;
  1792. --- 47,51 ----
  1793. X  struct anode *link , *ilink ;
  1794. X  STRING *sval ;
  1795. ! long     ival ;
  1796. X  CELL   *cp ;
  1797. X  }  ANODE ;
  1798. Index: files.h
  1799. *** 5.1    1991/12/05 07:59:18
  1800. --- 5.2    1992/12/17 02:48:01
  1801. ***************
  1802. *** 12,15 ****
  1803. --- 12,18 ----
  1804. X  
  1805. X  /*$Log: files.h,v $
  1806. +  * Revision 5.2  1992/12/17  02:48:01  mike
  1807. +  * 1.1.2d changes for DOS
  1808. +  *
  1809. X   * Revision 5.1  1991/12/05  07:59:18  brennan
  1810. X   * 1.1 pre-release
  1811. ***************
  1812. *** 38,42 ****
  1813. X  void PROTO(close_fake_pipes, (void)) ;
  1814. X  int  PROTO(close_fake_outpipe, (char *,int)) ;
  1815. ! char *PROTO(tmp_file_name, (int)) ;
  1816. X  #endif
  1817. X  
  1818. --- 41,45 ----
  1819. X  void PROTO(close_fake_pipes, (void)) ;
  1820. X  int  PROTO(close_fake_outpipe, (char *,int)) ;
  1821. ! char *PROTO(tmp_file_name, (int, char*)) ;
  1822. X  #endif
  1823. X  
  1824. ***************
  1825. *** 45,48 ****
  1826. --- 48,52 ----
  1827. X  int  PROTO(binmode, (void)) ;
  1828. X  void PROTO(set_binmode, (int)) ;
  1829. + void PROTO(enlarge_output_buffer, (FILE*)) ;
  1830. X  #endif
  1831. X  
  1832. Index: config/msc_dos.h
  1833. *** 4.3    1992/01/09 08:54:09
  1834. --- 4.4    1992/12/17 02:48:01
  1835. ***************
  1836. *** 14,17 ****
  1837. --- 14,20 ----
  1838. X  
  1839. X  /*$Log: msc_dos.h,v $
  1840. +  * Revision 4.4  1992/12/17  02:48:01  mike
  1841. +  * 1.1.2d changes for DOS
  1842. +  *
  1843. X   * Revision 4.3  1992/01/09  08:54:09  brennan
  1844. X   * changed SAMESEG macro
  1845. ***************
  1846. *** 31,34 ****
  1847. --- 34,39 ----
  1848. X  #define   HAVE_STDARG_H         1
  1849. X  #define   HAVE_STDLIB_H        1
  1850. + #define   HAVE_TIME_H        1
  1851. + #define   HAVE_STRERROR        1
  1852. X  
  1853. X  #define   FPE_TRAPS_ON        1
  1854. Index: array.c
  1855. *** 5.2    1992/04/07 17:17:31
  1856. --- 5.3.1.1    1993/01/20 12:24:25
  1857. ***************
  1858. *** 12,15 ****
  1859. --- 12,23 ----
  1860. X  
  1861. X  /* $Log: array.c,v $
  1862. +  * Revision 5.3.1.1  1993/01/20  12:24:25  mike
  1863. +  * patch3: safer double to int conversions
  1864. +  *
  1865. +  * Revision 5.3  1992/11/28  23:48:42  mike
  1866. +  * For internal conversion numeric->string, when testing
  1867. +  * if integer, use longs instead of ints so 16 and 32 bit
  1868. +  * systems behave the same
  1869. +  *
  1870. X   * Revision 5.2  1992/04/07  17:17:31  brennan
  1871. X   * patch 2
  1872. ***************
  1873. *** 34,38 ****
  1874. X  
  1875. X  static ANODE *PROTO(find_by_sval, (ARRAY, STRING *, int) ) ;
  1876. ! static ANODE *PROTO(find_by_index, (ARRAY, int,int,int) ) ;
  1877. X  static ANODE *PROTO(find_by_dval, (ARRAY, double, int)) ;
  1878. X  static void PROTO(load_array_ov, (ARRAY) ) ;
  1879. --- 42,46 ----
  1880. X  
  1881. X  static ANODE *PROTO(find_by_sval, (ARRAY, STRING *, int) ) ;
  1882. ! static ANODE *PROTO(find_by_index, (ARRAY, int,long,int) ) ;
  1883. X  static ANODE *PROTO(find_by_dval, (ARRAY, double, int)) ;
  1884. X  static void PROTO(load_array_ov, (ARRAY) ) ;
  1885. ***************
  1886. *** 98,104 ****
  1887. X  
  1888. X  
  1889. X  static ANODE  *find_by_index(A, index, ival, flag)
  1890. X    ARRAY  A ;
  1891. !   int index, ival, flag ;
  1892. X  {
  1893. X    register ANODE *p = A[index].ilink ;
  1894. --- 106,119 ----
  1895. X  
  1896. X  
  1897. + /* find an array by (long) integer ival.
  1898. +    Caller has already computed the hash value index.
  1899. +    (This allows fast insertion for split())
  1900. + */
  1901. X  static ANODE  *find_by_index(A, index, ival, flag)
  1902. X    ARRAY  A ;
  1903. !   int index; 
  1904. !   long ival; 
  1905. !   int flag ;
  1906. X  {
  1907. X    register ANODE *p = A[index].ilink ;
  1908. ***************
  1909. *** 116,123 ****
  1910. X     /* not there, still need to look by sval */
  1911. X     
  1912. !    { char xbuff[16] ;
  1913. X       STRING *sval ;
  1914. X       char *s = xbuff+14 ;
  1915. !      int x = ival ;
  1916. X  
  1917. X       xbuff[15] = 0 ;
  1918. --- 131,139 ----
  1919. X     /* not there, still need to look by sval */
  1920. X     
  1921. !    { /* convert to string */
  1922. !      char xbuff[16] ;
  1923. X       STRING *sval ;
  1924. X       char *s = xbuff+14 ;
  1925. !      long x = ival ;
  1926. X  
  1927. X       xbuff[15] = 0 ;
  1928. ***************
  1929. *** 143,148 ****
  1930. X    ARRAY A ;
  1931. X    double d ;
  1932. X  {
  1933. !   int ival ;
  1934. X    ANODE *p ;
  1935. X    char xbuff[260] ;
  1936. --- 159,165 ----
  1937. X    ARRAY A ;
  1938. X    double d ;
  1939. +   int flag ;
  1940. X  {
  1941. !   long lval ;
  1942. X    ANODE *p ;
  1943. X    char xbuff[260] ;
  1944. ***************
  1945. *** 150,159 ****
  1946. X    
  1947. X  
  1948. !   if ( (double)(ival = (int)d) == d ) /* integer valued */
  1949. X    {
  1950. !     if ( ival >= 0 )  
  1951. !             return  find_by_index(A, ival%A_HASH_PRIME, ival, flag) ;
  1952. !     
  1953. !     (void) sprintf(xbuff, "%d", ival) ;
  1954. X    } 
  1955. X    else (void) sprintf(xbuff, string(CONVFMT)->str, d) ;
  1956. --- 167,180 ----
  1957. X    
  1958. X  
  1959. !   lval = d_to_l(d) ;
  1960. !   if ( (double)lval == d ) /* integer valued */
  1961. X    {
  1962. !     if ( lval >= 0 )  
  1963. !     {
  1964. !             return 
  1965. !         find_by_index(A, (int)(lval%A_HASH_PRIME), lval, flag) ;
  1966. !     }
  1967. !     else
  1968. !     (void) sprintf(xbuff, INT_FMT, lval) ;
  1969. X    } 
  1970. X    else (void) sprintf(xbuff, string(CONVFMT)->str, d) ;
  1971. ***************
  1972. *** 202,207 ****
  1973. X      case C_DOUBLE :
  1974. X          ap = find_by_dval(A, cp->dval, NO_CREATE) ;
  1975. X          if ( ap && ap->ival >= 0 ) /* must be at front */
  1976. !                 A[ap->ival%A_HASH_PRIME].ilink = ap->ilink ;
  1977. X          break ;
  1978. X  
  1979. --- 223,229 ----
  1980. X      case C_DOUBLE :
  1981. X          ap = find_by_dval(A, cp->dval, NO_CREATE) ;
  1982. +     /* cut the ilink */
  1983. X          if ( ap && ap->ival >= 0 ) /* must be at front */
  1984. !                 A[(int)(ap->ival%A_HASH_PRIME)].ilink = ap->ilink ;
  1985. X          break ;
  1986. X  
  1987. ***************
  1988. *** 216,219 ****
  1989. --- 238,244 ----
  1990. X    }
  1991. X  
  1992. +   
  1993. +   /* delete -- leave the empty ANODE so for(i in A)
  1994. +      works */
  1995. X    if ( ap )
  1996. X    { free_STRING(ap->sval) ; ap->sval = (STRING *) 0 ;
  1997. ***************
  1998. *** 242,246 ****
  1999. X    while( 1 )
  2000. X    {
  2001. !     cp = find_by_index(A, index, cnt, NO_MOVE) ->cp ;
  2002. X      cell_destroy(cp) ;
  2003. X      cp->type = C_MBSTRN ;
  2004. --- 267,271 ----
  2005. X    while( 1 )
  2006. X    {
  2007. !     cp = find_by_index(A, index, (long)cnt, NO_MOVE) ->cp ;
  2008. X      cell_destroy(cp) ;
  2009. X      cp->type = C_MBSTRN ;
  2010. ***************
  2011. *** 316,320 ****
  2012. X    while ( cnt )
  2013. X    {
  2014. !     cp = find_by_index(A, index, cnt, NO_MOVE) ->cp  ;
  2015. X      cell_destroy(cp) ;
  2016. X      cp->type = C_MBSTRN ;
  2017. --- 341,345 ----
  2018. X    while ( cnt )
  2019. X    {
  2020. !     cp = find_by_index(A, index, (long) cnt, NO_MOVE) ->cp  ;
  2021. X      cell_destroy(cp) ;
  2022. X      cp->type = C_MBSTRN ;
  2023. ***************
  2024. *** 441,443 ****
  2025. X    }
  2026. X  }
  2027. --- 466,467 ----
  2028. Index: version.c
  2029. *** 5.4    1992/08/27 11:50:38
  2030. --- 5.6.1.2    1993/01/20 12:53:13
  2031. ***************
  2032. *** 12,15 ****
  2033. --- 12,27 ----
  2034. X  
  2035. X  /*$Log: version.c,v $
  2036. +  * Revision 5.6.1.2  1993/01/20  12:53:13  mike
  2037. +  * d_to_l()
  2038. +  *
  2039. +  * Revision 5.6.1.1  1993/01/15  03:33:54  mike
  2040. +  * patch3: safer double to int conversion
  2041. +  *
  2042. +  * Revision 5.6  1992/12/17  02:48:01  mike
  2043. +  * 1.1.2d changes for DOS
  2044. +  *
  2045. +  * Revision 5.5  1992/12/02  03:18:12  mike
  2046. +  * coherent patch
  2047. +  *
  2048. X   * Revision 5.4  1992/08/27  11:50:38  mike
  2049. X   * patch2
  2050. ***************
  2051. *** 29,34 ****
  2052. X  #include "patchlev.h"
  2053. X  
  2054. X  #define  VERSION_STRING  \
  2055. !   "mawk 1.1%s%s Aug 1992, Copyright (C) Michael D. Brennan\n\n"
  2056. X  
  2057. X  #define  DOS_STRING     ""
  2058. --- 41,49 ----
  2059. X  #include "patchlev.h"
  2060. X  
  2061. + static char rcsid[] =
  2062. + "@(#) $Id: version.c,v 5.6.1.2 1993/01/20 12:53:13 mike Exp $" ;
  2063. X  #define  VERSION_STRING  \
  2064. !   "mawk 1.1%s%s %s, Copyright (C) Michael D. Brennan\n\n"
  2065. X  
  2066. X  #define  DOS_STRING     ""
  2067. ***************
  2068. *** 64,76 ****
  2069. X  #endif
  2070. X  
  2071. X  /* print VERSION and exit */
  2072. X  void print_version()
  2073. ! { static char fmt[] = "%-14s%10u\n" ;
  2074. X  
  2075. !   printf(VERSION_STRING, PATCH_STRING, DOS_STRING) ;
  2076. X    fflush(stdout) ;
  2077. X    fprintf(stderr, "compiled limits:\n") ;
  2078. !   fprintf(stderr, fmt,  "largest field", MAX_FIELD) ;
  2079. !   fprintf(stderr, fmt,  "sprintf buffer",SPRINTF_SZ) ;
  2080. X    exit(0) ;
  2081. X  }
  2082. --- 79,178 ----
  2083. X  #endif
  2084. X  
  2085. + static char fmt[] = "%-14s%10lu\n" ;
  2086. X  /* print VERSION and exit */
  2087. X  void print_version()
  2088. ! { 
  2089. X  
  2090. !   printf(VERSION_STRING, PATCH_STRING, DOS_STRING, DATE_STRING) ;
  2091. X    fflush(stdout) ;
  2092. +   print_compiler_id() ;
  2093. X    fprintf(stderr, "compiled limits:\n") ;
  2094. !   fprintf(stderr, fmt,  "largest field", (long)MAX_FIELD) ;
  2095. !   fprintf(stderr, fmt,  "sprintf buffer", (long)SPRINTF_SZ) ;
  2096. !   print_aux_limits() ;
  2097. X    exit(0) ;
  2098. + }
  2099. + /*
  2100. +   Extra info for MSDOS.  This code contributed by
  2101. +   Ben Myers 
  2102. + */
  2103. + #ifdef __TURBOC__
  2104. + #include <alloc.h>   /* coreleft() */
  2105. + #define  BORL
  2106. + #endif
  2107. + #ifdef __BORLANDC__
  2108. + #include <alloc.h>   /* coreleft() */
  2109. + #define  BORL
  2110. + #endif
  2111. + #ifdef  BORL 
  2112. + #if     LM_DOS
  2113. + extern unsigned  _stklen = 16 * 1024U ; 
  2114. +    /*  4K of stack is enough for a user function call 
  2115. +        nesting depth of 75 so this is enough for 300 */
  2116. + #endif
  2117. + #endif
  2118. + #ifdef _MSC_VER
  2119. + #include <malloc.h>
  2120. + #endif
  2121. + #ifdef __ZTC__
  2122. + #include <dos.h>              /* _chkstack */
  2123. + #endif
  2124. + int print_compiler_id()
  2125. + {
  2126. + #ifdef  __TURBOC__
  2127. +   fprintf(stderr, "MsDOS Turbo C++ %d.%d\n",
  2128. +                 __TURBOC__>>8, __TURBOC__&0xff) ;
  2129. + #endif
  2130. +   
  2131. + #ifdef __BORLANDC__
  2132. +   fprintf (stderr, "MS-DOS Borland C++ __BORLANDC__ %x\n",
  2133. +         __BORLANDC__ );
  2134. + #endif
  2135. + #ifdef _MSC_VER
  2136. +   fprintf (stderr, "MS-DOS Microsoft C/C++ _MSC_VER %u\n", _MSC_VER );
  2137. + #endif
  2138. + #ifdef __ZTC__
  2139. +   fprintf (stderr, "MS-DOS Zortech C++ __ZTC__ %x\n", __ZTC__ );
  2140. + #endif
  2141. +   return 0 ; /*shut up */
  2142. + }
  2143. + int  print_aux_limits()
  2144. + {
  2145. + #ifdef BORL
  2146. +   extern unsigned _stklen ;
  2147. +   fprintf(stderr, fmt,  "stack size", (unsigned long)_stklen) ;
  2148. +   fprintf(stderr, fmt,  "heap size",  (unsigned long) coreleft()) ;
  2149. + #endif
  2150. + #ifdef _MSC_VER
  2151. +   fprintf(stderr, fmt,  "stack size", (unsigned long)_stackavail()) ;
  2152. + #if   SM_DOS
  2153. +   fprintf(stderr, fmt,  "heap size", (unsigned long) _memavl()) ;
  2154. + #endif
  2155. + #endif
  2156. + #ifdef __ZTC__
  2157. + /* large memory model only with ztc */
  2158. +   fprintf(stderr, fmt,  "stack size??", (unsigned long)_chkstack()) ;
  2159. +   fprintf(stderr, fmt,  "heap size", farcoreleft()) ;
  2160. + #endif
  2161. +   return 0 ;
  2162. X  }
  2163. DIFFGEN_EOF
  2164. SHAR_EOF
  2165. echo 'File patch3 is complete' &&
  2166. chmod 0640 patch3 ||
  2167. echo 'restore of patch3 failed'
  2168. Wc_c="`wc -c < 'patch3'`"
  2169. test 111555 -eq "$Wc_c" ||
  2170.     echo 'patch3: original size 111555, current size' "$Wc_c"
  2171. rm -f _shar_wnt_.tmp
  2172. fi
  2173. rm -f _shar_seq_.tmp
  2174. echo You have unpacked the last part
  2175. exit 0
  2176.