Xref: utzoo comp.lang.fortran:310 comp.unix.questions:4827
Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!udel!gatech!mcnc!decvax!ucbvax!jade!violet.berkeley.edu!jerry
From: jerry@violet.berkeley.edu ( Jerry Berkman )
Newsgroups: comp.lang.fortran,comp.unix.questions
Subject: Re: Want to expand includes for listing...
Message-ID: <6323@jade.BERKELEY.EDU>
Date: 17 Dec 87 18:30:08 GMT
References: <2317@utastro.UUCP>
Sender: usenet@jade.BERKELEY.EDU
Reply-To: jerry@violet.berkeley.edu ( Jerry Berkman )
Organization: University of California, Berkeley
Lines: 46
Keywords: fortran include

In article <2317@utastro.UUCP> anita@utastro.UUCP (Anita Cochran) writes:
>Normally, I would just use lpr
>to print a listing but then the listing would have things like
>    include 'file.com'
>instead of actually listing the common.  Does anyone know of a utility
>or have a program or script to substitute the contents of an included
>file into the appropriate place of a source so that it can be listed
>(I have 4.2BSD UNIX)?  Surely, this is such a useful utility that someone
>must have invented it before.  I have already tried calling the files
>src.F and running f77 with the -F flag to run them through the preprocessor
>but this leaves the source unchanged with the includes still in it.
>
>Thanks in advance.
>
>-- 
> Anita Cochran  uucp:  {noao, ut-sally, ut-ngp}!utastro!anita
>                arpa:  anita@astro.as.utexas.edu  
>                snail: Astronomy Dept., The Univ. of Texas, Austin, TX, 78712
>                at&t:  (512) 471-1471

The following commands work on Ultrix and 4.3 BSD:

more *.f | sed -e 's/^[ 	]*include/.so/' 	\
	-e /^\.so/s/\[\"\']//g
	| soelim

The first "-e" option looks for a line with "include" preceded only by
blanks and tabs.  It replaces that by ".so".  The second "-e" deletes
the characters " and ' .  So:

	include "files.com"

now is:

.so files.com

Then the UNIX "soelim" command, designed for use with nroff, replaces
the ".so" by the text.  This only expands one level of includes; if
your include files include other files, you will need to modify the
script.

This script does not worry about the unlikely possibility that the
program has lines with "i" in column 6 for continuation and
"nclude" in columns 7-12 in non-include statements.

	- Jerry Berkman