home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / mawk11as.zip / BI_VARS.C < prev    next >
C/C++ Source or Header  |  1991-12-18  |  2KB  |  87 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.1  91/12/05  07:55:38  brennan
  15.  * 1.1 pre-release
  16.  * 
  17. */
  18.  
  19.  
  20. /* bi_vars.c */
  21.  
  22. #include "mawk.h"
  23. #include "symtype.h"
  24. #include "bi_vars.h"
  25. #include "field.h"
  26. #include "init.h"
  27. #include "memory.h"
  28.  
  29. /* the builtin variables */
  30. CELL  bi_vars[NUM_BI_VAR] ;
  31.  
  32. /* the order here must match the order in bi_vars.h */
  33.  
  34. static char *bi_var_names[NUM_BI_VAR] = {
  35. "NR" ,
  36. "FNR" ,
  37. "ARGC" ,
  38. "FILENAME" ,
  39. "OFS" ,
  40. "ORS" ,
  41. "RLENGTH" ,
  42. "RSTART" ,
  43. "SUBSEP"
  44. #if MSDOS  && NO_BINMODE==0
  45. , "BINMODE"
  46. #endif
  47. } ;
  48.  
  49. /* insert the builtin vars in the hash table */
  50.  
  51. void  bi_vars_init()
  52. { register int i ;
  53.   register SYMTAB *s ;
  54.  
  55.   
  56.   for ( i = 0 ; i < NUM_BI_VAR ; i++ )
  57.   { s = insert( bi_var_names[i] ) ;
  58.     s->type = i <= 1 ? ST_NR : ST_VAR ; 
  59.     s->stval.cp = bi_vars + i ;
  60.     /* bi_vars[i].type = 0 which is C_NOINIT */
  61.   }
  62.  
  63.   s = insert("ENVIRON") ;
  64.   s->type = ST_ENV ;
  65.  
  66.   /* set defaults */
  67.  
  68.   FILENAME->type = C_STRING ;
  69.   FILENAME->ptr = (PTR) new_STRING( "" ) ; 
  70.  
  71.   OFS->type = C_STRING ;
  72.   OFS->ptr = (PTR) new_STRING( " " ) ;
  73.   
  74.   ORS->type = C_STRING ;
  75.   ORS->ptr = (PTR) new_STRING( "\n" ) ;
  76.  
  77.   SUBSEP->type = C_STRING ;
  78.   SUBSEP->ptr =  (PTR) new_STRING( "\034" ) ;
  79.  
  80.   NR->type = FNR->type = C_DOUBLE ;
  81.   /* dval is already 0.0 */
  82.  
  83. #if  MSDOS  && NO_BINMODE==0
  84.   BINMODE->type = C_DOUBLE ;
  85. #endif
  86. }
  87.