! 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 ! !++ ! ! libr ! ! libr infile outfile ! ! prepares a file of procedure as a "library" by inserting ! #ifdef inc_, #ifndef def_ , ! #define def_ before each begin-procedure ! and #endif def_ and #endif inc_ ! after each end-procedure. This allows each procedure ! to be a separately compilable module within the include ! file. ! ! "libr" is intended to be used with the "link" procedure ! which adds information about which routines depend on ! which other routines. ! ! ? Should we have libr add #define inc_ for ! ? each procedure called from a library? I think so. ! ? link, then, would simply look at a program module ! ? (non library) and cause #define inc_ for ! ? each procedure called THAT IS NOT DEFINED IN THE FILE. ! ! this could be modified to look for 'load-lookup'...'quiet' and ! call this a "module" in setup.sqh files. ! !-- ! ! Modification History ! ! Name Date Comment ! ---------------- ---------- ---------------------------------------- ! Ray Ontko 1997.01.14 Created ! !------------------------------------------------------------------- libr begin-procedure libr local move 'libr.tmp' to $tname move 'libr.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 libr_file( $iname , $tname ) do fixup_files ( $tname, $oname, $bname ) end-procedure ! libr !-------------------------------------------------------------- libr_file begin-procedure libr_file( $infile , $outfile ) ! inserts #ifdef inc_/#ifndef def_/#define def_ for a library .sqh file ! open $infile as 1 for-reading record={SQRSH_LINE_MAX}:vary open $outfile as 2 for-writing record={SQRSH_LINE_MAX}:vary read 1 into $line:{SQRSH_LINE_MAX} while not #_end-file unstring $line by ' ' into $p0 $p1 lowercase $p0 evaluate $p0 when = 'begin-procedure' unstring $p1 by '(' into $proc_name write 2 from '#ifdef inc_' $proc_name write 2 from '#ifndef def_' $proc_name write 2 from '#define def_' $proc_name write 2 from $line break when = 'end-procedure' write 2 from $line write 2 from '#endif def_' $proc_name write 2 from '#endif inc_' $proc_name break when-other if substr($line,1,11) = '#ifdef inc_' or substr($line,1,12) = '#ifndef def_' or substr($line,1,12) = '#define def_' or substr($line,1,11) = '#endif inc_' or substr($line,1,11) = '#endif def_' ! do nothing else write 2 from $line end-if end-evaluate read 1 into $line:{SQRSH_LINE_MAX} end-while close 2 close 1 end-procedure ! libr_file