Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix Subject: Re: Joining Textlines containing "Key: Text." Message-ID: <2168@umcp-cs.UUCP> Date: Sat, 9-Nov-85 04:31:08 EST Article-I.D.: umcp-cs.2168 Posted: Sat Nov 9 04:31:08 1985 Date-Received: Sun, 10-Nov-85 08:43:55 EST References: <429@unido.UUCP> <2155@umcp-cs.UUCP> <731@h-sc1.UUCP> Distribution: net Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 44 The original example in <429@unido.UUCP> had, if I recall correctly, repeated keys that were not in sequence. If all your keys are in sequence then the associative array feature of awk is unnecessary and is indeed wasteful, as you point out. For another example, here is the last part of my current `generic makefile'. It runs through a set of programs, each assumed to consist of one `.c' file, and finds what they `#include'. The output of `cc -M', which of course consists of `key: text' lines, is joined into lines no more than 78 columns long. This is then inserted into the makefile itself, so that it will have an accurate dependency list---includingfiles, which have here a tendency toward rapid change. The -M option is available only in late 4.2 and 4.3 `cc's, unfortunately. depend: for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} depend); done for i in ${STD} ${NSTD} ${KMEM} ${SETUID}; do \ cc -M $$i.c | sed -e 's/\.o//' | awk '{ if ($$1 != prev) { \ if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec }'; done >makedep echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>Makefile echo '# see make depend above' >>Makefile # Files listed in ${NSTD} have explicit make lines given below. # DO NOT DELETE THIS LINE -- make depend uses it # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY # see make depend above -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu