mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-09 02:43:21 +00:00
Estimated hours taken: 0.2 tools/binary: tools/divide: tools/linear: Fix some software rot in these scripts: we now need main.[co] in the top level directory, and END_MODULE is now spelt MR_END_MODULE.
37 lines
817 B
Bash
Executable File
37 lines
817 B
Bash
Executable File
#!/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
|
|
/^MR_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
|