File: divide

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (36 lines) | stat: -rwxr-xr-x 814 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Given the name of a C source file generated by the Mercury compiler,
# and a count of the number of the number of modules in it (say N),
# generate N+1 files named $filename.part.{0,1,...N}.
#
# $filename.part.N will contain the module initialization stuff from the
# of the source file; the other files will contain a module each. Any stuff
# before the first module will be in $filename.part.0.
#
# Since divide can take a long time, it prints messages saying which part
# it is up to.

if test $# != 2
then
	echo "Usage: divide filename module_count"
	exit 1
fi

TERMCAP=/etc/termcap; export TERMCAP
cp $1 tmp

i=0
while test $i -lt $2
do
	ed - tmp > /dev/null << END
	/^END_MODULE/
	1,.w $1.part.$i
	1,.d
	w
	q
END
	echo done part $i
	i=`expr $i + 1`
done
mv tmp $1.part.$i
echo done final part $i