! sqrsh (sqr shell) ! Copyright (C) 1997 Ray Ontko & Company ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! !++ ! ! modhist ! ! modhist iname oname ! ! inserts an Author/Modification History block following the first ! "!--" tag in an sqr file. If the file already contains "! Author" ! or "! Modification History" on the first line following the "!--" tag ! (and is not a blank comment line), an Author/Modification History block ! is not inserted. ! ! The template for the Author/Modification History block is obtained ! from a file. The name of the file is obtained by first checking ! the environment variable SQRSH_MODHIST. If this is not found ! it looks for the environment variable SQRSHDIR and appends the ! name 'modhist.txt'. ! !-- ! ! Modification History ! ! Name Date Comment ! ---------------- ---------- ---------------------------------------- ! First Last yyyy.mm.dd Comment ! !---------------------------------------------------------------- modhist begin-procedure modhist local move 'modhist.tmp' to $tname move 'modhist.bak' to $bname if isnull( $_p1 ) input $iname 'Input file' else move $_p1 to $iname end-if if isnull( $_p2 ) input $oname 'Output file' else move $_p2 to $oname end-if do modhist_file( $iname , $tname ) do fixup_files( $tname, $oname, $bname ) end-procedure ! modhist !----------------------------------------------------------- modhist_file begin-procedure modhist_file( $infile , $outfile ) open $infile as 1 for-reading record={SQRSH_LINE_MAX}:vary status=#status if #status show 'error opening input file "' $infile '"' else open $outfile as 2 for-writing record={SQRSH_LINE_MAX}:vary status=#status if #status show 'error opening output file "' $outfile '"' else move 0 to #state read 1 into $line:{SQRSH_LINE_MAX} while not #_end-file if #state = 0 and $line = '!!--' move 1 to #state else if #state = 1 and $line <> '!!' if lower( $line ) <> '!! modification history' and lower( $line ) <> '!! author' do modhist_insert end-if move 2 to #state end-if end-if write 2 from $line read 1 into $line:{SQRSH_LINE_MAX} end-while close 2 end-if close 1 end-if end-procedure ! modhist_file !--------------------------------------------------------- modhist_insert begin-procedure modhist_insert local let $modhist_file = getenv( 'SQRSH_MODHIST' ) if isnull( $modhist_file ) let $modhist_file = getenv( 'SQRSHDIR' ) || 'modhist.txt' end-if open $modhist_file as 3 for-reading record={SQRSH_LINE_MAX}:vary status=#status if #status show 'error opening modification history template file "' $modhist_file '"' else read 3 into $line:{SQRSH_LINE_MAX} while not #_end-file write 2 from $line read 3 into $line:{SQRSH_LINE_MAX} end-while close 3 end-if end-procedure ! modhist_insert