[CSC 415] Splitting Source Files
Andrew J. Pounds
POUNDS_AJ at mercer.edu
Wed Mar 16 13:55:20 EDT 2011
I know that several of you are working on code and working on splitting up code. Here is something I have used before from the UNIX POWER TOOLS for breaking up C code into individual source files.
example, adapted from AT&T's UNIX User's Reference Manual :
%
csplit -s -k -f routine. prog.c '%main(%' '/^}/+1' '{99}'
The idea is that the file prog.c contains a group of C routines, and we want to place each one in a separate file ( routine.00 , routine.01 , etc.). The first pattern uses % because we want to discard anything before main . The next argument says, "Look for a closing brace at the beginning of a line (the conventional end of a routine) and split on the following line (the assumed beginning of the next routine)." Repeat this split up to 99 times, using -k to preserve the created files. [4]
[4] In this case, the repeat can actually occur only 98 times, since we've already specified two arguments and the maximum number is 100.
If you want to do Fortran, then there is a program called fsplit that I have installed on zeus. (type man fsplit)
--
Andrew J. Pounds, Ph.D. (pounds at theochem.mercer.edu<mailto:pounds at theochem.mercer.edu>)
Associate Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://theochem.mercer.edu/pipermail/csc415/attachments/20110316/fc215774/attachment.html
More information about the csc415
mailing list