home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume9 / teco / part01 / te_data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-11  |  7.2 KB  |  184 lines

  1. /* TECO for Ultrix   Copyright 1986 Matt Fichtenbaum                        */
  2. /* This program and its components belong to GenRad Inc, Concord MA 01742    */
  3. /* They may be copied if this copyright notice is included                    */
  4.  
  5. /* te_data.c global variables  12/31/85 */
  6.  
  7. #include "te_defs.h"
  8.  
  9. /* error message text */
  10. char *errors[] =
  11.     {
  12.     "> not in iteration",
  13.     "Can't pop Q register",
  14.     "Can't open output file ",
  15.     "File not found ",
  16.     "Invalid E character",
  17.     "Invalid F character",
  18.     "Invalid insert arg",
  19.     "Invalid command",
  20.     "Invalid number",
  21.     "Invalid P arg",
  22.     "Invalid \" character",
  23.     "Invalid Q-reg name",
  24.     "Invalid radix arg",
  25.     "Invalid search arg",
  26.     "Invalid search string",
  27.     "Invalid ^ character",
  28.     "Insufficient memory available",
  29.     "Missing )",
  30.     "No arg before ^_",
  31.     "No arg before ,",
  32.     "No arg before =",
  33.     "No arg before )",
  34.     "No arg before \"",
  35.     "No arg before ;",
  36.     "No arg before U",
  37.     "No file for input",
  38.     "No file for output",
  39.     "Numeric arg with Y",
  40.     "Output file already open",
  41.     "Pushdown list overflow",
  42.     "Pointer off page",
  43.     "; not in iteration",
  44.     "Search failure ",
  45.     "String too long",
  46.     "Unterminated command",
  47.     "Unterminated macro",
  48.     "Execution interrupted",
  49.     "Y command suppressed",
  50.     "Invalid W arg",
  51.     "Numeric arg with FR",
  52.     "Internal error",
  53.     "EOF read from std input",
  54.     "Invalid A arg",
  55.     "Ambiguous file specification ",
  56.     "System fork or pipe error"
  57.     } ;
  58. /* declare global variables */
  59.     struct buffcell *freebuff = NULL;        /* buffcell free-list pointer */
  60.     struct buffcell *dly_freebuff = NULL;    /* delayed free-list pointer */
  61.     struct qp *freedcell = NULL;            /* cell free-list pointer */
  62.  
  63. /* the text buffer header */
  64.     struct qh buff = { NULL, NULL, 0, 0 } ;
  65.  
  66. /* the q-register headers point to the start of the buffer and registers */
  67.     struct qh qreg[NQREGS+5];        /* for q regs, command, search, file, sys-command, time/date */
  68.  
  69. /* the q-register stack contains temporary copies of q-register contents */
  70.     struct qh qstack[QSTACKSIZE];    /* q-reg stack */
  71.     struct qh *qsp;                    /* q-reg stack pointer */
  72.  
  73. /* the macro stack contains pointers to the currently active macros. */
  74. /* the top of the stack is the command pointer */
  75.     struct qp mstack[MSTACKSIZE];    /* macro stack */
  76.     struct qp *msp;                    /* macro stack pointer */
  77.  
  78. /* the expression stack */
  79.     struct exp_entry estack[ESTACKSIZE];    /* expression stack */
  80.     struct exp_entry *esp;                    /* expression stack pointer */
  81.  
  82. /* global variables, etc. */
  83.  
  84. int char_count = 0;                    /* char count for tab typer            */
  85. char lastc = ' ';                    /* last char read                    */
  86. int ttyerr;                            /* error return from ioctl            */
  87. extern int errno;                    /* system error code                */
  88. struct sgttyb ttybuf;                /* local copy of tty control data    */
  89. jmp_buf xxx;                        /* preserved environment for error restart */
  90. int err;                            /* local error code                    */
  91. struct qp t_qp;                        /* temporary buffer pointer            */
  92. struct qp aa, bb, cc;                /* more temporaries                    */
  93. struct buffcell t_bcell;            /* temporary bcell                    */
  94. int tabmask = 7;                    /* mask for typing tabs                */
  95. int exitflag;                        /* flag for ending command str exec    */
  96. char term_char = ESC;                /* terminator for insert, search, etc.    */
  97. char cmdc;                            /* current command character        */
  98. char skipc;                            /* char found by "skipto()"            */
  99. int dot, z, tdot;                    /* current, last, temp buffer position    */
  100. int ins_count;                        /* count of chars inserted            */
  101. int ll, mm, nn;                        /* general temps                    */
  102. int ctrl_e = 0;                        /* form feed flag                    */
  103. int ctrl_r = 10;                    /* numeric radix (8, 10, 16)        */
  104. int ctrl_s = 0;                        /* string length for S, I, G        */
  105. int ctrl_x = 0;                        /* search mode flag                    */
  106. int ed_val = 0;                        /* ED value                            */
  107. int es_val = 0;                        /* ES value                            */
  108. int et_val = 518;                    /* ET value                            */
  109. int eu_val = -1;                    /* EU value                            */
  110. int ev_val = 0;                        /* EV value                            */
  111. int ez_val = 0;                        /* EZ value                            */
  112. int srch_result = 0;                /* result of last :S executed        */
  113. int atflag = 0;                        /* flag for @ char typed            */
  114. int colonflag = 0;                    /* flag for : char typed            */
  115. int trace_sw = 0;                    /* nonzero if tracing command exec    */
  116.  
  117. struct buffcell *insert_p;            /* pointer to temp buffer segment during insert */
  118. int buff_mod;                        /* set to earliest buffer change    */
  119. int search_flag;                    /* set nonzero by search            */
  120. /* character mapping table (direct) */
  121. char mapch[] =
  122. {
  123.  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,        /* ^@ - ^M */
  124. 16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,        /* ^N - ^_ */
  125. ' ', '!', '"', '#', '$', '%', '&', '\'','(', ')', '*', '+', ',', '-', '.', '/',        /* sp - /  */
  126. '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',        /* 0 - ?   */
  127. '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',        /* @ - O   */
  128. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\',']', '^', '_',        /* P - _   */
  129. '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',        /* ` - o   */
  130. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|','}', '~', 0177        /* p - del */
  131. } ;
  132.  
  133. /* character table (mapped to lower case) */
  134. char mapch_l[] =
  135. {
  136.  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,        /* ^@ - ^M */
  137. 16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,        /* ^N - ^_ */
  138. ' ', '!', '"', '#', '$', '%', '&', '\'','(', ')', '*', '+', ',', '-', '.', '/',        /* sp - /  */
  139. '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',        /* 0 - ?   */
  140. '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',        /* @ - O   */
  141. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '^', '_',        /* P - _   */
  142. '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',        /* ` - o   */
  143. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|','}', '~', 0177        /* p - del */
  144. } ;
  145. /* table of special characters for "search," "skipto()," and "lines()"    */
  146. /* see "te_defs.h for meaning of bits */
  147.  
  148. char spec_chars[] =
  149. {
  150. 0,            A_S,        0,            0,                /* ^@ ^A ^B ^C */
  151. 0,            A_A,        0,            0,                /* ^D ^E ^F ^G */
  152. 0,            A_T,        A_L,        A_L,            /* ^H ^I ^J ^K */
  153. A_L,        0,            A_A,        0,                /* ^L ^M ^N ^O */
  154. 0,            A_A,        A_A,        A_A,            /* ^P ^Q ^R ^S */
  155. 0,            A_T|A_Q,    0,            0,                /* ^T ^U ^V ^W */
  156. A_A,        0,            0,            0,                /* ^X ^Y ^Z ^[ */
  157. 0,            0,            A_S,        0,                /* ^\ ^] ^^ ^_ */
  158. 0,            A_S,        A_X,        0,                /*    !  "  #  */
  159. 0,            0,            0,            A_X,            /* $  %  &  '  */
  160. 0,            0,            0,            0,                /* (  )  *  +  */
  161. 0,            0,            0,            0,                /* ,  -  .  /  */
  162. 0,            0,            0,            0,                /* 0  1  2  3  */
  163. 0,            0,            0,            0,                /* 4  5  6  7  */
  164. 0,            0,            0,            0,                /* 8  9  :  ;  */
  165. A_X,        0,            A_X,        0,                /* <  =  >  ?  */
  166. A_S,        0,            A_E|A_F,    0,                /* @  A  B  C  */
  167. 0,            A_S,        A_S,        A_Q,            /* D  E  F  G  */
  168. 0,            A_T|A_E,    0,            0,                /* H  I  J  K  */
  169. 0,            A_Q,        A_T|A_F,    A_T,            /* L  M  N  O  */
  170. 0,            A_Q,        A_E,        A_T|A_F,        /* P  Q  R  S  */
  171. 0,            A_Q,        0,            A_E,            /* T  U  V  W  */
  172. A_Q,        0,            0,            A_Q,            /* X  Y  Z  [  */
  173. 0,            A_Q,        A_S,        A_T|A_E,        /* \  ]  ^  _  */
  174. 0,            0,            A_E|A_F,    0,                /* `  a  b  c  */
  175. 0,            A_S,        A_S,        A_Q,            /* d  e  f  g  */
  176. 0,            A_T|A_E,    0,            0,                /* h  i  j  k  */
  177. 0,            A_Q,        A_T|A_F,    A_T,            /* l  m  n  o  */
  178. 0,            A_Q,        A_E,        A_T|A_F,        /* p  q  r  s  */
  179. 0,            A_Q,        0,            A_E,            /* t  u  v  w  */
  180. A_Q,        0,            0,            0,                /* x  y  z  {  */
  181. A_X,        0,            0,            0,                /* |  }  ~  del */
  182. } ;
  183.  
  184.