.; Bonner Lab Runoff format .ps64,76.lm0.rm76.nopaging.nhy 1 XSE .p0 The XSE "stream editor" performs line by line changes to a text file. The command line format is: .p5 $ XSE [-c command ] [-f comspec ] [-o outspec] [-version] inspec .b1 2 Flags .lm12.rm74.ts12.p-12 -c#command perform command (see sub-topic "Commands"). Up to 10 instances of -c are allowed. .p -f#comspec read commands from file comspec. The conventional filetype is TR, but this must be given explicitly. .p -o#outspec write output to file outspec (default is the user's terminal). .p -version print XSE's version number etc.. .lm0.b1 2 Parameter .b1 inspec is the full filename of the file to be edited. The default filetype is none. If no inspec parameter is given, or the file cannot be opened, then input is taken from the terminal. .b1 2 Commands .p0 XSE commands, which may be entered as arguments to the -c flag, or as a list in a file specified with -f, take one of the following forms: .lm12.p-12 : a comment. The rest of the line is ignored. .p a#text the string text is appended to the end of the file. .p i#text the string text is inserted at the beginning of the file. .p s/regular__expression/replacement/[g][+] .br One or more s commands specify replacements to be made within the file. Each line is examined and, by default, the first s command which matches a sequence of characters within the line is applied. If a g modifier is appended to the end of the s command line, then ALL occurrences of regular__expression in the line are substituted, otherwise only the first is. If a + modifier is appended, then the next s command in sequence is also applied to the line. The / delimiter may be replaced by any character which does not occur in regular__expression or replacement. .lm0.b1 3 Regular__expressions .rm74.p0 A regular expression is a shorthand notation for a sequence of target characters, which may include wildcard specifications and notations for certain non-printing characters:- .b1.nf char_^ matches any series of char's. ? matches any character except newline. .lm12.f.i-12 * matches any group of characters except newline, such that a*b matches everything including and between the first 'a' on the line to the last 'b'. .i-12 _^ as the left-most character requires the expression to be at the beginning of a line. .i-12 $ as the right-most character requires the expression to be at the end of a line. .i-12 [...] matches any character within the brackets, e.g_. [abc] matches a, b, or c. A hyphen other than as the first character specifies a range, e.g_. [a-z]. .i-12 [!...] matches any character EXCEPT newline and those bracketed. .i-12 _\(..._\) brackets an expression, for use in substitutions (see sub-topic "Replacement__expressions"). .lm0.nf _\b matches a backspace. _\f matches a form feed. .;_\n matches a newline. _\r matches a carriage-return. _\t matches a horizontal tab. _\v matches a vertical tab. _\_\ matches a backslash. _\ddd matches a character with ASCII octal code ddd. .b1.lm0 3 Replacement__expressions .f.p0 The following have special significance in replacement expressions:- .lm12.p-12 _& is replaced by the expression which regular__expression matched. Use _\_& to insert a real ampersand. .i-12 _\(n is replaced by the n'th bracketed expression _\(..._\) in regular__expression. n=1-9. .lm0.nf _\(ln as above, but the string is converted to all lowercase. _\(un as above, but the string is converted to all uppercase. _\b inserts a backspace. _\f inserts a form feed. _\n inserts a line feed. _\r inserts a carriage-return. _\t inserts a horizontal tab. _\v inserts a vertical tab. _\_\ inserts a backslash. _\_& inserts an ampersand. _\ddd inserts a character with ASCII octal code ddd. .b1 2 Examples .rm76.f.p0 $ XSE -fSYS$COMFILE:TOX68000.TR -OPROG.T PROG.S .b1 translates an assembler output, PROG.S, from the 68000 C cross-compiler to file PROG.T, in a form suitable for X68000. Translation file SYS$COMFILE:TOX68000.TR contains: .b1.lm5.nf : translation file for xse to convert output from p2.68k : into a form suitable for x68000 : s/_\*/;/ s/.long L/.ADDR L/ s/.long/.DOUBLE/ s/.text/.PSECT __text/ s/.data/.PSECT __data/ s/.=./.ORG ./ s/.globl/.EXTERNAL/ i .PROCESSOR M68000 a .PSECT __data a .EVEN a .PSECT __text a .EVEN a .END .lm0.s2 $ xse -cs/smg__/smg$/ -cs/lib__/lib$/ -cs/sys__/sys$/ -cs/gks__/gks$/ - -cs/str__/str$/ -cs/ots__/ots$/ -cs/mth__/mth$/ -cs/dtk__/dtk$/ - -oMACSRC.MAR MACSRC.MAR;-1 .s.f creates a new version of MACSRC.MAR in which all occurrences of "smg__", "lib__" etc_. are changed to begin smg$, lib$, etc.. This enables C programs to call VAX/VMS system library functions, which contain $ signs in their names, not accepted by Whitesmiths' C. Note that (a) the name must be in lower case, and (b) the source file must be specified as version -1, since XSE opens the output (with the same name) first. .;.b2 .;$ XSE -cs/_\33_\[4m/_\33_\&dD/g+ -cs/_\33_\[24m/_\33_\_&d@/g+ -oMAN.MEM MAN.LNI .;.b1 .;translates the underline on and off escape sequences in .LNI file produced by .;RUNOFF with /DEVICE=LN03 to a form suitable for output to the HP Laserjet .;printer. (Several other translations would be required in a real application.) .;.b2 .;$ XSE -cs/_\33[a-zA-Z]//g MANUAL.MEM .;.b1 .;displays file MANUAL.MEM on the terminal, removing (most) ANSI escape .;sequences, presumably for a device which does not recognise them. .b1 2 BUGS .rm76.p0 The following bugs are known for version V1.0 15apr86, and have been reported to Real Time Systems:- .list 1 .le;If the input file cannot be opened, XSE defaults to taking its input from the terminal, and appears to hang. Press control/Z to get out of this situation. .le;A regular expression of the form a*z matches all characters from the first a on the line to the LAST z, not the NEXT z as should be expected. .le;_\r and _\n in regular expressions give strange effects, and should be avoided. .le;Special characters represented by _\n, _\r, _\t, _\v, and _\ddd are not always found, even when they exist in the text. .le;Only lower-case strings can be matched or substituted from a command line command. This is a restriction in the way C interfaces with the VMS command line dispatch mechanism. .le;The command s/a_\0/x/ produces a spurious error message if included in the command line, as a -c flag argument. It appears to be accepted in a translation control file, however. .le;Attempting to place an ampersand or backslash into a replacement expression using _\_\ or _\_& may give incorrect results, especially when these special characters appear in combination. .els0