Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!sundc!gouldsd!mjranum From: mjranum@gouldsd.UUCP Newsgroups: net.sources Subject: possibly useful toy Message-ID: <484@gouldsd.UUCP> Date: Thu, 26-Mar-87 11:26:43 EST Article-I.D.: gouldsd.484 Posted: Thu Mar 26 11:26:43 1987 Date-Received: Sat, 28-Mar-87 04:23:47 EST Organization: Gould Electronics, Landover MD. Lines: 197 Keywords: break large .c files up into what it thinks are subroutines This is a quick hack that may come in handy. It takes a .c file and tries to chop it up into discrete subroutines. (Note the "TRIES") If you use it, I suggest using it in a subdirectory of its own, and on one file at a time. It functions by getting subroutine names, prepending and "_" and then appending what it thinks is the subroutine. Misc stuff (that it can't recognize) goes into _header.h Hope it comes in handy... --mjr() --------------------------cut anywhere you like ------------ : #FROBOZZOROBOZZO #the following files are in this bundle: (Use them wisely) # Makefile shred.l # To unbundle - sh this file echo unbundling: Makefile shred.l echo unbundling Makefile if [ -f Makefile ] ; then echo cannot unbundle Makefile - file exists already exit 1 fi cat >Makefile <<'End of Makefile' DEST = . LINKER = cc CFLGS = -O -s -n PROGRAM = shred SRCS = lex.yy.c $(PROGRAM): $(SRCS) $(LINKER) $(CFLGS) -o $(PROGRAM) $(SRCS) @echo "done" lex.yy.c: shred.l lex shred.l install: $(PROGRAM) cp $(PROGRAM) $(DEST) chmod 555 $(DEST) End of Makefile echo done unbundling Makefile echo unbundling shred.l if [ -f shred.l ] ; then echo cannot unbundle shred.l - file exists already exit 1 fi cat >shred.l <<'End of shred.l' shred.l: %e 2000 %p 5000 %n 1000 %k 500 %a 4000 %o 2000 %{ /* Copyright, 1987, Marcus J Ranum */ /* All rights reserved. This code can be distributed, modified, */ /* or altered at will, but it or versions of it may not be sold */ /* for profit */ /* krufty hack to rip large source modules into subroutine modules */ /* this program is only semi-intelligent and should be treated as such */ #include #include int trigger =0; int bracelev =0; int incomment =0; int ininclude =0; int junkint =0; struct stat stbuf; char jfname[400]; char *strcat(); %} %% [a-zA-Z1-9 ]+"("[a-zA-Z1-9, ]*")" { /* found a function decl ! */ if(!bracelev && !incomment &&!ininclude) { (void)sprintf(jfname,"_%s",yytext); for(junkint = 0 ; junkint