long vs. short names

Toby Harness toby at gargoyle.UChicago.UUCP
Tue Aug 28 06:25:42 AEST 1984


> re: long vs. short identifiers; it seems to me that with a bit of
> judiciousness, one can have it both ways:
> 	instead of doggoneid1 being confused with
> 		   doggoneid2 in a truncating compiler, if you declare them
> like this:	   1doggoneid and
> 		   2doggoneid, ie, make the unique part first instead of last,
> then you have portable long ids.  see any holes kids?  ernie harkins

That`s fine when one is writting new code, (and in fact should be considered
necessary by any standard of good programming style) but it`s not so helpful
when one is porting a piece of code who`s author gave no such consideration to 
unique identifers.  I find myself spending too much time on the latter.
Here is a short little script that I pass most 4.2 stuff through.

#!/bin/sh
# UNISRC_ID: @(#)cnam.sh	1.5	5/12/84
# printout C identifers greater that 15 characters
# Toby Harness

tmp=/tmp/cnam$$
tmpa=/tmp/cnama$$
trap 'rm -f $tmp $tmpa' 1 2 3

for i in $*
do
	tr -cs '[a-z][A-Z][0-9]_' '[\012*]' < $i |
	grep '...............*' >> $tmp
done

sort -d $tmp | uniq > $tmpa
fgrep `cut -c1-15 $tmpa | uniq -d` $tmpa

rm $tmp $tmpa

------------------------------------------------

Note: The machines I deal with support 15 character external identifers. 
You may have to change the "grep" and the "cut" to fit your compiler/linker.


Toby Harness		Ogburn/Stouffer Center, University of Chicago
			...ihnp4!gargoyle!toby



More information about the Comp.unix.wizards mailing list