sed.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #
  2. /*
  3. * sed -- stream editor
  4. *
  5. *
  6. */
  7. #define CBRA 1
  8. #define CCHR 2
  9. #define CDOT 4
  10. #define CCL 6
  11. #define CNL 8
  12. #define CDOL 10
  13. #define CEOF 11
  14. #define CKET 12
  15. #define CNULL 13
  16. #define CLNUM 14
  17. #define CEND 16
  18. #define CDONT 17
  19. #define CBACK 18
  20. #define STAR 01
  21. #define NLINES 256
  22. #define DEPTH 20
  23. #define PTRSIZE 1024
  24. #define RESIZE 20000
  25. #define ABUFSIZE 20
  26. #define LBSIZE 4000
  27. #define LABSIZE 50
  28. #define NBRA 9
  29. typedef unsigned char uchar;
  30. FILE *fin;
  31. union reptr *abuf[ABUFSIZE];
  32. union reptr **aptr;
  33. uchar *lastre;
  34. uchar ibuf[512];
  35. uchar *cbp;
  36. uchar *ebp;
  37. uchar genbuf[LBSIZE];
  38. uchar *loc1;
  39. uchar *loc2;
  40. uchar *locs;
  41. uchar seof;
  42. uchar *reend;
  43. uchar *lbend;
  44. uchar *hend;
  45. uchar *lcomend;
  46. union reptr *ptrend;
  47. int eflag;
  48. int dolflag;
  49. int sflag;
  50. int jflag;
  51. int numbra;
  52. int delflag;
  53. long lnum;
  54. uchar linebuf[LBSIZE+1];
  55. uchar holdsp[LBSIZE+1];
  56. uchar *spend;
  57. uchar *hspend;
  58. int nflag;
  59. int gflag;
  60. uchar *braelist[NBRA];
  61. uchar *braslist[NBRA];
  62. long tlno[NLINES];
  63. int nlno;
  64. #define MAXFILES 120
  65. char fname[MAXFILES][40];
  66. FILE *fcode[MAXFILES];
  67. int nfiles;
  68. #define ACOM 01
  69. #define BCOM 020
  70. #define CCOM 02
  71. #define CDCOM 025
  72. #define CNCOM 022
  73. #define COCOM 017
  74. #define CPCOM 023
  75. #define DCOM 03
  76. #define ECOM 015
  77. #define EQCOM 013
  78. #define FCOM 016
  79. #define GCOM 027
  80. #define CGCOM 030
  81. #define HCOM 031
  82. #define CHCOM 032
  83. #define ICOM 04
  84. #define LCOM 05
  85. #define NCOM 012
  86. #define PCOM 010
  87. #define QCOM 011
  88. #define RCOM 06
  89. #define SCOM 07
  90. #define TCOM 021
  91. #define WCOM 014
  92. #define CWCOM 024
  93. #define YCOM 026
  94. #define XCOM 033
  95. uchar *cp;
  96. uchar *reend;
  97. uchar *lbend;
  98. union reptr {
  99. struct reptr1 {
  100. uchar *ad1;
  101. uchar *ad2;
  102. uchar *re1;
  103. uchar *rhs;
  104. FILE *fcode;
  105. uchar command;
  106. uchar gfl;
  107. uchar pfl;
  108. uchar inar;
  109. uchar negfl;
  110. } r1;
  111. struct reptr2 {
  112. uchar *ad1;
  113. uchar *ad2;
  114. union reptr *lb1;
  115. uchar *rhs;
  116. FILE *fcode;
  117. uchar command;
  118. uchar gfl;
  119. uchar pfl;
  120. uchar inar;
  121. uchar negfl;
  122. } r2;
  123. } ptrspace[PTRSIZE], *rep;
  124. uchar respace[RESIZE];
  125. struct label {
  126. uchar asc[9];
  127. union reptr *chain;
  128. union reptr *address;
  129. } ltab[LABSIZE];
  130. struct label *lab;
  131. struct label *labend;
  132. int f;
  133. int depth;
  134. int eargc;
  135. uchar **eargv;
  136. uchar *address(uchar *);
  137. int advance(uchar *, uchar *);
  138. void arout(void);
  139. extern uchar bittab[];
  140. uchar bad;
  141. uchar *badp;
  142. int cmp(uchar *, uchar *);
  143. union reptr **cmpend[DEPTH];
  144. void command(union reptr *);
  145. uchar compfl;
  146. uchar *compile(uchar *);
  147. uchar *compsub(uchar *);
  148. void dechain(void);
  149. int depth;
  150. void dosub(uchar *);
  151. int ecmp(uchar *, uchar *, int);
  152. void execute(uchar *);
  153. void fcomp(void);
  154. uchar *gline(uchar *);
  155. uchar *lformat(int, uchar *);
  156. int match(uchar *, int);
  157. union reptr *pending;
  158. uchar *place(uchar *, uchar *, uchar *);
  159. int rline(uchar *);
  160. struct label *search(struct label *);
  161. int substitute(union reptr *);
  162. uchar *text(uchar *);
  163. uchar *ycomp(uchar *);