mush 7.0 on SCO Xenix 286 ?
Barton E. Schaefer
schaefer at ogicse.ogi.edu
Mon Feb 26 07:32:44 AEST 1990
In article <10304 at rel.mi.org> bob at rel.mi.org (Bob Leffler) writes:
} In article <8162 at pt.cs.cmu.edu>, libove at 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 at cse.ogi.edu (used to be cse.ogc.edu)
More information about the Comp.sources.bugs
mailing list