o unifdef -D__STDC__

o remove badly bit-rotted compat file that likely won't work on the systems
  it purports to support.
This commit is contained in:
Warner Losh 2002-03-23 23:30:30 +00:00
parent 7ddea7b836
commit c120448ada
6 changed files with 5 additions and 412 deletions

View File

@ -4,7 +4,7 @@
PROG= make
CFLAGS+=-I${.CURDIR}
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
make.c parse.c str.c suff.c targ.c var.c util.c
make.c parse.c str.c suff.c targ.c var.c
SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \
lstFind.c lstFindFrom.c lstFirst.c lstForEach.c lstForEachFrom.c \

View File

@ -47,9 +47,7 @@
#define _LST_H_
#include <sys/param.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include "sprite.h"
/*

View File

@ -90,11 +90,7 @@ __RCSID("$FreeBSD$");
#include <fcntl.h>
#include <stdio.h>
#include <sysexits.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <unistd.h>
#include "make.h"
#include "hash.h"
@ -1100,22 +1096,11 @@ bad:
*/
/* VARARGS */
void
#ifdef __STDC__
Error(char *fmt, ...)
#else
Error(va_alist)
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap, char *);
#endif
va_start(ap, fmt);
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
@ -1135,22 +1120,11 @@ Error(va_alist)
*/
/* VARARGS */
void
#ifdef __STDC__
Fatal(char *fmt, ...)
#else
Fatal(va_alist)
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap, char *);
#endif
va_start(ap, fmt);
if (jobsRunning)
Job_Wait();
@ -1177,23 +1151,11 @@ Fatal(va_alist)
*/
/* VARARGS */
void
#ifdef __STDC__
Punt(char *fmt, ...)
#else
Punt(va_alist)
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap, char *);
#endif
(void)fprintf(stderr, "make: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);

View File

@ -85,11 +85,7 @@ __RCSID("$FreeBSD$");
* Parse_MainName Returns a Lst of the main target to create.
*/
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <ctype.h>
#include <err.h>
#include <stdio.h>
@ -312,25 +308,11 @@ ParseFindKeyword (str)
*/
/* VARARGS */
void
#ifdef __STDC__
Parse_Error(int type, char *fmt, ...)
#else
Parse_Error(va_alist)
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, fmt);
#else
int type; /* Error type (PARSE_WARNING, PARSE_FATAL) */
char *fmt;
va_start(ap);
type = va_arg(ap, int);
fmt = va_arg(ap, char *);
#endif
(void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno);
if (type == PARSE_WARNING)
(void)fprintf(stderr, "warning: ");

View File

@ -489,13 +489,8 @@ Targ_PrintType (type)
{
register int tbit;
#ifdef __STDC__
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
#else
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf(".attr "); break
#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break
#endif /* __STDC__ */
type &= ~OP_OPMASK;

View File

@ -1,344 +0,0 @@
/*
* Missing stuff from OS's
*/
#ifndef lint
#include <sys/cdefs.h>
__RCSID("$FreeBSD$");
#endif
#include <stdio.h>
#include <errno.h>
#include "make.h"
#if !__STDC__
# ifndef const
# define const
# endif
#endif
#ifdef sun
extern int errno, sys_nerr;
extern char *sys_errlist[];
char *
strerror(e)
int e;
{
static char buf[100];
if (e < 0 || e >= sys_nerr) {
sprintf(buf, "Unknown error %d", e);
return buf;
}
else
return sys_errlist[e];
}
#endif
#ifdef ultrix
#include <string.h>
/* strdup
*
* Make a duplicate of a string.
* For systems which lack this function.
*/
char *
strdup(str)
const char *str;
{
size_t len;
if (str == NULL)
return NULL;
len = strlen(str) + 1;
if ((p = malloc(len)) == NULL)
return NULL;
return memcpy(p, str, len);
}
#endif
#if defined(sun) || defined(__hpux) || defined(__sgi)
int
setenv(name, value, dum)
const char *name;
const char *value;
int dum;
{
register char *p;
int len = strlen(name) + strlen(value) + 2; /* = \0 */
char *ptr = (char*) malloc(len);
(void) dum;
if (ptr == NULL)
return -1;
p = ptr;
while (*name)
*p++ = *name++;
*p++ = '=';
while (*value)
*p++ = *value++;
*p = '\0';
len = putenv(ptr);
/* free(ptr); */
return len;
}
#endif
#ifdef __hpux
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/signal.h>
#include <sys/stat.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
int
killpg(pid, sig)
int pid, sig;
{
return kill(-pid, sig);
}
void
srandom(seed)
long seed;
{
srand48(seed);
}
long
random()
{
return lrand48();
}
/* turn into bsd signals */
void (*
signal(s, a)) ()
int s;
void (*a)();
{
struct sigvec osv, sv;
(void) sigvector(s, (struct sigvec *) 0, &osv);
sv = osv;
sv.sv_handler = a;
#ifdef SV_BSDSIG
sv.sv_flags = SV_BSDSIG;
#endif
if (sigvector(s, &sv, (struct sigvec *) 0) == -1)
return (BADSIG);
return (osv.sv_handler);
}
#if !defined(BSD) && !defined(d_fileno)
# define d_fileno d_ino
#endif
#ifndef DEV_DEV_COMPARE
# define DEV_DEV_COMPARE(a, b) ((a) == (b))
#endif
/* strrcpy():
* Like strcpy, going backwards and returning the new pointer
*/
static char *
strrcpy(ptr, str)
register char *ptr, *str;
{
register int len = strlen(str);
while (len)
*--ptr = str[--len];
return (ptr);
} /* end strrcpy */
char *
getwd(pathname)
char *pathname;
{
DIR *dp;
struct dirent *d;
struct stat st_root, st_cur, st_next, st_dotdot;
char pathbuf[MAXPATHLEN], nextpathbuf[MAXPATHLEN * 2];
char *pathptr, *nextpathptr, *cur_name_add;
/* find the inode of root */
if (stat("/", &st_root) == -1) {
(void) sprintf(pathname,
"getwd: Cannot stat \"/\" (%s)", strerror(errno));
return (NULL);
}
pathbuf[MAXPATHLEN - 1] = '\0';
pathptr = &pathbuf[MAXPATHLEN - 1];
nextpathbuf[MAXPATHLEN - 1] = '\0';
cur_name_add = nextpathptr = &nextpathbuf[MAXPATHLEN - 1];
/* find the inode of the current directory */
if (lstat(".", &st_cur) == -1) {
(void) sprintf(pathname,
"getwd: Cannot stat \".\" (%s)", strerror(errno));
return (NULL);
}
nextpathptr = strrcpy(nextpathptr, "../");
/* Descend to root */
for (;;) {
/* look if we found root yet */
if (st_cur.st_ino == st_root.st_ino &&
DEV_DEV_COMPARE(st_cur.st_dev, st_root.st_dev)) {
(void) strcpy(pathname, *pathptr != '/' ? "/" : pathptr);
return (pathname);
}
/* open the parent directory */
if (stat(nextpathptr, &st_dotdot) == -1) {
snprintf(pathname, sizeof(pathname),
"getwd: Cannot stat directory \"%s\" (%s)",
nextpathptr, strerror(errno));
return (NULL);
}
if ((dp = opendir(nextpathptr)) == NULL) {
snprintf(pathname, sizeof(pathname),
"getwd: Cannot open directory \"%s\" (%s)",
nextpathptr, strerror(errno));
return (NULL);
}
/* look in the parent for the entry with the same inode */
if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) {
/* Parent has same device. No need to stat every member */
for (d = readdir(dp); d != NULL; d = readdir(dp))
if (d->d_fileno == st_cur.st_ino)
break;
}
else {
/*
* Parent has a different device. This is a mount point so we
* need to stat every member
*/
for (d = readdir(dp); d != NULL; d = readdir(dp)) {
if (ISDOT(d->d_name) || ISDOTDOT(d->d_name))
continue;
(void) strcpy(cur_name_add, d->d_name);
if (lstat(nextpathptr, &st_next) == -1) {
snprintf(pathname, sizeof(pathname), "getwd: Cannot stat \"%s\" (%s)",
d->d_name, strerror(errno));
(void) closedir(dp);
return (NULL);
}
/* check if we found it yet */
if (st_next.st_ino == st_cur.st_ino &&
DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev))
break;
}
}
if (d == NULL) {
(void) sprintf(pathname, "getwd: Cannot find \".\" in \"..\"");
(void) closedir(dp);
return (NULL);
}
st_cur = st_dotdot;
pathptr = strrcpy(pathptr, d->d_name);
pathptr = strrcpy(pathptr, "/");
nextpathptr = strrcpy(nextpathptr, "../");
(void) closedir(dp);
*cur_name_add = '\0';
}
} /* end getwd */
char *sys_siglist[] = {
"Signal 0",
"Hangup", /* SIGHUP */
"Interrupt", /* SIGINT */
"Quit", /* SIGQUIT */
"Illegal instruction", /* SIGILL */
"Trace/BPT trap", /* SIGTRAP */
"IOT trap", /* SIGIOT */
"EMT trap", /* SIGEMT */
"Floating point exception", /* SIGFPE */
"Killed", /* SIGKILL */
"Bus error", /* SIGBUS */
"Segmentation fault", /* SIGSEGV */
"Bad system call", /* SIGSYS */
"Broken pipe", /* SIGPIPE */
"Alarm clock", /* SIGALRM */
"Terminated", /* SIGTERM */
"User defined signal 1", /* SIGUSR1 */
"User defined signal 2", /* SIGUSR2 */
"Child exited", /* SIGCLD */
"Power-fail restart", /* SIGPWR */
"Virtual timer expired", /* SIGVTALRM */
"Profiling timer expired", /* SIGPROF */
"I/O possible", /* SIGIO */
"Window size changes", /* SIGWINDOW */
"Stopped (signal)", /* SIGSTOP */
"Stopped", /* SIGTSTP */
"Continued", /* SIGCONT */
"Stopped (tty input)", /* SIGTTIN */
"Stopped (tty output)", /* SIGTTOU */
"Urgent I/O condition", /* SIGURG */
"Remote lock lost (NFS)", /* SIGLOST */
"Signal 31", /* reserved */
"DIL signal" /* SIGDIL */
};
int
utimes(file, tvp)
char *file;
struct timeval tvp[2];
{
struct utimbuf t;
t.actime = tvp[0].tv_sec;
t.modtime = tvp[1].tv_sec;
return(utime(file, &t));
}
#endif /* __hpux */
#if defined(sun) && defined(__svr4__)
#include <signal.h>
/* turn into bsd signals */
void (*
signal(s, a)) ()
int s;
void (*a)();
{
struct sigaction sa, osa;
sa.sa_handler = a;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(s, &sa, &osa) == -1)
return SIG_ERR;
else
return osa.sa_handler;
}
#endif