1: /* $Header: perl.h,v 1.0.1.4 88/01/30 08:54:00 root Exp $ 2: * 3: * $Log: perl.h,v $ 4: * Revision 1.0.1.4 88/01/30 08:54:00 root 5: * patch9: changed #define YYDEBUG; to #define YYDEBUG 1 6: * 7: * Revision 1.0.1.3 88/01/28 10:24:17 root 8: * patch8: added eval operator. 9: * 10: * Revision 1.0.1.2 88/01/24 03:53:47 root 11: * patch 2: hid str_peek() in #ifdef DEBUGGING. 12: * 13: * Revision 1.0.1.1 88/01/21 21:29:23 root 14: * No longer defines STDSTDIO--gets it from config.h now. 15: * 16: * Revision 1.0 87/12/18 13:05:38 root 17: * Initial revision 18: * 19: */ 20: 21: #define DEBUGGING 22: 23: #define VOIDUSED 1 24: #include "config.h" 25: 26: #ifndef BCOPY 27: # define bcopy(s1,s2,l) memcpy(s2,s1,l); 28: # define bzero(s,l) memset(s,0,l); 29: #endif 30: 31: #include <stdio.h> 32: #include <ctype.h> 33: #include <setjmp.h> 34: #include <sys/types.h> 35: #include <sys/stat.h> 36: 37: #ifdef TMINSYS 38: #include <sys/time.h> 39: #else 40: #include <time.h> 41: #endif 42: 43: #include <sys/times.h> 44: 45: typedef struct arg ARG; 46: typedef struct cmd CMD; 47: typedef struct formcmd FCMD; 48: typedef struct scanpat SPAT; 49: typedef struct stab STAB; 50: typedef struct stio STIO; 51: typedef struct string STR; 52: typedef struct atbl ARRAY; 53: typedef struct htbl HASH; 54: 55: #include "str.h" 56: #include "form.h" 57: #include "stab.h" 58: #include "spat.h" 59: #include "arg.h" 60: #include "cmd.h" 61: #include "array.h" 62: #include "hash.h" 63: 64: #ifdef CHARSPRINTF 65: char *sprintf(); 66: #else 67: int sprintf(); 68: #endif 69: 70: /* A string is TRUE if not "" or "0". */ 71: #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1]))) 72: EXT char *Yes INIT("1"); 73: EXT char *No INIT(""); 74: 75: #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 ))) 76: 77: #ifdef DEBUGGING 78: #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" ))) 79: #endif 80: 81: #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) 82: #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str))) 83: EXT STR *Str; 84: 85: #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) 86: 87: CMD *add_label(); 88: CMD *block_head(); 89: CMD *append_line(); 90: CMD *make_acmd(); 91: CMD *make_ccmd(); 92: CMD *invert(); 93: CMD *addcond(); 94: CMD *addloop(); 95: CMD *wopt(); 96: 97: SPAT *stab_to_spat(); 98: 99: STAB *stabent(); 100: 101: ARG *stab_to_arg(); 102: ARG *op_new(); 103: ARG *make_op(); 104: ARG *make_lval(); 105: ARG *make_match(); 106: ARG *make_split(); 107: ARG *flipflip(); 108: 109: STR *arg_to_str(); 110: STR *str_new(); 111: STR *stab_str(); 112: STR *eval(); /* this evaluates expressions */ 113: STR *do_eval(); /* this evaluates eval operator */ 114: 115: FCMD *load_format(); 116: 117: char *scanpat(); 118: char *scansubst(); 119: char *scantrans(); 120: char *scanstr(); 121: char *scanreg(); 122: char *reg_get(); 123: char *str_append_till(); 124: char *str_gets(); 125: 126: bool do_match(); 127: bool do_open(); 128: bool do_close(); 129: bool do_print(); 130: 131: int do_subst(); 132: 133: void str_free(); 134: void freearg(); 135: 136: EXT int line INIT(0); 137: EXT int arybase INIT(0); 138: 139: struct outrec { 140: int o_lines; 141: char *o_str; 142: int o_len; 143: }; 144: 145: EXT struct outrec outrec; 146: EXT struct outrec toprec; 147: 148: EXT STAB *last_in_stab INIT(Nullstab); 149: EXT STAB *defstab INIT(Nullstab); 150: EXT STAB *argvstab INIT(Nullstab); 151: EXT STAB *envstab INIT(Nullstab); 152: EXT STAB *sigstab INIT(Nullstab); 153: EXT STAB *defoutstab INIT(Nullstab); 154: EXT STAB *curoutstab INIT(Nullstab); 155: EXT STAB *argvoutstab INIT(Nullstab); 156: 157: EXT STR *freestrroot INIT(Nullstr); 158: 159: EXT FILE *rsfp; 160: EXT char buf[1024]; 161: EXT char *bufptr INIT(buf); 162: 163: EXT STR *linestr INIT(Nullstr); 164: 165: EXT char record_separator INIT('\n'); 166: EXT char *ofs INIT(Nullch); 167: EXT char *ors INIT(Nullch); 168: EXT char *ofmt INIT(Nullch); 169: EXT char *inplace INIT(Nullch); 170: 171: EXT char tokenbuf[256]; 172: EXT int expectterm INIT(TRUE); 173: EXT int lex_newlines INIT(FALSE); 174: EXT int in_eval INIT(FALSE); 175: 176: FILE *popen(); 177: /* char *str_get(); */ 178: STR *interp(); 179: void free_arg(); 180: STIO *stio_new(); 181: 182: EXT struct stat statbuf; 183: EXT struct tms timesbuf; 184: 185: #ifdef DEBUGGING 186: EXT int debug INIT(0); 187: EXT int dlevel INIT(0); 188: EXT char debname[40]; 189: EXT char debdelim[40]; 190: #define YYDEBUG 1 191: extern int yydebug; 192: #endif 193: 194: EXT STR str_no; 195: EXT STR str_yes; 196: 197: /* runtime control stuff */ 198: 199: EXT struct loop { 200: char *loop_label; 201: jmp_buf loop_env; 202: } loop_stack[32]; 203: 204: EXT int loop_ptr INIT(-1); 205: 206: EXT jmp_buf top_env; 207: EXT jmp_buf eval_env; 208: 209: EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ 210: 211: double atof(); 212: long time(); 213: struct tm *gmtime(), *localtime(); 214: 215: #ifdef EUNICE 216: #define UNLINK(f) while (unlink(f) >= 0) 217: #else 218: #define UNLINK unlink 219: #endif