! STRIPR.TEC !! THE ".TCO" FORM. ! ! This TECO macro strips comments and tabs (except tabs within retained comments) from commented macros (the ".TCO" form). It does not strip spaces or CRLFs, except for CRLFs, spaces, and/or tabs between adjacent deleted comments. !! While any valid input file extension can be specified, the default input file extension is ".TCO". Whatever input file extension may have been have been specified, the output file extension is forced to be ".TEC". ! ! Execute STRIPR by EDIT/EXECUTE:'FILNAM.TCO' STRIPR (if under RT-11) or EDIT/EXECUTE:FILNAM STRIPR (also RT-11) or MUNG STRIPR,FILNAM.TCO (for other operating systems) !!......................................................................! J ! Move to beginning of the buffer. ! HXI ! Put entered filespec into QI (Input) ! HXO ! and into QO (Output). ! ! Does entered filespec of file to be stripped ! @:S/./ ! contain a specified extension? ! "U @:^UI/.TCO/ ! If not, append default ".TCO" to QI ! @:^UO/.TEC/ ! and ".TEC" to output filespec. ! | K @I/TEC/ HXO ' ! If yes, kill the specifed input ext ! ! replace it with ".TEC", put the thusly! ! modified filespec into QO. ! HK ! Cleanup the buffer. ! @:ER/^EQI/ ! Read edit the input file. ! "U @^A/TECO-F-FILE / :G* ! If file not found, report... ! @^A/ NOT FOUND./ EX ! ...and abort. ! | 013^T 010^T ! If okay, issue a CRLF and tell the ! 009^T @^A/Stripping / ! operator what we are doing and ! :G* 032^T ' ! to which file we are doing it. ! A ! Append the input file into the buffer.! @EW/^EQO/ ! Open an output file in the name of ! ! the output filespec. ! 033@^UE// ! Put an exclamation mark into QE. ! 013@^UC// ! Put a carriage return,... ! 010@:^UC// ! ...and line feed into QC. ! < ! Begin iteration. ! J ! Start at beginning of buffer. ! < ! Begin iteration. ! < ! Begin iteration. ! (.-Z); ! If at end of bufr, breakout of iter. ! @::S/^N^EQE/ ; ! Step over any char other than excla- ! ! mation mark. Breakout if excla mark. ! > ! End iteration. ! (.-Z); ! If at end of bufr, breakout of iter. ! ."N .-1,.@:FB/^EL/ UT ! Provided this is not the first char ! QT"U .-1,.@:FB/O/ UT ' ! in the buffer, check the immediately ! | -1UT ' ! preceeding character to determine if ! ! this exclamation mark is immediately ! ! preceeded by either a line terminator ! ! or the letter "O"? If it is, it is ! ! either a label, a comment which the ! ! author desires to be left in, or a ! ! GOTO; in whichever case we do want to ! ! retain it. ! .U1 @2S/^EQE/ ! Save the position immediately before ! ! the exclamark and find the terminating! ! exclamark. ! QT"F Q1,.K ! If the found exclamark is not immed- ! ! iately preceeded by a line terminator ! ! or the letter "O", it is a comment. ! ! Kill it and, if that comment is ! < .U1 @::S/^EQC/ ; ! immediately followed by a CRLF then a ! @::S/^ES/ ; ! non-null string of spaces and/or tabs ! @::S/^EQE/ ; ! then another exclamark, it is a com- ! ! ment on the next line. ! @S/^EQE/ Q1,.K ! Kill it, too. ! > ' ! End iteration. ! > ! Loop back to test the next character. ! ! During the second pass thru this buffer... ! J ! Jump to the beginning of the buffer. ! 009@^UT// ! Put a tab into QT. ! < ! Begin iteration. ! (.-Z); ! If at buffer end, breakout. ! @::S/^EQE/ ! If this char is not an exclamark and ! "F @::S/^N^EQT/ ! is not a tab, step over it. ! "F D ' ! But if it is a tab, delete it. ! | @S/^EQE/ ' ! If it was a comment, label, or GOTO ! ! which we wanted to retain go to its ! ! terminating exclamation mark. ! > ! Loop back to test the next character. ! :P ; ! We are done with this bufr. Output it ! ! and bring in more of the input file, ! ! if there is any more. ! > ! Loop back to strip this new buffer. ! ! When we have stripped the entire input file... ! 013^T 010^T ! ...Report... ! @^A/Done./ 013^T 010^T ! ...having finished and... ! EX ! ...Exit. ! ! End STRIPR.TEC ! ! Now two real (and invisible) escapes to force this macro to self-start.!