Using identifiers with more than 7 chars. #$%@

Steven Pemberton steven at boring.uucp
Wed Mar 5 23:25:35 AEST 1986


In article <526 at dsi1.UUCP> ron at dsi1.UUCP (Ron Flax) writes:
> I  wish  that the people that post sources to the net would try to keep
> in mind that some of us have compilers that can't swollow  indentifiers
> that are longer than seven (7) characters long.

The problem is that the compilers don't have a switch to ask them to check
for such limits. Even if you're trying to write portable programs, it is all
too easy to use identifiers that don't differ over the right number of
characters.

Here then is a reposting of three little shell command files I wrote (only
tried under BSD: they use the nm(1) command, and depend on its output
format) to check different limits:

	8limit - all identifiers used in an object module differ over the
		 first 8 characters
	7limit - all external identifiers in a binary differ over the
		 first 7 characters
	6limit - all externals in a binary differ in the first 6 characters
		 case-insensitively (some people really have this limit!)

Note carefully that 8limit takes a list of *.o files, while 6/7limit take an
executable.

Steven Pemberton, CWI, Amsterdam; steven at mcvax.uucp

: ---------------------- CUT HERE -------------------------------
: This is a shar archive. Extract with sh, not csh.
: The rest of this file will extract:
: 6limit 7limit 8limit
echo x - 6limit
sed -e 's/^X//' <<'Bye-Bye' >6limit
X: Check externals differ case-insensitively over first 6 chars
Xcase $# in
X1) ;;
X*) echo Usage: $0 executable-file ; exit 1;;
Xesac
X
Xtrap 'rm -f /tmp/lim1.$$ /tmp/lim2.$$; exit 1' 1 2 15
Xnm -g $1 | sed "s/^............//" >/tmp/lim1.$$
Xsed "s/^\(......\).*/\1/" </tmp/lim1.$$ | tr A-Z a-z | sort | uniq -d | sed "s/.*/grep -i \"^&\" \/tmp\/lim1.$$/" > /tmp/lim2.$$
Xif test -s /tmp/lim2.$$
Xthen
X	echo The following externals don\'t differ in the first 6 characters:
X	sh /tmp/lim2.$$
Xelse
X	echo All externals differ in the first 6 characters
Xfi
Xrm -f /tmp/lim1.$$ /tmp/lim2.$$
Bye-Bye
echo x - 7limit
sed -e 's/^X//' <<'Bye-Bye' >7limit
X: Check externals differ over first 7 chars
Xcase $# in
X1) ;;
X*) echo Usage: $0 executable-file ; exit 1;;
Xesac
X
Xtrap 'rm -f /tmp/lim1.$$ /tmp/lim2.$$; exit 1' 1 2 15
Xnm -g $1 | sed "s/^............//" >/tmp/lim1.$$
Xsed "s/^\(.......\).*/\1/" </tmp/lim1.$$ | uniq -d | sed "s/.*/grep \"^&\" \/tmp\/lim1.$$/" > /tmp/lim2.$$
Xif test -s /tmp/lim2.$$
Xthen
X	echo The following externals don\'t differ in the first 7 characters:
X	sh /tmp/lim2.$$
Xelse
X	echo All externals differ in the first 7 characters
Xfi
Xrm -f /tmp/lim1.$$ /tmp/lim2.$$
Bye-Bye
echo x - 8limit
sed -e 's/^X//' <<'Bye-Bye' >8limit
X: Check names differ over first 8 chars
Xcase $# in
X0) echo Usage: $0 object-files ... ; exit 1;;
X*) ;;
Xesac
X
Xtrap 'rm -f /tmp/lim1.$$ /tmp/lim2.$$; exit 1' 1 2 15
Xfor f
Xdo
X   echo $f:
X   nm $f | sed "s/^...........//" | grep "^_" | sed "s/^_//" >/tmp/lim1.$$
X   sed "s/^\(........\).*/\1/" </tmp/lim1.$$ | uniq -d | sed "s/.*/grep \"^&\" \/tmp\/lim1.$$/" >/tmp/lim2.$$
X   if test -s /tmp/lim2.$$
X   then
X	echo In $f the following don\'t differ in the first 8 characters:
X	sh /tmp/lim2.$$
X   fi
Xdone
Xrm -f /tmp/lim1.$$ /tmp/lim2.$$
Bye-Bye
exit 0



More information about the Comp.sources.unix mailing list