[comp.lang.perl] Long function names

raymond@bosco.berkeley.edu (Raymond Chen) (07/03/90)

Has anyone succeeded in bringing up perl on machines which limit
external identifiers to 8 characters?  Perl uses the names do_split
and do_splice, which both become _do_spli after truncation.

I changed do_splice to do_splce in eval.c and dolist.c, and that seemed
to work; nevertheless, I'm afraid that there might be some other collisions
that weren't caught by the regressions.

(Any chance Larry'll add this warning to the README?)

Also, is anybody working on porting perl to OS/2?  I figure I'll use
Diomidis' MS-DOS version as a base, but I'd like to know if anybody
else has tackled the task already.

$_="-|";open _||print"creaJklrnue  osrhptt,aeh ";while(<_>){$}=5;s/(.{$}})(.)/(print$2),$1/eg while--$};print;}

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/04/90)

In article <1990Jul3.001958.19915@agate.berkeley.edu> raymond@math.berkeley.edu (Raymond Chen) writes:
: Has anyone succeeded in bringing up perl on machines which limit
: external identifiers to 8 characters?  Perl uses the names do_split
: and do_splice, which both become _do_spli after truncation.
: 
: I changed do_splice to do_splce in eval.c and dolist.c, and that seemed
: to work; nevertheless, I'm afraid that there might be some other collisions
: that weren't caught by the regressions.

There's also potential problems with do_exec{,free}, localiz{e,ing} and
origarg{c,v}.

: (Any chance Larry'll add this warning to the README?)

Nah, I'll just fix 'em.

: Also, is anybody working on porting perl to OS/2?  I figure I'll use
: Diomidis' MS-DOS version as a base, but I'd like to know if anybody
: else has tackled the task already.

Several people have newer versions of that, so you probably want one
of them.

: $_="-|";open _||print"creaJklrnue  osrhptt,aeh ";while(<_>){$}=5;s/(.{$}})(.)/(print$2),$1/eg while--$};print;}

Truly perverse.

Larry

P.S.  Here's the script I used to check conflicts:

#!/usr/bin/perl

$xname = shift;

open(NM,"nm -g $xname|") || die "Can't run nm: $!\n";

while (<NM>) {
    ($addr, $type, $name) = split(/\s+/);
    next if length($name) < 8;
    ($pre,$post) = unpack('a8a100',$name);
    if ($pre eq $lastpre) {
	if ($lastname ne '') {
	    print "\n",$lastname,"\n";
	}
	print $name,"\n";
	$lastname = '';
    }
    else {
	$lastname = $name;
	$lastpre = $pre;
    }

}

I have a fancier one that will check the sources.  It goes like this:

#!/usr/bin/perl

$CRITLEN = 7;
$CRITPAT = "a$CRITLEN a100";

while ($ARGV[0] =~ /^-/) {
    $_ = shift;
    if (/^-D(.*)/) {
	$defines .= " -D" . ($1 ? $1 : shift);
    }
    elsif (/^-I(.*)/) {
	$includes .= " -I" . ($1 ? $1 : shift);
    }
    elsif (/^-v/) {
	$verbose++;
    }
    else {
	die "Unrecognized switch: $_\n";
    }
}

open(LOC, ">/tmp/uniqid$$") || die "Can't create /tmp/uniqid$$: $!\n";

foreach $file (@ARGV) {
    print STDERR "$file\n" if $verbose;
    open(CPP,"cc -E $defines $includes $file|") || die "Can't run cpp: $!\n";
    $line = 2;

    while (<CPP>) {
	++$line;
	if (/^#/) {
	    next unless /^# \d/;
	    ($junk,$newline,$filename) = split;
	    $filename =~ s/"//g;
	    if ($stack[$#stack] eq $filename) {
		$line = $newline-1;
		next;
	    }
	    if ($stack[$#stack-1] eq $filename) {
		$line = pop(@lines)-1;
		pop(@stack);
	    }
	    else {
		push(@lines,$line);
		$line = $newline;
		push(@stack,$filename);
	    }
	}
    }
    else {
	@words = split(/\W+/,$_);
	shift(@words) if $words[0] eq '';
	foreach $word (@words) {
	    next if length($word) < $CRITLEN;
	    ($pre,$post) = unpack($CRITPAT,$word);
	    print LOC "$pre $post $filename $line\n";
	    $mapping = $mapping{$pre};
	    if (defined $mapping) {
		next if $mapping eq $post;
		$conflicts{$pre}++;		# Bingo!
		print STDERR "Found $pre$mapping vs $pre$post\n" if $verbose;
	    }
	    else {
		$mapping{$pre} = $post;
	    }
	}
    }
    close CPP;
    $line = 0;
}
close LOC;

@conflicts = sort keys(%conflicts);
if (@conflicts) {
    print "Conflicts with ",int(@conflicts)," prefixes\n";
    open(LOC, "/tmp/uniqid$$") || die "Can't reopen /tmp/uniqid$$: $!\n";
    while (<LOC>) {
	($pre,$post,$file,$line) = split(/ /);
	next unless $conflicts{$pre};
	chop($line);
	$tale{$pre} .= <<EOF unless $seen{$_}++;
$pre$post \toccurs in file $file at line $line.
EOF
    }
    close LOC;
    foreach $pre (@conflicts) {
	print "\nConflicts with $pre*:\n";
	print $tale{$pre};
    }
}

unlink "/tmp/uniqid$$";