[comp.mail.mush] mush 7.0 on SCO Xenix 286 ?

bob@rel.mi.org (Bob Leffler) (02/25/90)

In article <8162@pt.cs.cmu.edu>, libove@ius3.ius.cs.cmu.edu (Jay Libove) writes:
> I'm trying to build mush 7.0 (as told by ucbvax.berkeley.edu) on
> an 80286 box running SCO Xenix v2.2.1. Compiling the 'curs_io.c'
> module, I get:
> curs_io.c(519) : error 65: `FMETA' undefined
> curs_io.c(656) : error 65: `FMETA' undefined
> despite the fact that curs_io.c includes glob.h and the last line
> in glob.h unconditionally defines FMETA.


I started working on Mush 7.0 yesterday and ran into the same problem.  My
quick hack was to put a #define FMETA line above each reference of FMETA
in curs_io.c  I haven't had the time to figure our why the define doesn't
work from glob.h yet.  I even copied the last three or four lines from
glob.h to curs_io.c and didn't help.


> Has anyone gotten mush 7.0 to build and run properly on SCO
> Xenix 286 v2.2.1? Please send me whatever hints you can!


After you resolve the curs_io.c problem, you'll run into something similar
in glob.c.  I've resolved one define problem, but I have a couple more
problems that I haven't had time to resolve.

bob




-- 
Bob Leffler - Electronic Data Systems, GM Corporate Staffs Account
3011 West Grand Blvd., Room 9074, Detroit, MI 48202 (313) 556-4474
bob@rel.mi.org or {uunet!edsews, rutgers, sharkey}!rel!bob
Opinions expressed may not be those of my employer.

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (02/26/90)

In article <10304@rel.mi.org> bob@rel.mi.org (Bob Leffler) writes:
} In article <8162@pt.cs.cmu.edu>, libove@ius3.ius.cs.cmu.edu (Jay Libove) writes:
} > I'm trying to build mush 7.0 (as told by ucbvax.berkeley.edu) on
} > an 80286 box running SCO Xenix v2.2.1. Compiling the 'curs_io.c'
} > module, I get:
} > curs_io.c(519) : error 65: `FMETA' undefined
} > curs_io.c(656) : error 65: `FMETA' undefined
} > despite the fact that curs_io.c includes glob.h and the last line
} > in glob.h unconditionally defines FMETA.
} 
} I started working on Mush 7.0 yesterday and ran into the same problem.  My
} quick hack was to put a #define FMETA line above each reference of FMETA
} in curs_io.c  I haven't had the time to figure our why the define doesn't
} work from glob.h yet.  I even copied the last three or four lines from
} glob.h to curs_io.c and didn't help.

I wonder if there aren't such a large number of #definitions that the
Xenix compiler simply gives up and drops one of them.  However, if you
have managed to get Perl-3.0 up and running, here's a program that will
perform a rudimentary check for what is being defined and how many
definitions there are altogether.

Crossposted to comp.lang.perl in case (just?) another perl hacker out
there wants to improve it; it currently understands

	#define symbol
	#undef symbol
	#ifdef symbol
	#ifndef symbol
	#if [!] defined(sym1) {&&,||} [!] defined(sym2) [...]
	#if <digits>
	#else
	#endif
	#include

but only uses its understanding to process #includes and count #defines.
Seems like it could be a good skeleton for a perl-based cpp ...

#! /usr/bin/perl
#
# Usage: ckcpp [-dvx] [-Ddefinition ...] [files ...]
#	-d	Print debugging output
#	-v	Toggle Verbose output (on by default)
#	-x	Echo every line scanned
#	-Ddef	As the C preprocessor
#
# Reads STDIN if no files named.

$HANDLE = 'FILE00000';

sub incl {
    local($file) = @_;
    local($FILE) = $HANDLE++;
    if ($file =~ m:\<(.*)\>:) { $file = "/usr/include/$1"; }
    elsif ($file =~ m:"([^"]*)":) { $file = $1; }
    print "Reading $file\n" if $verbose;
    unless (open($FILE, "<$file")) {
	warn "Can't read $file\n";
	return;
    }
    do scan($FILE);
    close($FILE);
    print "Finished $file\n" if $verbose;
}

sub endif {
    local($FILE) = @_;
    local($_);
    while (<$FILE>) {
	print if $echo;
	if ( /^#[ \t]*if/ ) {
	    do endif($FILE);
	}
	elsif ( /^#[ \t]*endif/ ) {
	    return;
	}
    }
    warn "#if with no #endif !!!\n";
}

sub hashelse {
    local($FILE) = @_;
    local($_);
    while (<$FILE>) {
	print if $echo;
	if ( /^#[ \t]*if/ ) {
	    do endif($FILE);
	}
	elsif ( /^#[ \t]*else/ || /^#[ \t]*endif/ ) {
	    return;
	}
    }
    warn "#if with no #endif !!!\n";
}

sub hashif {
    local($_) = $_[0];
    local($not,$token,$symbol,$conj);
    if ( /^(n{0,1})def[ \t]*([_A-Za-z][_A-Za-z0-9]*)/ ) {
	if ($1 ne "n" && ! $defined{$2} || $1 eq "n" && $defined{$2}) {
	    print "Skipping to #else or #endif /* $2 */\n" if $debug;
	    do hashelse($FILE);
	}
    }
    elsif ( /^[ \t]*(!{0,1})[ \t]*defined\(([_A-Za-z][_A-Za-z0-9]*)\)/ ) {
	$not = $1;
	$token = $symbol = $2;
	$_ = $';
	if ( /(\&\&){1}/ || /(\|\|){1}/ ) {
	    $conj = $1;
	    $_ = $';
	}
	if ($not eq "!") {
	    if ($defined{$symbol}) {
		undef $symbol;
	    }
	} else {
	    if (! $defined{$symbol}) {
		undef $symbol;
	    }
	}
	if ($symbol && $conj eq "&&" || ! $symbol && $conj eq "||") {
	    print "Testing $conj$_\n" if $debug;
	    do hashif($_);
	} elsif (! $symbol) {
	    print "Skipping to #endif /* $token */\n" if $debug;
	    do hashelse($FILE);
	}
    }
    elsif ( /([0-9][0-9]*)/ ) {
	if ($1 == 0) {
	    print "Skipping to #endif\n" if $debug;
	    do hashelse($FILE);
	}
    }
    else {
	if ($debug || $echo || $verbose) {
	    print "\tUnrecognized #if expression: $_\n";
	}
	else {
	    warn "Unrecognized #if expression $_\n";
	}
    }
}

sub scan {
    local($FILE) = @_;
    local($_,$if);
    while (<$FILE>) {
	print if $echo;
	if ( /^#[ \t]*if(.*)/ ) {
	    print "Testing $_" if $debug;
	    do hashif($1);
	}
	elsif ( /^#[ \t]*else/ ) {
	    do endif($FILE);
	}
	elsif ( /^#[ \t]*undef[ \t]*([_A-Za-z][_A-Za-z0-9]*)/ ) {
	    if ($defined{$1}) {
		print "\tUndefining $1\n" if $debug;
		$defined{$1} = 0;
		if ($max < $define) { $max = $define; }
		$define--;
	    }
	}
	elsif ( /^#[ \t]*define[ \t]([_A-Za-z][_A-Za-z0-9]*)/ ) {
	    if (! $defined{$1}) {
		$define++;
		print "\tDefining $1\n" if $debug;
		$defined{$1} = $file;
	    }
	    else {
		if ($debug || $echo || $verbose) {
		    print "\t$1 redefined (seen in $defined{$1})\n";
		}
		else {
		    warn "$1 redefined (seen in $defined{$1})\n";
		}
	    }
	} elsif ( /^#[ \t]*include[ \t]+([^ \t]*)/ ) {
	    do incl($1);
	}
    }
}

$verbose = 1;

while ($_ = shift(@ARGV)) {
    if ( /^-D(.*)={0,1}/ ) { $predef++; $predefined{$1} = "command line"; }
    elsif ( /^-d/ ) { $debug = 1; }
    elsif ( /^-x/ ) { $echo = 1; }
    elsif ( /^-v/ ) { $verbose = ! $verbose; }
    else { push(@Files,$_); }
}
if ($#Files < $[) { unshift(@Files,"&STDIN"); }
print "Predefined $predef symbols:\n\t", join("\n\t",keys(%predefined)), "\n";

$FILE = $HANDLE;

while ($_ = shift(@Files)) {
    open($FILE,"<$_") || warn "Can't read $_\n" && next;
    %defined = %predefined;
    $max = $define = $predef;
    do scan($FILE);
    if ($define > $max) { $max = $define; }
    print "Total of $define symbols defined, max was $max.\n";
}
-- 
Bart Schaefer          "February.  The hangnail on the big toe of the year."
                                                                    -- Duffy

schaefer@cse.ogi.edu (used to be cse.ogc.edu)

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (02/26/90)

In article <7552@ogicse.ogi.edu> schaefer@ogicse.ogi.edu, I wrote:
}
} [....  H]ere's a program that will
} perform a rudimentary check for what is being defined and how many
} definitions there are altogether.

I also meant to append the output of that program for curs_io.c in
particular; just as well I didn't for lang.perl, I guess.  Here it
is, with verbosity turned off and some "redefined" messages deleted:

% ckcpp -v -DSYSV -DM_XENIX curs_io.c
Predefined 2 symbols:
	M_XENIX
	SYSV
Total of 388 symbols defined, max was 388.

% ckcpp -v -DCURSES -DSYSV -DM_XENIX curs_io.c
Unrecognized #if expression  (!defined(SUNTOOL))
Predefined 3 symbols:
	M_XENIX
	CURSES
	SYSV
Total of 584 symbols defined, max was 584.

Damn, it doesn't understand parens around [!]defined().  Oh well.

Unfortunately, the above was not run on a Xenix system :-} so I can't
vouch for the numbers.  Here's what it looks like with the correct
definitions for my system:

% ckcpp -v -DCURSES -DBSD curs_io.c
Predefined 2 symbols:
	CURSES
	BSD
Unrecognized #if expression  (!defined(SUNTOOL))
Total of 576 symbols defined, max was 576.

Does this number of symbols look like it might cause problems for the
Xenix compiler?
-- 
Bart Schaefer          "February.  The hangnail on the big toe of the year."
                                                                    -- Duffy

schaefer@cse.ogi.edu (used to be cse.ogc.edu)