sed.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* sed.h -- types and constants for the stream editor */
  2. /* data area sizes used by both modules */
  3. #define MAXBUF 4000 /* current line buffer size */
  4. #define MAXAPPENDS 20 /* maximum number of appends */
  5. #define MAXTAGS 9 /* tagged patterns are \1 to \9 */
  6. /* constants for compiled-command representation */
  7. #define EQCMD 0x01 /* = -- print current line number */
  8. #define ACMD 0x02 /* a -- append text after current line */
  9. #define BCMD 0x03 /* b -- branch to label */
  10. #define CCMD 0x04 /* c -- change current line */
  11. #define DCMD 0x05 /* d -- delete all of pattern space */
  12. #define CDCMD 0x06 /* D -- delete first line of pattern space */
  13. #define GCMD 0x07 /* g -- copy hold space to pattern space */
  14. #define CGCMD 0x08 /* G -- append hold space to pattern space */
  15. #define HCMD 0x09 /* h -- copy pattern space to hold space */
  16. #define CHCMD 0x0A /* H -- append hold space to pattern space */
  17. #define ICMD 0x0B /* i -- insert text before current line */
  18. #define LCMD 0x0C /* l -- print pattern space in escaped form */
  19. #define NCMD 0x0D /* n -- get next line into pattern space */
  20. #define CNCMD 0x0E /* N -- append next line to pattern space */
  21. #define PCMD 0x0F /* p -- print pattern space to output */
  22. #define CPCMD 0x10 /* P -- print first line of pattern space */
  23. #define QCMD 0x11 /* q -- exit the stream editor */
  24. #define RCMD 0x12 /* r -- read in a file after current line */
  25. #define SCMD 0x13 /* s -- regular-expression substitute */
  26. #define TCMD 0x14 /* t -- branch on last substitute successful */
  27. #define CTCMD 0x15 /* T -- branch on last substitute failed */
  28. #define WCMD 0x16 /* w -- write pattern space to file */
  29. #define CWCMD 0x17 /* W -- write first line of pattern space */
  30. #define XCMD 0x18 /* x -- exhange pattern and hold spaces */
  31. #define YCMD 0x19 /* y -- transliterate text */
  32. struct cmd_t /* compiled-command representation */
  33. {
  34. char *addr1; /* first address for command */
  35. char *addr2; /* second address for command */
  36. char command; /* command code */
  37. union
  38. {
  39. char *lhs; /* s command left-hand side */
  40. struct cmd_t *link; /* label link */
  41. } u;
  42. char *rhs; /* s command replacement string */
  43. FILE *fout; /* associated output file descriptor */
  44. struct
  45. {
  46. unsigned allbut : 1; /* was negation specified? */
  47. unsigned global : 1; /* was g postfix specified? */
  48. unsigned firstl : 1; /* stop print (if any) on \n */
  49. unsigned active : 1; /* is command now selected? */
  50. } flags;
  51. };
  52. typedef struct cmd_t sedcmd; /* use this name for declarations */
  53. #define BAD ((char *) -1) /* guaranteed not a string ptr */
  54. #if (VOIDOK == 0)
  55. #define void int
  56. #endif
  57. /* address and regular expression compiled-form markers */
  58. #define STAR 0x01 /* marker for Kleene star */
  59. #define CCHR 0x02 /* non-newline character to be matched follows */
  60. #define CDOT 0x04 /* dot wild-card marker */
  61. #define CCL 0x06 /* character class follows */
  62. #define CNL 0x08 /* match line start */
  63. #define CDOL 0x0A /* match line end */
  64. #define CBRA 0x0C /* tagged pattern start marker */
  65. #define CKET 0x0E /* tagged pattern end marker */
  66. #define CBACK 0x10 /* backslash-digit pair marker */
  67. #define CLNUM 0x12 /* numeric-address index follows */
  68. #define CEND 0x14 /* symbol for end-of-source */
  69. #define CEOF 0x16 /* end-of-field mark */
  70. #define TAGMARK 0x80 /* mark valid tag references in right-hand side */
  71. /* sed.h ends here */