home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / bi_vars.c < prev    next >
C/C++ Source or Header  |  1992-07-10  |  2KB  |  90 lines

  1.  
  2. /********************************************
  3. bi_vars.c
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13. /* $Log: bi_vars.c,v $
  14.  * Revision 5.2  1992/07/10  16:17:10  brennan
  15.  * MsDOS: remove NO_BINMODE macro
  16.  *
  17.  * Revision 5.1  1991/12/05  07:55:38  brennan
  18.  * 1.1 pre-release
  19.  *
  20. */
  21.  
  22.  
  23. /* bi_vars.c */
  24.  
  25. #include "mawk.h"
  26. #include "symtype.h"
  27. #include "bi_vars.h"
  28. #include "field.h"
  29. #include "init.h"
  30. #include "memory.h"
  31.  
  32. /* the builtin variables */
  33. CELL  bi_vars[NUM_BI_VAR] ;
  34.  
  35. /* the order here must match the order in bi_vars.h */
  36.  
  37. static char *bi_var_names[NUM_BI_VAR] = {
  38. "NR" ,
  39. "FNR" ,
  40. "ARGC" ,
  41. "FILENAME" ,
  42. "OFS" ,
  43. "ORS" ,
  44. "RLENGTH" ,
  45. "RSTART" ,
  46. "SUBSEP"
  47. #if MSDOS 
  48. , "BINMODE"
  49. #endif
  50. } ;
  51.  
  52. /* insert the builtin vars in the hash table */
  53.  
  54. void  bi_vars_init()
  55. { register int i ;
  56.   register SYMTAB *s ;
  57.  
  58.   
  59.   for ( i = 0 ; i < NUM_BI_VAR ; i++ )
  60.   { s = insert( bi_var_names[i] ) ;
  61.     s->type = i <= 1 ? ST_NR : ST_VAR ; 
  62.     s->stval.cp = bi_vars + i ;
  63.     /* bi_vars[i].type = 0 which is C_NOINIT */
  64.   }
  65.  
  66.   s = insert("ENVIRON") ;
  67.   s->type = ST_ENV ;
  68.  
  69.   /* set defaults */
  70.  
  71.   FILENAME->type = C_STRING ;
  72.   FILENAME->ptr = (PTR) new_STRING( "" ) ; 
  73.  
  74.   OFS->type = C_STRING ;
  75.   OFS->ptr = (PTR) new_STRING( " " ) ;
  76.   
  77.   ORS->type = C_STRING ;
  78.   ORS->ptr = (PTR) new_STRING( "\n" ) ;
  79.  
  80.   SUBSEP->type = C_STRING ;
  81.   SUBSEP->ptr =  (PTR) new_STRING( "\034" ) ;
  82.  
  83.   NR->type = FNR->type = C_DOUBLE ;
  84.   /* dval is already 0.0 */
  85.  
  86. #if  MSDOS  
  87.   BINMODE->type = C_DOUBLE ;
  88. #endif
  89. }
  90.