Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
+16
-14
@@ -1,10 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.210 2012/08/08 14:13:46 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.214 2013/11/22 16:10:25 christos Exp $
|
||||
# from: @(#)Makefile 8.3 (Berkeley) 1/7/94
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR= asa \
|
||||
banner basename bdes \
|
||||
banner basename \
|
||||
bzip2 bzip2recover cal calendar \
|
||||
checknr chpass cksum col colcrt colrm \
|
||||
column comm csplit ctags cut \
|
||||
@@ -13,31 +13,30 @@ SUBDIR= asa \
|
||||
finger fold fpr from \
|
||||
fsplit ftp genassym getopt \
|
||||
head hexdump id indent infocmp join jot \
|
||||
lam ldd leave \
|
||||
last \
|
||||
lam last ldd leave \
|
||||
lock login logname lorder m4 \
|
||||
machine make man menuc mesg \
|
||||
mkdep mkfifo mkstr mktemp \
|
||||
msgc \
|
||||
nbperf newgrp nice nl nohup nvi \
|
||||
nbperf newgrp nice nl nohup \
|
||||
passwd paste pathchk pr \
|
||||
printenv printf pwhash \
|
||||
renice rev \
|
||||
\
|
||||
sdiff sed seq shlock \
|
||||
shuffle soelim sort split stat su \
|
||||
shuffle sort split stat su \
|
||||
tee tic tput \
|
||||
tr tsort tty ul uname unexpand unifdef \
|
||||
toproto \
|
||||
uniq units unvis unzip users \
|
||||
uuidgen vis \
|
||||
wall write \
|
||||
xargs xinstall xstr yes \
|
||||
wc what whatis who whois
|
||||
\
|
||||
wall wc what who whois \
|
||||
write xargs xinstall xstr yes
|
||||
|
||||
.if !defined(__MINIX)
|
||||
SUBDIR+= ../external/zlib/pigz/bin/pigz
|
||||
.else
|
||||
|
||||
# Non-NetBSD imports
|
||||
SUBDIR+= ministat
|
||||
|
||||
@@ -45,10 +44,13 @@ SUBDIR+= ministat
|
||||
SUBDIR+= top
|
||||
SUBDIR+= toproto
|
||||
|
||||
# LSC FIXME For now we compile unconditionnaly apropos and whatis even if we
|
||||
# do not have whatis
|
||||
SUBDIR+= apropos whatis
|
||||
.endif # defie
|
||||
# LSC FIXME For now we compile those unconditionnaly
|
||||
SUBDIR+= apropos whatis bdes soelim
|
||||
.endif # defined(__MINIX)
|
||||
|
||||
.if (${MKGROFF} == "no")
|
||||
SUBDIR+= soelim
|
||||
.endif
|
||||
|
||||
.if (${MKMAKEMANDB} == "no")
|
||||
SUBDIR+= apropos whatis
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# $NetBSD: Makefile,v 1.7 2007/05/28 12:06:24 tls Exp $
|
||||
# $NetBSD: Makefile,v 1.8 2013/08/11 06:47:38 dholland Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
USE_FORT?= yes # cryptographic software
|
||||
|
||||
WARNS= 3
|
||||
PROG= bdes
|
||||
|
||||
LDADD+= -lcrypt
|
||||
|
||||
+53
-51
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $ */
|
||||
/* $NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bdes.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $");
|
||||
__RCSID("$NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -141,44 +141,46 @@ typedef char Desbuf[8];
|
||||
*/
|
||||
#define KEY_DEFAULT 0 /* interpret radix of key from key */
|
||||
#define KEY_ASCII 1 /* key is in ASCII characters */
|
||||
int keybase = KEY_DEFAULT; /* how to interpret the key */
|
||||
static int keybase = KEY_DEFAULT; /* how to interpret the key */
|
||||
|
||||
enum { /* encrypt, decrypt, authenticate */
|
||||
static enum { /* encrypt, decrypt, authenticate */
|
||||
MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE
|
||||
} mode = MODE_ENCRYPT;
|
||||
enum { /* ecb, cbc, cfb, cfba, ofb? */
|
||||
static enum { /* ecb, cbc, cfb, cfba, ofb? */
|
||||
ALG_ECB, ALG_CBC, ALG_CFB, ALG_OFB, ALG_CFBA
|
||||
} alg = ALG_CBC;
|
||||
|
||||
Desbuf ivec; /* initialization vector */
|
||||
char bits[] = { /* used to extract bits from a char */
|
||||
static Desbuf ivec; /* initialization vector */
|
||||
static const char bits[] = { /* used to extract bits from a char */
|
||||
'\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001'
|
||||
};
|
||||
int inverse; /* 0 to encrypt, 1 to decrypt */
|
||||
int macbits = -1; /* number of bits in authentication */
|
||||
int fbbits = -1; /* number of feedback bits */
|
||||
int pflag; /* 1 to preserve parity bits */
|
||||
static int inverse; /* 0 to encrypt, 1 to decrypt */
|
||||
static int macbits = -1; /* number of bits in authentication */
|
||||
static int fbbits = -1; /* number of feedback bits */
|
||||
static int pflag; /* 1 to preserve parity bits */
|
||||
|
||||
int setbits(char *, int);
|
||||
void bdes_err(int, const char *);
|
||||
int tobinhex(char, int);
|
||||
void cvtkey(char *, char *);
|
||||
void makekey(Desbuf);
|
||||
void ecbenc(void);
|
||||
void ecbdec(void);
|
||||
void cbcenc(void);
|
||||
void cbcdec(void);
|
||||
void cbcauth(void);
|
||||
void cfbenc(void);
|
||||
void cfbdec(void);
|
||||
void cfbaenc(void);
|
||||
void cfbadec(void);
|
||||
void ofbenc(void);
|
||||
void ofbdec(void);
|
||||
void cfbauth(void);
|
||||
void expand(Desbuf, char *);
|
||||
void compress(char *, Desbuf);
|
||||
void usage(void);
|
||||
static int setbits(char *, int);
|
||||
static void bdes_err(int, const char *) __dead;
|
||||
static int tobinhex(char, int);
|
||||
static void cvtkey(char *, char *);
|
||||
static void makekey(Desbuf);
|
||||
static void ecbenc(void);
|
||||
static void ecbdec(void);
|
||||
static void cbcenc(void);
|
||||
static void cbcdec(void);
|
||||
static void cbcauth(void);
|
||||
static void cfbenc(void);
|
||||
static void cfbdec(void);
|
||||
static void cfbaenc(void);
|
||||
static void cfbadec(void);
|
||||
static void ofbenc(void);
|
||||
static void ofbdec(void);
|
||||
static void cfbauth(void);
|
||||
#ifndef FASTWAY
|
||||
static void expand(Desbuf, char *);
|
||||
static void compress(char *, Desbuf);
|
||||
#endif
|
||||
static void usage(void) __dead;
|
||||
|
||||
int
|
||||
main(int ac, char *av[])
|
||||
@@ -357,7 +359,7 @@ main(int ac, char *av[])
|
||||
/*
|
||||
* print a warning message and, possibly, terminate
|
||||
*/
|
||||
void
|
||||
static void
|
||||
bdes_err(int n, const char *s)
|
||||
{
|
||||
if (n > 0)
|
||||
@@ -371,7 +373,7 @@ bdes_err(int n, const char *s)
|
||||
/*
|
||||
* map a hex character to an integer
|
||||
*/
|
||||
int
|
||||
static int
|
||||
tobinhex(char c, int radix)
|
||||
{
|
||||
switch(c) {
|
||||
@@ -401,7 +403,7 @@ tobinhex(char c, int radix)
|
||||
/*
|
||||
* convert the key to a bit pattern
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cvtkey(char *obuf, char *ibuf)
|
||||
{
|
||||
register int i, j; /* counter in a for loop */
|
||||
@@ -468,7 +470,7 @@ cvtkey(char *obuf, char *ibuf)
|
||||
* 2. must be a valid decimal number
|
||||
* 3. must be a multiple of mult
|
||||
*/
|
||||
int
|
||||
static int
|
||||
setbits(char *s, int mult)
|
||||
{
|
||||
char *p;
|
||||
@@ -497,7 +499,7 @@ setbits(char *s, int mult)
|
||||
* systems set the parity (high) bit of each character to 0, and the
|
||||
* DES ignores the low order bit of each character.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
makekey(Desbuf buf)
|
||||
{
|
||||
register int i, j; /* counter in a for loop */
|
||||
@@ -525,7 +527,7 @@ makekey(Desbuf buf)
|
||||
/*
|
||||
* This encrypts using the Electronic Code Book mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
ecbenc(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -554,7 +556,7 @@ ecbenc(void)
|
||||
/*
|
||||
* This decrypts using the Electronic Code Book mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
ecbdec(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -587,7 +589,7 @@ ecbdec(void)
|
||||
/*
|
||||
* This encrypts using the Cipher Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cbcenc(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -621,7 +623,7 @@ cbcenc(void)
|
||||
/*
|
||||
* This decrypts using the Cipher Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cbcdec(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -659,7 +661,7 @@ cbcdec(void)
|
||||
/*
|
||||
* This authenticates using the Cipher Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cbcauth(void)
|
||||
{
|
||||
register int n, j; /* number of bytes actually read */
|
||||
@@ -704,7 +706,7 @@ cbcauth(void)
|
||||
/*
|
||||
* This encrypts using the Cipher FeedBack mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cfbenc(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -746,7 +748,7 @@ cfbenc(void)
|
||||
/*
|
||||
* This decrypts using the Cipher Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cfbdec(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -793,7 +795,7 @@ cfbdec(void)
|
||||
/*
|
||||
* This encrypts using the alternative Cipher FeedBack mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cfbaenc(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -839,7 +841,7 @@ cfbaenc(void)
|
||||
/*
|
||||
* This decrypts using the alternative Cipher Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cfbadec(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -887,7 +889,7 @@ cfbadec(void)
|
||||
/*
|
||||
* This encrypts using the Output FeedBack mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
ofbenc(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -933,7 +935,7 @@ ofbenc(void)
|
||||
/*
|
||||
* This decrypts using the Output Block Chaining mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
ofbdec(void)
|
||||
{
|
||||
register int n; /* number of bytes actually read */
|
||||
@@ -983,7 +985,7 @@ ofbdec(void)
|
||||
/*
|
||||
* This authenticates using the Cipher FeedBack mode of DES
|
||||
*/
|
||||
void
|
||||
static void
|
||||
cfbauth(void)
|
||||
{
|
||||
register int n, j; /* number of bytes actually read */
|
||||
@@ -1035,7 +1037,7 @@ cfbauth(void)
|
||||
/*
|
||||
* change from 8 bits/Uchar to 1 bit/Uchar
|
||||
*/
|
||||
void
|
||||
static void
|
||||
expand(Desbuf from, char *to)
|
||||
{
|
||||
register int i, j; /* counters in for loop */
|
||||
@@ -1048,7 +1050,7 @@ expand(Desbuf from, char *to)
|
||||
/*
|
||||
* change from 1 bit/char to 8 bits/Uchar
|
||||
*/
|
||||
void
|
||||
static void
|
||||
compress(char *from, Desbuf to)
|
||||
{
|
||||
register int i, j; /* counters in for loop */
|
||||
@@ -1064,7 +1066,7 @@ compress(char *from, Desbuf to)
|
||||
/*
|
||||
* message about usage
|
||||
*/
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
.include <bsd.own.mk> # for MKDYNAMICROOT definition
|
||||
|
||||
.if defined(__MINIX)
|
||||
MKDYNAMICROOT= no
|
||||
SMALLPROG= yes
|
||||
.endif
|
||||
USE_FORT?= yes # data-driven bugs?
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.5 2009/04/14 22:15:18 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.6 2013/08/11 06:39:47 dholland Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
WARNS?= 2 # fails -Wcast-qual
|
||||
|
||||
PROG= checknr
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
+57
-54
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: checknr.c,v 1.20 2008/07/21 14:19:21 lukem Exp $ */
|
||||
/* $NetBSD: checknr.c,v 1.24 2013/08/12 14:03:18 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: checknr.c,v 1.20 2008/07/21 14:19:21 lukem Exp $");
|
||||
__RCSID("$NetBSD: checknr.c,v 1.24 2013/08/12 14:03:18 joerg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -63,20 +63,20 @@ __RCSID("$NetBSD: checknr.c,v 1.20 2008/07/21 14:19:21 lukem Exp $");
|
||||
/*
|
||||
* The stack on which we remember what we've seen so far.
|
||||
*/
|
||||
struct stkstr {
|
||||
static struct stkstr {
|
||||
int opno; /* number of opening bracket */
|
||||
int pl; /* '+', '-', ' ' for \s, 1 for \f, 0 for .ft */
|
||||
int parm; /* parm to size, font, etc */
|
||||
int lno; /* line number the thing came in in */
|
||||
} stk[MAXSTK];
|
||||
int stktop;
|
||||
static int stktop;
|
||||
|
||||
/*
|
||||
* The kinds of opening and closing brackets.
|
||||
*/
|
||||
struct brstr {
|
||||
char *opbr;
|
||||
char *clbr;
|
||||
static struct brstr {
|
||||
const char *opbr;
|
||||
const char *clbr;
|
||||
} br[MAXBR] = {
|
||||
/* A few bare bones troff commands */
|
||||
#define SZ 0
|
||||
@@ -146,7 +146,7 @@ struct brstr {
|
||||
* All commands known to nroff, plus macro packages.
|
||||
* Used so we can complain about unrecognized commands.
|
||||
*/
|
||||
char *knowncmds[MAXCMDS] = {
|
||||
static const char *knowncmds[MAXCMDS] = {
|
||||
"$c", "$f", "$h", "$p", "$s", "%A", "%B", "%C", "%D", "%I", "%J", "%N",
|
||||
"%O", "%P", "%Q", "%R", "%T", "%V", "(b", "(c", "(d", "(f", "(l", "(q",
|
||||
"(t", "(x", "(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x",
|
||||
@@ -191,27 +191,26 @@ char *knowncmds[MAXCMDS] = {
|
||||
"uf", "uh", "ul", "vs", "wh", "xp", "yr", 0
|
||||
};
|
||||
|
||||
int lineno; /* current line number in input file */
|
||||
char *cfilename; /* name of current file */
|
||||
int nfiles; /* number of files to process */
|
||||
int fflag; /* -f: ignore \f */
|
||||
int sflag; /* -s: ignore \s */
|
||||
int ncmds; /* size of knowncmds */
|
||||
int slot; /* slot in knowncmds found by binsrch */
|
||||
static int lineno; /* current line number in input file */
|
||||
static const char *cfilename; /* name of current file */
|
||||
static int nfiles; /* number of files to process */
|
||||
static int fflag; /* -f: ignore \f */
|
||||
static int sflag; /* -s: ignore \s */
|
||||
static int ncmds; /* size of knowncmds */
|
||||
static int slot; /* slot in knowncmds found by binsrch */
|
||||
|
||||
void addcmd(char *);
|
||||
void addmac(char *);
|
||||
int binsrch(char *);
|
||||
void checkknown(char *);
|
||||
void chkcmd(char *, char *);
|
||||
void complain(int);
|
||||
int eq(const void *, const void *);
|
||||
int main(int, char **);
|
||||
void nomatch(char *);
|
||||
void pe(int);
|
||||
void process(FILE *);
|
||||
void prop(int);
|
||||
void usage(void);
|
||||
static void addcmd(char *);
|
||||
static void addmac(const char *);
|
||||
static int binsrch(const char *);
|
||||
static void checkknown(const char *);
|
||||
static void chkcmd(const char *);
|
||||
static void complain(int);
|
||||
static int eq(const char *, const char *);
|
||||
static void nomatch(const char *);
|
||||
static void pe(int);
|
||||
static void process(FILE *);
|
||||
static void prop(int);
|
||||
static void usage(void) __dead;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@@ -236,14 +235,18 @@ main(int argc, char **argv)
|
||||
for (i=0; br[i].opbr; i++)
|
||||
;
|
||||
for (cp=argv[1]+3; cp[-1]; cp += 6) {
|
||||
char *tmp;
|
||||
|
||||
if (i >= MAXBR)
|
||||
errx(1, "too many pairs");
|
||||
if ((br[i].opbr = malloc(3)) == NULL)
|
||||
if ((tmp = malloc(3)) == NULL)
|
||||
err(1, "malloc");
|
||||
strlcpy(br[i].opbr, cp, 3);
|
||||
if ((br[i].clbr = malloc(3)) == NULL)
|
||||
strlcpy(tmp, cp, 3);
|
||||
br[i].opbr = tmp;
|
||||
if ((tmp = malloc(3)) == NULL)
|
||||
err(1, "malloc");
|
||||
strlcpy(br[i].clbr, cp+3, 3);
|
||||
strlcpy(tmp, cp+3, 3);
|
||||
br[i].clbr = tmp;
|
||||
addmac(br[i].opbr); /* knows pairs are also known cmds */
|
||||
addmac(br[i].clbr);
|
||||
i++;
|
||||
@@ -298,7 +301,7 @@ main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
@@ -307,7 +310,7 @@ usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
process(FILE *f)
|
||||
{
|
||||
int i, n;
|
||||
@@ -345,7 +348,7 @@ process(FILE *f)
|
||||
if (eq(mac, "de"))
|
||||
addcmd(line);
|
||||
|
||||
chkcmd(line, mac);
|
||||
chkcmd(mac);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -406,7 +409,7 @@ process(FILE *f)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
complain(int i)
|
||||
{
|
||||
pe(stk[i].lno);
|
||||
@@ -415,7 +418,7 @@ complain(int i)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
prop(int i)
|
||||
{
|
||||
if (stk[i].pl == 0)
|
||||
@@ -434,8 +437,8 @@ prop(int i)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
chkcmd(char *line, char *mac)
|
||||
static void
|
||||
chkcmd(const char *mac)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -470,8 +473,8 @@ chkcmd(char *line, char *mac)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nomatch(char *mac)
|
||||
static void
|
||||
nomatch(const char *mac)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -515,14 +518,14 @@ nomatch(char *mac)
|
||||
}
|
||||
|
||||
/* eq: are two strings equal? */
|
||||
int
|
||||
eq(const void *s1, const void *s2)
|
||||
static int
|
||||
eq(const char *s1, const char *s2)
|
||||
{
|
||||
return (strcmp((char *)s1, (char *)s2) == 0);
|
||||
return strcmp(s1, s2) == 0;
|
||||
}
|
||||
|
||||
/* print the first part of an error message, given the line number */
|
||||
void
|
||||
static void
|
||||
pe(int pelineno)
|
||||
{
|
||||
if (nfiles > 1)
|
||||
@@ -530,8 +533,8 @@ pe(int pelineno)
|
||||
printf("%d: ", pelineno);
|
||||
}
|
||||
|
||||
void
|
||||
checkknown(char *mac)
|
||||
static void
|
||||
checkknown(const char *mac)
|
||||
{
|
||||
|
||||
if (eq(mac, "."))
|
||||
@@ -548,7 +551,7 @@ checkknown(char *mac)
|
||||
/*
|
||||
* We have a .de xx line in "line". Add xx to the list of known commands.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
addcmd(char *line)
|
||||
{
|
||||
char *mac;
|
||||
@@ -579,10 +582,10 @@ addcmd(char *line)
|
||||
* me someday?) Anyway, I claim that .de is fairly rare in user
|
||||
* nroff programs, and the register loop below is pretty fast.
|
||||
*/
|
||||
void
|
||||
addmac(char *mac)
|
||||
static void
|
||||
addmac(const char *mac)
|
||||
{
|
||||
char **src, **dest, **loc;
|
||||
const char **src, **dest, **loc;
|
||||
|
||||
if (binsrch(mac) >= 0){ /* it's OK to redefine something */
|
||||
#ifdef DEBUG
|
||||
@@ -613,10 +616,10 @@ addmac(char *mac)
|
||||
* Do a binary search in knowncmds for mac.
|
||||
* If found, return the index. If not, return -1.
|
||||
*/
|
||||
int
|
||||
binsrch(char *mac)
|
||||
static int
|
||||
binsrch(const char *mac)
|
||||
{
|
||||
char *p; /* pointer to current cmd in list */
|
||||
const char *p; /* pointer to current cmd in list */
|
||||
int d; /* difference if any */
|
||||
int mid; /* mid point in binary search */
|
||||
int top, bot; /* boundaries of bin search, inclusive */
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if defined(__MINIX)
|
||||
WARNS=3
|
||||
.endif
|
||||
|
||||
USE_FORT?= yes # setuid
|
||||
PROG= chpass
|
||||
SRCS= chpass.c edit.c field.c table.c util.c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: chpass.1,v 1.23 2006/10/07 20:09:09 elad Exp $
|
||||
.\" $NetBSD: chpass.1,v 1.25 2012/04/21 12:27:29 roy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1988, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" @(#)chpass.1 8.2 (Berkeley) 12/30/93
|
||||
.\"
|
||||
.Dd October 7, 2006
|
||||
.Dd April 5, 2012
|
||||
.Dt CHPASS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -78,7 +78,7 @@ option attempts to change the user's shell to
|
||||
This option causes the password to be updated only in the local
|
||||
password file.
|
||||
When changing only the local password,
|
||||
.Xr pwd_mkdb 8
|
||||
.Xr pwd_mkdb 8
|
||||
is used to update the password databases.
|
||||
.It Fl y
|
||||
This forces the YP password database entry to be changed, even if
|
||||
@@ -180,7 +180,7 @@ field is a key for a user's login class.
|
||||
Login classes are defined in
|
||||
.Xr login.conf 5 ,
|
||||
which is a
|
||||
.Xr termcap 5
|
||||
.Xr capfile 5
|
||||
style database of user attributes, accounting, resource and
|
||||
environment settings.
|
||||
.Pp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chpass.c,v 1.33 2008/07/21 14:19:21 lukem Exp $ */
|
||||
/* $NetBSD: chpass.c,v 1.35 2011/08/31 16:24:57 plunky Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1993, 1994
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: chpass.c,v 1.33 2008/07/21 14:19:21 lukem Exp $");
|
||||
__RCSID("$NetBSD: chpass.c,v 1.35 2011/08/31 16:24:57 plunky Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -73,9 +73,9 @@ void (*Pw_error)(const char *, int, int);
|
||||
extern int _yp_check(char **); /* buried deep inside libc */
|
||||
#endif
|
||||
|
||||
void baduser(void);
|
||||
void cleanup(void);
|
||||
void usage(void);
|
||||
__dead static void baduser(void);
|
||||
static void cleanup(void);
|
||||
__dead static void usage(void);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@@ -244,7 +244,7 @@ main(int argc, char **argv)
|
||||
#ifdef YP
|
||||
if (use_yp) {
|
||||
if (pw_yp(pw, uid))
|
||||
yppw_error((char *)NULL, 0, 1);
|
||||
yppw_error(NULL, 0, 1);
|
||||
else
|
||||
exit(0);
|
||||
/* Will not exit from this if. */
|
||||
@@ -290,14 +290,14 @@ main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
baduser(void)
|
||||
{
|
||||
|
||||
errx(1, "%s", strerror(EACCES));
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
@@ -308,7 +308,7 @@ usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chpass.h,v 1.12 2005/02/17 17:09:48 xtraeme Exp $ */
|
||||
/* $NetBSD: chpass.h,v 1.13 2011/08/29 14:08:39 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993, 1994
|
||||
@@ -72,7 +72,7 @@ int verify(char *, struct passwd *);
|
||||
#ifdef YP
|
||||
int check_yppasswdd(void);
|
||||
int pw_yp(struct passwd *, uid_t);
|
||||
void yppw_error(const char *name, int, int);
|
||||
__dead void yppw_error(const char *name, int, int);
|
||||
void yppw_prompt(void);
|
||||
struct passwd *ypgetpwnam(const char *);
|
||||
struct passwd *ypgetpwuid(uid_t);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: edit.c,v 1.20 2009/04/11 12:10:02 lukem Exp $ */
|
||||
/* $NetBSD: edit.c,v 1.21 2011/08/31 16:24:57 plunky Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: edit.c,v 1.20 2009/04/11 12:10:02 lukem Exp $");
|
||||
__RCSID("$NetBSD: edit.c,v 1.21 2011/08/31 16:24:57 plunky Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -151,13 +151,8 @@ verify(char *tempname, struct passwd *pw)
|
||||
int len, fd;
|
||||
static char buf[LINE_MAX];
|
||||
|
||||
#ifdef __minix
|
||||
if ((fd = open(tempname, O_RDONLY)) == -1 ||
|
||||
(fp = fdopen(fd, "r")) == NULL)
|
||||
#else
|
||||
if ((fd = open(tempname, O_RDONLY|O_NOFOLLOW)) == -1 ||
|
||||
(fp = fdopen(fd, "r")) == NULL)
|
||||
#endif
|
||||
(*Pw_error)(tempname, 1, 1);
|
||||
if (fstat(fd, &sb))
|
||||
(*Pw_error)(tempname, 1, 1);
|
||||
@@ -223,5 +218,5 @@ bad: (void)fclose(fp);
|
||||
warnx("entries too long");
|
||||
return (0);
|
||||
}
|
||||
return (pw_scan(buf, pw, (int *)NULL));
|
||||
return (pw_scan(buf, pw, NULL));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: cksum.1,v 1.44 2012/06/25 02:32:12 riastradh Exp $
|
||||
.\" $NetBSD: cksum.1,v 1.45 2013/03/28 22:54:25 njoly Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -266,7 +266,7 @@ article.
|
||||
.Rs
|
||||
.%T "Computation of Cyclic Redundancy Checks Via Table Lookup"
|
||||
.%A Dilip V. Sarwate
|
||||
.%J "Communications of the \*(tNACM\*(sP"
|
||||
.%J "Communications of the ACM"
|
||||
.%D "August 1988"
|
||||
.Re
|
||||
.Rs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cksum.c,v 1.45 2011/08/29 14:12:29 joerg Exp $ */
|
||||
/* $NetBSD: cksum.c,v 1.46 2013/10/18 20:47:06 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cksum.c 8.2 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
__RCSID("$NetBSD: cksum.c,v 1.45 2011/08/29 14:12:29 joerg Exp $");
|
||||
__RCSID("$NetBSD: cksum.c,v 1.46 2013/10/18 20:47:06 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -149,7 +149,7 @@ __dead static void usage(void);
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int ch, fd, rval, dosum, pflag, nohashstdin;
|
||||
int ch, fd, rval, pflag, nohashstdin;
|
||||
u_int32_t val;
|
||||
off_t len;
|
||||
char *fn;
|
||||
@@ -161,7 +161,7 @@ main(int argc, char **argv)
|
||||
|
||||
cfncn = NULL;
|
||||
pfncn = NULL;
|
||||
dosum = pflag = nohashstdin = 0;
|
||||
pflag = nohashstdin = 0;
|
||||
normal = 0;
|
||||
check_warn = 0;
|
||||
do_check = 0;
|
||||
@@ -178,7 +178,6 @@ main(int argc, char **argv)
|
||||
hash = NULL;
|
||||
|
||||
if (!strcmp(progname, "sum")) {
|
||||
dosum = 1;
|
||||
cfncn = csum1;
|
||||
pfncn = psum1;
|
||||
} else {
|
||||
|
||||
+4
-16
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: deroff.c,v 1.9 2011/08/31 13:38:19 joerg Exp $ */
|
||||
/* $NetBSD: deroff.c,v 1.11 2013/10/18 20:47:06 christos Exp $ */
|
||||
|
||||
/* taken from: OpenBSD: deroff.c,v 1.6 2004/06/02 14:58:46 tom Exp */
|
||||
|
||||
@@ -64,21 +64,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)deroff.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
static const char rcsid[] = "$NetBSD: deroff.c,v 1.9 2011/08/31 13:38:19 joerg Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: deroff.c,v 1.11 2013/10/18 20:47:06 christos Exp $");
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
@@ -178,7 +166,7 @@ typedef int pacmac; /* compressed macro name */
|
||||
static int argconcat = 0; /* concat arguments together (-me only) */
|
||||
|
||||
#define tomac(c1, c2) ((((c1) & 0xFF) << 8) | ((c2) & 0xFF))
|
||||
#define frommac(src, c1, c2) (((c1)=((src)>>8)&0xFF),((c2) =(src)&0xFF))
|
||||
#define frommac(src, c1, c2) (((c1)=((src)>>8)&0xFF),((c2) =(src)&0xFF), __USE(c1), __USE(c2))
|
||||
|
||||
struct mactab {
|
||||
int condition;
|
||||
|
||||
+9
-4
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: du.1,v 1.21 2006/09/24 07:19:16 wiz Exp $
|
||||
.\" $NetBSD: du.1,v 1.23 2012/05/14 21:14:14 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
|
||||
.\"
|
||||
.Dd September 24, 2006
|
||||
.Dd May 14, 2012
|
||||
.Dt DU 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -39,12 +39,12 @@
|
||||
.Nm
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Op Fl a | Fl d Ar depth | Fl s
|
||||
.Op Fl cghkmnrx
|
||||
.Op Fl cghikmnrx
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility displays the file system block usage for each file argument
|
||||
utility displays the file system usage for each file argument
|
||||
and for each directory in the file hierarchy rooted in each directory
|
||||
argument.
|
||||
If no file is specified, the block usage of the hierarchy rooted in
|
||||
@@ -79,6 +79,9 @@ flag is specified, the numbers will be displayed in "human-readable"
|
||||
format.
|
||||
Use unit suffixes: B (Byte), K (Kilobyte), M (Megabyte), G (Gigabyte),
|
||||
T (Terabyte) and P (Petabyte).
|
||||
.It Fl i
|
||||
Output inode usage instead of blocks.
|
||||
All "human-readable" options are ignored.
|
||||
.It Fl k
|
||||
By default,
|
||||
.Nm
|
||||
@@ -149,6 +152,8 @@ and
|
||||
options are not specified, the block counts will be displayed in units of that
|
||||
size block.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr df 1 ,
|
||||
.Xr chflags 2 ,
|
||||
|
||||
+24
-12
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: du.c,v 1.35 2011/09/01 13:37:33 joerg Exp $ */
|
||||
/* $NetBSD: du.c,v 1.36 2012/03/11 11:23:20 shattered Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: du.c,v 1.35 2011/09/01 13:37:33 joerg Exp $");
|
||||
__RCSID("$NetBSD: du.c,v 1.36 2012/03/11 11:23:20 shattered Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -54,6 +54,7 @@ __RCSID("$NetBSD: du.c,v 1.35 2011/09/01 13:37:33 joerg Exp $");
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <inttypes.h>
|
||||
#include <util.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -61,11 +62,14 @@ __RCSID("$NetBSD: du.c,v 1.35 2011/09/01 13:37:33 joerg Exp $");
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* Count inodes or file size */
|
||||
#define COUNT (iflag ? 1 : p->fts_statp->st_blocks)
|
||||
|
||||
static int linkchk(dev_t, ino_t);
|
||||
static void prstat(const char *, int64_t);
|
||||
__dead static void usage(void);
|
||||
|
||||
static int hflag;
|
||||
static int hflag, iflag;
|
||||
static long blocksize;
|
||||
|
||||
int
|
||||
@@ -83,7 +87,7 @@ main(int argc, char *argv[])
|
||||
totalblocks = 0;
|
||||
ftsoptions = FTS_PHYSICAL;
|
||||
depth = INT_MAX;
|
||||
while ((ch = getopt(argc, argv, "HLPacd:ghkmnrsx")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HLPacd:ghikmnrsx")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@@ -118,6 +122,9 @@ main(int argc, char *argv[])
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
break;
|
||||
case 'k':
|
||||
blocksize = 1024;
|
||||
gkmflag = 1;
|
||||
@@ -206,9 +213,9 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case FTS_DP:
|
||||
p->fts_parent->fts_number +=
|
||||
p->fts_number += p->fts_statp->st_blocks;
|
||||
p->fts_number += COUNT;
|
||||
if (cflag)
|
||||
totalblocks += p->fts_statp->st_blocks;
|
||||
totalblocks += COUNT;
|
||||
/*
|
||||
* If listing each directory, or not listing files
|
||||
* or directories and this is post-order of the
|
||||
@@ -235,10 +242,10 @@ main(int argc, char *argv[])
|
||||
* the root of a traversal, display the total.
|
||||
*/
|
||||
if (listfiles || !p->fts_level)
|
||||
prstat(p->fts_path, p->fts_statp->st_blocks);
|
||||
p->fts_parent->fts_number += p->fts_statp->st_blocks;
|
||||
prstat(p->fts_path, COUNT);
|
||||
p->fts_parent->fts_number += COUNT;
|
||||
if (cflag)
|
||||
totalblocks += p->fts_statp->st_blocks;
|
||||
totalblocks += COUNT;
|
||||
}
|
||||
}
|
||||
if (errno)
|
||||
@@ -251,6 +258,11 @@ main(int argc, char *argv[])
|
||||
static void
|
||||
prstat(const char *fname, int64_t blocks)
|
||||
{
|
||||
if (iflag) {
|
||||
(void)printf("%" PRId64 "\t%s\n", blocks, fname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hflag) {
|
||||
char buf[5];
|
||||
int64_t sz = blocks * 512;
|
||||
@@ -260,8 +272,8 @@ prstat(const char *fname, int64_t blocks)
|
||||
|
||||
(void)printf("%s\t%s\n", buf, fname);
|
||||
} else
|
||||
(void)printf("%lld\t%s\n",
|
||||
(long long)howmany(blocks, (int64_t)blocksize),
|
||||
(void)printf("%" PRId64 "\t%s\n",
|
||||
howmany(blocks, (int64_t)blocksize),
|
||||
fname);
|
||||
}
|
||||
|
||||
@@ -345,6 +357,6 @@ usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: du [-H | -L | -P] [-a | -d depth | -s] [-cghkmnrx] [file ...]\n");
|
||||
"usage: du [-H | -L | -P] [-a | -d depth | -s] [-cghikmnrx] [file ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)fsplit.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fsplit.c,v 1.28 2011/09/16 15:39:26 joerg Exp $");
|
||||
__RCSID("$NetBSD: fsplit.c,v 1.29 2013/01/23 20:39:46 riastradh Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -235,9 +235,10 @@ saveit(const char *name)
|
||||
}
|
||||
strlcpy(fname, name, sizeof(fname));
|
||||
fnamelen = strlen(fname);
|
||||
/* Guaranteed by scan_name. */
|
||||
assert(fnamelen > 2);
|
||||
assert(fname[fnamelen-2] = '.');
|
||||
assert(fname[fnamelen-1] = 'f');
|
||||
assert(fname[fnamelen-2] == '.');
|
||||
assert(fname[fnamelen-1] == 'f');
|
||||
fname[fnamelen-2] = '\0';
|
||||
|
||||
for (i = 0; i < numextonly; i++) {
|
||||
|
||||
@@ -13,10 +13,6 @@ SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
|
||||
#
|
||||
#CPPFLAGS+=-DGATE_SERVER=\"ftp-gw.host\" # -DGATE_PORT=21
|
||||
|
||||
.if defined(__MINIX)
|
||||
CPPFLAGS+= -DDIRENT_MISSING_D_NAMLEN
|
||||
.endif # defined (__MINIX)
|
||||
|
||||
.if defined(SMALLPROG)
|
||||
CPPFLAGS+=-DNO_EDITCOMPLETE -DNO_ABOUT -DNO_AUTH -DNO_HELP -DNO_STATUS -DNO_DEBUG -DNO_USAGE
|
||||
.else
|
||||
|
||||
+88
-44
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fetch.c,v 1.202 2013/02/23 13:47:36 christos Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.205 2013/11/07 02:06:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.202 2013/02/23 13:47:36 christos Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.205 2013/11/07 02:06:51 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -80,6 +80,7 @@ typedef enum {
|
||||
} url_t;
|
||||
|
||||
__dead static void aborthttp(int);
|
||||
__dead static void timeouthttp(int);
|
||||
#ifndef NO_AUTH
|
||||
static int auth_url(const char *, char **, const char *, const char *);
|
||||
static void base64_encode(const unsigned char *, size_t, unsigned char *);
|
||||
@@ -492,8 +493,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
{
|
||||
struct addrinfo hints, *res, *res0 = NULL;
|
||||
int error;
|
||||
sigfunc volatile oldintr;
|
||||
sigfunc volatile oldintp;
|
||||
sigfunc volatile oldint;
|
||||
sigfunc volatile oldpipe;
|
||||
sigfunc volatile oldalrm;
|
||||
sigfunc volatile oldquit;
|
||||
int volatile s;
|
||||
struct stat sb;
|
||||
int volatile ischunked;
|
||||
@@ -519,6 +522,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
int (*volatile closefunc)(FILE *);
|
||||
FETCH *volatile fin;
|
||||
FILE *volatile fout;
|
||||
const char *volatile penv = proxyenv;
|
||||
time_t mtime;
|
||||
url_t urltype;
|
||||
in_port_t portnum;
|
||||
@@ -526,9 +530,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
void *ssl;
|
||||
#endif
|
||||
|
||||
DPRINTF("fetch_url: `%s' proxyenv `%s'\n", url, STRorNULL(proxyenv));
|
||||
DPRINTF("%s: `%s' proxyenv `%s'\n", __func__, url, STRorNULL(penv));
|
||||
|
||||
oldintr = oldintp = NULL;
|
||||
oldquit = oldalrm = oldint = oldpipe = NULL;
|
||||
closefunc = NULL;
|
||||
fin = NULL;
|
||||
fout = NULL;
|
||||
@@ -539,6 +543,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
rval = 1;
|
||||
uuser = pass = host = path = decodedpath = puser = ppass = NULL;
|
||||
|
||||
if (sigsetjmp(httpabort, 1))
|
||||
goto cleanup_fetch_url;
|
||||
|
||||
if (parse_url(url, "URL", &urltype, &uuser, &pass, &host, &port,
|
||||
&portnum, &path) == -1)
|
||||
goto cleanup_fetch_url;
|
||||
@@ -572,7 +579,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
else
|
||||
savefile = ftp_strdup(decodedpath);
|
||||
}
|
||||
DPRINTF("fetch_url: savefile `%s'\n", savefile);
|
||||
DPRINTF("%s: savefile `%s'\n", __func__, savefile);
|
||||
if (EMPTYSTRING(savefile)) {
|
||||
if (urltype == FTP_URL_T) {
|
||||
rval = fetch_ftp(url);
|
||||
@@ -624,18 +631,18 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
const char *leading;
|
||||
int hasleading;
|
||||
|
||||
if (proxyenv == NULL) {
|
||||
if (penv == NULL) {
|
||||
#ifdef WITH_SSL
|
||||
if (urltype == HTTPS_URL_T)
|
||||
proxyenv = getoptionvalue("https_proxy");
|
||||
penv = getoptionvalue("https_proxy");
|
||||
#endif
|
||||
if (proxyenv == NULL && IS_HTTP_TYPE(urltype))
|
||||
proxyenv = getoptionvalue("http_proxy");
|
||||
if (penv == NULL && IS_HTTP_TYPE(urltype))
|
||||
penv = getoptionvalue("http_proxy");
|
||||
else if (urltype == FTP_URL_T)
|
||||
proxyenv = getoptionvalue("ftp_proxy");
|
||||
penv = getoptionvalue("ftp_proxy");
|
||||
}
|
||||
direction = "retrieved";
|
||||
if (! EMPTYSTRING(proxyenv)) { /* use proxy */
|
||||
if (! EMPTYSTRING(penv)) { /* use proxy */
|
||||
url_t purltype;
|
||||
char *phost, *ppath;
|
||||
char *pport, *no_proxy;
|
||||
@@ -682,10 +689,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
if (isproxy) {
|
||||
if (restart_point) {
|
||||
warnx("Can't restart via proxy URL `%s'",
|
||||
proxyenv);
|
||||
penv);
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
if (parse_url(proxyenv, "proxy URL", &purltype,
|
||||
if (parse_url(penv, "proxy URL", &purltype,
|
||||
&puser, &ppass, &phost, &pport, &pportnum,
|
||||
&ppath) == -1)
|
||||
goto cleanup_fetch_url;
|
||||
@@ -695,8 +702,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
EMPTYSTRING(phost) ||
|
||||
(! EMPTYSTRING(ppath)
|
||||
&& strcmp(ppath, "/") != 0)) {
|
||||
warnx("Malformed proxy URL `%s'",
|
||||
proxyenv);
|
||||
warnx("Malformed proxy URL `%s'", penv);
|
||||
FREEPTR(phost);
|
||||
FREEPTR(pport);
|
||||
FREEPTR(ppath);
|
||||
@@ -722,7 +728,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
FREEPTR(ppath);
|
||||
urltype = purltype;
|
||||
}
|
||||
} /* ! EMPTYSTRING(proxyenv) */
|
||||
} /* ! EMPTYSTRING(penv) */
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = 0;
|
||||
@@ -794,9 +800,13 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
|
||||
oldalrm = xsignal(SIGALRM, timeouthttp);
|
||||
alarmtimer(quit_time ? quit_time : 60);
|
||||
fin = fetch_fdopen(s, "r+");
|
||||
fetch_set_ssl(fin, ssl);
|
||||
alarmtimer(0);
|
||||
|
||||
alarmtimer(quit_time ? quit_time : 60);
|
||||
/*
|
||||
* Construct and send the request.
|
||||
*/
|
||||
@@ -883,11 +893,15 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
fetch_printf(fin, "\r\n");
|
||||
if (fetch_flush(fin) == EOF) {
|
||||
warn("Writing HTTP request");
|
||||
alarmtimer(0);
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
alarmtimer(0);
|
||||
|
||||
/* Read the response */
|
||||
alarmtimer(quit_time ? quit_time : 60);
|
||||
len = fetch_getline(fin, buf, sizeof(buf), &errormsg);
|
||||
alarmtimer(0);
|
||||
if (len < 0) {
|
||||
if (*errormsg == '\n')
|
||||
errormsg++;
|
||||
@@ -896,7 +910,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
}
|
||||
while (len > 0 && (ISLWS(buf[len-1])))
|
||||
buf[--len] = '\0';
|
||||
DPRINTF("fetch_url: received `%s'\n", buf);
|
||||
DPRINTF("%s: received `%s'\n", __func__, buf);
|
||||
|
||||
/* Determine HTTP response code */
|
||||
cp = strchr(buf, ' ');
|
||||
@@ -911,7 +925,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
|
||||
/* Read the rest of the header. */
|
||||
while (1) {
|
||||
alarmtimer(quit_time ? quit_time : 60);
|
||||
len = fetch_getline(fin, buf, sizeof(buf), &errormsg);
|
||||
alarmtimer(0);
|
||||
if (len < 0) {
|
||||
if (*errormsg == '\n')
|
||||
errormsg++;
|
||||
@@ -922,7 +938,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
buf[--len] = '\0';
|
||||
if (len == 0)
|
||||
break;
|
||||
DPRINTF("fetch_url: received `%s'\n", buf);
|
||||
DPRINTF("%s: received `%s'\n", __func__, buf);
|
||||
|
||||
/*
|
||||
* Look for some headers
|
||||
@@ -934,8 +950,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
filesize = STRTOLL(cp, &ep, 10);
|
||||
if (filesize < 0 || *ep != '\0')
|
||||
goto improper;
|
||||
DPRINTF("fetch_url: parsed len as: " LLF "\n",
|
||||
(LLT)filesize);
|
||||
DPRINTF("%s: parsed len as: " LLF "\n",
|
||||
__func__, (LLT)filesize);
|
||||
|
||||
} else if (match_token(&cp, "Content-Range:")) {
|
||||
if (! match_token(&cp, "bytes"))
|
||||
@@ -1006,8 +1022,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
|
||||
} else if (match_token(&cp, "Location:")) {
|
||||
location = ftp_strdup(cp);
|
||||
DPRINTF("fetch_url: parsed location as `%s'\n",
|
||||
cp);
|
||||
DPRINTF("%s: parsed location as `%s'\n",
|
||||
__func__, cp);
|
||||
|
||||
} else if (match_token(&cp, "Transfer-Encoding:")) {
|
||||
if (match_token(&cp, "binary")) {
|
||||
@@ -1022,19 +1038,20 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
ischunked++;
|
||||
DPRINTF("fetch_url: using chunked encoding\n");
|
||||
DPRINTF("%s: using chunked encoding\n",
|
||||
__func__);
|
||||
|
||||
} else if (match_token(&cp, "Proxy-Authenticate:")
|
||||
|| match_token(&cp, "WWW-Authenticate:")) {
|
||||
if (! (token = match_token(&cp, "Basic"))) {
|
||||
DPRINTF(
|
||||
"fetch_url: skipping unknown auth scheme `%s'\n",
|
||||
token);
|
||||
DPRINTF("%s: skipping unknown auth "
|
||||
"scheme `%s'\n", __func__, token);
|
||||
continue;
|
||||
}
|
||||
FREEPTR(auth);
|
||||
auth = ftp_strdup(token);
|
||||
DPRINTF("fetch_url: parsed auth as `%s'\n", cp);
|
||||
DPRINTF("%s: parsed auth as `%s'\n",
|
||||
__func__, cp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1116,7 +1133,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
apass = NULL;
|
||||
}
|
||||
if (auth_url(auth, authp, auser, apass) == 0) {
|
||||
rval = fetch_url(url, proxyenv,
|
||||
rval = fetch_url(url, penv,
|
||||
proxyauth, wwwauth);
|
||||
memset(*authp, 0, strlen(*authp));
|
||||
FREEPTR(*authp);
|
||||
@@ -1137,7 +1154,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
if (strcmp(savefile, "-") == 0) {
|
||||
fout = stdout;
|
||||
} else if (*savefile == '|') {
|
||||
oldintp = xsignal(SIGPIPE, SIG_IGN);
|
||||
oldpipe = xsignal(SIGPIPE, SIG_IGN);
|
||||
fout = popen(savefile + 1, "w");
|
||||
if (fout == NULL) {
|
||||
warn("Can't execute `%s'", savefile + 1);
|
||||
@@ -1173,10 +1190,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
}
|
||||
|
||||
/* Trap signals */
|
||||
if (sigsetjmp(httpabort, 1))
|
||||
goto cleanup_fetch_url;
|
||||
(void)xsignal(SIGQUIT, psummary);
|
||||
oldintr = xsignal(SIGINT, aborthttp);
|
||||
oldquit = xsignal(SIGQUIT, psummary);
|
||||
oldint = xsignal(SIGINT, aborthttp);
|
||||
|
||||
assert(rcvbuf_size > 0);
|
||||
if ((size_t)rcvbuf_size > bufsize) {
|
||||
@@ -1188,6 +1203,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
|
||||
bytes = 0;
|
||||
hashbytes = mark;
|
||||
if (oldalrm) {
|
||||
(void)xsignal(SIGALRM, oldalrm);
|
||||
oldalrm = NULL;
|
||||
}
|
||||
progressmeter(-1);
|
||||
|
||||
/* Finally, suck down the file. */
|
||||
@@ -1234,7 +1253,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
warnx("Unexpected data following chunk-size");
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
DPRINTF("fetch_url: got chunk-size of " LLF "\n",
|
||||
DPRINTF("%s: got chunk-size of " LLF "\n", __func__,
|
||||
(LLT)chunksize);
|
||||
if (chunksize == 0) {
|
||||
lastchunk = 1;
|
||||
@@ -1244,7 +1263,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
/* transfer file or chunk */
|
||||
while (1) {
|
||||
struct timeval then, now, td;
|
||||
off_t bufrem;
|
||||
volatile off_t bufrem;
|
||||
|
||||
if (rate_get)
|
||||
(void)gettimeofday(&then, NULL);
|
||||
@@ -1292,6 +1311,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
chunkdone:
|
||||
if (ischunked) {
|
||||
if (fetch_getln(xferbuf, bufsize, fin) == NULL) {
|
||||
alarmtimer(0);
|
||||
warnx("Unexpected EOF reading chunk CRLF");
|
||||
goto cleanup_fetch_url;
|
||||
}
|
||||
@@ -1343,10 +1363,14 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
warnx("Improper response from `%s:%s'", host, port);
|
||||
|
||||
cleanup_fetch_url:
|
||||
if (oldintr)
|
||||
(void)xsignal(SIGINT, oldintr);
|
||||
if (oldintp)
|
||||
(void)xsignal(SIGPIPE, oldintp);
|
||||
if (oldint)
|
||||
(void)xsignal(SIGINT, oldint);
|
||||
if (oldpipe)
|
||||
(void)xsignal(SIGPIPE, oldpipe);
|
||||
if (oldalrm)
|
||||
(void)xsignal(SIGALRM, oldalrm);
|
||||
if (oldquit)
|
||||
(void)xsignal(SIGQUIT, oldpipe);
|
||||
if (fin != NULL)
|
||||
fetch_close(fin);
|
||||
else if (s != -1)
|
||||
@@ -1381,12 +1405,32 @@ static void
|
||||
aborthttp(int notused)
|
||||
{
|
||||
char msgbuf[100];
|
||||
size_t len;
|
||||
int len;
|
||||
|
||||
sigint_raised = 1;
|
||||
alarmtimer(0);
|
||||
len = strlcpy(msgbuf, "\nHTTP fetch aborted.\n", sizeof(msgbuf));
|
||||
write(fileno(ttyout), msgbuf, len);
|
||||
if (fromatty) {
|
||||
len = snprintf(msgbuf, sizeof(msgbuf),
|
||||
"\n%s: HTTP fetch aborted.\n", getprogname());
|
||||
if (len > 0)
|
||||
write(fileno(ttyout), msgbuf, len);
|
||||
}
|
||||
siglongjmp(httpabort, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
timeouthttp(int notused)
|
||||
{
|
||||
char msgbuf[100];
|
||||
int len;
|
||||
|
||||
alarmtimer(0);
|
||||
if (fromatty) {
|
||||
len = snprintf(msgbuf, sizeof(msgbuf),
|
||||
"\n%s: HTTP fetch timeout.\n", getprogname());
|
||||
if (len > 0)
|
||||
write(fileno(ttyout), msgbuf, len);
|
||||
}
|
||||
siglongjmp(httpabort, 1);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -102,10 +102,10 @@ __RCSID("$NetBSD: ftp.c,v 1.164 2012/07/04 06:09:37 is Exp $");
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/ftp.h>
|
||||
#include <arpa/telnet.h>
|
||||
@@ -165,9 +165,9 @@ hookup(const char *host, const char *port)
|
||||
struct addrinfo hints, *res, *res0;
|
||||
static char hostnamebuf[MAXHOSTNAMELEN];
|
||||
socklen_t len;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
int on = 1;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
|
||||
memset((char *)&myctladdr, 0, sizeof (myctladdr));
|
||||
@@ -274,12 +274,12 @@ hookup(const char *host, const char *port)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE,
|
||||
(void *)&on, sizeof(on)) == -1) {
|
||||
DWARN("setsockopt %s (ignored)", "SO_OOBINLINE");
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
return (hostname);
|
||||
bad:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: version.h,v 1.83 2013/02/06 16:37:20 christos Exp $ */
|
||||
/* $NetBSD: version.h,v 1.84 2013/05/05 10:40:19 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
|
||||
@@ -34,5 +34,5 @@
|
||||
#endif
|
||||
|
||||
#ifndef FTP_VERSION
|
||||
#define FTP_VERSION "20121224"
|
||||
#define FTP_VERSION "20130220"
|
||||
#endif
|
||||
|
||||
+11
-8
@@ -1,26 +1,29 @@
|
||||
# $NetBSD: Makefile,v 1.16 2011/06/21 13:25:45 joerg Exp $
|
||||
|
||||
# LSC Until it compiles cleanly...
|
||||
NOGCCERROR:=yes
|
||||
# $NetBSD: Makefile,v 1.18 2013/11/13 11:12:24 pettai Exp $
|
||||
|
||||
USE_FORT?= yes # data-driven bugs?
|
||||
|
||||
PROG= gzip
|
||||
MAN= gzip.1 gzexe.1 zdiff.1 zforce.1 zmore.1 znew.1
|
||||
MAN= gzip.1 gzexe.1 zdiff.1 zforce.1 zgrep.1 zmore.1 znew.1
|
||||
|
||||
DPADD= ${LIBZ} ${LIBBZ2} ${LIBLZMA}
|
||||
LDADD= -lz -lbz2 -llzma
|
||||
|
||||
SCRIPTS= gzexe zdiff zforce zmore znew
|
||||
SCRIPTS= gzexe zdiff zforce zgrep zmore znew
|
||||
|
||||
MLINKS+= gzip.1 gunzip.1 \
|
||||
gzip.1 gzcat.1 \
|
||||
gzip.1 zcat.1 \
|
||||
zdiff.1 zcmp.1
|
||||
zdiff.1 zcmp.1 \
|
||||
zgrep.1 zegrep.1 \
|
||||
zgrep.1 zfgrep.1 \
|
||||
zmore.1 zless.1
|
||||
|
||||
LINKS+= ${BINDIR}/gzip ${BINDIR}/gunzip \
|
||||
${BINDIR}/gzip ${BINDIR}/gzcat \
|
||||
${BINDIR}/gzip ${BINDIR}/zcat \
|
||||
${BINDIR}/zdiff ${BINDIR}/zcmp
|
||||
${BINDIR}/zdiff ${BINDIR}/zcmp \
|
||||
${BINDIR}/zgrep ${BINDIR}/zegrep \
|
||||
${BINDIR}/zgrep ${BINDIR}/zfgrep \
|
||||
${BINDIR}/zmore ${BINDIR}/zless
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: gzip.1,v 1.21 2011/06/19 02:22:36 christos Exp $
|
||||
.\" $NetBSD: gzip.1,v 1.22 2013/07/20 21:40:00 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997, 2003, 2004 Matthew R. Green
|
||||
.\" All rights reserved.
|
||||
@@ -196,4 +196,4 @@ version 20040427.
|
||||
This implementation of
|
||||
.Nm
|
||||
was written by
|
||||
.An Matthew R. Green Aq mrg@eterna.com.au .
|
||||
.An Matthew R. Green Aq Mt mrg@eterna.com.au .
|
||||
|
||||
+2
-2
@@ -1074,10 +1074,10 @@ copymodes(int fd, const struct stat *sbp, const char *file)
|
||||
maybe_warn("couldn't fchmod: %s", file);
|
||||
|
||||
/* only try flags if they exist already */
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (sb.st_flags != 0 && fchflags(fd, sb.st_flags) < 0)
|
||||
maybe_warn("couldn't fchflags: %s", file);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtimespec);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: zgrep,v 1.7 2008/05/08 15:35:23 wiz Exp $
|
||||
# $NetBSD: zgrep,v 1.8 2013/07/25 12:25:23 pgoyette Exp $
|
||||
#
|
||||
# Copyright (c) 2003 Thomas Klausner.
|
||||
#
|
||||
@@ -33,7 +33,7 @@ grep_args=""
|
||||
hyphen=0
|
||||
silent=0
|
||||
|
||||
prg=$0
|
||||
prg=$(basename $0)
|
||||
|
||||
# handle being called 'zegrep' or 'zfgrep'
|
||||
case ${prg} in
|
||||
|
||||
+8
-2
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# $NetBSD: zmore,v 1.3 2004/03/29 09:59:42 wiz Exp $
|
||||
# $NetBSD: zmore,v 1.4 2013/11/12 21:58:37 pettai Exp $
|
||||
#
|
||||
# $OpenBSD: zmore,v 1.4 2003/07/29 07:42:45 otto Exp $
|
||||
# $OpenBSD: zmore,v 1.6 2008/08/20 09:22:02 mpf Exp $
|
||||
#
|
||||
# Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
#
|
||||
@@ -41,6 +41,12 @@ while test $# -ne 0; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ `basename $0` == "zless" ] ; then
|
||||
pager=${PAGER-less}
|
||||
else
|
||||
pager=${PAGER-more}
|
||||
fi
|
||||
|
||||
# No files means read from stdin
|
||||
if [ $# -eq 0 ]; then
|
||||
gzip -cdfq 2>&1 | ${PAGER-more} $flags
|
||||
|
||||
+23
-7
@@ -1,5 +1,5 @@
|
||||
.\" $NetBSD: zmore.1,v 1.3 2003/12/28 12:47:52 wiz Exp $
|
||||
.\" $OpenBSD: zmore.1,v 1.3 2003/06/23 21:00:48 deraadt Exp $
|
||||
.\" $NetBSD: zmore.1,v 1.4 2013/11/12 21:58:37 pettai Exp $
|
||||
.\" $OpenBSD: zmore.1,v 1.10 2009/08/16 09:41:08 sobrado Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
.\"
|
||||
@@ -19,16 +19,20 @@
|
||||
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||
.\"
|
||||
.Dd June 23, 2003
|
||||
.Dd August 16, 2009
|
||||
.Dt ZMORE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm zmore
|
||||
.Nd view compressed files on a CRT
|
||||
.Nm zmore ,
|
||||
.Nm zless
|
||||
.Nd view compressed files
|
||||
.Sh SYNOPSIS
|
||||
.Nm zmore
|
||||
.Op Ar flags
|
||||
.Op Ar file ...
|
||||
.Op Ar
|
||||
.Nm zless
|
||||
.Op Ar flags
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a filter that allows the viewing of files compressed with Lempel-Ziv
|
||||
@@ -50,6 +54,14 @@ that are specified are passed to the user's preferred
|
||||
.Pa /usr/bin/more
|
||||
by default).
|
||||
.Pp
|
||||
.Nm zless
|
||||
is equivalent to
|
||||
.Nm zmore
|
||||
but uses
|
||||
.Xr less 1
|
||||
as a pager instead of
|
||||
.Xr more 1 .
|
||||
.Pp
|
||||
When multiple files are specified,
|
||||
.Nm
|
||||
will pause at the end of each file and present the following prompt to the user:
|
||||
@@ -85,7 +97,11 @@ style compression since there is no suffix on which to make a decision.
|
||||
Program used to display files.
|
||||
If unset,
|
||||
.Pa /usr/bin/more
|
||||
is used.
|
||||
is used
|
||||
.Pq Nm zmore
|
||||
or
|
||||
.Pa /usr/bin/less
|
||||
.Pq Nm zless .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr compress 1 ,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $ */
|
||||
/* $NetBSD: conv.c,v 1.14 2013/02/09 02:49:36 jakllsch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: conv.c,v 1.13 2010/02/09 14:06:37 drochner Exp $");
|
||||
__RCSID("$NetBSD: conv.c,v 1.14 2013/02/09 02:49:36 jakllsch Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -105,7 +105,7 @@ conv_u(PR *pr, u_char *p)
|
||||
static const char *list[] = {
|
||||
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
|
||||
"bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
|
||||
"dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
|
||||
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
|
||||
"can", "em", "sub", "esc", "fs", "gs", "rs", "us",
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: display.c,v 1.21 2009/01/18 21:34:32 apb Exp $ */
|
||||
/* $NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: display.c,v 1.21 2009/01/18 21:34:32 apb Exp $");
|
||||
__RCSID("$NetBSD: display.c,v 1.22 2013/10/18 20:19:03 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -344,7 +344,9 @@ doskip(const char *fname, int statok)
|
||||
skip -= sb.st_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else
|
||||
sb.st_mode = S_IFIFO;
|
||||
|
||||
if (S_ISREG(sb.st_mode)) {
|
||||
if (fseek(stdin, skip, SEEK_SET))
|
||||
err(1, "fseek %s", fname);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.1 2010/02/03 15:16:33 roy Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2013/08/11 06:48:46 dholland Exp $
|
||||
|
||||
PROG= infocmp
|
||||
WARNS= 4
|
||||
|
||||
CPPFLAGS+= -I${.CURDIR}/../../lib/libterminfo
|
||||
LDADD+= -lterminfo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: infocmp.1,v 1.5 2011/01/14 14:21:36 wiz Exp $
|
||||
.\" $NetBSD: infocmp.1,v 1.6 2013/07/20 21:40:01 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -128,4 +128,4 @@ utility outputs information that conforms to the
|
||||
.St -xcurses4.2
|
||||
standard.
|
||||
.Sh AUTHORS
|
||||
.An Roy Marples Aq roy@NetBSD.org
|
||||
.An Roy Marples Aq Mt roy@NetBSD.org
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: infocmp.c,v 1.7 2010/02/22 23:05:39 roy Exp $ */
|
||||
/* $NetBSD: infocmp.c,v 1.8 2013/10/01 09:01:49 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
|
||||
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: infocmp.c,v 1.7 2010/02/22 23:05:39 roy Exp $");
|
||||
__RCSID("$NetBSD: infocmp.c,v 1.8 2013/10/01 09:01:49 roy Exp $");
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -41,10 +41,6 @@ __RCSID("$NetBSD: infocmp.c,v 1.7 2010/02/22 23:05:39 roy Exp $");
|
||||
#include <term.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __minix
|
||||
#include <sys/ttycom.h>
|
||||
#endif
|
||||
|
||||
#define SW 8
|
||||
|
||||
typedef struct tient {
|
||||
@@ -727,7 +723,7 @@ main(int argc, char **argv)
|
||||
printf("internal database\n");
|
||||
else
|
||||
printf("%s%s\n", _ti_database,
|
||||
*_ti_database == '/' ? ".db" : "");
|
||||
*_ti_database == '/' ? ".cdb" : "");
|
||||
}
|
||||
printf("%s", t->name);
|
||||
if (t->_alias != NULL && *t->_alias != '\0')
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: lam.1,v 1.7 2010/04/05 21:18:56 joerg Exp $
|
||||
.\" $NetBSD: lam.1,v 1.8 2012/12/13 21:09:34 pgoyette Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -107,7 +107,7 @@ lam file1 file2 file3 file4
|
||||
joins 4 files together along each line.
|
||||
To merge the lines from four different files use
|
||||
.Bd -literal -offset indent
|
||||
lam file1 \-S "\e
|
||||
lam file1 \-s "\e
|
||||
" file2 file3 file4
|
||||
.Ed
|
||||
.Pp
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# $NetBSD: Makefile.common,v 1.2 2012/02/17 08:13:18 matt Exp $
|
||||
|
||||
# LSC Until it compiles cleanly...
|
||||
NOGCCERROR:=yes
|
||||
# $NetBSD: Makefile.common,v 1.3 2013/04/25 07:12:46 matt Exp $
|
||||
|
||||
LDELFSO=${NETBSDSRCDIR}/libexec/ld.elf_so
|
||||
CPPFLAGS+= -I${LDELFSO} -DLIBDIR=\"${LIBDIR}\"
|
||||
CPPFLAGS+= -D_RTLD_SOURCE
|
||||
.if !empty(MACHINE_ARCH:Mearm*)
|
||||
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
|
||||
.endif
|
||||
#CPPFLAGS+= -DDEBUG
|
||||
.PATH: ${LDELFSO}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# $NetBSD: Makefile.elf,v 1.3 2009/01/07 07:52:28 mrg Exp $
|
||||
# $NetBSD: Makefile.elf,v 1.5 2013/05/07 13:00:35 christos Exp $
|
||||
|
||||
# Makefile fragment to build a (32 or 64 bit) libldd_elfxx.a.
|
||||
# Expects CPPFLAGS to have ELFSIZE set, and LIB to be set.
|
||||
|
||||
SRCS= ldd_elfxx.c
|
||||
SRCS+= xmalloc.c debug.c expand.c map_object_fallback.c map_object.c load.c search.c \
|
||||
headers.c paths.c
|
||||
SRCS+= xmalloc.c debug.c expand.c map_object.c load.c search.c \
|
||||
headers.c paths.c tls.c symver.c
|
||||
|
||||
CPPFLAGS+= -DLDD
|
||||
.if defined(__MINIX)
|
||||
SRCS+= map_object_fallback.c
|
||||
.endif # defined(__MINIX)
|
||||
|
||||
.include "Makefile.common"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.4 2009/12/15 04:06:43 mrg Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.5 2013/03/20 15:18:42 macallan Exp $
|
||||
|
||||
WARNS?= 3 # XXX: -Wsign-compare issues ld.elf_so source
|
||||
|
||||
@@ -18,7 +18,7 @@ MLIBDIR= powerpc
|
||||
.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el")
|
||||
MLIBDIR= 64
|
||||
COMPAT_MLIBDIR= o32
|
||||
CPPFLAGS+= -DLDD_ELF64
|
||||
CPPFLAGS+= -DLDD_ELF64 -DMIPS_N32
|
||||
.endif
|
||||
|
||||
.if exists(${.CURDIR}/../../Makefile.inc)
|
||||
|
||||
+29
-100
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ldd.c,v 1.15 2010/10/16 10:27:08 skrll Exp $ */
|
||||
/* $NetBSD: ldd.c,v 1.21 2013/03/20 15:18:42 macallan Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ldd.c,v 1.15 2010/10/16 10:27:08 skrll Exp $");
|
||||
__RCSID("$NetBSD: ldd.c,v 1.21 2013/03/20 15:18:42 macallan Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -89,6 +89,10 @@ __RCSID("$NetBSD: ldd.c,v 1.15 2010/10/16 10:27:08 skrll Exp $");
|
||||
*/
|
||||
static char *error_message; /* Message for dlopen(), or NULL */
|
||||
bool _rtld_trust; /* False for setuid and setgid programs */
|
||||
/*
|
||||
* This may be ELF64 or ELF32 but since they are used opaquely it doesn't
|
||||
* really matter.
|
||||
*/
|
||||
Obj_Entry *_rtld_objlist; /* Head of linked list of shared objects */
|
||||
Obj_Entry **_rtld_objtail = &_rtld_objlist;
|
||||
/* Link field of last object in list */
|
||||
@@ -161,9 +165,9 @@ main(int argc, char **argv)
|
||||
}
|
||||
if (elf_ldd(fd, *argv, fmt1, fmt2) == -1
|
||||
/* Alpha never had 32 bit support. */
|
||||
#if defined(_LP64) && !defined(__alpha__)
|
||||
#if (defined(_LP64) && !defined(__alpha__)) || defined(MIPS_N32)
|
||||
&& elf32_ldd(fd, *argv, fmt1, fmt2) == -1
|
||||
#ifdef __mips__
|
||||
#if defined(__mips__) && 0 /* XXX this is still hosed for some reason */
|
||||
&& elf32_ldd_compat(fd, *argv, fmt1, fmt2) == -1
|
||||
#endif
|
||||
#endif
|
||||
@@ -200,106 +204,31 @@ dlerror()
|
||||
}
|
||||
|
||||
void
|
||||
fmtprint(const char *libname, Obj_Entry *obj, const char *fmt1,
|
||||
const char *fmt2)
|
||||
_rtld_die(void)
|
||||
{
|
||||
const char *libpath = obj ? obj->path : "not found";
|
||||
char libnamebuf[200];
|
||||
char *libmajor = NULL;
|
||||
const char *fmt;
|
||||
char *cp;
|
||||
int c;
|
||||
const char *msg = dlerror();
|
||||
|
||||
if (strncmp(libname, "lib", 3) == 0 &&
|
||||
(cp = strstr(libname, ".so")) != NULL) {
|
||||
int i = cp - (libname + 3);
|
||||
|
||||
if (i >= sizeof(libnamebuf))
|
||||
i = sizeof(libnamebuf) - 1;
|
||||
(void)memcpy(libnamebuf, libname + 3, i);
|
||||
libnamebuf[i] = '\0';
|
||||
if (cp[3] && isdigit((unsigned char)cp[4]))
|
||||
libmajor = &cp[4];
|
||||
libname = libnamebuf;
|
||||
}
|
||||
|
||||
if (fmt1 == NULL)
|
||||
fmt1 = libmajor != NULL ?
|
||||
"\t-l%o.%m => %p\n" :
|
||||
"\t-l%o => %p\n";
|
||||
if (fmt2 == NULL)
|
||||
fmt2 = "\t%o => %p\n";
|
||||
|
||||
fmt = libname == libnamebuf ? fmt1 : fmt2;
|
||||
while ((c = *fmt++) != '\0') {
|
||||
switch (c) {
|
||||
default:
|
||||
putchar(c);
|
||||
continue;
|
||||
case '\\':
|
||||
switch (c = *fmt) {
|
||||
case '\0':
|
||||
continue;
|
||||
case 'n':
|
||||
putchar('\n');
|
||||
break;
|
||||
case 't':
|
||||
putchar('\t');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
switch (c = *fmt) {
|
||||
case '\0':
|
||||
continue;
|
||||
case '%':
|
||||
default:
|
||||
putchar(c);
|
||||
break;
|
||||
case 'A':
|
||||
printf("%s", main_local);
|
||||
break;
|
||||
case 'a':
|
||||
printf("%s", main_progname);
|
||||
break;
|
||||
case 'o':
|
||||
printf("%s", libname);
|
||||
break;
|
||||
case 'm':
|
||||
printf("%s", libmajor);
|
||||
break;
|
||||
case 'n':
|
||||
/* XXX: not supported for elf */
|
||||
break;
|
||||
case 'p':
|
||||
printf("%s", libpath);
|
||||
break;
|
||||
case 'x':
|
||||
printf("%p", obj ? obj->mapbase : 0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++fmt;
|
||||
}
|
||||
if (msg == NULL)
|
||||
msg = "Fatal error";
|
||||
xerrx(1, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
print_needed(Obj_Entry *obj, const char *fmt1, const char *fmt2)
|
||||
_rtld_shared_enter(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_rtld_shared_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_rtld_exclusive_enter(sigset_t *mask)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_rtld_exclusive_exit(sigset_t *mask)
|
||||
{
|
||||
const Needed_Entry *needed;
|
||||
|
||||
for (needed = obj->needed; needed != NULL; needed = needed->next) {
|
||||
const char *libname = obj->strtab + needed->name;
|
||||
|
||||
if (needed->obj != NULL) {
|
||||
if (!needed->obj->printed) {
|
||||
fmtprint(libname, needed->obj, fmt1, fmt2);
|
||||
needed->obj->printed = 1;
|
||||
print_needed(needed->obj, fmt1, fmt2);
|
||||
}
|
||||
} else {
|
||||
fmtprint(libname, needed->obj, fmt1, fmt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ldd.h,v 1.6 2009/12/15 04:06:43 mrg Exp $ */
|
||||
/* $NetBSD: ldd.h,v 1.7 2012/07/08 00:53:44 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Matthew R. Green
|
||||
@@ -43,8 +43,5 @@ int elf64_ldd(int, char *, const char *, const char *);
|
||||
#define elf_ldd elf32_ldd
|
||||
#endif
|
||||
|
||||
void fmtprint(const char *, Obj_Entry *, const char *, const char *);
|
||||
void print_needed(Obj_Entry *, const char *, const char *);
|
||||
|
||||
extern char *main_local;
|
||||
extern char *main_progname;
|
||||
|
||||
+111
-3
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ldd_elfxx.c,v 1.4 2009/09/07 04:49:03 dholland Exp $ */
|
||||
/* $NetBSD: ldd_elfxx.c,v 1.6 2012/07/08 00:53:44 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ldd_elfxx.c,v 1.4 2009/09/07 04:49:03 dholland Exp $");
|
||||
__RCSID("$NetBSD: ldd_elfxx.c,v 1.6 2012/07/08 00:53:44 matt Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -84,8 +84,11 @@ __RCSID("$NetBSD: ldd_elfxx.c,v 1.4 2009/09/07 04:49:03 dholland Exp $");
|
||||
#include "rtld.h"
|
||||
#include "ldd.h"
|
||||
|
||||
static void print_needed(Obj_Entry *, const char *, const char *);
|
||||
static void fmtprint(const char *, Obj_Entry *, const char *, const char *);
|
||||
|
||||
/*
|
||||
* elfxx_ldd() - bit-size independant ELF ldd implementation.
|
||||
* elfxx_ldd() - bit-size independent ELF ldd implementation.
|
||||
* returns 0 on success and -1 on failure.
|
||||
*/
|
||||
int
|
||||
@@ -158,3 +161,108 @@ ELFNAME(ldd)(int fd, char *path, const char *fmt1, const char *fmt2)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
fmtprint(const char *libname, Obj_Entry *obj, const char *fmt1,
|
||||
const char *fmt2)
|
||||
{
|
||||
const char *libpath = obj ? obj->path : "not found";
|
||||
char libnamebuf[200];
|
||||
char *libmajor = NULL;
|
||||
const char *fmt;
|
||||
char *cp;
|
||||
int c;
|
||||
|
||||
if (strncmp(libname, "lib", 3) == 0 &&
|
||||
(cp = strstr(libname, ".so")) != NULL) {
|
||||
size_t i = cp - (libname + 3);
|
||||
|
||||
if (i >= sizeof(libnamebuf))
|
||||
i = sizeof(libnamebuf) - 1;
|
||||
(void)memcpy(libnamebuf, libname + 3, i);
|
||||
libnamebuf[i] = '\0';
|
||||
if (cp[3] && isdigit((unsigned char)cp[4]))
|
||||
libmajor = &cp[4];
|
||||
libname = libnamebuf;
|
||||
}
|
||||
|
||||
if (fmt1 == NULL)
|
||||
fmt1 = libmajor != NULL ?
|
||||
"\t-l%o.%m => %p\n" :
|
||||
"\t-l%o => %p\n";
|
||||
if (fmt2 == NULL)
|
||||
fmt2 = "\t%o => %p\n";
|
||||
|
||||
fmt = libname == libnamebuf ? fmt1 : fmt2;
|
||||
while ((c = *fmt++) != '\0') {
|
||||
switch (c) {
|
||||
default:
|
||||
putchar(c);
|
||||
continue;
|
||||
case '\\':
|
||||
switch (c = *fmt) {
|
||||
case '\0':
|
||||
continue;
|
||||
case 'n':
|
||||
putchar('\n');
|
||||
break;
|
||||
case 't':
|
||||
putchar('\t');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
switch (c = *fmt) {
|
||||
case '\0':
|
||||
continue;
|
||||
case '%':
|
||||
default:
|
||||
putchar(c);
|
||||
break;
|
||||
case 'A':
|
||||
printf("%s", main_local);
|
||||
break;
|
||||
case 'a':
|
||||
printf("%s", main_progname);
|
||||
break;
|
||||
case 'o':
|
||||
printf("%s", libname);
|
||||
break;
|
||||
case 'm':
|
||||
printf("%s", libmajor);
|
||||
break;
|
||||
case 'n':
|
||||
/* XXX: not supported for elf */
|
||||
break;
|
||||
case 'p':
|
||||
printf("%s", libpath);
|
||||
break;
|
||||
case 'x':
|
||||
printf("%p", obj ? obj->mapbase : 0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++fmt;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
print_needed(Obj_Entry *obj, const char *fmt1, const char *fmt2)
|
||||
{
|
||||
const Needed_Entry *needed;
|
||||
|
||||
for (needed = obj->needed; needed != NULL; needed = needed->next) {
|
||||
const char *libname = obj->strtab + needed->name;
|
||||
|
||||
if (needed->obj != NULL) {
|
||||
if (!needed->obj->printed) {
|
||||
fmtprint(libname, needed->obj, fmt1, fmt2);
|
||||
needed->obj->printed = 1;
|
||||
print_needed(needed->obj, fmt1, fmt2);
|
||||
}
|
||||
} else {
|
||||
fmtprint(libname, needed->obj, fmt1, fmt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lock.c,v 1.32 2012/03/20 20:34:58 matt Exp $ */
|
||||
/* $NetBSD: lock.c,v 1.33 2013/10/18 20:47:06 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1987, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: lock.c,v 1.32 2012/03/20 20:34:58 matt Exp $");
|
||||
__RCSID("$NetBSD: lock.c,v 1.33 2013/10/18 20:47:06 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -105,7 +105,7 @@ main(int argc, char **argv)
|
||||
time_t curtime;
|
||||
int ch, usemine;
|
||||
long sectimeout;
|
||||
char *ap, *mypw, *ttynam;
|
||||
char *ap, *ttynam;
|
||||
const char *tzn;
|
||||
uid_t uid = getuid();
|
||||
char hostname[MAXHOSTNAMELEN + 1], s[BUFSIZ], s1[BUFSIZ];
|
||||
@@ -113,6 +113,8 @@ main(int argc, char **argv)
|
||||
pam_handle_t *pamh = NULL;
|
||||
static const struct pam_conv pamc = { &openpam_ttyconv, NULL };
|
||||
int pam_err;
|
||||
#else
|
||||
char *mypw = NULL;
|
||||
#endif
|
||||
|
||||
if ((pw = getpwuid(getuid())) == NULL)
|
||||
@@ -120,7 +122,6 @@ main(int argc, char **argv)
|
||||
|
||||
notimeout = 0;
|
||||
sectimeout = TIMEOUT;
|
||||
mypw = NULL;
|
||||
usemine = 0;
|
||||
|
||||
while ((ch = getopt(argc, argv, "npt:")) != -1)
|
||||
@@ -210,7 +211,9 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
s[0] = '\0';
|
||||
#ifndef USE_PAM
|
||||
mypw = s1;
|
||||
#endif
|
||||
}
|
||||
#ifdef USE_PAM
|
||||
if (usemine) {
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.55 2012/04/24 16:52:26 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.56 2013/08/11 06:32:13 dholland Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 7/19/93
|
||||
|
||||
.if defined(__MINIX)
|
||||
WARNS=2
|
||||
.endif
|
||||
|
||||
WARNS?= 5
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
USE_FORT?= yes # setuid
|
||||
@@ -24,6 +18,7 @@ LDADD+= -lpam ${PAM_STATIC_LDADD}
|
||||
DPADD+= ${LIBPAM} ${PAM_STATIC_DPADD}
|
||||
.else # USE_PAM == no
|
||||
SRCS+= login.c
|
||||
# MINIX: NO LOGIN_CAP
|
||||
CPPFLAGS+= -DSUPPORT_UTMP -DSUPPORT_UTMPX #-DLOGIN_CAP
|
||||
|
||||
.if (${USE_KERBEROS} != "no")
|
||||
|
||||
+19
-11
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: common.c,v 1.3 2009/12/29 20:15:15 christos Exp $ */
|
||||
/* $NetBSD: common.c,v 1.6 2012/05/19 00:02:44 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
|
||||
@@ -29,7 +29,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: common.c,v 1.3 2009/12/29 20:15:15 christos Exp $");
|
||||
__RCSID("$NetBSD: common.c,v 1.6 2012/05/19 00:02:44 christos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@@ -77,11 +77,20 @@ u_int timeout = 300;
|
||||
void decode_ss(const char *);
|
||||
struct passwd *pwd;
|
||||
int failures, have_ss;
|
||||
char term[64], *envinit[1], *hostname, *username, *tty, *nested;
|
||||
char term[64], *envinit[1], *hostname, *tty, *nested;
|
||||
const char *username;
|
||||
struct timeval now;
|
||||
struct sockaddr_storage ss;
|
||||
|
||||
void
|
||||
char *
|
||||
trimloginname(char *u)
|
||||
{
|
||||
if (strlen(u) > MAXLOGNAME)
|
||||
u[MAXLOGNAME] = '\0';
|
||||
return u;
|
||||
}
|
||||
|
||||
char *
|
||||
getloginname(void)
|
||||
{
|
||||
int ch;
|
||||
@@ -104,8 +113,7 @@ getloginname(void)
|
||||
"login names may not start with '-'.\n");
|
||||
else {
|
||||
*p = '\0';
|
||||
username = nbuf;
|
||||
break;
|
||||
return nbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +130,7 @@ rootterm(char *ttyn)
|
||||
static jmp_buf motdinterrupt;
|
||||
|
||||
void
|
||||
motd(char *fname)
|
||||
motd(const char *fname)
|
||||
{
|
||||
int fd, nchars;
|
||||
sig_t oldint;
|
||||
@@ -139,7 +147,7 @@ motd(char *fname)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
void __dead
|
||||
sigint(int signo)
|
||||
{
|
||||
|
||||
@@ -147,7 +155,7 @@ sigint(int signo)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
void __dead
|
||||
timedout(int signo)
|
||||
{
|
||||
|
||||
@@ -243,7 +251,7 @@ doutmpx(void)
|
||||
utmpx.ut_type = USER_PROCESS;
|
||||
utmpx.ut_pid = getpid();
|
||||
t = tty + strlen(tty);
|
||||
if (t - tty >= sizeof(utmpx.ut_id)) {
|
||||
if ((size_t)(t - tty) >= sizeof(utmpx.ut_id)) {
|
||||
(void)strncpy(utmpx.ut_id, t - sizeof(utmpx.ut_id),
|
||||
sizeof(utmpx.ut_id));
|
||||
} else {
|
||||
@@ -364,7 +372,7 @@ stypeof(const char *ttyid)
|
||||
return (ttyid && (t = getttynam(ttyid)) ? t->ty_type : NULL);
|
||||
}
|
||||
|
||||
void
|
||||
void __dead
|
||||
sleepexit(int eval)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: common.h,v 1.1 2009/12/29 19:26:13 christos Exp $ */
|
||||
/* $NetBSD: common.h,v 1.4 2012/05/19 00:02:44 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
|
||||
@@ -33,19 +33,21 @@ __BEGIN_DECLS
|
||||
|
||||
void badlogin(const char *);
|
||||
void update_db(int, int, int);
|
||||
void getloginname(void);
|
||||
void motd(char *);
|
||||
char *trimloginname(char *);
|
||||
char *getloginname(void);
|
||||
void motd(const char *);
|
||||
int rootterm(char *);
|
||||
void sigint(int);
|
||||
void sleepexit(int);
|
||||
void __dead sigint(int);
|
||||
void __dead sleepexit(int);
|
||||
const char *stypeof(const char *);
|
||||
void timedout(int);
|
||||
void __dead timedout(int);
|
||||
void decode_ss(const char *);
|
||||
|
||||
extern u_int timeout;
|
||||
extern struct passwd *pwd;
|
||||
extern int failures, have_ss;
|
||||
extern char term[64], *envinit[1], *hostname, *username, *tty, *nested;
|
||||
extern char term[64], *envinit[1], *hostname, *tty, *nested;
|
||||
extern const char *username;
|
||||
extern struct timeval now;
|
||||
extern struct sockaddr_storage ss;
|
||||
extern const char copyrightstr[];
|
||||
|
||||
+50
-72
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: k5login.c,v 1.27 2006/03/23 23:33:28 wiz Exp $ */
|
||||
/* $NetBSD: k5login.c,v 1.33 2012/04/24 16:52:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@@ -51,7 +51,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)klogin.c 5.11 (Berkeley) 7/12/92";
|
||||
#endif
|
||||
__RCSID("$NetBSD: k5login.c,v 1.27 2006/03/23 23:33:28 wiz Exp $");
|
||||
__RCSID("$NetBSD: k5login.c,v 1.33 2012/04/24 16:52:26 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#ifdef KERBEROS5
|
||||
@@ -71,7 +71,7 @@ __RCSID("$NetBSD: k5login.c,v 1.27 2006/03/23 23:33:28 wiz Exp $");
|
||||
|
||||
krb5_context kcontext;
|
||||
|
||||
int notickets;
|
||||
extern int notickets;
|
||||
int krb5_configured;
|
||||
char *krb5tkfile_env;
|
||||
extern char *tty;
|
||||
@@ -81,7 +81,7 @@ extern int has_ccache;
|
||||
static char tkt_location[MAXPATHLEN];
|
||||
static krb5_creds forw_creds;
|
||||
int have_forward;
|
||||
static krb5_principal me, server;
|
||||
static krb5_principal me;
|
||||
|
||||
int k5_read_creds(char *);
|
||||
int k5_write_creds(void);
|
||||
@@ -89,12 +89,26 @@ int k5_verify_creds(krb5_context, krb5_ccache);
|
||||
int k5login(struct passwd *, char *, char *, char *);
|
||||
void k5destroy(void);
|
||||
|
||||
#ifndef krb5_realm_length
|
||||
#define krb5_realm_length(r) ((r).length)
|
||||
#endif
|
||||
#ifndef krb5_realm_data
|
||||
#define krb5_realm_data(r) ((r).data)
|
||||
#endif
|
||||
static void __printflike(3, 4)
|
||||
k5_log(krb5_context context, krb5_error_code kerror, const char *fmt, ...)
|
||||
{
|
||||
const char *msg = krb5_get_error_message(context, kerror);
|
||||
char *str;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (vasprintf(&str, fmt, ap) == -1) {
|
||||
va_end(ap);
|
||||
syslog(LOG_NOTICE, "Cannot allocate memory for error %s: %s",
|
||||
fmt, msg);
|
||||
return;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
syslog(LOG_NOTICE, "warning: %s: %s", str, msg);
|
||||
krb5_free_error_message(kcontext, msg);
|
||||
free(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify the Kerberos ticket-granting ticket just retrieved for the
|
||||
@@ -163,8 +177,7 @@ k5_verify_creds(krb5_context c, krb5_ccache ccache)
|
||||
else if (kerror) {
|
||||
krb5_warn(kcontext, kerror,
|
||||
"Unable to verify Kerberos V5 TGT: %s", phost);
|
||||
syslog(LOG_NOTICE, "Kerberos V5 TGT bad: %s",
|
||||
krb5_get_err_text(kcontext, kerror));
|
||||
k5_log(kcontext, kerror, "Kerberos V5 TGT bad");
|
||||
retval = -1;
|
||||
goto EGRESS;
|
||||
}
|
||||
@@ -192,11 +205,9 @@ k5_verify_creds(krb5_context c, krb5_ccache ccache)
|
||||
retval = -1;
|
||||
}
|
||||
krb5_warn(kcontext, kerror, "Unable to verify host ticket");
|
||||
syslog(LOG_NOTICE, "can't verify v5 ticket: %s; %s\n",
|
||||
krb5_get_err_text(kcontext, kerror),
|
||||
retval
|
||||
? "keytab found, assuming failure"
|
||||
: "no keytab found, assuming success");
|
||||
k5_log(kcontext, kerror, "can't verify v5 ticket (%s)",
|
||||
retval ? "keytab found, assuming failure" :
|
||||
"no keytab found, assuming success");
|
||||
goto EGRESS;
|
||||
}
|
||||
/*
|
||||
@@ -243,13 +254,13 @@ k5_read_creds(char *username)
|
||||
}
|
||||
|
||||
mcreds.client = me;
|
||||
const char *realm = krb5_principal_get_realm(kcontext, me);
|
||||
size_t rlen = strlen(realm);
|
||||
kerror = krb5_build_principal_ext(kcontext, &mcreds.server,
|
||||
krb5_realm_length(*krb5_princ_realm(kcontext, me)),
|
||||
krb5_realm_data(*krb5_princ_realm(kcontext, me)),
|
||||
rlen, realm,
|
||||
KRB5_TGS_NAME_SIZE,
|
||||
KRB5_TGS_NAME,
|
||||
krb5_realm_length(*krb5_princ_realm(kcontext, me)),
|
||||
krb5_realm_data(*krb5_princ_realm(kcontext, me)),
|
||||
rlen, realm,
|
||||
0);
|
||||
if (kerror) {
|
||||
krb5_warn(kcontext, kerror, "while building server name");
|
||||
@@ -321,17 +332,12 @@ k5login(struct passwd *pw, char *instance, char *localhost, char *password)
|
||||
{
|
||||
krb5_error_code kerror;
|
||||
krb5_creds my_creds;
|
||||
krb5_timestamp now;
|
||||
krb5_ccache ccache = NULL;
|
||||
long lifetime = KRB5_DEFAULT_LIFE;
|
||||
int options = KRB5_DEFAULT_OPTIONS;
|
||||
char *realm, *client_name;
|
||||
char *principal;
|
||||
|
||||
krb5_configured = 1;
|
||||
|
||||
if (login_krb5_forwardable_tgt)
|
||||
options |= KDC_OPT_FORWARDABLE;
|
||||
|
||||
/*
|
||||
* Root logins don't use Kerberos.
|
||||
@@ -355,10 +361,10 @@ k5login(struct passwd *pw, char *instance, char *localhost, char *password)
|
||||
|
||||
if (strcmp(instance, "root") != 0)
|
||||
(void)snprintf(tkt_location, sizeof tkt_location,
|
||||
"FILE:/tmp/krb5cc_%d.%s", pw->pw_uid, tty);
|
||||
"FILE:/tmp/krb5cc_%d", pw->pw_uid);
|
||||
else
|
||||
(void)snprintf(tkt_location, sizeof tkt_location,
|
||||
"FILE:/tmp/krb5cc_root_%d.%s", pw->pw_uid, tty);
|
||||
"FILE:/tmp/krb5cc_root_%d", pw->pw_uid);
|
||||
krb5tkfile_env = tkt_location;
|
||||
has_ccache = 1;
|
||||
|
||||
@@ -372,71 +378,43 @@ k5login(struct passwd *pw, char *instance, char *localhost, char *password)
|
||||
}
|
||||
|
||||
if ((kerror = krb5_cc_resolve(kcontext, tkt_location, &ccache)) != 0) {
|
||||
syslog(LOG_NOTICE, "warning: %s while getting default ccache",
|
||||
krb5_get_err_text(kcontext, kerror));
|
||||
k5_log(kcontext, kerror, "while getting default ccache");
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((kerror = krb5_parse_name(kcontext, principal, &me)) != 0) {
|
||||
syslog(LOG_NOTICE, "warning: %s when parsing name %s",
|
||||
krb5_get_err_text(kcontext, kerror), principal);
|
||||
k5_log(kcontext, kerror, "when parsing name %s", principal);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((kerror = krb5_unparse_name(kcontext, me, &client_name)) != 0) {
|
||||
syslog(LOG_NOTICE, "warning: %s when unparsing name %s",
|
||||
krb5_get_err_text(kcontext, kerror), principal);
|
||||
k5_log(kcontext, kerror, "when unparsing name %s", principal);
|
||||
return (1);
|
||||
}
|
||||
|
||||
kerror = krb5_cc_initialize(kcontext, ccache, me);
|
||||
if (kerror != 0) {
|
||||
syslog(LOG_NOTICE, "%s when initializing cache %s",
|
||||
krb5_get_err_text(kcontext, kerror), tkt_location);
|
||||
k5_log(kcontext, kerror, "when initializing cache %s",
|
||||
tkt_location);
|
||||
return (1);
|
||||
}
|
||||
|
||||
memset((char *)&my_creds, 0, sizeof(my_creds));
|
||||
memset(&my_creds, 0, sizeof(my_creds));
|
||||
krb5_get_init_creds_opt *opt;
|
||||
|
||||
my_creds.client = me;
|
||||
|
||||
if ((kerror = krb5_build_principal_ext(kcontext,
|
||||
&server,
|
||||
krb5_realm_length(*krb5_princ_realm(kcontext, me)),
|
||||
krb5_realm_data(*krb5_princ_realm(kcontext, me)),
|
||||
KRB5_TGS_NAME_SIZE,
|
||||
KRB5_TGS_NAME,
|
||||
krb5_realm_length(*krb5_princ_realm(kcontext, me)),
|
||||
krb5_realm_data(*krb5_princ_realm(kcontext, me)),
|
||||
0)) != 0) {
|
||||
syslog(LOG_NOTICE, "%s while building server name",
|
||||
krb5_get_err_text(kcontext, kerror));
|
||||
if ((kerror = krb5_get_init_creds_opt_alloc(kcontext, &opt)) != 0) {
|
||||
k5_log(kcontext, kerror, "while getting options");
|
||||
return (1);
|
||||
}
|
||||
if (login_krb5_forwardable_tgt)
|
||||
krb5_get_init_creds_opt_set_forwardable(opt, 1);
|
||||
|
||||
my_creds.server = server;
|
||||
kerror = krb5_get_init_creds_password(kcontext, &my_creds, me, password,
|
||||
NULL, NULL, 0, NULL, opt);
|
||||
|
||||
if ((kerror = krb5_timeofday(kcontext, &now)) != 0) {
|
||||
syslog(LOG_NOTICE, "%s while getting time of day",
|
||||
krb5_get_err_text(kcontext, kerror));
|
||||
return (1);
|
||||
}
|
||||
|
||||
my_creds.times.starttime = 0; /* start timer when request
|
||||
gets to KDC */
|
||||
my_creds.times.endtime = now + lifetime;
|
||||
my_creds.times.renew_till = 0;
|
||||
|
||||
kerror = krb5_get_in_tkt_with_password(kcontext, options,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
password,
|
||||
ccache,
|
||||
&my_creds, 0);
|
||||
|
||||
if (my_creds.server != NULL)
|
||||
krb5_free_principal(kcontext, my_creds.server);
|
||||
krb5_get_init_creds_opt_free(kcontext, opt);
|
||||
if (kerror == 0)
|
||||
kerror = krb5_cc_store_cred(kcontext, ccache, &my_creds);
|
||||
|
||||
if (chown(&tkt_location[5], pw->pw_uid, pw->pw_gid) < 0)
|
||||
syslog(LOG_ERR, "chown tkfile (%s): %m", &tkt_location[5]);
|
||||
|
||||
+24
-24
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: login.c,v 1.97 2009/12/29 19:26:13 christos Exp $ */
|
||||
/* $NetBSD: login.c,v 1.103 2012/04/29 01:26:56 wiz Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
__RCSID("$NetBSD: login.c,v 1.97 2009/12/29 19:26:13 christos Exp $");
|
||||
__RCSID("$NetBSD: login.c,v 1.103 2012/04/29 01:26:56 wiz Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -83,7 +83,7 @@ __RCSID("$NetBSD: login.c,v 1.97 2009/12/29 19:26:13 christos Exp $");
|
||||
#endif
|
||||
#ifdef KERBEROS5
|
||||
#include <krb5/krb5.h>
|
||||
#include <com_err.h>
|
||||
#include <krb5/com_err.h>
|
||||
#endif
|
||||
#ifdef LOGIN_CAP
|
||||
#include <login_cap.h>
|
||||
@@ -103,13 +103,13 @@ static void checknologin(char *);
|
||||
#ifdef KERBEROS5
|
||||
int k5login(struct passwd *, char *, char *, char *);
|
||||
void k5destroy(void);
|
||||
int k5_read_creds(char*);
|
||||
int k5_read_creds(const char *);
|
||||
int k5_write_creds(void);
|
||||
#endif
|
||||
#if defined(KERBEROS5)
|
||||
static void dofork(void);
|
||||
#endif
|
||||
static void usage(void);
|
||||
static void usage(void) __attribute__((__noreturn__));
|
||||
|
||||
#define TTYGRPNAME "tty" /* name of group to own ttys */
|
||||
|
||||
@@ -118,10 +118,10 @@ static void usage(void);
|
||||
|
||||
#if defined(KERBEROS5)
|
||||
int has_ccache = 0;
|
||||
static int notickets = 1;
|
||||
static char *instance;
|
||||
int notickets = 1;
|
||||
extern krb5_context kcontext;
|
||||
extern int have_forward;
|
||||
static char *instance;
|
||||
extern char *krb5tkfile_env;
|
||||
extern int krb5_configured;
|
||||
#endif
|
||||
@@ -142,13 +142,15 @@ main(int argc, char *argv[])
|
||||
uid_t uid, saved_uid;
|
||||
gid_t saved_gid, saved_gids[NGROUPS_MAX];
|
||||
int nsaved_gids;
|
||||
char *domain, *p, *ttyn, *pwprompt;
|
||||
char *domain, *p, *ttyn;
|
||||
const char *pwprompt;
|
||||
char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
|
||||
char localhost[MAXHOSTNAMELEN + 1];
|
||||
int need_chpass, require_chpass;
|
||||
int login_retries = DEFAULT_RETRIES,
|
||||
login_backoff = DEFAULT_BACKOFF;
|
||||
time_t pw_warntime = _PASSWORD_WARNDAYS * SECSPERDAY;
|
||||
char *loginname = NULL;
|
||||
#ifdef KERBEROS5
|
||||
krb5_error_code kerror;
|
||||
#endif
|
||||
@@ -236,14 +238,14 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
setproctitle(NULL);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (*argv) {
|
||||
username = *argv;
|
||||
username = loginname = *argv;
|
||||
ask = 0;
|
||||
} else
|
||||
ask = 1;
|
||||
@@ -315,18 +317,16 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
if (ask) {
|
||||
fflag = 0;
|
||||
getloginname();
|
||||
loginname = getloginname();
|
||||
}
|
||||
rootlogin = 0;
|
||||
#ifdef KERBEROS5
|
||||
if ((instance = strchr(username, '/')) != NULL)
|
||||
if ((instance = strchr(loginname, '/')) != NULL)
|
||||
*instance++ = '\0';
|
||||
else
|
||||
instance = "";
|
||||
instance = __UNCONST("");
|
||||
#endif
|
||||
if (strlen(username) > MAXLOGNAME)
|
||||
username[MAXLOGNAME] = '\0';
|
||||
|
||||
username = trimloginname(loginname);
|
||||
/*
|
||||
* Note if trying multiple user names; log failures for
|
||||
* previous user name, but don't bother logging one failure
|
||||
@@ -508,7 +508,7 @@ main(int argc, char *argv[])
|
||||
(void)printf("No home directory %s!\n", pwd->pw_dir);
|
||||
if (chdir("/") == -1)
|
||||
exit(EXIT_FAILURE);
|
||||
pwd->pw_dir = "/";
|
||||
pwd->pw_dir = __UNCONST("/");
|
||||
(void)printf("Logging in with home = \"/\".\n");
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ main(int argc, char *argv[])
|
||||
_PASSWORD_WARNDAYS * SECSPERDAY);
|
||||
#endif
|
||||
|
||||
(void)gettimeofday(&now, (struct timezone *)NULL);
|
||||
(void)gettimeofday(&now, NULL);
|
||||
if (pwd->pw_expire) {
|
||||
if (now.tv_sec >= pwd->pw_expire) {
|
||||
(void)printf("Sorry -- your account has expired.\n");
|
||||
@@ -583,10 +583,10 @@ main(int argc, char *argv[])
|
||||
|
||||
initgroups(username, pwd->pw_gid);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (nested == NULL && setlogin(pwd->pw_name) < 0)
|
||||
syslog(LOG_ERR, "setlogin() failure: %m");
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/* Discard permissions last so can't get killed and drop core. */
|
||||
if (rootlogin)
|
||||
@@ -596,7 +596,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
if (*pwd->pw_shell == '\0')
|
||||
pwd->pw_shell = _PATH_BSHELL;
|
||||
pwd->pw_shell = __UNCONST(_PATH_BSHELL);
|
||||
#ifdef LOGIN_CAP
|
||||
if ((shell = login_getcapstr(lc, "shell", NULL, NULL)) != NULL) {
|
||||
if ((shell = strdup(shell)) == NULL) {
|
||||
@@ -610,7 +610,7 @@ main(int argc, char *argv[])
|
||||
(void)setenv("HOME", pwd->pw_dir, 1);
|
||||
(void)setenv("SHELL", pwd->pw_shell, 1);
|
||||
if (term[0] == '\0') {
|
||||
char *tt = (char *)stypeof(tty);
|
||||
const char *tt = stypeof(tty);
|
||||
#ifdef LOGIN_CAP
|
||||
if (tt == NULL)
|
||||
tt = login_getcapstr(lc, "term", NULL, NULL);
|
||||
@@ -652,7 +652,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
if (!quietlog) {
|
||||
char *fname;
|
||||
const char *fname;
|
||||
#ifdef LOGIN_CAP
|
||||
fname = login_getcapstr(lc, "copyright", NULL, NULL);
|
||||
if (fname != NULL && access(fname, F_OK) == 0)
|
||||
|
||||
+10
-15
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: login_pam.c,v 1.20 2009/12/29 19:26:13 christos Exp $ */
|
||||
/* $NetBSD: login_pam.c,v 1.23 2013/10/18 20:47:06 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
__RCSID("$NetBSD: login_pam.c,v 1.20 2009/12/29 19:26:13 christos Exp $");
|
||||
__RCSID("$NetBSD: login_pam.c,v 1.23 2013/10/18 20:47:06 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -107,10 +107,9 @@ main(int argc, char *argv[])
|
||||
uid_t uid, saved_uid;
|
||||
gid_t saved_gid, saved_gids[NGROUPS_MAX];
|
||||
int nsaved_gids;
|
||||
char *domain, *p, *ttyn, *pwprompt;
|
||||
char *domain, *p, *ttyn;
|
||||
char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
|
||||
char localhost[MAXHOSTNAMELEN + 1];
|
||||
int need_chpass, require_chpass;
|
||||
int login_retries = DEFAULT_RETRIES,
|
||||
login_backoff = DEFAULT_BACKOFF;
|
||||
char *shell = NULL;
|
||||
@@ -126,9 +125,7 @@ main(int argc, char *argv[])
|
||||
char **pamenv;
|
||||
|
||||
tbuf[0] = '\0';
|
||||
pwprompt = NULL;
|
||||
nested = NULL;
|
||||
need_chpass = require_chpass = 0;
|
||||
|
||||
oabrt = signal(SIGABRT, SIG_IGN);
|
||||
oalrm = signal(SIGALRM, timedout);
|
||||
@@ -194,7 +191,7 @@ main(int argc, char *argv[])
|
||||
argv += optind;
|
||||
|
||||
if (*argv) {
|
||||
username = *argv;
|
||||
username = trimloginname(*argv);
|
||||
ask = 0;
|
||||
} else
|
||||
ask = 1;
|
||||
@@ -240,12 +237,10 @@ main(int argc, char *argv[])
|
||||
for (cnt = 0;; ask = 1) {
|
||||
if (ask) {
|
||||
fflag = 0;
|
||||
getloginname();
|
||||
username = trimloginname(getloginname());
|
||||
}
|
||||
rootlogin = 0;
|
||||
auth_passed = 0;
|
||||
if (strlen(username) > MAXLOGNAME)
|
||||
username[MAXLOGNAME] = '\0';
|
||||
|
||||
/*
|
||||
* Note if trying multiple user names; log failures for
|
||||
@@ -334,7 +329,7 @@ main(int argc, char *argv[])
|
||||
if (pam_err != PAM_SUCCESS)
|
||||
PAM_END("pam_get_item(PAM_USER)");
|
||||
|
||||
username = (char *)newuser;
|
||||
username = newuser;
|
||||
/*
|
||||
* Don't check for errors, because we don't want to give
|
||||
* out any information.
|
||||
@@ -441,7 +436,7 @@ skip_auth:
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pwd->pw_dir = "/";
|
||||
pwd->pw_dir = __UNCONST("/");
|
||||
(void)printf("Logging in with home = \"/\".\n");
|
||||
}
|
||||
|
||||
@@ -570,7 +565,7 @@ skip_auth:
|
||||
}
|
||||
|
||||
if (*pwd->pw_shell == '\0')
|
||||
pwd->pw_shell = _PATH_BSHELL;
|
||||
pwd->pw_shell = __UNCONST(_PATH_BSHELL);
|
||||
|
||||
shell = login_getcapstr(lc, "shell", pwd->pw_shell, pwd->pw_shell);
|
||||
if (*shell == '\0')
|
||||
@@ -584,7 +579,7 @@ skip_auth:
|
||||
(void)setenv("HOME", pwd->pw_dir, 1);
|
||||
(void)setenv("SHELL", pwd->pw_shell, 1);
|
||||
if (term[0] == '\0') {
|
||||
char *tt = (char *)stypeof(tty);
|
||||
const char *tt = stypeof(tty);
|
||||
|
||||
if (tt == NULL)
|
||||
tt = login_getcapstr(lc, "term", NULL, NULL);
|
||||
@@ -618,7 +613,7 @@ skip_auth:
|
||||
}
|
||||
|
||||
if (!quietlog) {
|
||||
char *fname;
|
||||
const char *fname;
|
||||
|
||||
fname = login_getcapstr(lc, "copyright", NULL, NULL);
|
||||
if (fname != NULL && access(fname, F_OK) == 0)
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: m4.1,v 1.23 2012/04/08 22:00:39 wiz Exp $
|
||||
.\" $NetBSD: m4.1,v 1.24 2013/07/20 21:40:00 wiz Exp $
|
||||
.\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1993
|
||||
@@ -483,9 +483,9 @@ Many other
|
||||
have dire size limitations with respect to buffer sizes.
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.An Ozan Yigit Aq oz@sis.yorku.ca
|
||||
.An Ozan Yigit Aq Mt oz@sis.yorku.ca
|
||||
and
|
||||
.An Richard A. O'Keefe Aq ok@goanna.cs.rmit.OZ.AU .
|
||||
.An Richard A. O'Keefe Aq Mt ok@goanna.cs.rmit.OZ.AU .
|
||||
.Pp
|
||||
GNU-m4 compatibility extensions by
|
||||
.An Marc Espie Aq espie@cvs.openbsd.org .
|
||||
.An Marc Espie Aq Mt espie@cvs.openbsd.org .
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/* $OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $ */
|
||||
/* $NetBSD: mdef.h,v 1.14 2011/03/05 16:37:50 christos Exp $ */
|
||||
/* $NetBSD: mdef.h,v 1.15 2013/10/18 20:19:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -127,8 +127,12 @@
|
||||
#define ALL 1
|
||||
#define TOP 0
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#define cycle for(;;)
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.55 2011/08/14 13:06:09 christos Exp $
|
||||
# @(#)Makefile 5.2 (Berkeley) 12/28/90
|
||||
|
||||
PROG= make
|
||||
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 trace.c var.c util.c
|
||||
SRCS+= strlist.c
|
||||
SRCS+= make_malloc.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 \
|
||||
lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \
|
||||
lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
|
||||
SRCS += lstPrev.c
|
||||
|
||||
# let people experiment for a bit
|
||||
USE_META ?= no
|
||||
.if ${USE_META:tl} != "no"
|
||||
SRCS+= meta.c
|
||||
CPPFLAGS+= -DUSE_META
|
||||
FILEMON_H ?= ${.CURDIR:H:H}/sys/dev/filemon/filemon.h
|
||||
.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
|
||||
COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# For MINIX
|
||||
CPPFLAGS+= -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP \
|
||||
-DHAVE_STRFTIME -DHAVE_VSNPRINTF -DUSE_SELECT
|
||||
|
||||
# Gross hack, but we assume i386 everywhere
|
||||
.if ${MACHINE_ARCH} == "i686"
|
||||
MACHINE_ARCH=i386
|
||||
.endif
|
||||
.if $(MACHINE) == "i686"
|
||||
MACHINE=i386
|
||||
.endif
|
||||
CPPFLAGS+= -DTARGET_MACHINE=\"${MACHINE}\" \
|
||||
-DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" \
|
||||
-DMAKE_MACHINE=\"${MACHINE}\" \
|
||||
-DMAKE_MACHINE_ARCH=\"${MACHINE_ARCH}\"
|
||||
|
||||
|
||||
.PATH: ${.CURDIR}/lst.lib
|
||||
.if make(install)
|
||||
SUBDIR= PSD.doc
|
||||
.endif
|
||||
.if make(obj) || make(clean)
|
||||
SUBDIR+= unit-tests
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.subdir.mk>
|
||||
|
||||
.ifdef TOOLDIR
|
||||
CPPFLAGS+= -DMAKE_NATIVE
|
||||
COPTS.var.c += -Wno-cast-qual
|
||||
COPTS.job.c += -Wno-format-nonliteral
|
||||
COPTS.parse.c += -Wno-format-nonliteral
|
||||
COPTS.var.c += -Wno-format-nonliteral
|
||||
|
||||
# this is a native netbsd build,
|
||||
# use libutil rather than the local emalloc etc.
|
||||
CPPFLAGS+= -DUSE_EMALLOC
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
.endif
|
||||
|
||||
# A simple unit-test driver to help catch regressions
|
||||
accept test:
|
||||
cd ${.CURDIR}/unit-tests && ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
|
||||
+14
-10
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $ */
|
||||
/* $NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $");
|
||||
__RCSID("$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -329,18 +329,23 @@ again:
|
||||
* We need to pass the command off to the shell, typically
|
||||
* because the command contains a "meta" character.
|
||||
*/
|
||||
static const char *shargv[4];
|
||||
static const char *shargv[5];
|
||||
int shargc;
|
||||
|
||||
shargv[0] = shellPath;
|
||||
shargc = 0;
|
||||
shargv[shargc++] = shellPath;
|
||||
/*
|
||||
* The following work for any of the builtin shell specs.
|
||||
*/
|
||||
if (errCheck && shellErrFlag) {
|
||||
shargv[shargc++] = shellErrFlag;
|
||||
}
|
||||
if (DEBUG(SHELL))
|
||||
shargv[1] = "-xc";
|
||||
shargv[shargc++] = "-xc";
|
||||
else
|
||||
shargv[1] = "-c";
|
||||
shargv[2] = cmd;
|
||||
shargv[3] = NULL;
|
||||
shargv[shargc++] = "-c";
|
||||
shargv[shargc++] = cmd;
|
||||
shargv[shargc++] = NULL;
|
||||
av = shargv;
|
||||
argc = 0;
|
||||
bp = NULL;
|
||||
@@ -374,7 +379,6 @@ again:
|
||||
Fatal("Could not fork");
|
||||
}
|
||||
if (cpid == 0) {
|
||||
Check_Cwd(av);
|
||||
Var_ExportVars();
|
||||
#ifdef USE_META
|
||||
if (useMeta) {
|
||||
|
||||
+20
-17
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $ */
|
||||
/* $NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $";
|
||||
static char rcsid[] = "$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $");
|
||||
__RCSID("$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -1227,7 +1227,8 @@ do_Cond_EvalExpression(Boolean *value)
|
||||
int
|
||||
Cond_Eval(char *line)
|
||||
{
|
||||
#define MAXIF 128 /* maximum depth of .if'ing */
|
||||
#define MAXIF 128 /* maximum depth of .if'ing */
|
||||
#define MAXIF_BUMP 32 /* how much to grow by */
|
||||
enum if_states {
|
||||
IF_ACTIVE, /* .if or .elif part active */
|
||||
ELSE_ACTIVE, /* .else part active */
|
||||
@@ -1235,7 +1236,8 @@ Cond_Eval(char *line)
|
||||
SKIP_TO_ELSE, /* has been true, but not seen '.else' */
|
||||
SKIP_TO_ENDIF /* nothing else to execute */
|
||||
};
|
||||
static enum if_states cond_state[MAXIF + 1] = { IF_ACTIVE };
|
||||
static enum if_states *cond_state = NULL;
|
||||
static unsigned int max_if_depth = MAXIF;
|
||||
|
||||
const struct If *ifp;
|
||||
Boolean isElif;
|
||||
@@ -1244,7 +1246,10 @@ Cond_Eval(char *line)
|
||||
enum if_states state;
|
||||
|
||||
level = PARSE_FATAL;
|
||||
|
||||
if (!cond_state) {
|
||||
cond_state = bmake_malloc(max_if_depth * sizeof(*cond_state));
|
||||
cond_state[0] = IF_ACTIVE;
|
||||
}
|
||||
/* skip leading character (the '.') and any whitespace */
|
||||
for (line++; *line == ' ' || *line == '\t'; line++)
|
||||
continue;
|
||||
@@ -1261,8 +1266,6 @@ Cond_Eval(char *line)
|
||||
}
|
||||
/* Return state for previous conditional */
|
||||
cond_depth--;
|
||||
if (cond_depth > MAXIF)
|
||||
return COND_SKIP;
|
||||
return cond_state[cond_depth] <= ELSE_ACTIVE ? COND_PARSE : COND_SKIP;
|
||||
}
|
||||
|
||||
@@ -1275,8 +1278,6 @@ Cond_Eval(char *line)
|
||||
return COND_PARSE;
|
||||
}
|
||||
|
||||
if (cond_depth > MAXIF)
|
||||
return COND_SKIP;
|
||||
state = cond_state[cond_depth];
|
||||
switch (state) {
|
||||
case SEARCH_FOR_ELIF:
|
||||
@@ -1325,9 +1326,6 @@ Cond_Eval(char *line)
|
||||
Parse_Error(level, "if-less elif");
|
||||
return COND_PARSE;
|
||||
}
|
||||
if (cond_depth > MAXIF)
|
||||
/* Error reported when we saw the .if ... */
|
||||
return COND_SKIP;
|
||||
state = cond_state[cond_depth];
|
||||
if (state == SKIP_TO_ENDIF || state == ELSE_ACTIVE) {
|
||||
Parse_Error(PARSE_WARNING, "extra elif");
|
||||
@@ -1341,10 +1339,15 @@ Cond_Eval(char *line)
|
||||
}
|
||||
} else {
|
||||
/* Normal .if */
|
||||
if (cond_depth >= MAXIF) {
|
||||
cond_depth++;
|
||||
Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.", MAXIF);
|
||||
return COND_SKIP;
|
||||
if (cond_depth + 1 >= max_if_depth) {
|
||||
/*
|
||||
* This is rare, but not impossible.
|
||||
* In meta mode, dirdeps.mk (only runs at level 0)
|
||||
* can need more than the default.
|
||||
*/
|
||||
max_if_depth += MAXIF_BUMP;
|
||||
cond_state = bmake_realloc(cond_state, max_if_depth *
|
||||
sizeof(*cond_state));
|
||||
}
|
||||
state = cond_state[cond_depth];
|
||||
cond_depth++;
|
||||
|
||||
+9
-6
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $";
|
||||
static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $");
|
||||
__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -145,6 +145,7 @@ __RCSID("$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $");
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
#include "dir.h"
|
||||
#include "job.h"
|
||||
|
||||
/*
|
||||
* A search path consists of a Lst of Path structures. A Path structure
|
||||
@@ -1463,9 +1464,11 @@ Dir_MTime(GNode *gn, Boolean recheck)
|
||||
* so that we give that to the compiler.
|
||||
*/
|
||||
gn->path = bmake_strdup(fullName);
|
||||
fprintf(stdout,
|
||||
"%s: ignoring stale %s for %s, found %s\n",
|
||||
progname, makeDependfile, gn->name, fullName);
|
||||
if (!Job_RunTarget(".STALE", gn->fname))
|
||||
fprintf(stdout,
|
||||
"%s: %s, %d: ignoring stale %s for %s, "
|
||||
"found %s\n", progname, gn->fname, gn->lineno,
|
||||
makeDependfile, gn->name, fullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hash.c,v 1.19 2009/01/24 10:59:09 dsl Exp $ */
|
||||
/* $NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: hash.c,v 1.19 2009/01/24 10:59:09 dsl Exp $";
|
||||
static char rcsid[] = "$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: hash.c,v 1.19 2009/01/24 10:59:09 dsl Exp $");
|
||||
__RCSID("$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -221,6 +221,9 @@ Hash_FindEntry(Hash_Table *t, const char *key)
|
||||
unsigned h;
|
||||
const char *p;
|
||||
|
||||
if (t == NULL || t->bucketPtr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (h = 0, p = key; *p;)
|
||||
h = (h << 5) - h + *p++;
|
||||
p = key;
|
||||
|
||||
+120
-58
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $ */
|
||||
/* $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -139,6 +139,7 @@ __RCSID("$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $");
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef USE_SELECT
|
||||
@@ -299,6 +300,7 @@ static Shell *commandShell = &shells[DEFSHELL_INDEX]; /* this is the shell to
|
||||
const char *shellPath = NULL, /* full pathname of
|
||||
* executable image */
|
||||
*shellName = NULL; /* last component of shell */
|
||||
char *shellErrFlag = NULL;
|
||||
static const char *shellArgv = NULL; /* Custom shell args */
|
||||
|
||||
|
||||
@@ -330,7 +332,7 @@ static Job childExitJob; /* child exit pseudo-job */
|
||||
|
||||
#define TARG_FMT "%s %s ---\n" /* Default format */
|
||||
#define MESSAGE(fp, gn) \
|
||||
if (maxJobs != 1) \
|
||||
if (maxJobs != 1 && targPrefix && *targPrefix) \
|
||||
(void)fprintf(fp, TARG_FMT, targPrefix, gn->name)
|
||||
|
||||
static sigset_t caught_signals; /* Set of signals we handle */
|
||||
@@ -400,6 +402,15 @@ JobCreatePipe(Job *job, int minfd)
|
||||
if (pipe(job->jobPipe) == -1)
|
||||
Punt("Cannot create pipe: %s", strerror(errno));
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
/* Avoid using low numbered fds */
|
||||
fd = fcntl(job->jobPipe[i], F_DUPFD, minfd);
|
||||
if (fd != -1) {
|
||||
close(job->jobPipe[i]);
|
||||
job->jobPipe[i] = fd;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set close-on-exec flag for both */
|
||||
(void)fcntl(job->jobPipe[0], F_SETFD, 1);
|
||||
(void)fcntl(job->jobPipe[1], F_SETFD, 1);
|
||||
@@ -412,15 +423,6 @@ JobCreatePipe(Job *job, int minfd)
|
||||
*/
|
||||
fcntl(job->jobPipe[0], F_SETFL,
|
||||
fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
/* Avoid using low numbered fds */
|
||||
fd = fcntl(job->jobPipe[i], F_DUPFD, minfd);
|
||||
if (fd != -1) {
|
||||
close(job->jobPipe[i]);
|
||||
job->jobPipe[i] = fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -477,7 +479,8 @@ JobCondPassSig(int signo)
|
||||
static void
|
||||
JobChildSig(int signo MAKE_ATTR_UNUSED)
|
||||
{
|
||||
write(childExitJob.outPipe, CHILD_EXIT, 1);
|
||||
while (write(childExitJob.outPipe, CHILD_EXIT, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -504,7 +507,9 @@ JobContinueSig(int signo MAKE_ATTR_UNUSED)
|
||||
* Defer sending to SIGCONT to our stopped children until we return
|
||||
* from the signal handler.
|
||||
*/
|
||||
write(childExitJob.outPipe, DO_JOB_RESUME, 1);
|
||||
while (write(childExitJob.outPipe, DO_JOB_RESUME, 1) == -1 &&
|
||||
errno == EAGAIN)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -675,7 +680,6 @@ JobPrintCommand(void *cmdp, void *jobp)
|
||||
char *escCmd = NULL; /* Command with quotes/backticks escaped */
|
||||
char *cmd = (char *)cmdp;
|
||||
Job *job = (Job *)jobp;
|
||||
char *cp, *tmp;
|
||||
int i, j;
|
||||
|
||||
noSpecials = NoExecute(job->node);
|
||||
@@ -847,11 +851,6 @@ JobPrintCommand(void *cmdp, void *jobp)
|
||||
job->flags |= JOB_TRACED;
|
||||
}
|
||||
|
||||
if ((cp = Check_Cwd_Cmd(cmd)) != NULL) {
|
||||
DBPRINTF("test -d %s && ", cp);
|
||||
DBPRINTF("cd %s\n", cp);
|
||||
}
|
||||
|
||||
DBPRINTF(cmdTemplate, cmd);
|
||||
free(cmdStart);
|
||||
if (escCmd)
|
||||
@@ -871,10 +870,6 @@ JobPrintCommand(void *cmdp, void *jobp)
|
||||
if (shutUp && commandShell->hasEchoCtl) {
|
||||
DBPRINTF("%s\n", commandShell->echoOn);
|
||||
}
|
||||
if (cp != NULL) {
|
||||
DBPRINTF("test -d %s && ", cp);
|
||||
DBPRINTF("cd %s\n", Var_Value(".OBJDIR", VAR_GLOBAL, &tmp));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1171,7 +1166,8 @@ Job_Touch(GNode *gn, Boolean silent)
|
||||
*/
|
||||
if (read(streamID, &c, 1) == 1) {
|
||||
(void)lseek(streamID, (off_t)0, SEEK_SET);
|
||||
(void)write(streamID, &c, 1);
|
||||
while (write(streamID, &c, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
}
|
||||
|
||||
(void)close(streamID);
|
||||
@@ -1237,8 +1233,10 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
|
||||
static const char msg[] = ": don't know how to make";
|
||||
|
||||
if (gn->flags & FROM_DEPEND) {
|
||||
fprintf(stdout, "%s: ignoring stale %s for %s\n",
|
||||
progname, makeDependfile, gn->name);
|
||||
if (!Job_RunTarget(".STALE", gn->fname))
|
||||
fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n",
|
||||
progname, gn->fname, gn->lineno, makeDependfile,
|
||||
gn->name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1381,11 +1379,13 @@ JobExec(Job *job, char **argv)
|
||||
* we can kill it and all its descendants in one fell swoop,
|
||||
* by killing its process family, but not commit suicide.
|
||||
*/
|
||||
#if defined(MAKE_NATIVE) || defined(HAVE_SETPGID)
|
||||
#if defined(SYSV) || defined(__minix)
|
||||
/* XXX: dsl - I'm sure this should be setpgrp()... */
|
||||
(void)setsid();
|
||||
#else
|
||||
(void)setpgid(0, getpid());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Var_ExportVars();
|
||||
@@ -2051,31 +2051,45 @@ Job_CatchOutput(void)
|
||||
(void)fflush(stdout);
|
||||
|
||||
/* The first fd in the list is the job token pipe */
|
||||
nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC);
|
||||
do {
|
||||
nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC);
|
||||
} while (nready < 0 && errno == EINTR);
|
||||
|
||||
if (nready < 0 || readyfd(&childExitJob)) {
|
||||
if (nready < 0)
|
||||
Punt("poll: %s", strerror(errno));
|
||||
|
||||
if (nready > 0 && readyfd(&childExitJob)) {
|
||||
char token = 0;
|
||||
nready -= 1;
|
||||
(void)read(childExitJob.inPipe, &token, 1);
|
||||
if (token == DO_JOB_RESUME[0])
|
||||
/* Complete relay requested from our SIGCONT handler */
|
||||
JobRestartJobs();
|
||||
Job_CatchChildren();
|
||||
ssize_t count;
|
||||
count = read(childExitJob.inPipe, &token, 1);
|
||||
switch (count) {
|
||||
case 0:
|
||||
Punt("unexpected eof on token pipe");
|
||||
case -1:
|
||||
Punt("token pipe read: %s", strerror(errno));
|
||||
case 1:
|
||||
if (token == DO_JOB_RESUME[0])
|
||||
/* Complete relay requested from our SIGCONT handler */
|
||||
JobRestartJobs();
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
--nready;
|
||||
}
|
||||
|
||||
if (nready <= 0)
|
||||
return;
|
||||
|
||||
if (wantToken && readyfd(&tokenWaitJob))
|
||||
nready--;
|
||||
Job_CatchChildren();
|
||||
if (nready == 0)
|
||||
return;
|
||||
|
||||
for (i = 2; i < nfds; i++) {
|
||||
if (!fds[i].revents)
|
||||
continue;
|
||||
job = jobfds[i];
|
||||
if (job->job_state != JOB_ST_RUNNING)
|
||||
continue;
|
||||
JobDoOutput(job, FALSE);
|
||||
if (job->job_state == JOB_ST_RUNNING)
|
||||
JobDoOutput(job, FALSE);
|
||||
if (--nready == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2123,6 +2137,24 @@ Shell_Init(void)
|
||||
if (commandShell->echo == NULL) {
|
||||
commandShell->echo = "";
|
||||
}
|
||||
if (commandShell->hasErrCtl && *commandShell->exit) {
|
||||
if (shellErrFlag &&
|
||||
strcmp(commandShell->exit, &shellErrFlag[1]) != 0) {
|
||||
free(shellErrFlag);
|
||||
shellErrFlag = NULL;
|
||||
}
|
||||
if (!shellErrFlag) {
|
||||
int n = strlen(commandShell->exit) + 2;
|
||||
|
||||
shellErrFlag = bmake_malloc(n);
|
||||
if (shellErrFlag) {
|
||||
snprintf(shellErrFlag, n, "-%s", commandShell->exit);
|
||||
}
|
||||
}
|
||||
} else if (shellErrFlag) {
|
||||
free(shellErrFlag);
|
||||
shellErrFlag = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -2166,8 +2198,7 @@ Job_SetPrefix(void)
|
||||
void
|
||||
Job_Init(void)
|
||||
{
|
||||
GNode *begin; /* node for commands to do at the very start */
|
||||
|
||||
Job_SetPrefix();
|
||||
/* Allocate space for all the job info */
|
||||
job_table = bmake_malloc(maxJobs * sizeof *job_table);
|
||||
memset(job_table, 0, maxJobs * sizeof *job_table);
|
||||
@@ -2243,15 +2274,7 @@ Job_Init(void)
|
||||
ADDSIG(SIGCONT, JobContinueSig)
|
||||
#undef ADDSIG
|
||||
|
||||
begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
|
||||
|
||||
if (begin != NULL) {
|
||||
JobRun(begin);
|
||||
if (begin->made == ERROR) {
|
||||
PrintOnError(begin, "\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
(void)Job_RunTarget(".BEGIN", NULL);
|
||||
postCommands = Targ_FindNode(".END", TARG_CREATE);
|
||||
}
|
||||
|
||||
@@ -2477,6 +2500,8 @@ Job_ParseShell(char *line)
|
||||
commandShell = bmake_malloc(sizeof(Shell));
|
||||
*commandShell = newShell;
|
||||
}
|
||||
/* this will take care of shellErrFlag */
|
||||
Shell_Init();
|
||||
}
|
||||
|
||||
if (commandShell->echoOn && commandShell->echoOff) {
|
||||
@@ -2787,7 +2812,8 @@ JobTokenAdd(void)
|
||||
if (DEBUG(JOB))
|
||||
fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
|
||||
getpid(), aborting, JOB_TOKENS[aborting]);
|
||||
write(tokenWaitJob.outPipe, &tok, 1);
|
||||
while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -2808,6 +2834,8 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1)
|
||||
/* Pipe passed in from parent */
|
||||
tokenWaitJob.inPipe = jp_0;
|
||||
tokenWaitJob.outPipe = jp_1;
|
||||
(void)fcntl(jp_0, F_SETFD, 1);
|
||||
(void)fcntl(jp_1, F_SETFD, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2900,13 +2928,15 @@ Job_TokenWithdraw(void)
|
||||
while (read(tokenWaitJob.inPipe, &tok1, 1) == 1)
|
||||
continue;
|
||||
/* And put the stopper back */
|
||||
write(tokenWaitJob.outPipe, &tok, 1);
|
||||
while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
Fatal("A failure has been detected in another branch of the parallel make");
|
||||
}
|
||||
|
||||
if (count == 1 && jobTokensRunning == 0)
|
||||
/* We didn't want the token really */
|
||||
write(tokenWaitJob.outPipe, &tok, 1);
|
||||
while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
|
||||
jobTokensRunning++;
|
||||
if (DEBUG(JOB))
|
||||
@@ -2914,6 +2944,38 @@ Job_TokenWithdraw(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Job_RunTarget --
|
||||
* Run the named target if found. If a filename is specified, then
|
||||
* set that to the sources.
|
||||
*
|
||||
* Results:
|
||||
* None
|
||||
*
|
||||
* Side Effects:
|
||||
* exits if the target fails.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Job_RunTarget(const char *target, const char *fname) {
|
||||
GNode *gn = Targ_FindNode(target, TARG_NOCREATE);
|
||||
|
||||
if (gn == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (fname)
|
||||
Var_Set(ALLSRC, fname, gn, 0);
|
||||
|
||||
JobRun(gn);
|
||||
if (gn->made == ERROR) {
|
||||
PrintOnError(gn, "\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef USE_SELECT
|
||||
int
|
||||
emul_poll(struct pollfd *fd, int nfd, int timeout)
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.h,v 1.40 2010/09/13 15:36:57 sjg Exp $ */
|
||||
/* $NetBSD: job.h,v 1.42 2013/07/05 22:14:56 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@@ -243,6 +243,7 @@ typedef struct Shell {
|
||||
|
||||
extern const char *shellPath;
|
||||
extern const char *shellName;
|
||||
extern char *shellErrFlag;
|
||||
|
||||
extern int jobTokensRunning; /* tokens currently "out" */
|
||||
extern int maxJobs; /* Max jobs we can run */
|
||||
@@ -268,5 +269,6 @@ void Job_TokenReturn(void);
|
||||
Boolean Job_TokenWithdraw(void);
|
||||
void Job_ServerStart(int, int, int);
|
||||
void Job_SetPrefix(void);
|
||||
Boolean Job_RunTarget(const char *, const char *);
|
||||
|
||||
#endif /* _JOB_H_ */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lstMember.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
/* $NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -33,14 +33,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstMember.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
static char rcsid[] = "$NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstMember.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
__RCSID("$NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -58,6 +58,9 @@ Lst_Member(Lst l, void *d)
|
||||
List list = l;
|
||||
ListNode lNode;
|
||||
|
||||
if (list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
lNode = list->firstPtr;
|
||||
if (lNode == NULL) {
|
||||
return NULL;
|
||||
|
||||
+120
-224
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $ */
|
||||
/* $NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -117,19 +117,21 @@ __RCSID("$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $");
|
||||
#include <sys/time.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef MAKE_NATIVE
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
@@ -165,6 +167,7 @@ Boolean noRecursiveExecute; /* -N flag */
|
||||
Boolean keepgoing; /* -k flag */
|
||||
Boolean queryFlag; /* -q flag */
|
||||
Boolean touchFlag; /* -t flag */
|
||||
Boolean enterFlag; /* -w flag */
|
||||
Boolean ignoreErrors; /* -i flag */
|
||||
Boolean beSilent; /* -s flag */
|
||||
Boolean oldVars; /* variable substitution style */
|
||||
@@ -176,7 +179,6 @@ Boolean varNoExportEnv; /* -X flag */
|
||||
Boolean doing_depend; /* Set while reading .depend */
|
||||
static Boolean jobsRunning; /* TRUE if the jobs might be running */
|
||||
static const char * tracefile;
|
||||
static char * Check_Cwd_av(int, char **, int);
|
||||
static void MainParseArgs(int, char **);
|
||||
static int ReadMakefile(const void *, const void *);
|
||||
static void usage(void) MAKE_ATTR_DEAD;
|
||||
@@ -187,11 +189,44 @@ char curdir[MAXPATHLEN + 1]; /* Startup directory */
|
||||
char *progname; /* the program name */
|
||||
char *makeDependfile;
|
||||
pid_t myPid;
|
||||
int makelevel;
|
||||
|
||||
Boolean forceJobs = FALSE;
|
||||
|
||||
extern Lst parseIncPath;
|
||||
|
||||
/*
|
||||
* For compatibility with the POSIX version of MAKEFLAGS that includes
|
||||
* all the options with out -, convert flags to -f -l -a -g -s.
|
||||
*/
|
||||
static char *
|
||||
explode(const char *flags)
|
||||
{
|
||||
size_t len;
|
||||
char *nf, *st;
|
||||
const char *f;
|
||||
|
||||
if (flags == NULL)
|
||||
return NULL;
|
||||
|
||||
for (f = flags; *f; f++)
|
||||
if (!isalpha((unsigned char)*f))
|
||||
break;
|
||||
|
||||
if (*f)
|
||||
return bmake_strdup(flags);
|
||||
|
||||
len = strlen(flags);
|
||||
st = nf = bmake_malloc(len * 3 + 1);
|
||||
while (*flags) {
|
||||
*nf++ = '-';
|
||||
*nf++ = *flags++;
|
||||
*nf++ = ' ';
|
||||
}
|
||||
*nf = '\0';
|
||||
return st;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_debug_options(const char *argvalue)
|
||||
{
|
||||
@@ -344,7 +379,7 @@ MainParseArgs(int argc, char **argv)
|
||||
Boolean inOption, dashDash = FALSE;
|
||||
char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */
|
||||
|
||||
#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrst"
|
||||
#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstw"
|
||||
/* Can't actually use getopt(3) because rescanning is not portable */
|
||||
|
||||
getopt_def = OPTFLAGS;
|
||||
@@ -552,6 +587,10 @@ rearg:
|
||||
touchFlag = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL);
|
||||
break;
|
||||
case 'w':
|
||||
enterFlag = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-w", VAR_GLOBAL);
|
||||
break;
|
||||
case '-':
|
||||
dashDash = TRUE;
|
||||
break;
|
||||
@@ -742,7 +781,7 @@ MakeMode(const char *mode)
|
||||
}
|
||||
#if USE_META
|
||||
if (strstr(mode, "meta"))
|
||||
meta_init(mode);
|
||||
meta_mode_init(mode);
|
||||
#endif
|
||||
}
|
||||
if (mp)
|
||||
@@ -772,7 +811,7 @@ main(int argc, char **argv)
|
||||
Lst targs; /* target nodes to create -- passed to Make_Init */
|
||||
Boolean outOfDate = FALSE; /* FALSE if all targets up to date */
|
||||
struct stat sb, sa;
|
||||
char *p1, *path, *pwd;
|
||||
char *p1, *path;
|
||||
char mdpath[MAXPATHLEN];
|
||||
const char *machine = getenv("MACHINE");
|
||||
const char *machine_arch = getenv("MACHINE_ARCH");
|
||||
@@ -783,9 +822,7 @@ main(int argc, char **argv)
|
||||
static char defsyspath[] = _PATH_DEFSYSPATH;
|
||||
char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */
|
||||
struct timeval rightnow; /* to initialize random seed */
|
||||
#ifdef MAKE_NATIVE
|
||||
struct utsname utsname;
|
||||
#endif
|
||||
|
||||
/* default to writing debug to stderr */
|
||||
debug_file = stderr;
|
||||
@@ -804,7 +841,7 @@ main(int argc, char **argv)
|
||||
progname++;
|
||||
else
|
||||
progname = argv[0];
|
||||
#if defined(RLIMIT_NOFILE) && !defined(__minix)
|
||||
#if !defined(__minix) && (defined(MAKE_NATIVE) || (defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)))
|
||||
/*
|
||||
* get rid of resource limit on file descriptors
|
||||
*/
|
||||
@@ -818,6 +855,12 @@ main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uname(&utsname) == -1) {
|
||||
(void)fprintf(stderr, "%s: uname failed (%s).\n", progname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name of this type of MACHINE from utsname
|
||||
* so we can share an executable for similar machines.
|
||||
@@ -828,11 +871,6 @@ main(int argc, char **argv)
|
||||
*/
|
||||
if (!machine) {
|
||||
#ifdef MAKE_NATIVE
|
||||
if (uname(&utsname) == -1) {
|
||||
(void)fprintf(stderr, "%s: uname failed (%s).\n", progname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
machine = utsname.machine;
|
||||
#else
|
||||
#ifdef MAKE_MACHINE
|
||||
@@ -844,6 +882,20 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!machine_arch) {
|
||||
#if defined(MAKE_NATIVE) && !defined(__minix)
|
||||
static char machine_arch_buf[sizeof(utsname.machine)];
|
||||
const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
|
||||
size_t len = sizeof(machine_arch_buf);
|
||||
|
||||
if (sysctl(mib, __arraycount(mib), machine_arch_buf,
|
||||
&len, NULL, 0) < 0) {
|
||||
(void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
|
||||
machine_arch = machine_arch_buf;
|
||||
#else
|
||||
#ifndef MACHINE_ARCH
|
||||
#ifdef MAKE_MACHINE_ARCH
|
||||
machine_arch = MAKE_MACHINE_ARCH;
|
||||
@@ -852,6 +904,7 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
#else
|
||||
machine_arch = MACHINE_ARCH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -862,6 +915,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
Var_Init(); /* Initialize the lists of variables for
|
||||
* parsing arguments */
|
||||
Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0);
|
||||
Var_Set("MACHINE", machine, VAR_GLOBAL, 0);
|
||||
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0);
|
||||
#ifdef MAKE_VERSION
|
||||
@@ -935,32 +989,43 @@ main(int argc, char **argv)
|
||||
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
|
||||
Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
|
||||
Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);
|
||||
/* some makefiles need to know this */
|
||||
Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD, 0);
|
||||
|
||||
/*
|
||||
* Set some other useful macros
|
||||
*/
|
||||
{
|
||||
char tmp[64];
|
||||
const char *ep;
|
||||
char tmp[64], *ep;
|
||||
|
||||
if (!(ep = getenv(MAKE_LEVEL))) {
|
||||
ep = "0";
|
||||
}
|
||||
Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
|
||||
makelevel = ((ep = getenv(MAKE_LEVEL_ENV)) && *ep) ? atoi(ep) : 0;
|
||||
if (makelevel < 0)
|
||||
makelevel = 0;
|
||||
snprintf(tmp, sizeof(tmp), "%d", makelevel);
|
||||
Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0);
|
||||
snprintf(tmp, sizeof(tmp), "%u", myPid);
|
||||
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
|
||||
snprintf(tmp, sizeof(tmp), "%u", getppid());
|
||||
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
|
||||
}
|
||||
Job_SetPrefix();
|
||||
if (makelevel > 0) {
|
||||
char pn[1024];
|
||||
snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel);
|
||||
progname = bmake_strdup(pn);
|
||||
}
|
||||
|
||||
#ifdef USE_META
|
||||
meta_init();
|
||||
#endif
|
||||
/*
|
||||
* First snag any flags out of the MAKE environment variable.
|
||||
* (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
|
||||
* in a different format).
|
||||
*/
|
||||
#ifdef POSIX
|
||||
Main_ParseArgLine(getenv("MAKEFLAGS"));
|
||||
p1 = explode(getenv("MAKEFLAGS"));
|
||||
Main_ParseArgLine(p1);
|
||||
free(p1);
|
||||
#else
|
||||
Main_ParseArgLine(getenv("MAKE"));
|
||||
#endif
|
||||
@@ -977,6 +1042,9 @@ main(int argc, char **argv)
|
||||
|
||||
MainParseArgs(argc, argv);
|
||||
|
||||
if (enterFlag)
|
||||
printf("%s: Entering directory `%s'\n", progname, curdir);
|
||||
|
||||
/*
|
||||
* Verify that cwd is sane.
|
||||
*/
|
||||
@@ -997,17 +1065,23 @@ main(int argc, char **argv)
|
||||
* So, to stop it breaking this case only, we ignore PWD if
|
||||
* MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains a transform.
|
||||
*/
|
||||
if (!ignorePWD &&
|
||||
(pwd = getenv("PWD")) != NULL &&
|
||||
getenv("MAKEOBJDIRPREFIX") == NULL) {
|
||||
const char *makeobjdir = getenv("MAKEOBJDIR");
|
||||
#ifndef NO_PWD_OVERRIDE
|
||||
if (!ignorePWD) {
|
||||
char *pwd;
|
||||
|
||||
if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
|
||||
if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&
|
||||
sa.st_dev == sb.st_dev)
|
||||
(void)strncpy(curdir, pwd, MAXPATHLEN);
|
||||
if ((pwd = getenv("PWD")) != NULL &&
|
||||
getenv("MAKEOBJDIRPREFIX") == NULL) {
|
||||
const char *makeobjdir = getenv("MAKEOBJDIR");
|
||||
|
||||
if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
|
||||
if (stat(pwd, &sb) == 0 &&
|
||||
sa.st_ino == sb.st_ino &&
|
||||
sa.st_dev == sb.st_dev)
|
||||
(void)strncpy(curdir, pwd, MAXPATHLEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
|
||||
|
||||
/*
|
||||
@@ -1165,8 +1239,6 @@ main(int argc, char **argv)
|
||||
jp_0, jp_1, maxJobs, maxJobTokens, compatMake);
|
||||
|
||||
Main_ExportMAKEFLAGS(TRUE); /* initial export */
|
||||
|
||||
Check_Cwd_av(0, NULL, 0); /* initialize it */
|
||||
|
||||
|
||||
/*
|
||||
@@ -1295,6 +1367,9 @@ main(int argc, char **argv)
|
||||
|
||||
Trace_Log(MAKEEND, 0);
|
||||
|
||||
if (enterFlag)
|
||||
printf("%s: Leaving directory `%s'\n", progname, curdir);
|
||||
|
||||
Suff_End();
|
||||
Targ_End();
|
||||
Arch_End();
|
||||
@@ -1327,7 +1402,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
|
||||
|
||||
if (!strcmp(fname, "-")) {
|
||||
Parse_File(NULL /*stdin*/, -1);
|
||||
Var_Set("MAKEFILE", "", VAR_GLOBAL, 0);
|
||||
Var_Set("MAKEFILE", "", VAR_INTERNAL, 0);
|
||||
} else {
|
||||
/* if we've chdir'd, rebuild the path name */
|
||||
if (strcmp(curdir, objdir) && *fname != '/') {
|
||||
@@ -1376,7 +1451,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
|
||||
*/
|
||||
found:
|
||||
if (!doing_depend)
|
||||
Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0);
|
||||
Var_Set("MAKEFILE", fname, VAR_INTERNAL, 0);
|
||||
Parse_File(fname, fd);
|
||||
}
|
||||
free(path);
|
||||
@@ -1384,190 +1459,6 @@ found:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If MAKEOBJDIRPREFIX is in use, make ends up not in .CURDIR
|
||||
* in situations that would not arrise with ./obj (links or not).
|
||||
* This tends to break things like:
|
||||
*
|
||||
* build:
|
||||
* ${MAKE} includes
|
||||
*
|
||||
* This function spots when ${.MAKE:T} or ${.MAKE} is a command (as
|
||||
* opposed to an argument) in a command line and if so returns
|
||||
* ${.CURDIR} so caller can chdir() so that the assumptions made by
|
||||
* the Makefile hold true.
|
||||
*
|
||||
* If ${.MAKE} does not contain any '/', then ${.MAKE:T} is skipped.
|
||||
*
|
||||
* The chdir() only happens in the child process, and does nothing if
|
||||
* MAKEOBJDIRPREFIX and MAKEOBJDIR are not in the environment so it
|
||||
* should not break anything. Also if NOCHECKMAKECHDIR is set we
|
||||
* do nothing - to ensure historic semantics can be retained.
|
||||
*/
|
||||
static int Check_Cwd_Off = 0;
|
||||
|
||||
static char *
|
||||
Check_Cwd_av(int ac, char **av, int copy)
|
||||
{
|
||||
static char *make[4];
|
||||
static char *cur_dir = NULL;
|
||||
char **mp;
|
||||
char *cp;
|
||||
int is_cmd, next_cmd;
|
||||
int i;
|
||||
int n;
|
||||
|
||||
if (Check_Cwd_Off) {
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "check_cwd: check is off.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (make[0] == NULL) {
|
||||
if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) {
|
||||
Check_Cwd_Off = 1;
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "check_cwd: turning check off.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
make[1] = Var_Value(".MAKE", VAR_GLOBAL, &cp);
|
||||
if ((make[0] = strrchr(make[1], '/')) == NULL) {
|
||||
make[0] = make[1];
|
||||
make[1] = NULL;
|
||||
} else
|
||||
++make[0];
|
||||
make[2] = NULL;
|
||||
cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
|
||||
}
|
||||
if (ac == 0 || av == NULL) {
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "check_cwd: empty command.\n");
|
||||
return NULL; /* initialization only */
|
||||
}
|
||||
|
||||
if (getenv("MAKEOBJDIR") == NULL &&
|
||||
getenv("MAKEOBJDIRPREFIX") == NULL) {
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "check_cwd: no obj dirs.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
next_cmd = 1;
|
||||
for (i = 0; i < ac; ++i) {
|
||||
is_cmd = next_cmd;
|
||||
|
||||
n = strlen(av[i]);
|
||||
cp = &(av[i])[n - 1];
|
||||
if (strspn(av[i], "|&;") == (size_t)n) {
|
||||
next_cmd = 1;
|
||||
continue;
|
||||
} else if (*cp == ';' || *cp == '&' || *cp == '|' || *cp == ')') {
|
||||
next_cmd = 1;
|
||||
if (copy) {
|
||||
do {
|
||||
*cp-- = '\0';
|
||||
} while (*cp == ';' || *cp == '&' || *cp == '|' ||
|
||||
*cp == ')' || *cp == '}') ;
|
||||
} else {
|
||||
/*
|
||||
* XXX this should not happen.
|
||||
*/
|
||||
fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n",
|
||||
progname, av[i]);
|
||||
}
|
||||
} else
|
||||
next_cmd = 0;
|
||||
|
||||
cp = av[i];
|
||||
if (*cp == ';' || *cp == '&' || *cp == '|')
|
||||
is_cmd = 1;
|
||||
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "av[%d] == %s '%s'",
|
||||
i, (is_cmd) ? "cmd" : "arg", av[i]);
|
||||
if (is_cmd != 0) {
|
||||
if (*cp == '(' || *cp == '{' ||
|
||||
*cp == ';' || *cp == '&' || *cp == '|') {
|
||||
do {
|
||||
++cp;
|
||||
} while (*cp == '(' || *cp == '{' ||
|
||||
*cp == ';' || *cp == '&' || *cp == '|');
|
||||
if (*cp == '\0') {
|
||||
next_cmd = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) {
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, " == cd, done.\n");
|
||||
return NULL;
|
||||
}
|
||||
for (mp = make; *mp != NULL; ++mp) {
|
||||
n = strlen(*mp);
|
||||
if (strcmp(cp, *mp) == 0) {
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, " %s == '%s', chdir(%s)\n",
|
||||
cp, *mp, cur_dir);
|
||||
return cur_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "\n");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
Check_Cwd_Cmd(const char *cmd)
|
||||
{
|
||||
char *cp, *bp;
|
||||
char **av;
|
||||
int ac;
|
||||
|
||||
if (Check_Cwd_Off)
|
||||
return NULL;
|
||||
|
||||
if (cmd) {
|
||||
av = brk_string(cmd, &ac, TRUE, &bp);
|
||||
if (DEBUG(CWD))
|
||||
fprintf(debug_file, "splitting: '%s' -> %d words\n",
|
||||
cmd, ac);
|
||||
} else {
|
||||
ac = 0;
|
||||
av = NULL;
|
||||
bp = NULL;
|
||||
}
|
||||
cp = Check_Cwd_av(ac, av, 1);
|
||||
if (bp)
|
||||
free(bp);
|
||||
if (av)
|
||||
free(av);
|
||||
return cp;
|
||||
}
|
||||
|
||||
void
|
||||
Check_Cwd(const char **argv)
|
||||
{
|
||||
char *cp;
|
||||
int ac;
|
||||
|
||||
if (Check_Cwd_Off)
|
||||
return;
|
||||
|
||||
for (ac = 0; argv[ac] != NULL; ++ac)
|
||||
/* NOTHING */;
|
||||
if (ac == 3 && *argv[1] == '-') {
|
||||
cp = Check_Cwd_Cmd(argv[2]);
|
||||
} else {
|
||||
cp = Check_Cwd_av(ac, UNCONST(argv), 0);
|
||||
}
|
||||
if (cp) {
|
||||
chdir(cp);
|
||||
}
|
||||
}
|
||||
|
||||
/*-
|
||||
* Cmd_Exec --
|
||||
@@ -1849,7 +1740,7 @@ Finish(int errors)
|
||||
}
|
||||
|
||||
/*
|
||||
* enunlink --
|
||||
* eunlink --
|
||||
* Remove a file carefully, avoiding directories.
|
||||
*/
|
||||
int
|
||||
@@ -1895,7 +1786,8 @@ execError(const char *af, const char *av)
|
||||
IOADD(")\n");
|
||||
|
||||
#ifdef USE_IOVEC
|
||||
(void)writev(2, iov, 8);
|
||||
while (writev(2, iov, 8) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1906,8 +1798,12 @@ execError(const char *af, const char *av)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
char *p;
|
||||
if ((p = strchr(progname, '[')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-BeikNnqrstWX] \n\
|
||||
"usage: %s [-BeikNnqrstWwX] \n\
|
||||
[-C directory] [-D variable] [-d flags] [-f makefile]\n\
|
||||
[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
|
||||
[-V variable] [variable=value] [target ...]\n", progname);
|
||||
|
||||
+106
-29
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: make.1,v 1.209 2012/10/08 15:09:48 christos Exp $
|
||||
.\" $NetBSD: make.1,v 1.226 2013/11/07 18:50:46 dholland Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
|
||||
.\"
|
||||
.Dd October 8, 2012
|
||||
.Dd October 25, 2013
|
||||
.Dt MAKE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -37,7 +37,7 @@
|
||||
.Nd maintain program dependencies
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl BeikNnqrstWX
|
||||
.Op Fl BeikNnqrstWwX
|
||||
.Op Fl C Ar directory
|
||||
.Op Fl D Ar variable
|
||||
.Op Fl d Ar flags
|
||||
@@ -209,6 +209,8 @@ Force the
|
||||
option to print raw values of variables.
|
||||
.It Ar v
|
||||
Print debugging information about variable assignment.
|
||||
.It Ar w
|
||||
Print entering and leaving directory messages, pre and post processing.
|
||||
.It Ar x
|
||||
Run shell commands with
|
||||
.Fl x
|
||||
@@ -468,6 +470,50 @@ except that the effect can be limited to a single line of a script.
|
||||
A
|
||||
.Ql Ic \-
|
||||
causes any non-zero exit status of the command line to be ignored.
|
||||
.Pp
|
||||
When
|
||||
.Nm
|
||||
is run in jobs mode with
|
||||
.Fl j Ar max_jobs ,
|
||||
the entire script for the target is fed to a
|
||||
single instance of the shell.
|
||||
.Pp
|
||||
In compatibility (non-jobs) mode, each command is run in a separate process.
|
||||
If the command contains any shell meta characters
|
||||
.Pq Ql #=|^(){};&<>*?[]:$`\e\en
|
||||
it will be passed to the shell, otherwise
|
||||
.Nm
|
||||
will attempt direct execution.
|
||||
.Pp
|
||||
Since
|
||||
.Nm
|
||||
will
|
||||
.Xr chdir 2
|
||||
to
|
||||
.Ql Va .OBJDIR
|
||||
before executing any targets, each child process
|
||||
starts with that as its current working directory.
|
||||
.Pp
|
||||
Makefiles should be written so that the mode of
|
||||
.Nm
|
||||
operation does not change their behavior.
|
||||
For example, any command which needs to use
|
||||
.Dq cd
|
||||
or
|
||||
.Dq chdir ,
|
||||
without side-effect should be put in parenthesis:
|
||||
.Bd -literal -offset indent
|
||||
|
||||
avoid-chdir-side-effects:
|
||||
@echo Building $@ in `pwd`
|
||||
@(cd ${.CURDIR} && ${.MAKE} $@)
|
||||
@echo Back in `pwd`
|
||||
|
||||
ensure-one-shell-regardless-of-mode:
|
||||
@echo Building $@ in `pwd`; \\
|
||||
(cd ${.CURDIR} && ${.MAKE} $@); \\
|
||||
echo Back in `pwd`
|
||||
.Ed
|
||||
.Sh VARIABLE ASSIGNMENTS
|
||||
Variables in make are much like variables in the shell, and, by tradition,
|
||||
consist of all upper-case letters.
|
||||
@@ -699,6 +745,9 @@ then output for each target is prefixed with a token
|
||||
.Ql --- target ---
|
||||
the first part of which can be controlled via
|
||||
.Va .MAKE.JOB.PREFIX .
|
||||
If
|
||||
.Va .MAKE.JOB.PREFIX
|
||||
is empty, no token is printed.
|
||||
.br
|
||||
For example:
|
||||
.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
|
||||
@@ -812,6 +861,11 @@ In "meta" mode, this variable contains a list of all the meta files
|
||||
used (updated or not).
|
||||
This list can be used to process the meta files to extract dependency
|
||||
information.
|
||||
.It Va .MAKE.META.IGNORE_PATHS
|
||||
Provides a list of path prefixes that should be ignored;
|
||||
because the contents are expected to change over time.
|
||||
The default list includes:
|
||||
.Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
|
||||
.It Va .MAKE.META.PREFIX
|
||||
Defines the message printed for each meta file updated in "meta verbose" mode.
|
||||
The default value is:
|
||||
@@ -830,6 +884,13 @@ by appending their names to
|
||||
is re-exported whenever
|
||||
.Ql Va .MAKEOVERRIDES
|
||||
is modified.
|
||||
.It Va .MAKE.PATH_FILEMON
|
||||
If
|
||||
.Nm
|
||||
was built with
|
||||
.Xr filemon 4
|
||||
support, this is set to the path of the device node.
|
||||
This allows makefiles to test for this support.
|
||||
.It Va .MAKE.PID
|
||||
The process-id of
|
||||
.Nm .
|
||||
@@ -1005,6 +1066,13 @@ may
|
||||
be used.
|
||||
The wildcard characters may be escaped with a backslash
|
||||
.Pq Ql \e .
|
||||
As a consequence of the way values are split into words, matched,
|
||||
and then joined, a construct like
|
||||
.Dl ${VAR:M*}
|
||||
will normalise the inter-word spacing, removing all leading and
|
||||
trailing space, and converting multiple consecutive spaces
|
||||
to single spaces.
|
||||
.
|
||||
.It Cm \&:N Ns Ar pattern
|
||||
This is identical to
|
||||
.Ql Cm \&:M ,
|
||||
@@ -1148,7 +1216,7 @@ The
|
||||
modifier is just like the
|
||||
.Cm \&:S
|
||||
modifier except that the old and new strings, instead of being
|
||||
simple strings, are a regular expression (see
|
||||
simple strings, are an extended regular expression (see
|
||||
.Xr regex 3 )
|
||||
string
|
||||
.Ar pattern
|
||||
@@ -1247,7 +1315,7 @@ should start and end with a period.
|
||||
For example.
|
||||
.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
|
||||
.Pp
|
||||
However a single character varaiable is often more readable:
|
||||
However a single character variable is often more readable:
|
||||
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
|
||||
.It Cm \&:U Ns Ar newval
|
||||
If the variable is undefined
|
||||
@@ -1270,7 +1338,7 @@ The path of the node which has the same name as the variable
|
||||
is the value.
|
||||
If no such node exists or its path is null, then the
|
||||
name of the variable is used.
|
||||
In order for this modifier to work, the name (node) must at least have
|
||||
In order for this modifier to work, the name (node) must at least have
|
||||
appeared on the rhs of a dependency.
|
||||
.Sm off
|
||||
.It Cm \&:\&! Ar cmd Cm \&!
|
||||
@@ -1690,7 +1758,7 @@ or
|
||||
.Fl t
|
||||
options were specified.
|
||||
Normally used to mark recursive
|
||||
.Nm Ns 's .
|
||||
.Nm Ns s .
|
||||
.It Ic .META
|
||||
Create a meta file for the target, even if it is flagged as
|
||||
.Ic .PHONY ,
|
||||
@@ -1713,6 +1781,20 @@ targets.
|
||||
Ignore differences in commands when deciding if target is out of date.
|
||||
This is useful if the command contains a value which always changes.
|
||||
If the number of commands change, though, the target will still be out of date.
|
||||
The same effect applies to any command line that uses the variable
|
||||
.Va .OODATE ,
|
||||
which can be used for that purpose even when not otherwise needed or desired:
|
||||
.Bd -literal -offset indent
|
||||
|
||||
skip-compare-for-some:
|
||||
@echo this will be compared
|
||||
@echo this will not ${.OODATE:M.NOMETA_CMP}
|
||||
@echo this will also be compared
|
||||
|
||||
.Ed
|
||||
The
|
||||
.Cm \&:M
|
||||
pattern suppresses any expansion of the unwanted variable.
|
||||
.It Ic .NOPATH
|
||||
Do not search for the target in the directories specified by
|
||||
.Ic .PATH .
|
||||
@@ -1896,6 +1978,12 @@ If the source is the special
|
||||
.Ic .DOTLAST
|
||||
target, then the current working
|
||||
directory is searched last.
|
||||
.It Ic .PATH. Ns Va suffix
|
||||
Like
|
||||
.Ic .PATH
|
||||
but applies only to files with a particular suffix.
|
||||
The suffix must have been previously declared with
|
||||
.Ic .SUFFIXES .
|
||||
.It Ic .PHONY
|
||||
Apply the
|
||||
.Ic .PHONY
|
||||
@@ -1964,6 +2052,10 @@ If no sources are specified, the
|
||||
.Ic .SILENT
|
||||
attribute is applied to every
|
||||
command in the file.
|
||||
.It Ic .STALE
|
||||
This target gets run when a dependency file contains stale entries, having
|
||||
.Va .ALLSRC
|
||||
set to the name of that dependency file.
|
||||
.It Ic .SUFFIXES
|
||||
Each source specifies a suffix to
|
||||
.Nm .
|
||||
@@ -2027,28 +2119,6 @@ The way that .for loop variables are substituted changed after
|
||||
so that they still appear to be variable expansions.
|
||||
In particular this stops them being treated as syntax, and removes some
|
||||
obscure problems using them in .if statements.
|
||||
.Pp
|
||||
Unlike other
|
||||
.Nm
|
||||
programs, this implementation by default executes all commands for a given
|
||||
target using a single shell invocation.
|
||||
This is done for both efficiency and to simplify error handling in remote
|
||||
command invocations.
|
||||
Typically this is transparent to the user, unless the target commands change
|
||||
the current working directory using
|
||||
.Dq cd
|
||||
or
|
||||
.Dq chdir .
|
||||
To be compatible with Makefiles that do this, one can use
|
||||
.Fl B
|
||||
to disable this behavior.
|
||||
.Pp
|
||||
In compatibility mode, each command is run in a separate process.
|
||||
If the command contains any shell meta characters
|
||||
.Pq Ql #=|^(){};&<>*?[]:$`\e\en
|
||||
it will be passed to the shell, otherwise
|
||||
.Nm
|
||||
will attempt direct execution.
|
||||
.Sh SEE ALSO
|
||||
.Xr mkdep 1
|
||||
.Sh HISTORY
|
||||
@@ -2063,6 +2133,13 @@ for Sprite at Berkeley.
|
||||
It was designed to be a parallel distributed make running jobs on different
|
||||
machines using a daemon called
|
||||
.Dq customs .
|
||||
.Pp
|
||||
Historically the target/dependency
|
||||
.Dq FRC
|
||||
has been used to FoRCe rebuilding (since the target/dependency
|
||||
does not exist... unless someone creates an
|
||||
.Dq FRC
|
||||
file).
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $ */
|
||||
/* $NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $";
|
||||
static char rcsid[] = "$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $");
|
||||
__RCSID("$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -1032,7 +1032,7 @@ MakeBuildChild(void *v_cn, void *toBeMade_next)
|
||||
if (cn->order_pred && Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) {
|
||||
/* Can't build this (or anything else in this child list) yet */
|
||||
cn->made = DEFERRED;
|
||||
return 1;
|
||||
return 0; /* but keep looking */
|
||||
}
|
||||
|
||||
if (DEBUG(MAKE))
|
||||
@@ -1055,7 +1055,7 @@ MakeBuildChild(void *v_cn, void *toBeMade_next)
|
||||
return cn->type & OP_WAIT && cn->unmade > 0;
|
||||
}
|
||||
|
||||
/* When a .ORDER RHS node completes we do this on each LHS */
|
||||
/* When a .ORDER LHS node completes we do this on each RHS */
|
||||
static int
|
||||
MakeBuildParent(void *v_pn, void *toBeMade_next)
|
||||
{
|
||||
|
||||
+8
-1
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.h,v 1.89 2012/06/12 19:21:51 joerg Exp $ */
|
||||
/* $NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -388,6 +388,10 @@ extern Boolean varNoExportEnv; /* TRUE if we should not export variables
|
||||
|
||||
extern GNode *DEFAULT; /* .DEFAULT rule */
|
||||
|
||||
extern GNode *VAR_INTERNAL; /* Variables defined internally by make
|
||||
* which should not override those set by
|
||||
* makefiles.
|
||||
*/
|
||||
extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
|
||||
* in the Makefile itself */
|
||||
extern GNode *VAR_CMD; /* Variables defined on the command line */
|
||||
@@ -426,6 +430,9 @@ extern pid_t myPid;
|
||||
#define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
|
||||
#define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
|
||||
#define MAKE_MODE ".MAKE.MODE"
|
||||
#ifndef MAKE_LEVEL_ENV
|
||||
# define MAKE_LEVEL_ENV "MAKELEVEL"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* debug control:
|
||||
|
||||
+125
-50
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: meta.c,v 1.25 2012/06/27 17:22:58 sjg Exp $ */
|
||||
/* $NetBSD: meta.c,v 1.33 2013/10/01 05:37:17 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Implement 'meta' mode.
|
||||
@@ -55,7 +55,12 @@
|
||||
#endif
|
||||
|
||||
static BuildMon Mybm; /* for compat */
|
||||
static Lst metaBailiwick; /* our scope of control */
|
||||
static Lst metaBailiwick; /* our scope of control */
|
||||
static Lst metaIgnorePaths; /* paths we deliberately ignore */
|
||||
|
||||
#ifndef MAKE_META_IGNORE_PATHS
|
||||
#define MAKE_META_IGNORE_PATHS ".MAKE.META.IGNORE_PATHS"
|
||||
#endif
|
||||
|
||||
Boolean useMeta = FALSE;
|
||||
static Boolean useFilemon = FALSE;
|
||||
@@ -539,8 +544,24 @@ boolValue(char *s)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialization we need before reading makefiles.
|
||||
*/
|
||||
void
|
||||
meta_init(const char *make_mode)
|
||||
meta_init(void)
|
||||
{
|
||||
#ifdef USE_FILEMON
|
||||
/* this allows makefiles to test if we have filemon support */
|
||||
Var_Set(".MAKE.PATH_FILEMON", _PATH_FILEMON, VAR_GLOBAL, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialization we need after reading makefiles.
|
||||
*/
|
||||
void
|
||||
meta_mode_init(const char *make_mode)
|
||||
{
|
||||
static int once = 0;
|
||||
char *cp;
|
||||
@@ -591,6 +612,17 @@ meta_init(const char *make_mode)
|
||||
if (cp) {
|
||||
str2Lst_Append(metaBailiwick, cp, NULL);
|
||||
}
|
||||
/*
|
||||
* We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
|
||||
*/
|
||||
metaIgnorePaths = Lst_Init(FALSE);
|
||||
Var_Append(MAKE_META_IGNORE_PATHS,
|
||||
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
|
||||
cp = Var_Subst(NULL,
|
||||
"${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, 0);
|
||||
if (cp) {
|
||||
str2Lst_Append(metaIgnorePaths, cp, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -828,6 +860,13 @@ string_match(const void *p, const void *q)
|
||||
continue; \
|
||||
}
|
||||
|
||||
#define DEQUOTE(p) if (*p == '\'') { \
|
||||
char *ep; \
|
||||
p++; \
|
||||
if ((ep = strchr(p, '\''))) \
|
||||
*ep = '\0'; \
|
||||
}
|
||||
|
||||
Boolean
|
||||
meta_oodate(GNode *gn, Boolean oodate)
|
||||
{
|
||||
@@ -840,10 +879,12 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
char fname2[MAXPATHLEN];
|
||||
char *p;
|
||||
char *cp;
|
||||
char *link_src;
|
||||
char *move_target;
|
||||
static size_t cwdlen = 0;
|
||||
static size_t tmplen = 0;
|
||||
FILE *fp;
|
||||
Boolean ignoreOODATE = FALSE;
|
||||
Boolean needOODATE = FALSE;
|
||||
Lst missingFiles;
|
||||
|
||||
if (oodate)
|
||||
@@ -906,6 +947,8 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
oodate = TRUE;
|
||||
break;
|
||||
}
|
||||
link_src = NULL;
|
||||
move_target = NULL;
|
||||
/* Find the start of the build monitor section. */
|
||||
if (!f) {
|
||||
if (strncmp(buf, "-- filemon", 10) == 0) {
|
||||
@@ -1019,16 +1062,21 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
break;
|
||||
|
||||
case 'M': /* renaMe */
|
||||
if (Lst_IsEmpty(missingFiles))
|
||||
break;
|
||||
/*
|
||||
* For 'M'oves we want to check
|
||||
* the src as for 'R'ead
|
||||
* and the target as for 'W'rite.
|
||||
*/
|
||||
cp = p; /* save this for a second */
|
||||
/* now get target */
|
||||
if (strsep(&p, " ") == NULL)
|
||||
continue;
|
||||
CHECK_VALID_META(p);
|
||||
move_target = p;
|
||||
p = cp;
|
||||
/* 'L' and 'M' put single quotes around the args */
|
||||
if (*p == '\'') {
|
||||
char *ep;
|
||||
|
||||
p++;
|
||||
if ((ep = strchr(p, '\'')))
|
||||
*ep = '\0';
|
||||
}
|
||||
DEQUOTE(p);
|
||||
DEQUOTE(move_target);
|
||||
/* FALLTHROUGH */
|
||||
case 'D': /* unlink */
|
||||
if (*p == '/' && !Lst_IsEmpty(missingFiles)) {
|
||||
@@ -1037,24 +1085,42 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
char *tp = Lst_Datum(ln);
|
||||
Lst_Remove(missingFiles, ln);
|
||||
free(tp);
|
||||
ln = NULL; /* we're done with it */
|
||||
}
|
||||
}
|
||||
if (buf[0] == 'M') {
|
||||
/* the target of the mv is a file 'W'ritten */
|
||||
#ifdef DEBUG_META_MODE
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "meta_oodate: M %s -> %s\n",
|
||||
p, move_target);
|
||||
#endif
|
||||
p = move_target;
|
||||
goto check_write;
|
||||
}
|
||||
break;
|
||||
case 'L': /* Link */
|
||||
/* we want the target */
|
||||
/*
|
||||
* For 'L'inks check
|
||||
* the src as for 'R'ead
|
||||
* and the target as for 'W'rite.
|
||||
*/
|
||||
link_src = p;
|
||||
/* now get target */
|
||||
if (strsep(&p, " ") == NULL)
|
||||
continue;
|
||||
CHECK_VALID_META(p);
|
||||
/* 'L' and 'M' put single quotes around the args */
|
||||
if (*p == '\'') {
|
||||
char *ep;
|
||||
|
||||
p++;
|
||||
if ((ep = strchr(p, '\'')))
|
||||
*ep = '\0';
|
||||
}
|
||||
DEQUOTE(p);
|
||||
DEQUOTE(link_src);
|
||||
#ifdef DEBUG_META_MODE
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "meta_oodate: L %s -> %s\n",
|
||||
link_src, p);
|
||||
#endif
|
||||
/* FALLTHROUGH */
|
||||
case 'W': /* Write */
|
||||
check_write:
|
||||
/*
|
||||
* If a file we generated within our bailiwick
|
||||
* but outside of .OBJDIR is missing,
|
||||
@@ -1086,6 +1152,14 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
Lst_AtEnd(missingFiles, bmake_strdup(p));
|
||||
}
|
||||
break;
|
||||
check_link_src:
|
||||
p = link_src;
|
||||
link_src = NULL;
|
||||
#ifdef DEBUG_META_MODE
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "meta_oodate: L src %s\n", p);
|
||||
#endif
|
||||
/* FALLTHROUGH */
|
||||
case 'R': /* Read */
|
||||
case 'E': /* Exec */
|
||||
/*
|
||||
@@ -1093,20 +1167,15 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
* be part of the dependencies because
|
||||
* they are _expected_ to change.
|
||||
*/
|
||||
if (strncmp(p, "/tmp/", 5) == 0 ||
|
||||
(tmplen > 0 && strncmp(p, tmpdir, tmplen) == 0))
|
||||
break;
|
||||
|
||||
if (strncmp(p, "/var/", 5) == 0)
|
||||
break;
|
||||
|
||||
/* Ignore device files. */
|
||||
if (strncmp(p, "/dev/", 5) == 0)
|
||||
break;
|
||||
|
||||
/* Ignore /etc/ files. */
|
||||
if (strncmp(p, "/etc/", 5) == 0)
|
||||
if (*p == '/' &&
|
||||
Lst_ForEach(metaIgnorePaths, prefix_match, p)) {
|
||||
#ifdef DEBUG_META_MODE
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "meta_oodate: ignoring: %s\n",
|
||||
p);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if ((cp = strrchr(p, '/'))) {
|
||||
cp++;
|
||||
@@ -1185,6 +1254,8 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!oodate && buf[0] == 'L' && link_src != NULL)
|
||||
goto check_link_src;
|
||||
} else if (strcmp(buf, "CMD") == 0) {
|
||||
/*
|
||||
* Compare the current command with the one in the
|
||||
@@ -1196,17 +1267,19 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
oodate = TRUE;
|
||||
} else {
|
||||
char *cmd = (char *)Lst_Datum(ln);
|
||||
Boolean hasOODATE = FALSE;
|
||||
|
||||
if (!ignoreOODATE) {
|
||||
if (strstr(cmd, "$?"))
|
||||
ignoreOODATE = TRUE;
|
||||
else if ((cp = strstr(cmd, ".OODATE"))) {
|
||||
/* check for $[{(].OODATE[)}] */
|
||||
if (cp > cmd + 2 && cp[-2] == '$')
|
||||
ignoreOODATE = TRUE;
|
||||
}
|
||||
if (ignoreOODATE && DEBUG(META))
|
||||
fprintf(debug_file, "%s: %d: cannot compare commands using .OODATE\n", fname, lineno);
|
||||
if (strstr(cmd, "$?"))
|
||||
hasOODATE = TRUE;
|
||||
else if ((cp = strstr(cmd, ".OODATE"))) {
|
||||
/* check for $[{(].OODATE[:)}] */
|
||||
if (cp > cmd + 2 && cp[-2] == '$')
|
||||
hasOODATE = TRUE;
|
||||
}
|
||||
if (hasOODATE) {
|
||||
needOODATE = TRUE;
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "%s: %d: cannot compare command using .OODATE\n", fname, lineno);
|
||||
}
|
||||
cmd = Var_Subst(NULL, cmd, gn, TRUE);
|
||||
|
||||
@@ -1235,7 +1308,7 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
if (buf[x - 1] == '\n')
|
||||
buf[x - 1] = '\0';
|
||||
}
|
||||
if (!ignoreOODATE &&
|
||||
if (!hasOODATE &&
|
||||
!(gn->type & OP_NOMETA_CMP) &&
|
||||
strcmp(p, cmd) != 0) {
|
||||
if (DEBUG(META))
|
||||
@@ -1279,14 +1352,16 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
oodate = TRUE;
|
||||
}
|
||||
}
|
||||
if (oodate && ignoreOODATE) {
|
||||
if (oodate && needOODATE) {
|
||||
/*
|
||||
* Target uses .OODATE, so we need to re-compute it.
|
||||
* We need to clean up what Make_DoAllVar() did.
|
||||
* Target uses .OODATE which is empty; or we wouldn't be here.
|
||||
* We have decided it is oodate, so .OODATE needs to be set.
|
||||
* All we can sanely do is set it to .ALLSRC.
|
||||
*/
|
||||
Var_Delete(ALLSRC, gn);
|
||||
Var_Delete(OODATE, gn);
|
||||
gn->flags &= ~DONE_ALLSRC;
|
||||
Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0);
|
||||
if (cp)
|
||||
free(cp);
|
||||
}
|
||||
return oodate;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: meta.h,v 1.2 2011/03/30 22:03:49 sjg Exp $ */
|
||||
/* $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Things needed for 'meta' mode.
|
||||
@@ -41,7 +41,8 @@ typedef struct BuildMon {
|
||||
extern Boolean useMeta;
|
||||
|
||||
struct Job; /* not defined yet */
|
||||
void meta_init(const char *);
|
||||
void meta_init(void);
|
||||
void meta_mode_init(const char *);
|
||||
void meta_job_start(struct Job *, GNode *);
|
||||
void meta_job_child(struct Job *);
|
||||
void meta_job_error(struct Job *, GNode *, int, int);
|
||||
|
||||
+81
-51
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -68,22 +68,15 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __minix
|
||||
#ifndef MAP_COPY
|
||||
#define MAP_COPY MAP_PRIVATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $";
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -140,6 +133,9 @@ __RCSID("$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $");
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
#ifndef MAP_COPY
|
||||
#define MAP_COPY MAP_PRIVATE
|
||||
#endif
|
||||
@@ -158,7 +154,7 @@ __RCSID("$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $");
|
||||
* Structure for a file being read ("included file")
|
||||
*/
|
||||
typedef struct IFile {
|
||||
const char *fname; /* name of file */
|
||||
char *fname; /* name of file */
|
||||
int lineno; /* current line number in file */
|
||||
int first_lineno; /* line number of start of text */
|
||||
int cond_depth; /* 'if' nesting when file opened */
|
||||
@@ -214,6 +210,7 @@ typedef enum {
|
||||
ExShell, /* .SHELL */
|
||||
Silent, /* .SILENT */
|
||||
SingleShell, /* .SINGLESHELL */
|
||||
Stale, /* .STALE */
|
||||
Suffixes, /* .SUFFIXES */
|
||||
Wait, /* .WAIT */
|
||||
Attribute /* Generic attribute */
|
||||
@@ -337,6 +334,7 @@ static const struct {
|
||||
{ ".SHELL", ExShell, 0 },
|
||||
{ ".SILENT", Silent, OP_SILENT },
|
||||
{ ".SINGLESHELL", SingleShell, 0 },
|
||||
{ ".STALE", Stale, 0 },
|
||||
{ ".SUFFIXES", Suffixes, 0 },
|
||||
{ ".USE", Attribute, OP_USE },
|
||||
{ ".USEBEFORE", Attribute, OP_USEBEFORE },
|
||||
@@ -521,7 +519,6 @@ loadfile(const char *path, int fd)
|
||||
* FUTURE: remove PROT_WRITE when the parser no longer
|
||||
* needs to scribble on the input.
|
||||
*/
|
||||
|
||||
lf->buf = mmap(NULL, lf->maplen, PROT_READ|PROT_WRITE,
|
||||
MAP_FILE|MAP_COPY, fd, 0);
|
||||
if (lf->buf != MAP_FAILED) {
|
||||
@@ -910,6 +907,8 @@ ParseDoOp(void *gnp, void *opp)
|
||||
gn->type |= op & ~OP_OPMASK;
|
||||
|
||||
cohort = Targ_FindNode(gn->name, TARG_NOHASH);
|
||||
if (doing_depend)
|
||||
ParseMark(cohort);
|
||||
/*
|
||||
* Make the cohort invisible as well to avoid duplicating it into
|
||||
* other variables. True, parents of this target won't tend to do
|
||||
@@ -982,6 +981,8 @@ ParseDoSrc(int tOp, const char *src)
|
||||
*/
|
||||
snprintf(wait_src, sizeof wait_src, ".WAIT_%u", ++wait_number);
|
||||
gn = Targ_FindNode(wait_src, TARG_NOHASH);
|
||||
if (doing_depend)
|
||||
ParseMark(gn);
|
||||
gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
|
||||
Lst_ForEach(targets, ParseLinkSrc, gn);
|
||||
return;
|
||||
@@ -1013,6 +1014,8 @@ ParseDoSrc(int tOp, const char *src)
|
||||
* source and the current one.
|
||||
*/
|
||||
gn = Targ_FindNode(src, TARG_CREATE);
|
||||
if (doing_depend)
|
||||
ParseMark(gn);
|
||||
if (predecessor != NULL) {
|
||||
(void)Lst_AtEnd(predecessor->order_succ, gn);
|
||||
(void)Lst_AtEnd(gn->order_pred, predecessor);
|
||||
@@ -1044,6 +1047,8 @@ ParseDoSrc(int tOp, const char *src)
|
||||
|
||||
/* Find/create the 'src' node and attach to all targets */
|
||||
gn = Targ_FindNode(src, TARG_CREATE);
|
||||
if (doing_depend)
|
||||
ParseMark(gn);
|
||||
if (tOp) {
|
||||
gn->type |= tOp;
|
||||
} else {
|
||||
@@ -1201,9 +1206,8 @@ ParseDoDependency(char *line)
|
||||
*/
|
||||
int length;
|
||||
void *freeIt;
|
||||
char *result;
|
||||
|
||||
result = Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
|
||||
(void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
|
||||
if (freeIt)
|
||||
free(freeIt);
|
||||
cp += length-1;
|
||||
@@ -1289,6 +1293,7 @@ ParseDoDependency(char *line)
|
||||
* apply the .DEFAULT commands.
|
||||
* .PHONY The list of targets
|
||||
* .NOPATH Don't search for file in the path
|
||||
* .STALE
|
||||
* .BEGIN
|
||||
* .END
|
||||
* .ERROR
|
||||
@@ -1299,42 +1304,45 @@ ParseDoDependency(char *line)
|
||||
* .ORDER Must set initial predecessor to NULL
|
||||
*/
|
||||
switch (specType) {
|
||||
case ExPath:
|
||||
if (paths == NULL) {
|
||||
paths = Lst_Init(FALSE);
|
||||
}
|
||||
(void)Lst_AtEnd(paths, dirSearchPath);
|
||||
break;
|
||||
case Main:
|
||||
if (!Lst_IsEmpty(create)) {
|
||||
specType = Not;
|
||||
}
|
||||
break;
|
||||
case Begin:
|
||||
case End:
|
||||
case dotError:
|
||||
case Interrupt:
|
||||
gn = Targ_FindNode(line, TARG_CREATE);
|
||||
gn->type |= OP_NOTMAIN|OP_SPECIAL;
|
||||
(void)Lst_AtEnd(targets, gn);
|
||||
break;
|
||||
case Default:
|
||||
gn = Targ_NewGN(".DEFAULT");
|
||||
gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
|
||||
(void)Lst_AtEnd(targets, gn);
|
||||
DEFAULT = gn;
|
||||
break;
|
||||
case NotParallel:
|
||||
maxJobs = 1;
|
||||
break;
|
||||
case SingleShell:
|
||||
compatMake = TRUE;
|
||||
break;
|
||||
case Order:
|
||||
predecessor = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case ExPath:
|
||||
if (paths == NULL) {
|
||||
paths = Lst_Init(FALSE);
|
||||
}
|
||||
(void)Lst_AtEnd(paths, dirSearchPath);
|
||||
break;
|
||||
case Main:
|
||||
if (!Lst_IsEmpty(create)) {
|
||||
specType = Not;
|
||||
}
|
||||
break;
|
||||
case Begin:
|
||||
case End:
|
||||
case Stale:
|
||||
case dotError:
|
||||
case Interrupt:
|
||||
gn = Targ_FindNode(line, TARG_CREATE);
|
||||
if (doing_depend)
|
||||
ParseMark(gn);
|
||||
gn->type |= OP_NOTMAIN|OP_SPECIAL;
|
||||
(void)Lst_AtEnd(targets, gn);
|
||||
break;
|
||||
case Default:
|
||||
gn = Targ_NewGN(".DEFAULT");
|
||||
gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
|
||||
(void)Lst_AtEnd(targets, gn);
|
||||
DEFAULT = gn;
|
||||
break;
|
||||
case NotParallel:
|
||||
maxJobs = 1;
|
||||
break;
|
||||
case SingleShell:
|
||||
compatMake = TRUE;
|
||||
break;
|
||||
case Order:
|
||||
predecessor = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (strncmp(line, ".PATH", 5) == 0) {
|
||||
/*
|
||||
@@ -1393,6 +1401,8 @@ ParseDoDependency(char *line)
|
||||
} else {
|
||||
gn = Suff_AddTransform(targName);
|
||||
}
|
||||
if (doing_depend)
|
||||
ParseMark(gn);
|
||||
|
||||
(void)Lst_AtEnd(targets, gn);
|
||||
}
|
||||
@@ -1440,6 +1450,7 @@ ParseDoDependency(char *line)
|
||||
Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored");
|
||||
break;
|
||||
case Default:
|
||||
case Stale:
|
||||
case Begin:
|
||||
case End:
|
||||
case dotError:
|
||||
@@ -1729,6 +1740,12 @@ Parse_IsVar(char *line)
|
||||
ch = *line++;
|
||||
wasSpace = TRUE;
|
||||
}
|
||||
#ifdef SUNSHCMD
|
||||
if (ch == ':' && strncmp(line, "sh", 2) == 0) {
|
||||
line += 2;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (ch == '=')
|
||||
return TRUE;
|
||||
if (*line == '=' && ISEQOPERATOR(ch))
|
||||
@@ -2322,7 +2339,7 @@ Parse_SetInput(const char *name, int line, int fd,
|
||||
* name of the include file so error messages refer to the right
|
||||
* place.
|
||||
*/
|
||||
curFile->fname = name;
|
||||
curFile->fname = bmake_strdup(name);
|
||||
curFile->lineno = line;
|
||||
curFile->first_lineno = line;
|
||||
curFile->nextbuf = nextbuf;
|
||||
@@ -2335,6 +2352,8 @@ Parse_SetInput(const char *name, int line, int fd,
|
||||
buf = curFile->nextbuf(curFile->nextbuf_arg, &len);
|
||||
if (buf == NULL) {
|
||||
/* Was all a waste of time ... */
|
||||
if (curFile->fname)
|
||||
free(curFile->fname);
|
||||
free(curFile);
|
||||
return;
|
||||
}
|
||||
@@ -2449,6 +2468,7 @@ ParseGmakeExport(char *line)
|
||||
"Variable/Value missing from \"export\"");
|
||||
return;
|
||||
}
|
||||
*value++ = '\0'; /* terminate variable */
|
||||
|
||||
/*
|
||||
* Expand the value before putting it in the environment.
|
||||
@@ -2557,6 +2577,16 @@ ParseGetLine(int flags, int *length)
|
||||
if (cf->P_end == NULL)
|
||||
/* End of string (aka for loop) data */
|
||||
break;
|
||||
/* see if there is more we can parse */
|
||||
while (ptr++ < cf->P_end) {
|
||||
if ((ch = *ptr) == '\n') {
|
||||
if (ptr > line && ptr[-1] == '\\')
|
||||
continue;
|
||||
Parse_Error(PARSE_WARNING,
|
||||
"Zero byte read from file, skipping rest of line.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cf->nextbuf != NULL) {
|
||||
/*
|
||||
* End of this buffer; return EOF and outer logic
|
||||
|
||||
+100
-99
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $ */
|
||||
/* $NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $");
|
||||
__RCSID("$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -684,8 +684,8 @@ GNode *
|
||||
Suff_AddTransform(char *line)
|
||||
{
|
||||
GNode *gn; /* GNode of transformation rule */
|
||||
Suff *s = NULL, /* source suffix */
|
||||
*t = NULL; /* target suffix */
|
||||
Suff *s, /* source suffix */
|
||||
*t; /* target suffix */
|
||||
LstNode ln; /* Node for existing transformation */
|
||||
|
||||
ln = Lst_Find(transforms, line, SuffGNHasNameP);
|
||||
@@ -2058,118 +2058,124 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
|
||||
* children, then look for any overriding transformations they imply.
|
||||
* Should we find one, we discard the one we found before.
|
||||
*/
|
||||
bottom = NULL;
|
||||
targ = NULL;
|
||||
|
||||
while (ln != NULL) {
|
||||
/*
|
||||
* Look for next possible suffix...
|
||||
*/
|
||||
ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP);
|
||||
|
||||
if (ln != NULL) {
|
||||
int prefLen; /* Length of the prefix */
|
||||
if (!(gn->type & OP_PHONY)) {
|
||||
|
||||
while (ln != NULL) {
|
||||
/*
|
||||
* Allocate a Src structure to which things can be transformed
|
||||
* Look for next possible suffix...
|
||||
*/
|
||||
ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP);
|
||||
|
||||
if (ln != NULL) {
|
||||
int prefLen; /* Length of the prefix */
|
||||
|
||||
/*
|
||||
* Allocate a Src structure to which things can be transformed
|
||||
*/
|
||||
targ = bmake_malloc(sizeof(Src));
|
||||
targ->file = bmake_strdup(gn->name);
|
||||
targ->suff = (Suff *)Lst_Datum(ln);
|
||||
targ->suff->refCount++;
|
||||
targ->node = gn;
|
||||
targ->parent = NULL;
|
||||
targ->children = 0;
|
||||
#ifdef DEBUG_SRC
|
||||
targ->cp = Lst_Init(FALSE);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate room for the prefix, whose end is found by
|
||||
* subtracting the length of the suffix from
|
||||
* the end of the name.
|
||||
*/
|
||||
prefLen = (eoname - targ->suff->nameLen) - sopref;
|
||||
targ->pref = bmake_malloc(prefLen + 1);
|
||||
memcpy(targ->pref, sopref, prefLen);
|
||||
targ->pref[prefLen] = '\0';
|
||||
|
||||
/*
|
||||
* Add nodes from which the target can be made
|
||||
*/
|
||||
SuffAddLevel(srcs, targ);
|
||||
|
||||
/*
|
||||
* Record the target so we can nuke it
|
||||
*/
|
||||
(void)Lst_AtEnd(targs, targ);
|
||||
|
||||
/*
|
||||
* Search from this suffix's successor...
|
||||
*/
|
||||
ln = Lst_Succ(ln);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle target of unknown suffix...
|
||||
*/
|
||||
if (Lst_IsEmpty(targs) && suffNull != NULL) {
|
||||
if (DEBUG(SUFF)) {
|
||||
fprintf(debug_file, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
|
||||
}
|
||||
|
||||
targ = bmake_malloc(sizeof(Src));
|
||||
targ->file = bmake_strdup(gn->name);
|
||||
targ->suff = (Suff *)Lst_Datum(ln);
|
||||
targ->suff = suffNull;
|
||||
targ->suff->refCount++;
|
||||
targ->node = gn;
|
||||
targ->parent = NULL;
|
||||
targ->children = 0;
|
||||
targ->pref = bmake_strdup(sopref);
|
||||
#ifdef DEBUG_SRC
|
||||
targ->cp = Lst_Init(FALSE);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate room for the prefix, whose end is found by subtracting
|
||||
* the length of the suffix from the end of the name.
|
||||
* Only use the default suffix rules if we don't have commands
|
||||
* defined for this gnode; traditional make programs used to
|
||||
* not define suffix rules if the gnode had children but we
|
||||
* don't do this anymore.
|
||||
*/
|
||||
prefLen = (eoname - targ->suff->nameLen) - sopref;
|
||||
targ->pref = bmake_malloc(prefLen + 1);
|
||||
memcpy(targ->pref, sopref, prefLen);
|
||||
targ->pref[prefLen] = '\0';
|
||||
if (Lst_IsEmpty(gn->commands))
|
||||
SuffAddLevel(srcs, targ);
|
||||
else {
|
||||
if (DEBUG(SUFF))
|
||||
fprintf(debug_file, "not ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add nodes from which the target can be made
|
||||
*/
|
||||
SuffAddLevel(srcs, targ);
|
||||
|
||||
/*
|
||||
* Record the target so we can nuke it
|
||||
*/
|
||||
(void)Lst_AtEnd(targs, targ);
|
||||
|
||||
/*
|
||||
* Search from this suffix's successor...
|
||||
*/
|
||||
ln = Lst_Succ(ln);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle target of unknown suffix...
|
||||
*/
|
||||
if (Lst_IsEmpty(targs) && suffNull != NULL) {
|
||||
if (DEBUG(SUFF)) {
|
||||
fprintf(debug_file, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
|
||||
}
|
||||
|
||||
targ = bmake_malloc(sizeof(Src));
|
||||
targ->file = bmake_strdup(gn->name);
|
||||
targ->suff = suffNull;
|
||||
targ->suff->refCount++;
|
||||
targ->node = gn;
|
||||
targ->parent = NULL;
|
||||
targ->children = 0;
|
||||
targ->pref = bmake_strdup(sopref);
|
||||
#ifdef DEBUG_SRC
|
||||
targ->cp = Lst_Init(FALSE);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Only use the default suffix rules if we don't have commands
|
||||
* defined for this gnode; traditional make programs used to
|
||||
* not define suffix rules if the gnode had children but we
|
||||
* don't do this anymore.
|
||||
*/
|
||||
if (Lst_IsEmpty(gn->commands))
|
||||
SuffAddLevel(srcs, targ);
|
||||
else {
|
||||
if (DEBUG(SUFF))
|
||||
fprintf(debug_file, "not ");
|
||||
fprintf(debug_file, "adding suffix rules\n");
|
||||
|
||||
(void)Lst_AtEnd(targs, targ);
|
||||
}
|
||||
|
||||
if (DEBUG(SUFF))
|
||||
fprintf(debug_file, "adding suffix rules\n");
|
||||
|
||||
(void)Lst_AtEnd(targs, targ);
|
||||
}
|
||||
|
||||
/*
|
||||
* Using the list of possible sources built up from the target suffix(es),
|
||||
* try and find an existing file/target that matches.
|
||||
*/
|
||||
bottom = SuffFindThem(srcs, slst);
|
||||
|
||||
if (bottom == NULL) {
|
||||
/*
|
||||
* No known transformations -- use the first suffix found for setting
|
||||
* the local variables.
|
||||
* Using the list of possible sources built up from the target
|
||||
* suffix(es), try and find an existing file/target that matches.
|
||||
*/
|
||||
if (!Lst_IsEmpty(targs)) {
|
||||
targ = (Src *)Lst_Datum(Lst_First(targs));
|
||||
bottom = SuffFindThem(srcs, slst);
|
||||
|
||||
if (bottom == NULL) {
|
||||
/*
|
||||
* No known transformations -- use the first suffix found
|
||||
* for setting the local variables.
|
||||
*/
|
||||
if (!Lst_IsEmpty(targs)) {
|
||||
targ = (Src *)Lst_Datum(Lst_First(targs));
|
||||
} else {
|
||||
targ = NULL;
|
||||
}
|
||||
} else {
|
||||
targ = NULL;
|
||||
/*
|
||||
* Work up the transformation path to find the suffix of the
|
||||
* target to which the transformation was made.
|
||||
*/
|
||||
for (targ = bottom; targ->parent != NULL; targ = targ->parent)
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Work up the transformation path to find the suffix of the
|
||||
* target to which the transformation was made.
|
||||
*/
|
||||
for (targ = bottom; targ->parent != NULL; targ = targ->parent)
|
||||
continue;
|
||||
}
|
||||
|
||||
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
|
||||
@@ -2419,12 +2425,7 @@ SuffFindDeps(GNode *gn, Lst slst)
|
||||
*/
|
||||
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
|
||||
Var_Set(PREFIX, gn->name, gn, 0);
|
||||
if (gn->type & OP_PHONY) {
|
||||
/*
|
||||
* If this is a .PHONY target, we do not apply suffix rules.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG(SUFF)) {
|
||||
fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 sjg Exp $
|
||||
# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
# The main targets are:
|
||||
@@ -24,6 +24,7 @@ SUBFILES= \
|
||||
error \
|
||||
export \
|
||||
export-all \
|
||||
export-env \
|
||||
doterror \
|
||||
dotwait \
|
||||
forloop \
|
||||
@@ -36,9 +37,11 @@ SUBFILES= \
|
||||
modorder \
|
||||
modts \
|
||||
modword \
|
||||
order \
|
||||
phony-end \
|
||||
posix \
|
||||
qequals \
|
||||
sunshcmd \
|
||||
sysv \
|
||||
ternary \
|
||||
unexport \
|
||||
@@ -48,6 +51,7 @@ SUBFILES= \
|
||||
all: ${SUBFILES}
|
||||
|
||||
flags.doterror=
|
||||
flags.order=-j1
|
||||
|
||||
# the tests are actually done with sub-makes.
|
||||
.PHONY: ${SUBFILES}
|
||||
@@ -76,7 +80,7 @@ LANG= C
|
||||
test:
|
||||
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
|
||||
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
|
||||
${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
|
||||
${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
|
||||
-e '/stopped/s, /.*, unit-tests,' \
|
||||
-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
|
||||
-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# $Id: export-env,v 1.1 2013/03/22 16:36:46 sjg Exp $
|
||||
|
||||
# our normal .export, subsequent changes affect the environment
|
||||
UT_TEST=this
|
||||
.export UT_TEST
|
||||
UT_TEST:= ${.PARSEFILE}
|
||||
|
||||
# not so with .export-env
|
||||
UT_ENV=exported
|
||||
.export-env UT_ENV
|
||||
UT_ENV=not-exported
|
||||
|
||||
# gmake style export goes further; affects nothing but the environment
|
||||
UT_EXP=before-export
|
||||
export UT_EXP=exported
|
||||
UT_EXP=not-exported
|
||||
|
||||
all:
|
||||
@echo make:; ${UT_TEST UT_ENV UT_EXP:L:@v@echo $v=${$v};@}
|
||||
@echo env:; ${UT_TEST UT_ENV UT_EXP:L:@v@echo $v=$${$v};@}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# $NetBSD: order,v 1.1 2012/11/09 19:08:28 sjg Exp $
|
||||
|
||||
# Test that .ORDER is handled correctly.
|
||||
# The explicit dependency the.o: the.h will make us examine the.h
|
||||
# the .ORDER will prevent us building it immediately,
|
||||
# we should then examine the.c rather than stop.
|
||||
|
||||
all: the.o
|
||||
|
||||
.ORDER: the.c the.h
|
||||
|
||||
the.c the.h:
|
||||
@echo Making $@
|
||||
|
||||
.SUFFIXES: .o .c
|
||||
|
||||
.c.o:
|
||||
@echo Making $@ from $?
|
||||
|
||||
the.o: the.h
|
||||
@@ -0,0 +1,10 @@
|
||||
BYECMD = echo bye
|
||||
LATERCMD = echo later
|
||||
TEST1 :sh = echo hello
|
||||
TEST2 :sh = ${BYECMD}
|
||||
TEST3 = ${LATERCMD:sh}
|
||||
|
||||
all:
|
||||
@echo "TEST1=${TEST1}"
|
||||
@echo "TEST2=${TEST2}"
|
||||
@echo "TEST3=${TEST3}"
|
||||
@@ -43,6 +43,14 @@ UT_OK=good
|
||||
UT_OKDIR=unit-tests
|
||||
UT_TEST=export-all
|
||||
UT_ZOO=hoopie
|
||||
make:
|
||||
UT_TEST=export-env
|
||||
UT_ENV=not-exported
|
||||
UT_EXP=not-exported
|
||||
env:
|
||||
UT_TEST=export-env
|
||||
UT_ENV=exported
|
||||
UT_EXP=exported
|
||||
At first, I am
|
||||
happy
|
||||
and now: sad
|
||||
@@ -310,6 +318,9 @@ LIST:tw:C/ /,/g="one two three four five six"
|
||||
LIST:tw:C/ /,/1g="one two three four five six"
|
||||
LIST:tw:tW:C/ /,/="one,two three four five six"
|
||||
LIST:tW:tw:C/ /,/="one two three four five six"
|
||||
Making the.c
|
||||
Making the.h
|
||||
Making the.o from the.h the.c
|
||||
.TARGET="phony" .PREFIX="phony" .IMPSRC=""
|
||||
.TARGET="all" .PREFIX="all" .IMPSRC=""
|
||||
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
|
||||
@@ -338,6 +349,9 @@ Now we expect an error...
|
||||
*** Error code 1 (continuing)
|
||||
`all' not remade because of errors.
|
||||
V.i386 ?= OK
|
||||
TEST1=hello
|
||||
TEST2=bye
|
||||
TEST3=later
|
||||
FOOBAR =
|
||||
FOOBAR = foobar fubar
|
||||
fun
|
||||
|
||||
+6
-3
@@ -1,15 +1,18 @@
|
||||
/* $NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $ */
|
||||
/* $NetBSD: util.c,v 1.54 2013/11/26 13:44:41 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Missing stuff from OS's
|
||||
*/
|
||||
#if defined(__MINT__) || defined(__linux__)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: util.c,v 1.54 2013/11/26 13:44:41 joerg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.54 2013/11/26 13:44:41 joerg Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
+61
-65
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $ */
|
||||
/* $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@@ -139,6 +139,7 @@ __RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
|
||||
#include "dir.h"
|
||||
#include "job.h"
|
||||
|
||||
extern int makelevel;
|
||||
/*
|
||||
* This lets us tell if we have replaced the original environ
|
||||
* (which we cannot free).
|
||||
@@ -175,6 +176,7 @@ static char varNoError[] = "";
|
||||
* The four contexts are searched in the reverse order from which they are
|
||||
* listed.
|
||||
*/
|
||||
GNode *VAR_INTERNAL; /* variables from make itself */
|
||||
GNode *VAR_GLOBAL; /* variables from the makefile */
|
||||
GNode *VAR_CMD; /* variables defined on the command-line */
|
||||
|
||||
@@ -309,7 +311,6 @@ static char *VarGetPattern(GNode *, Var_Parse_State *,
|
||||
int, const char **, int, int *, int *,
|
||||
VarPattern *);
|
||||
static char *VarQuote(char *);
|
||||
static char *VarChangeCase(char *, int);
|
||||
static char *VarHash(char *);
|
||||
static char *VarModify(GNode *, Var_Parse_State *,
|
||||
const char *,
|
||||
@@ -408,6 +409,10 @@ VarFind(const char *name, GNode *ctxt, int flags)
|
||||
(ctxt != VAR_GLOBAL))
|
||||
{
|
||||
var = Hash_FindEntry(&VAR_GLOBAL->context, name);
|
||||
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
|
||||
/* VAR_INTERNAL is subordinate to VAR_GLOBAL */
|
||||
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
|
||||
}
|
||||
}
|
||||
if ((var == NULL) && (flags & FIND_ENV)) {
|
||||
char *env;
|
||||
@@ -429,6 +434,9 @@ VarFind(const char *name, GNode *ctxt, int flags)
|
||||
(ctxt != VAR_GLOBAL))
|
||||
{
|
||||
var = Hash_FindEntry(&VAR_GLOBAL->context, name);
|
||||
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
|
||||
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
|
||||
}
|
||||
if (var == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -530,11 +538,20 @@ void
|
||||
Var_Delete(const char *name, GNode *ctxt)
|
||||
{
|
||||
Hash_Entry *ln;
|
||||
|
||||
ln = Hash_FindEntry(&ctxt->context, name);
|
||||
char *cp;
|
||||
|
||||
if (strchr(name, '$')) {
|
||||
cp = Var_Subst(NULL, name, VAR_GLOBAL, 0);
|
||||
} else {
|
||||
cp = (char *)name;
|
||||
}
|
||||
ln = Hash_FindEntry(&ctxt->context, cp);
|
||||
if (DEBUG(VAR)) {
|
||||
fprintf(debug_file, "%s:delete %s%s\n",
|
||||
ctxt->name, name, ln ? "" : " (not found)");
|
||||
ctxt->name, cp, ln ? "" : " (not found)");
|
||||
}
|
||||
if (cp != name) {
|
||||
free(cp);
|
||||
}
|
||||
if (ln != NULL) {
|
||||
Var *v;
|
||||
@@ -649,6 +666,15 @@ Var_ExportVars(void)
|
||||
char *val;
|
||||
int n;
|
||||
|
||||
/*
|
||||
* Several make's support this sort of mechanism for tracking
|
||||
* recursion - but each uses a different name.
|
||||
* We allow the makefiles to update MAKELEVEL and ensure
|
||||
* children see a correctly incremented value.
|
||||
*/
|
||||
snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
|
||||
setenv(MAKE_LEVEL_ENV, tmp, 1);
|
||||
|
||||
if (VAR_EXPORTED_NONE == var_exportedVars)
|
||||
return;
|
||||
|
||||
@@ -770,7 +796,7 @@ Var_UnExport(char *str)
|
||||
if (unexport_env) {
|
||||
char **newenv;
|
||||
|
||||
cp = getenv(MAKE_LEVEL); /* we should preserve this */
|
||||
cp = getenv(MAKE_LEVEL_ENV); /* we should preserve this */
|
||||
if (environ == savedEnv) {
|
||||
/* we have been here before! */
|
||||
newenv = bmake_realloc(environ, 2 * sizeof(char *));
|
||||
@@ -787,7 +813,7 @@ Var_UnExport(char *str)
|
||||
environ = savedEnv = newenv;
|
||||
newenv[0] = NULL;
|
||||
newenv[1] = NULL;
|
||||
setenv(MAKE_LEVEL, cp, 1);
|
||||
setenv(MAKE_LEVEL_ENV, cp, 1);
|
||||
} else {
|
||||
for (; *str != '\n' && isspace((unsigned char) *str); str++)
|
||||
continue;
|
||||
@@ -911,6 +937,14 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
|
||||
}
|
||||
v = VarFind(name, ctxt, 0);
|
||||
if (v == NULL) {
|
||||
if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
|
||||
/*
|
||||
* This var would normally prevent the same name being added
|
||||
* to VAR_GLOBAL, so delete it from there if needed.
|
||||
* Otherwise -V name may show the wrong value.
|
||||
*/
|
||||
Var_Delete(name, VAR_GLOBAL);
|
||||
}
|
||||
VarAdd(name, val, ctxt);
|
||||
} else {
|
||||
Buf_Empty(&v->val);
|
||||
@@ -945,22 +979,6 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
|
||||
|
||||
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
|
||||
}
|
||||
/*
|
||||
* Another special case.
|
||||
* Several make's support this sort of mechanism for tracking
|
||||
* recursion - but each uses a different name.
|
||||
* We allow the makefiles to update .MAKE.LEVEL and ensure
|
||||
* children see a correctly incremented value.
|
||||
*/
|
||||
if (ctxt == VAR_GLOBAL && strcmp(MAKE_LEVEL, name) == 0) {
|
||||
char tmp[64];
|
||||
int level;
|
||||
|
||||
level = atoi(val);
|
||||
snprintf(tmp, sizeof(tmp), "%u", level + 1);
|
||||
setenv(MAKE_LEVEL, tmp, 1);
|
||||
}
|
||||
|
||||
|
||||
out:
|
||||
if (expanded_name != NULL)
|
||||
@@ -2296,9 +2314,7 @@ VarHash(char *str)
|
||||
size_t len, len2;
|
||||
unsigned char *ustr = (unsigned char *)str;
|
||||
uint32_t h, k, c1, c2;
|
||||
int done;
|
||||
|
||||
done = 1;
|
||||
h = 0x971e137bU;
|
||||
c1 = 0x95543787U;
|
||||
c2 = 0x2ad7eb25U;
|
||||
@@ -2328,7 +2344,7 @@ VarHash(char *str)
|
||||
h = (h << 13) ^ (h >> 19);
|
||||
h = h * 5 + 0x52dce729U;
|
||||
h ^= k;
|
||||
} while (!done);
|
||||
}
|
||||
h ^= len2;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
@@ -2344,37 +2360,6 @@ VarHash(char *str)
|
||||
return Buf_Destroy(&buf, FALSE);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* VarChangeCase --
|
||||
* Change the string to all uppercase or all lowercase
|
||||
*
|
||||
* Input:
|
||||
* str String to modify
|
||||
* upper TRUE -> uppercase, else lowercase
|
||||
*
|
||||
* Results:
|
||||
* The string with case changed
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static char *
|
||||
VarChangeCase(char *str, int upper)
|
||||
{
|
||||
Buffer buf;
|
||||
int (*modProc)(int);
|
||||
|
||||
modProc = (upper ? toupper : tolower);
|
||||
Buf_Init(&buf, 0);
|
||||
for (; *str ; str++) {
|
||||
Buf_AddByte(&buf, modProc(*str));
|
||||
}
|
||||
return Buf_Destroy(&buf, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
VarStrftime(const char *fmt, int zulu)
|
||||
{
|
||||
@@ -2561,7 +2546,8 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
}
|
||||
apply_mods:
|
||||
if (DEBUG(VAR)) {
|
||||
fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
|
||||
fprintf(debug_file, "Applying[%s] :%c to \"%s\"\n", v->name,
|
||||
*tstr, nstr);
|
||||
}
|
||||
newStr = var_Error;
|
||||
switch ((modifier = *tstr)) {
|
||||
@@ -3050,8 +3036,16 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
VarRealpath, NULL);
|
||||
cp = tstr + 2;
|
||||
termc = *cp;
|
||||
} else if (tstr[1] == 'u' || tstr[1] == 'l') {
|
||||
newStr = VarChangeCase(nstr, (tstr[1] == 'u'));
|
||||
} else if (tstr[1] == 'u') {
|
||||
char *dp = bmake_strdup(nstr);
|
||||
for (newStr = dp; *dp; dp++)
|
||||
*dp = toupper((unsigned char)*dp);
|
||||
cp = tstr + 2;
|
||||
termc = *cp;
|
||||
} else if (tstr[1] == 'l') {
|
||||
char *dp = bmake_strdup(nstr);
|
||||
for (newStr = dp; *dp; dp++)
|
||||
*dp = tolower((unsigned char)*dp);
|
||||
cp = tstr + 2;
|
||||
termc = *cp;
|
||||
} else if (tstr[1] == 'W' || tstr[1] == 'w') {
|
||||
@@ -3161,8 +3155,8 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
free(cp2);
|
||||
}
|
||||
if (DEBUG(VAR))
|
||||
fprintf(debug_file, "Pattern for [%s] is [%s]\n", nstr,
|
||||
pattern);
|
||||
fprintf(debug_file, "Pattern[%s] for [%s] is [%s]\n",
|
||||
v->name, nstr, pattern);
|
||||
if (*tstr == 'M') {
|
||||
newStr = VarModify(ctxt, &parsestate, nstr, VarMatch,
|
||||
pattern);
|
||||
@@ -3517,7 +3511,8 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
}
|
||||
}
|
||||
if (DEBUG(VAR)) {
|
||||
fprintf(debug_file, "Result of :%c is \"%s\"\n", modifier, newStr);
|
||||
fprintf(debug_file, "Result[%s] of :%c is \"%s\"\n",
|
||||
v->name, modifier, newStr);
|
||||
}
|
||||
|
||||
if (newStr != nstr) {
|
||||
@@ -4150,6 +4145,7 @@ Var_GetHead(char *file)
|
||||
void
|
||||
Var_Init(void)
|
||||
{
|
||||
VAR_INTERNAL = Targ_NewGN("Internal");
|
||||
VAR_GLOBAL = Targ_NewGN("Global");
|
||||
VAR_CMD = Targ_NewGN("Command");
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# $NetBSD: Makefile,v 1.11 2009/04/14 22:15:23 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.14 2013/07/19 04:17:02 uwe Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
WARNS?= 2 # XXX -Wcast-qual issues
|
||||
WARNS?= 6
|
||||
|
||||
PROG= man
|
||||
SRCS= man.c manconf.c
|
||||
MAN= man.1 man.conf.5
|
||||
|
||||
COPTS.man.c += -Wno-format-nonliteral
|
||||
|
||||
DPADD+= ${LIBUTIL}
|
||||
LDADD+= -lutil
|
||||
|
||||
|
||||
+2
-7
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: man.1,v 1.24 2011/10/07 10:52:31 mbalmer Exp $
|
||||
.\" $NetBSD: man.1,v 1.26 2013/07/18 03:40:31 uwe Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -201,8 +201,7 @@ The standard search path used by
|
||||
.Nm
|
||||
may be overridden by specifying a path in the
|
||||
.Ev MANPATH
|
||||
environment
|
||||
variable.
|
||||
environment variable.
|
||||
The format of the path is a colon
|
||||
.Pq Dq \&:
|
||||
separated list of directories.
|
||||
@@ -224,10 +223,6 @@ will be used.
|
||||
.Bl -hang -width /etc/man.conf -compact
|
||||
.It Pa /etc/man.conf
|
||||
default man configuration file.
|
||||
.It Pa /usr/{share,X11R7,pkg,local}/man/whatis.db
|
||||
standard whatis/apropos database search path,
|
||||
set in
|
||||
.Pa /etc/man.conf .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr apropos 1 ,
|
||||
|
||||
+94
-69
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $ */
|
||||
/* $NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994, 1995
|
||||
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $");
|
||||
__RCSID("$NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -101,23 +101,23 @@ struct manstate {
|
||||
|
||||
/* other misc stuff */
|
||||
const char *pager; /* pager to use */
|
||||
size_t pagerlen; /* length of the above */
|
||||
const char *machine; /* machine */
|
||||
const char *machclass; /* machine class */
|
||||
size_t pagerlen; /* length of the above */
|
||||
};
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void build_page(char *, char **, struct manstate *);
|
||||
static void cat(char *);
|
||||
static void build_page(const char *, char **, struct manstate *);
|
||||
static void cat(const char *);
|
||||
static const char *check_pager(const char *);
|
||||
static int cleanup(void);
|
||||
static void how(char *);
|
||||
static void jump(char **, char *, char *);
|
||||
static void how(const char *);
|
||||
static void jump(char **, const char *, const char *) __dead;
|
||||
static int manual(char *, struct manstate *, glob_t *);
|
||||
static void onsig(int);
|
||||
static void usage(void) __attribute__((__noreturn__));
|
||||
static void onsig(int) __dead;
|
||||
static void usage(void) __dead;
|
||||
static void addpath(struct manstate *, const char *, size_t, const char *);
|
||||
static const char *getclass(const char *);
|
||||
static void printmanpath(struct manstate *);
|
||||
@@ -128,7 +128,7 @@ static void printmanpath(struct manstate *);
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
static struct manstate m = { 0 }; /* init to zero */
|
||||
static struct manstate m;
|
||||
int ch, abs_section, found;
|
||||
ENTRY *esubd, *epath;
|
||||
char *p, **ap, *cmd;
|
||||
@@ -465,33 +465,71 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
static int
|
||||
manual_find_buildkeyword(char *escpage, const char *fmt,
|
||||
struct manstate *mp, glob_t *pg, size_t cnt)
|
||||
manual_find_literalfile(struct manstate *mp, char **pv)
|
||||
{
|
||||
ENTRY *suffix;
|
||||
int found;
|
||||
char *p, buf[MAXPATHLEN];
|
||||
char buf[MAXPATHLEN];
|
||||
const char *p;
|
||||
int suflen;
|
||||
|
||||
found = 0;
|
||||
/* Try the _build key words next. */
|
||||
|
||||
/*
|
||||
* Expand both '*' and suffix to force an actual
|
||||
* match via fnmatch(3). Since the only match in pg
|
||||
* is the literal file, the match is genuine.
|
||||
*/
|
||||
|
||||
TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) {
|
||||
for (p = suffix->s;
|
||||
for (p = suffix->s, suflen = 0;
|
||||
*p != '\0' && !isspace((unsigned char)*p);
|
||||
++p)
|
||||
continue;
|
||||
++suflen;
|
||||
if (*p == '\0')
|
||||
continue;
|
||||
|
||||
*p = '\0';
|
||||
(void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s);
|
||||
if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
|
||||
(void)snprintf(buf, sizeof(buf), "*%.*s", suflen, suffix->s);
|
||||
|
||||
if (!fnmatch(buf, *pv, 0)) {
|
||||
if (!mp->where)
|
||||
build_page(p + 1, &pg->gl_pathv[cnt], mp);
|
||||
*p = ' ';
|
||||
build_page(p + 1, pv, mp);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
*p = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static int
|
||||
manual_find_buildkeyword(const char *prefix, const char *escpage,
|
||||
struct manstate *mp, char **pv)
|
||||
{
|
||||
ENTRY *suffix;
|
||||
int found;
|
||||
char buf[MAXPATHLEN];
|
||||
const char *p;
|
||||
int suflen;
|
||||
|
||||
found = 0;
|
||||
/* Try the _build keywords next. */
|
||||
TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) {
|
||||
for (p = suffix->s, suflen = 0;
|
||||
*p != '\0' && !isspace((unsigned char)*p);
|
||||
++p)
|
||||
++suflen;
|
||||
if (*p == '\0')
|
||||
continue;
|
||||
|
||||
(void)snprintf(buf, sizeof(buf), "%s%s%.*s",
|
||||
prefix, escpage, suflen, suffix->s);
|
||||
if (!fnmatch(buf, *pv, 0)) {
|
||||
if (!mp->where)
|
||||
build_page(p + 1, pv, mp);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
@@ -536,10 +574,10 @@ manual(char *page, struct manstate *mp, glob_t *pg)
|
||||
*eptr = '\0';
|
||||
|
||||
/*
|
||||
* If 'page' is given with a full or relative path
|
||||
* then interpret it as a file specification.
|
||||
* If 'page' contains a slash then it's
|
||||
* interpreted as a file specification.
|
||||
*/
|
||||
if ((page[0] == '/') || (page[0] == '.')) {
|
||||
if (strchr(page, '/') != NULL) {
|
||||
/* check if file actually exists */
|
||||
(void)strlcpy(buf, escpage, sizeof(buf));
|
||||
error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg);
|
||||
@@ -554,30 +592,14 @@ manual(char *page, struct manstate *mp, glob_t *pg)
|
||||
if (pg->gl_matchc == 0)
|
||||
goto notfound;
|
||||
|
||||
/* clip suffix for the suffix check below */
|
||||
p = strrchr(escpage, '.');
|
||||
if (p && p[0] == '.' && isdigit((unsigned char)p[1]))
|
||||
p[0] = '\0';
|
||||
|
||||
found = 0;
|
||||
for (cnt = pg->gl_pathc - pg->gl_matchc;
|
||||
cnt < pg->gl_pathc; ++cnt)
|
||||
{
|
||||
found = manual_find_buildkeyword(escpage, "%s%s",
|
||||
mp, pg, cnt);
|
||||
if (found) {
|
||||
anyfound = 1;
|
||||
if (!mp->all) {
|
||||
/* Delete any other matches. */
|
||||
while (++cnt< pg->gl_pathc)
|
||||
pg->gl_pathv[cnt] = "";
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* literal file only yields one match */
|
||||
cnt = pg->gl_pathc - pg->gl_matchc;
|
||||
|
||||
if (manual_find_literalfile(mp, &pg->gl_pathv[cnt])) {
|
||||
anyfound = 1;
|
||||
} else {
|
||||
/* It's not a man page, forget about it. */
|
||||
pg->gl_pathv[cnt] = "";
|
||||
*pg->gl_pathv[cnt] = '\0';
|
||||
}
|
||||
|
||||
notfound:
|
||||
@@ -626,17 +648,17 @@ manual(char *page, struct manstate *mp, glob_t *pg)
|
||||
if (mp->pathsearch) {
|
||||
p = strstr(pg->gl_pathv[cnt], mp->pathsearch);
|
||||
if (!p || strchr(p, '/') == NULL) {
|
||||
pg->gl_pathv[cnt] = ""; /* zap! */
|
||||
*pg->gl_pathv[cnt] = '\0'; /* zap! */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try the _suffix key words first.
|
||||
* Try the _suffix keywords first.
|
||||
*
|
||||
* XXX
|
||||
* Older versions of man.conf didn't have the suffix
|
||||
* key words, it was assumed that everything was a .0.
|
||||
* Older versions of man.conf didn't have the _suffix
|
||||
* keywords, it was assumed that everything was a .0.
|
||||
* We just test for .0 first, it's fast and probably
|
||||
* going to hit.
|
||||
*/
|
||||
@@ -657,22 +679,22 @@ manual(char *page, struct manstate *mp, glob_t *pg)
|
||||
if (found)
|
||||
goto next;
|
||||
|
||||
/* Try the _build key words next. */
|
||||
found = manual_find_buildkeyword(escpage, "*/%s%s",
|
||||
mp, pg, cnt);
|
||||
/* Try the _build keywords next. */
|
||||
found = manual_find_buildkeyword("*/", escpage,
|
||||
mp, &pg->gl_pathv[cnt]);
|
||||
if (found) {
|
||||
next: anyfound = 1;
|
||||
if (!mp->all) {
|
||||
/* Delete any other matches. */
|
||||
while (++cnt< pg->gl_pathc)
|
||||
pg->gl_pathv[cnt] = "";
|
||||
*pg->gl_pathv[cnt] = '\0';
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* It's not a man page, forget about it. */
|
||||
pg->gl_pathv[cnt] = "";
|
||||
*pg->gl_pathv[cnt] = '\0';
|
||||
}
|
||||
|
||||
if (anyfound && !mp->all)
|
||||
@@ -697,10 +719,11 @@ next: anyfound = 1;
|
||||
* Build a man page for display.
|
||||
*/
|
||||
static void
|
||||
build_page(char *fmt, char **pathp, struct manstate *mp)
|
||||
build_page(const char *fmt, char **pathp, struct manstate *mp)
|
||||
{
|
||||
static int warned;
|
||||
int olddir, fd, n, tmpdirlen;
|
||||
int olddir, fd, n;
|
||||
size_t tmpdirlen;
|
||||
char *p, *b;
|
||||
char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[MAXPATHLEN];
|
||||
const char *tmpdir;
|
||||
@@ -746,7 +769,7 @@ build_page(char *fmt, char **pathp, struct manstate *mp)
|
||||
}
|
||||
|
||||
|
||||
/* advance fmt pass the suffix spec to the printf format string */
|
||||
/* advance fmt past the suffix spec to the printf format string */
|
||||
for (; *fmt && isspace((unsigned char)*fmt); ++fmt)
|
||||
continue;
|
||||
|
||||
@@ -758,7 +781,7 @@ build_page(char *fmt, char **pathp, struct manstate *mp)
|
||||
tmpdir = _PATH_TMP;
|
||||
tmpdirlen = strlen(tmpdir);
|
||||
(void)snprintf(tpath, sizeof (tpath), "%s%s%s", tmpdir,
|
||||
(tmpdirlen && tmpdir[tmpdirlen-1] == '/') ? "" : "/", TMPFILE);
|
||||
(tmpdirlen > 0 && tmpdir[tmpdirlen-1] == '/') ? "" : "/", TMPFILE);
|
||||
if ((fd = mkstemp(tpath)) == -1) {
|
||||
warn("%s", tpath);
|
||||
(void)cleanup();
|
||||
@@ -793,12 +816,13 @@ build_page(char *fmt, char **pathp, struct manstate *mp)
|
||||
* display how information
|
||||
*/
|
||||
static void
|
||||
how(char *fname)
|
||||
how(const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
int lcnt, print;
|
||||
char *p, buf[256];
|
||||
char buf[256];
|
||||
const char *p;
|
||||
|
||||
if (!(fp = fopen(fname, "r"))) {
|
||||
warn("%s", fname);
|
||||
@@ -840,9 +864,10 @@ how(char *fname)
|
||||
* cat out the file
|
||||
*/
|
||||
static void
|
||||
cat(char *fname)
|
||||
cat(const char *fname)
|
||||
{
|
||||
int fd, n;
|
||||
int fd;
|
||||
ssize_t n;
|
||||
char buf[2048];
|
||||
|
||||
if ((fd = open(fname, O_RDONLY, 0)) < 0) {
|
||||
@@ -851,7 +876,7 @@ cat(char *fname)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while ((n = read(fd, buf, sizeof(buf))) > 0)
|
||||
if (write(STDOUT_FILENO, buf, n) != n) {
|
||||
if (write(STDOUT_FILENO, buf, (size_t)n) != n) {
|
||||
warn("write");
|
||||
(void)cleanup();
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -898,11 +923,11 @@ check_pager(const char *name)
|
||||
* strip out flag argument and jump
|
||||
*/
|
||||
static void
|
||||
jump(char **argv, char *flag, char *name)
|
||||
jump(char **argv, const char *flag, const char *name)
|
||||
{
|
||||
char **arg;
|
||||
|
||||
argv[0] = name;
|
||||
argv[0] = __UNCONST(name);
|
||||
for (arg = argv + 1; *arg; ++arg)
|
||||
if (!strcmp(*arg, flag))
|
||||
break;
|
||||
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: man.conf.5,v 1.22 2012/04/29 03:46:43 christos Exp $
|
||||
.\" $NetBSD: man.conf.5,v 1.24 2013/06/28 10:13:18 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -81,9 +81,9 @@ Control keywords must start with the
|
||||
.Dq _
|
||||
character.
|
||||
The following control keywords are currently defined:
|
||||
.Bl -tag -width "_version"
|
||||
.Bl -tag -width XXmachineX
|
||||
.It _build
|
||||
identifies the set of suffixes used for manual pages that must be
|
||||
Identifies the set of suffixes used for manual pages that must be
|
||||
formatted for display and the command that should be used to format
|
||||
them.
|
||||
Manual file names, regardless of their format, are expected to end in a
|
||||
@@ -103,7 +103,7 @@ There should be exactly one occurrence of the string
|
||||
in the shell command line, and it will
|
||||
be replaced by the name of the file which is being formatted.
|
||||
.It _crunch
|
||||
used by
|
||||
Used by
|
||||
.Xr catman 8
|
||||
to determine how to crunch formatted pages
|
||||
which originally were compressed man pages: The first field lists a suffix
|
||||
@@ -115,9 +115,9 @@ There should be exactly one occurrence of the string
|
||||
in the shell command line, and it will
|
||||
be replaced by the name of the output file.
|
||||
.It _default
|
||||
contains the system-wide default man path used to search for man pages.
|
||||
Contains the system-wide default man path used to search for man pages.
|
||||
.It _subdir
|
||||
contains the list (in search order) of section subdirectories which will
|
||||
Contains the list (in search order) of section subdirectories which will
|
||||
be searched in any man path directory named with a trailing slash
|
||||
.Pq Dq /
|
||||
character.
|
||||
@@ -141,9 +141,9 @@ Each suffix may contain the normal shell globbing characters (NOT
|
||||
including curly braces
|
||||
.Pq Dq {} ) .
|
||||
.It _version
|
||||
contains the version of the configuration file.
|
||||
Contains the version of the configuration file.
|
||||
.It _whatdb
|
||||
defines the full pathname (not just a directory path) for a database to
|
||||
Defines the full pathname (not just a directory path) for a database to
|
||||
be used
|
||||
by the
|
||||
.Xr apropos 1
|
||||
@@ -156,8 +156,8 @@ including curly braces
|
||||
to escape a shell globbing character,
|
||||
precede it with a backslash
|
||||
.Pq Dq \e .
|
||||
.It _\*[Lt]machine\*[Gt]
|
||||
The defines additional paths to be searched for the particular
|
||||
.It _ Ns Aq machine
|
||||
Defines additional paths to be searched for the particular
|
||||
.Dv machine
|
||||
whose literal value is taken from
|
||||
.Xr uname 1
|
||||
@@ -241,7 +241,7 @@ sect3 /usr/share/man/{old/,}cat3
|
||||
By default, the command
|
||||
.Dq Li man mktemp
|
||||
will search for
|
||||
.Dq mktemp.\*[Lt]any_digit\*[Gt]
|
||||
.Dq mktemp. Ns Aq any_digit
|
||||
and
|
||||
.Dq mktemp.tbl
|
||||
in the directories
|
||||
@@ -260,7 +260,7 @@ searched.
|
||||
If
|
||||
.Dq mktemp.tbl
|
||||
was found first, the command
|
||||
.Dq Li tbl \*[Lt]manual page\*[Gt] | nroff -man
|
||||
.Dq Li tbl Ao manual page Ac | nroff -man
|
||||
would be run to build a man page for display to the user.
|
||||
.Pp
|
||||
The command
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: manconf.c,v 1.6 2008/03/08 15:48:27 christos Exp $ */
|
||||
/* $NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1995
|
||||
@@ -45,7 +45,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)config.c 8.8 (Berkeley) 1/31/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: manconf.c,v 1.6 2008/03/08 15:48:27 christos Exp $");
|
||||
__RCSID("$NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -172,8 +172,8 @@ config(const char *fname)
|
||||
* section entries can either be all absolute
|
||||
* paths or all relative paths, but not both.
|
||||
*/
|
||||
type = (TAILQ_FIRST(&tp->entrylist) != NULL) ?
|
||||
*(TAILQ_FIRST(&tp->entrylist)->s) : 0;
|
||||
type = (char)((TAILQ_FIRST(&tp->entrylist) != NULL) ?
|
||||
*(TAILQ_FIRST(&tp->entrylist)->s) : '\0');
|
||||
|
||||
for (++t; (p = strtok(t, " \t\n")) != NULL; t = NULL) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: defs.h,v 1.9 2012/03/06 16:55:18 mbalmer Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.10 2013/10/18 20:19:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@@ -50,10 +50,12 @@
|
||||
#define INIT(x)
|
||||
#endif
|
||||
|
||||
/* some constants */
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
/* Global variables .. to be defined in main.c, extern elsewhere. */
|
||||
|
||||
EXTERN char *prog_name;
|
||||
|
||||
@@ -6,7 +6,4 @@ MAN= mkdep.1
|
||||
PROG= mkdep
|
||||
SRCS= mkdep.c findcc.c
|
||||
|
||||
# LSC Until it compiles cleanly...
|
||||
NOGCCERROR:=yes
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: findcc.c,v 1.5 2009/04/12 14:23:30 lukem Exp $ */
|
||||
/* $NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@@ -37,7 +37,7 @@
|
||||
#if !defined(lint)
|
||||
__COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
|
||||
All rights reserved.");
|
||||
__RCSID("$NetBSD: findcc.c,v 1.5 2009/04/12 14:23:30 lukem Exp $");
|
||||
__RCSID("$NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -49,8 +49,7 @@ __RCSID("$NetBSD: findcc.c,v 1.5 2009/04/12 14:23:30 lukem Exp $");
|
||||
#include "findcc.h"
|
||||
|
||||
char *
|
||||
findcc(progname)
|
||||
const char *progname;
|
||||
findcc(const char *progname)
|
||||
{
|
||||
char *path, *dir, *next;
|
||||
char buffer[MAXPATHLEN];
|
||||
|
||||
+22
-4
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: mkdep.1,v 1.15 2010/10/15 05:46:48 dholland Exp $
|
||||
.\" $NetBSD: mkdep.1,v 1.18 2013/03/05 01:59:56 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" @(#)mkdep.1 8.1 (Berkeley) 6/6/93
|
||||
.\"
|
||||
.Dd October 15, 2010
|
||||
.Dd March 4, 2013
|
||||
.Dt MKDEP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -37,8 +37,9 @@
|
||||
.Nd construct Makefile dependency list
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl aDdopq
|
||||
.Op Fl aDdiopqv
|
||||
.Op Fl f Ar file
|
||||
.Op Fl P Ar prefix
|
||||
.Op Fl s Ar suffixes
|
||||
.Li --
|
||||
.Op Ar flags
|
||||
@@ -79,8 +80,23 @@ depend files into a single file.
|
||||
Write the include file dependencies to
|
||||
.Ar file ,
|
||||
instead of the default ``.depend''.
|
||||
.It Fl i
|
||||
When
|
||||
.Fl d
|
||||
or
|
||||
.Fl D
|
||||
is used, instead of inlining the contents of the files to the resulting
|
||||
depend file, use include statements to include the source dependency files.
|
||||
.It Fl o
|
||||
Add an additional .OPTIONAL line for each dependant file.
|
||||
Add an additional .OPTIONAL line for each dependent file.
|
||||
.It Fl P
|
||||
Prepend the string given in
|
||||
.Ar prefix
|
||||
to every target filename.
|
||||
This is useful for programs that have source files in multiple subdirectories
|
||||
and a single Makefile that references all of them explicitly (without using
|
||||
the VPATH functionality because there can be files with the same name in
|
||||
each subdirectory).
|
||||
.It Fl p
|
||||
Cause
|
||||
.Nm
|
||||
@@ -109,6 +125,8 @@ Expand each target filename to a list, replacing the
|
||||
suffix with each element of
|
||||
.Ar suffixes .
|
||||
The list of suffixes may be space or comma separated.
|
||||
.It Fl v
|
||||
print debugging output.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width .depend -compact
|
||||
|
||||
+123
-52
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mkdep.c,v 1.35 2010/05/26 18:07:34 christos Exp $ */
|
||||
/* $NetBSD: mkdep.c,v 1.43 2013/03/05 21:57:47 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@@ -37,7 +37,7 @@
|
||||
#if !defined(lint)
|
||||
__COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
|
||||
All rights reserved.");
|
||||
__RCSID("$NetBSD: mkdep.c,v 1.35 2010/05/26 18:07:34 christos Exp $");
|
||||
__RCSID("$NetBSD: mkdep.c,v 1.43 2013/03/05 21:57:47 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef __minix
|
||||
@@ -48,6 +48,7 @@ __RCSID("$NetBSD: mkdep.c,v 1.35 2010/05/26 18:07:34 christos Exp $");
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <locale.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
@@ -66,21 +67,22 @@ struct opt {
|
||||
char name[4];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct suff_list {
|
||||
size_t len;
|
||||
char suff[12];
|
||||
char *suff;
|
||||
struct suff_list *next;
|
||||
} suff_list_t;
|
||||
|
||||
/* tree of includes for -o processing */
|
||||
opt_t *opt;
|
||||
int width;
|
||||
static opt_t *opt;
|
||||
static int width;
|
||||
static int verbose;
|
||||
|
||||
#define DEFAULT_PATH _PATH_DEFPATH
|
||||
#define DEFAULT_FILENAME ".depend"
|
||||
|
||||
static void save_for_optional(const char *, const char *);
|
||||
static int write_optional(int, opt_t *, int);
|
||||
|
||||
static size_t write_optional(int, opt_t *, size_t);
|
||||
|
||||
static inline void *
|
||||
deconst(const void *p)
|
||||
@@ -88,11 +90,12 @@ deconst(const void *p)
|
||||
return (const char *)p - (const char *)0 + (char *)0;
|
||||
}
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-aDdopq] [-f file] [-s suffixes] -- [flags] file ...\n",
|
||||
"usage: %s [-aDdiopqv] [-f file] [-P prefix] [-s suffixes] "
|
||||
"-- [flags] file ...\n",
|
||||
getprogname());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -126,13 +129,19 @@ run_cc(int argc, char **argv, const char **fname)
|
||||
tmpdir = _PATH_TMP;
|
||||
(void)snprintf(tmpfilename, sizeof (tmpfilename), "%s/%s", tmpdir,
|
||||
"mkdepXXXXXX");
|
||||
if ((tmpfd = mkstemp(tmpfilename)) < 0) {
|
||||
warn("unable to create temporary file %s", tmpfilename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((tmpfd = mkstemp(tmpfilename)) < 0)
|
||||
err(EXIT_FAILURE, "Unable to create temporary file %s",
|
||||
tmpfilename);
|
||||
(void)unlink(tmpfilename);
|
||||
*fname = tmpfilename;
|
||||
|
||||
if (verbose) {
|
||||
char **a;
|
||||
for (a = args; *a; a++)
|
||||
printf("%s ", *a);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
switch (cpid = vfork()) {
|
||||
case 0:
|
||||
(void)dup2(tmpfd, STDOUT_FILENO);
|
||||
@@ -185,10 +194,31 @@ read_fname(void)
|
||||
return fbuf;
|
||||
}
|
||||
|
||||
static struct option longopt[] = {
|
||||
{ "sysroot", 1, NULL, 'R' },
|
||||
{ NULL, 0, NULL, '\0' },
|
||||
};
|
||||
|
||||
static void
|
||||
addsuff(suff_list_t **l, const char *s, size_t len)
|
||||
{
|
||||
suff_list_t *p = calloc(1, sizeof(*p));
|
||||
if (p == NULL)
|
||||
err(1, "calloc");
|
||||
p->suff = malloc(len + 1);
|
||||
if (p->suff == NULL)
|
||||
err(1, "malloc");
|
||||
memcpy(p->suff, s, len);
|
||||
p->suff[len] = '\0';
|
||||
p->len = len;
|
||||
p->next = *l;
|
||||
*l = p;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int aflag, dflag, oflag, qflag;
|
||||
int aflag, dflag, iflag, oflag, qflag;
|
||||
const char *filename;
|
||||
int dependfile;
|
||||
char *buf, *lim, *ptr, *line, *suf, *colon, *eol;
|
||||
@@ -197,6 +227,7 @@ main(int argc, char **argv)
|
||||
int fd;
|
||||
size_t slen;
|
||||
const char *fname;
|
||||
const char *prefix = NULL;
|
||||
const char *suffixes = NULL, *s;
|
||||
suff_list_t *suff_list = NULL, *sl;
|
||||
#ifdef __minix
|
||||
@@ -211,6 +242,7 @@ main(int argc, char **argv)
|
||||
|
||||
aflag = O_WRONLY | O_APPEND | O_CREAT | O_TRUNC;
|
||||
dflag = 0;
|
||||
iflag = 0;
|
||||
oflag = 0;
|
||||
qflag = 0;
|
||||
filename = DEFAULT_FILENAME;
|
||||
@@ -219,7 +251,7 @@ main(int argc, char **argv)
|
||||
opterr = 0; /* stop getopt() bleating about errors. */
|
||||
for (;;) {
|
||||
ok_ind = optind;
|
||||
ch = getopt(argc, argv, "aDdf:opqs:");
|
||||
ch = getopt_long(argc, argv, "aDdf:ioP:pqRs:v", longopt, NULL);
|
||||
switch (ch) {
|
||||
case -1:
|
||||
ok_ind = optind;
|
||||
@@ -238,18 +270,30 @@ main(int argc, char **argv)
|
||||
case 'f': /* Name of output file */
|
||||
filename = optarg;
|
||||
continue;
|
||||
case 'o': /* Mark dependant files .OPTIONAL */
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
continue;
|
||||
case 'o': /* Mark dependent files .OPTIONAL */
|
||||
oflag = 1;
|
||||
continue;
|
||||
case 'P': /* Prefix for each target filename */
|
||||
prefix = optarg;
|
||||
continue;
|
||||
case 'p': /* Program mode (x.o: -> x:) */
|
||||
suffixes = "";
|
||||
continue;
|
||||
case 'q': /* Quiet */
|
||||
qflag = 1;
|
||||
continue;
|
||||
case 'R':
|
||||
/* sysroot = optarg */
|
||||
continue;
|
||||
case 's': /* Suffix list */
|
||||
suffixes = optarg;
|
||||
continue;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
continue;
|
||||
default:
|
||||
if (dflag)
|
||||
usage();
|
||||
@@ -265,28 +309,20 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
if (suffixes != NULL) {
|
||||
/* parse list once and save names and lengths */
|
||||
/* allocate an extra entry to mark end of list */
|
||||
for (sz = 1, s = suffixes; *s != 0; s++)
|
||||
if (*s == '.')
|
||||
sz++;
|
||||
suff_list = calloc(sz, sizeof *suff_list);
|
||||
if (suff_list == NULL)
|
||||
err(2, "malloc");
|
||||
sl = suff_list;
|
||||
for (s = suffixes; (s = strchr(s, '.')); s += sz, sl++) {
|
||||
sz = strcspn(s, ", ");
|
||||
if (sz > sizeof sl->suff)
|
||||
errx(2, "suffix too long");
|
||||
sl->len = sz;
|
||||
memcpy(sl->suff, s, sz);
|
||||
}
|
||||
if (*suffixes) {
|
||||
for (s = suffixes; (sz = strcspn(s, ", ")) != 0;) {
|
||||
addsuff(&suff_list, s, sz);
|
||||
s += sz;
|
||||
while (*s && strchr(", ", *s))
|
||||
s++;
|
||||
}
|
||||
} else
|
||||
addsuff(&suff_list, "", 0);
|
||||
}
|
||||
|
||||
dependfile = open(filename, aflag, 0666);
|
||||
if (dependfile == -1)
|
||||
err(EXIT_FAILURE, "unable to %s to file %s\n",
|
||||
aflag & O_TRUNC ? "write" : "append", filename);
|
||||
goto wrerror;
|
||||
|
||||
while (dflag == 2 || *argv != NULL) {
|
||||
if (dflag) {
|
||||
@@ -296,6 +332,12 @@ main(int argc, char **argv)
|
||||
break;
|
||||
} else
|
||||
fname = *argv++;
|
||||
if (iflag) {
|
||||
if (dprintf(dependfile, ".-include \"%s\"\n",
|
||||
fname) < 0)
|
||||
goto wrerror;
|
||||
continue;
|
||||
}
|
||||
fd = open(fname, O_RDONLY, 0);
|
||||
if (fd == -1) {
|
||||
if (!qflag)
|
||||
@@ -358,7 +400,8 @@ main(int argc, char **argv)
|
||||
}
|
||||
if (isspace((unsigned char)*line) || colon == NULL) {
|
||||
/* No dependency - just transcribe line */
|
||||
write(dependfile, line, eol - line);
|
||||
if (write(dependfile, line, eol - line) < 0)
|
||||
goto wrerror;
|
||||
line = eol;
|
||||
continue;
|
||||
}
|
||||
@@ -373,8 +416,10 @@ main(int argc, char **argv)
|
||||
errx(EXIT_FAILURE,
|
||||
"Corrupted file `%s'", fname);
|
||||
/* Then look for any valid suffix */
|
||||
for (sl = suff_list; sl->len != 0; sl++) {
|
||||
if (!memcmp(suf - sl->len, sl->suff,
|
||||
for (sl = suff_list; sl != NULL;
|
||||
sl = sl->next) {
|
||||
if (sl->len && buf <= suf - sl->len &&
|
||||
!memcmp(suf - sl->len, sl->suff,
|
||||
sl->len))
|
||||
break;
|
||||
}
|
||||
@@ -382,7 +427,7 @@ main(int argc, char **argv)
|
||||
* Not found, check for .o, since the
|
||||
* original file will have it.
|
||||
*/
|
||||
if (sl->len == 0 && suff_list->len != 0) {
|
||||
if (sl == NULL) {
|
||||
if (memcmp(suf - 2, ".o", 2) == 0)
|
||||
slen = 2;
|
||||
else
|
||||
@@ -392,15 +437,33 @@ main(int argc, char **argv)
|
||||
}
|
||||
if (suff_list != NULL && slen != 0) {
|
||||
suf -= slen;
|
||||
for (sl = suff_list; sl->len != 0; sl++) {
|
||||
for (sl = suff_list; sl != NULL; sl = sl->next)
|
||||
{
|
||||
if (sl != suff_list)
|
||||
write(dependfile, " ", 1);
|
||||
write(dependfile, line, suf - line);
|
||||
write(dependfile, sl->suff, sl->len);
|
||||
if (write(dependfile, " ", 1)
|
||||
< 0)
|
||||
goto wrerror;
|
||||
if (prefix != NULL)
|
||||
if (write(dependfile, prefix,
|
||||
strlen(prefix)) < 0)
|
||||
goto wrerror;
|
||||
if (write(dependfile, line,
|
||||
suf - line) < 0)
|
||||
goto wrerror;
|
||||
if (write(dependfile, sl->suff,
|
||||
sl->len) < 0)
|
||||
goto wrerror;
|
||||
}
|
||||
write(dependfile, colon, eol - colon);
|
||||
} else
|
||||
write(dependfile, line, eol - line);
|
||||
if (write(dependfile, colon, eol - colon) < 0)
|
||||
goto wrerror;
|
||||
} else {
|
||||
if (prefix != NULL)
|
||||
if (write(dependfile, prefix,
|
||||
strlen(prefix)) < 0)
|
||||
goto wrerror;
|
||||
if (write(dependfile, line, eol - line) < 0)
|
||||
goto wrerror;
|
||||
}
|
||||
|
||||
if (oflag)
|
||||
save_for_optional(colon + 1, eol);
|
||||
@@ -414,15 +477,21 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (oflag && opt != NULL) {
|
||||
write(dependfile, ".OPTIONAL:", 10);
|
||||
if (write(dependfile, ".OPTIONAL:", 10) < 0)
|
||||
goto wrerror;
|
||||
width = 9;
|
||||
sz = write_optional(dependfile, opt, 0);
|
||||
if (sz == (size_t)-1)
|
||||
goto wrerror;
|
||||
/* 'depth' is about 39 for an i386 kernel */
|
||||
/* fprintf(stderr, "Recursion depth %d\n", sz); */
|
||||
}
|
||||
close(dependfile);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
wrerror:
|
||||
err(EXIT_FAILURE, "unable to %s to file %s\n",
|
||||
aflag & O_TRUNC ? "write" : "append", filename);
|
||||
}
|
||||
|
||||
|
||||
@@ -479,19 +548,21 @@ save_for_optional(const char *start, const char *limit)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
write_optional(int fd, opt_t *node, int depth)
|
||||
static size_t
|
||||
write_optional(int fd, opt_t *node, size_t depth)
|
||||
{
|
||||
int d1 = ++depth;
|
||||
size_t d1 = ++depth;
|
||||
|
||||
if (node->left)
|
||||
d1 = write_optional(fd, node->left, d1);
|
||||
if (width > 76 - node->len) {
|
||||
write(fd, " \\\n ", 4);
|
||||
if (write(fd, " \\\n ", 4) < 0)
|
||||
return (size_t)-1;
|
||||
width = 1;
|
||||
}
|
||||
width += 1 + node->len;
|
||||
write(fd, node->name, 1 + node->len);
|
||||
if (write(fd, node->name, 1 + node->len) < 0)
|
||||
return (size_t)-1;
|
||||
if (node->right)
|
||||
depth = write_optional(fd, node->right, depth);
|
||||
return d1 > depth ? d1 : depth;
|
||||
|
||||
+129
-86
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: mktemp.1,v 1.19 2009/08/15 20:44:56 wiz Exp $
|
||||
.\" $NetBSD: mktemp.1,v 1.21 2012/11/04 10:10:03 apb Exp $
|
||||
.\" From: $FreeBSD: src/usr.bin/mktemp/mktemp.1,v 1.5 1999/08/28 01:04:13 peter Exp $
|
||||
.\" From: $OpenBSD: mktemp.1,v 1.8 1998/03/19 06:13:37 millert Exp $
|
||||
.\"
|
||||
@@ -31,7 +31,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD: src/usr.bin/mktemp/mktemp.1,v 1.5 1999/08/28 01:04:13 peter Exp $
|
||||
.\"
|
||||
.Dd August 15, 2009
|
||||
.Dd November 4, 2012
|
||||
.Dt MKTEMP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -49,114 +49,131 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility takes each of the given file name templates and overwrites a
|
||||
portion of it to create a file name.
|
||||
This file name is unique and suitable for use by the application.
|
||||
The template may be any file name with some number of
|
||||
.Ql X Ns s
|
||||
appended to it, for example
|
||||
.Pa /tmp/temp.XXXX .
|
||||
utility
|
||||
is provided to allow shell scripts to safely use temporary files.
|
||||
It creates temporary files or directories using unique names,
|
||||
and prints the names.
|
||||
.Pp
|
||||
The name of each temporary file or directory is derived from a
|
||||
template that includes several trailing
|
||||
.Ql X
|
||||
characters, such as
|
||||
.Pa /tmp/prefix.XXXX .
|
||||
The trailing
|
||||
.Ql X Ns s
|
||||
are replaced with the current process number and/or a
|
||||
unique letter combination.
|
||||
.Ql X
|
||||
characters in the template are replaced by unique values derived from
|
||||
the current process number and additional letters or numbers.
|
||||
Any
|
||||
.Ql X
|
||||
characters other than at the end of the template are taken literally.
|
||||
The number of unique file names
|
||||
.Nm
|
||||
can return depends on the number of
|
||||
can return depends on the number of trailing
|
||||
.Ql X Ns s
|
||||
provided; six
|
||||
in the template; six
|
||||
.Ql X Ns s
|
||||
will result in
|
||||
.Nm
|
||||
testing roughly 26 ** 6 combinations.
|
||||
.Pp
|
||||
The templates used to create the unique names are derived from the
|
||||
.Fl t Ar prefix
|
||||
option, or the
|
||||
.Ar template
|
||||
arguments, possibly modified by other options.
|
||||
Any number of temporary files or directories may be created
|
||||
in a single invocation using multiple
|
||||
.Ar template
|
||||
arguments.
|
||||
It is possible to specify both a
|
||||
.Fl t Ar prefix
|
||||
option and one or more
|
||||
.Ar template
|
||||
arguments,
|
||||
but this is not usually done.
|
||||
.Pp
|
||||
If neither a
|
||||
.Fl t Ar prefix
|
||||
option, nor any
|
||||
.Ar template
|
||||
arguments are specified, then the default is equivalent to
|
||||
.Fl t Li mktemp .
|
||||
.Pp
|
||||
If
|
||||
.Nm
|
||||
can successfully generate a unique file name, the file
|
||||
is created with mode 0600 (unless the
|
||||
.Fl u
|
||||
flag is given) and the filename is printed to standard output.
|
||||
.Pp
|
||||
If the
|
||||
.Fl t Ar prefix
|
||||
option is given,
|
||||
.Nm
|
||||
will generate a template string based on the
|
||||
.Ar prefix
|
||||
and the
|
||||
.Ev TMPDIR
|
||||
environment variable, if set.
|
||||
The default location if
|
||||
.Ev TMPDIR
|
||||
is not set is
|
||||
.Pa /tmp .
|
||||
The default location of the temporary directory can be overridden with the
|
||||
.Fl p Ar tmpdir
|
||||
option.
|
||||
The template string created will consist of the
|
||||
.Ar prefix
|
||||
followed by a
|
||||
.So . Sc
|
||||
and an eight character unique letter combination.
|
||||
.Ql X Ns s
|
||||
in the
|
||||
.Ar prefix
|
||||
string will be treated as literal.
|
||||
If an additional
|
||||
.Ar template
|
||||
argument is passed, a second file will be created.
|
||||
Care should be taken to ensure that it is appropriate to use an
|
||||
environment variable potentially supplied by the user.
|
||||
.Pp
|
||||
Any number of temporary files may be created in a single invocation
|
||||
using multiple
|
||||
.Ar template
|
||||
arguments, also a single one based on the internal template with the
|
||||
.Fl t
|
||||
option value as filename prefix.
|
||||
.Pp
|
||||
At least one
|
||||
.Ar template
|
||||
argument or the
|
||||
.Fl t
|
||||
option must be present.
|
||||
.Pp
|
||||
.Nm
|
||||
is provided to allow shell scripts to safely use temporary files.
|
||||
Traditionally, many shell scripts take the name of the program with
|
||||
the pid as a suffix and use that as a temporary file name.
|
||||
This kind of naming scheme is predictable and the race condition
|
||||
it creates is easy for an attacker to win.
|
||||
A safer, though still inferior, approach
|
||||
is to make a temporary directory using the same naming scheme.
|
||||
While this does allow one to guarantee that a temporary file will
|
||||
not be subverted, it still allows a simple denial of service attack.
|
||||
For these reasons it is suggested that
|
||||
.Nm
|
||||
be used instead.
|
||||
.Sh OPTIONS
|
||||
The available options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl d
|
||||
Make a directory instead of a file.
|
||||
.It Fl p Ar tmpdir
|
||||
Specifies a directory in which temporary files should be created.
|
||||
If this option is specified, then it applies to all temporary files,
|
||||
including those created as a result of a
|
||||
.Fl t Ar prefix
|
||||
option, and those created as a result of a
|
||||
.Ar template
|
||||
argument.
|
||||
.Pp
|
||||
If the
|
||||
.Fl p Ar tmpdir
|
||||
option is not specified, then
|
||||
temporary files created as a result of a
|
||||
.Fl t Ar prefix
|
||||
option will use a default temporary directory
|
||||
(as described under the
|
||||
.Fl t
|
||||
option),
|
||||
but temporary files created as a result of a
|
||||
.Ar template
|
||||
argument will not use a default temporary directory
|
||||
(so they will be created relative to the current working directory, if the
|
||||
.Ar template
|
||||
does not begin with
|
||||
.Ql \&/ ) .
|
||||
.It Fl t Ar prefix
|
||||
Generate a template using an appropriate directory name, followed by the
|
||||
supplied
|
||||
.Ar prefix ,
|
||||
followed by
|
||||
.Ql \&.XXXXXXXX .
|
||||
Any
|
||||
.Ql X
|
||||
characters in the supplied
|
||||
.Ar prefix
|
||||
are taken literally, but the trailing
|
||||
.Ql X
|
||||
characters in the appended
|
||||
.Ql \&.XXXXXXXX
|
||||
are replaced by unique values.
|
||||
.Pp
|
||||
The directory name used for the template generated by the
|
||||
.Fl t Ar prefix
|
||||
option is taken from the
|
||||
.Fl p Ar tmpdir
|
||||
option, or from the
|
||||
.Ev TMPDIR
|
||||
environment variable, or
|
||||
.Pa /tmp
|
||||
as a default.
|
||||
.Pp
|
||||
If one or more
|
||||
.Ar template
|
||||
arguments are used in addition to the
|
||||
.Fl t Ar prefix
|
||||
option, then the
|
||||
.Ar prefix
|
||||
does not apply to the
|
||||
.Ar template
|
||||
arguments.
|
||||
.It Fl q
|
||||
Fail silently if an error occurs.
|
||||
This is useful if
|
||||
a script does not want error output to go to standard error.
|
||||
.It Fl t Ar prefix
|
||||
Generate a template (using the supplied
|
||||
.Ar prefix
|
||||
and
|
||||
.Ev TMPDIR
|
||||
if set) to create a filename template.
|
||||
If
|
||||
.Fl t Ar prefix
|
||||
and
|
||||
.Ar template
|
||||
are both given,
|
||||
.Ar prefix
|
||||
will not apply to
|
||||
.Ar template .
|
||||
.It Fl u
|
||||
Operate in
|
||||
.Dq unsafe
|
||||
@@ -169,6 +186,32 @@ This is slightly better than
|
||||
but still introduces a race condition.
|
||||
Use of this option is not encouraged.
|
||||
.El
|
||||
.Sh NOTES
|
||||
.Nm
|
||||
takes care to create the files or directories in a way that is
|
||||
safe from race conditions (provided the
|
||||
.Fl u
|
||||
option is not used).
|
||||
.Pp
|
||||
Traditionally, without
|
||||
.Nm ,
|
||||
many shell scripts created temporary files
|
||||
using the name of the program with
|
||||
the pid as a suffix.
|
||||
This kind of naming scheme is predictable and creates a race condition that
|
||||
allows an attacker to subvert the program by
|
||||
creating a different file, directory, or symbolic link
|
||||
under the same name.
|
||||
A safer, though still inferior, approach
|
||||
is to make a temporary directory using the same naming schem
|
||||
While this does allow one to guarantee that a temporary file will
|
||||
not be subverted, it still allows a simple denial of service attack.
|
||||
For these reasons it is recommended that
|
||||
.Nm
|
||||
should be used instead of simpler schemes.
|
||||
.Pp
|
||||
Care should be taken to ensure that it is appropriate to use an
|
||||
environment variable potentially supplied by the user.
|
||||
.Sh EXIT STATUS
|
||||
The
|
||||
.Nm
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mktemp.c,v 1.11 2009/08/15 20:02:28 christos Exp $ */
|
||||
/* $NetBSD: mktemp.c,v 1.12 2012/11/03 13:34:08 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994, 1995, 1996, 1998 Peter Wemm <peter@netplex.com.au>
|
||||
@@ -50,7 +50,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: mktemp.c,v 1.11 2009/08/15 20:02:28 christos Exp $");
|
||||
__RCSID("$NetBSD: mktemp.c,v 1.12 2012/11/03 13:34:08 christos Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
static void usage(void) __dead;
|
||||
@@ -100,6 +100,9 @@ main(int argc, char **argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (tflag == 0 && argc < 1)
|
||||
tflag = 1;
|
||||
|
||||
if (tflag) {
|
||||
if (tmpdir == NULL)
|
||||
tmpdir = getenv("TMPDIR");
|
||||
|
||||
+7
-4
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: defs.h,v 1.5 2012/03/06 16:26:01 mbalmer Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.6 2013/10/18 20:19:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@@ -49,9 +49,12 @@
|
||||
#define INIT(x)
|
||||
#endif
|
||||
|
||||
/* some constants */
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/* Global variables .. to be defined in main.c, extern elsewhere. */
|
||||
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nbperf-bdz.c,v 1.5 2012/09/25 20:53:46 joerg Exp $ */
|
||||
/* $NetBSD: nbperf-bdz.c,v 1.8 2013/03/01 18:26:10 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009, 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: nbperf-bdz.c,v 1.5 2012/09/25 20:53:46 joerg Exp $");
|
||||
__RCSID("$NetBSD: nbperf-bdz.c,v 1.8 2013/03/01 18:26:10 joerg Exp $");
|
||||
|
||||
#include <err.h>
|
||||
#include <inttypes.h>
|
||||
@@ -227,12 +227,12 @@ print_hash(struct nbperf *nbperf, struct state *state)
|
||||
state->graph.v);
|
||||
|
||||
fprintf(nbperf->output,
|
||||
"\tidx = 9 + ((g1[h[0] >> 6] >> (h[0] & 63)) &1)"
|
||||
"\t + ((g1[h[1] >> 6] >> (h[1] & 63)) & 1)"
|
||||
"\t + ((g1[h[2] >> 6] >> (h[2] & 63)) & 1)"
|
||||
"\t - ((g2[h[0] >> 6] >> (h[0] & 63)) & 1)"
|
||||
"\t - ((g2[h[1] >> 6] >> (h[1] & 63)) & 1)"
|
||||
"\t - ((g2[h[2] >> 6] >> (h[2] & 63)) & 1);"
|
||||
"\tidx = 9 + ((g1[h[0] >> 6] >> (h[0] & 63)) &1)\n"
|
||||
"\t + ((g1[h[1] >> 6] >> (h[1] & 63)) & 1)\n"
|
||||
"\t + ((g1[h[2] >> 6] >> (h[2] & 63)) & 1)\n"
|
||||
"\t - ((g2[h[0] >> 6] >> (h[0] & 63)) & 1)\n"
|
||||
"\t - ((g2[h[1] >> 6] >> (h[1] & 63)) & 1)\n"
|
||||
"\t - ((g2[h[2] >> 6] >> (h[2] & 63)) & 1);\n"
|
||||
);
|
||||
|
||||
fprintf(nbperf->output,
|
||||
@@ -241,7 +241,7 @@ print_hash(struct nbperf *nbperf, struct state *state)
|
||||
"\tidx2 = idx - holes64[idx >> 6] - holes64k[idx >> 16];\n"
|
||||
"\tidx2 -= popcount64(g1[idx >> 6] & g2[idx >> 6]\n"
|
||||
"\t & (((uint64_t)1 << idx) - 1));\n"
|
||||
"\treturn idx2;");
|
||||
"\treturn idx2;\n");
|
||||
|
||||
fprintf(nbperf->output, "}\n");
|
||||
|
||||
@@ -253,7 +253,7 @@ print_hash(struct nbperf *nbperf, struct state *state)
|
||||
}
|
||||
|
||||
int
|
||||
bdz_compute(struct nbperf *nbperf)
|
||||
bpz_compute(struct nbperf *nbperf)
|
||||
{
|
||||
struct state state;
|
||||
int retval = -1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: nbperf.1,v 1.5 2012/09/25 20:53:46 joerg Exp $
|
||||
.\" $NetBSD: nbperf.1,v 1.6 2013/01/31 16:32:02 joerg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -88,7 +88,7 @@ This makes the output for
|
||||
.Ar chm3
|
||||
noticable smaller than the output for
|
||||
.Ar chm .
|
||||
.It Sy bdz
|
||||
.It Sy bpz
|
||||
This results in a non-order preserving minimal perfect hash function.
|
||||
Output size is approximately 2.79 bit per key for the default value of
|
||||
.Ar utilisation ,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nbperf.c,v 1.4 2011/10/21 23:47:11 joerg Exp $ */
|
||||
/* $NetBSD: nbperf.c,v 1.5 2013/01/31 16:32:02 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: nbperf.c,v 1.4 2011/10/21 23:47:11 joerg Exp $");
|
||||
__RCSID("$NetBSD: nbperf.c,v 1.5 2013/01/31 16:32:02 joerg Exp $");
|
||||
|
||||
#include <sys/endian.h>
|
||||
#include <err.h>
|
||||
@@ -135,12 +135,14 @@ main(int argc, char **argv)
|
||||
while ((ch = getopt(argc, argv, "a:c:h:i:m:n:o:ps")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
/* Accept bdz as alias for netbsd-6 compat. */
|
||||
if (strcmp(optarg, "chm") == 0)
|
||||
build_hash = chm_compute;
|
||||
else if (strcmp(optarg, "chm3") == 0)
|
||||
build_hash = chm3_compute;
|
||||
else if (strcmp(optarg, "bdz") == 0)
|
||||
build_hash = bdz_compute;
|
||||
else if (strcmp(optarg, "bpz") == 0 ||
|
||||
strcmp(optarg, "bdz") == 0)
|
||||
build_hash = bpz_compute;
|
||||
else
|
||||
errx(1, "Unsupport algorithm: %s", optarg);
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nbperf.h,v 1.3 2010/03/03 01:55:04 joerg Exp $ */
|
||||
/* $NetBSD: nbperf.h,v 1.4 2013/01/31 16:32:02 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -56,4 +56,4 @@ struct nbperf {
|
||||
|
||||
int chm_compute(struct nbperf *);
|
||||
int chm3_compute(struct nbperf *);
|
||||
int bdz_compute(struct nbperf *);
|
||||
int bpz_compute(struct nbperf *);
|
||||
|
||||
@@ -8,11 +8,6 @@ SRCS= newgrp.c grutil.c
|
||||
BINOWN= root
|
||||
BINMODE=4555
|
||||
|
||||
.if defined(__MINIX)
|
||||
# Too many warnings for our clang otherwise
|
||||
WARNS=3
|
||||
.endif
|
||||
|
||||
CPPFLAGS+=-DGRUTIL_ACCEPT_GROUP_NUMBERS
|
||||
CPPFLAGS+=-DGRUTIL_ALLOW_GROUP_ERRORS # for POSIX.1 compliance
|
||||
.if !defined(__MINIX)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: grutil.c,v 1.2 2008/04/28 20:24:14 martin Exp $ */
|
||||
/* $NetBSD: grutil.c,v 1.3 2013/01/24 17:46:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@@ -29,7 +29,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: grutil.c,v 1.2 2008/04/28 20:24:14 martin Exp $");
|
||||
__RCSID("$NetBSD: grutil.c,v 1.3 2013/01/24 17:46:30 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <err.h>
|
||||
@@ -137,7 +137,8 @@ addgid(gid_t *groups, int ngroups, int ngroupsmax, gid_t gid, int makespace)
|
||||
static addgrp_ret_t
|
||||
addgrp(gid_t newgid, int makespace)
|
||||
{
|
||||
int ngroups, ngroupsmax, rval;
|
||||
int ngroups, ngroupsmax;
|
||||
addgrp_ret_t rval;
|
||||
gid_t *groups;
|
||||
gid_t oldgid;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: newgrp.c,v 1.6 2008/04/28 20:24:14 martin Exp $");
|
||||
__RCSID("$NetBSD: newgrp.c,v 1.7 2011/09/16 15:39:27 joerg Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -52,7 +52,7 @@ __RCSID("$NetBSD: newgrp.c,v 1.6 2008/04/28 20:24:14 martin Exp $");
|
||||
|
||||
#include "grutil.h"
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "usage: %s [-l] [group]\n", getprogname());
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.3 2008/10/13 18:11:54 dyoung Exp $
|
||||
|
||||
.include "Makefile.inc"
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if defined(__MINIX)
|
||||
SUBDIR+= build
|
||||
.else
|
||||
.if ${MKSHARE} != "no"
|
||||
SUBDIR+= catalog
|
||||
.endif
|
||||
|
||||
SUBDIR+= build recover
|
||||
|
||||
.if ${MKDOC} != "no"
|
||||
SUBDIR+= docs
|
||||
.endif
|
||||
.endif # defined(__MINIX)
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
@@ -1,11 +0,0 @@
|
||||
# $NetBSD: Makefile.inc,v 1.2 2008/07/13 03:44:41 christos Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if defined(__MINIX)
|
||||
NOCLANGERROR=yes
|
||||
NOGCCERROR=yes
|
||||
.endif
|
||||
|
||||
DIST= ${NETBSDSRCDIR}/dist/nvi
|
||||
.PATH: ${DIST}
|
||||
@@ -1,69 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.17 2012/03/21 05:44:39 matt Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
USE_WIDECHAR?=yes
|
||||
|
||||
CWARNFLAGS.clang+= -Wno-uninitialized -Wno-format-security
|
||||
|
||||
CPPFLAGS+=-I${DIST}/include -I${.CURDIR} -I. -DGTAGS
|
||||
#DBG=-g
|
||||
|
||||
#CWARNFLAGS+=-Wno-parentheses -Wno-unused -Wno-missing-prototypes
|
||||
#.if defined(HAVE_GCC)
|
||||
#CWARNFLAGS+=-Wno-pointer-sign
|
||||
#COPTS+=-fno-strict-aliasing
|
||||
#.endif
|
||||
|
||||
LDADD+= -lcurses -lterminfo
|
||||
DPADD+= ${LIBCURSES} ${LIBTERMINFO}
|
||||
PROG= vi
|
||||
SRCS= api.c cl_bsd.c cl_funcs.c cl_main.c cl_read.c cl_screen.c cl_term.c \
|
||||
conv.c cut.c db.c db1.c delete.c ex.c ex_abbrev.c ex_append.c \
|
||||
ex_args.c ex_argv.c ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_cscope.c \
|
||||
ex_delete.c ex_display.c ex_edit.c ex_equal.c ex_file.c ex_filter.c \
|
||||
ex_global.c ex_init.c ex_join.c ex_map.c ex_mark.c ex_mkexrc.c \
|
||||
ex_move.c ex_open.c ex_perl.c ex_preserve.c ex_print.c ex_put.c \
|
||||
ex_quit.c ex_read.c ex_screen.c ex_script.c ex_set.c ex_shell.c \
|
||||
ex_shift.c ex_source.c ex_stop.c ex_subst.c ex_tag.c ex_tcl.c \
|
||||
ex_txt.c ex_undo.c ex_usage.c ex_util.c ex_version.c ex_visual.c \
|
||||
ex_write.c ex_yank.c ex_z.c exf.c getc.c gs.c key.c log.c \
|
||||
main.c mark.c msg.c nothread.c options.c options_f.c put.c recover.c \
|
||||
screen.c search.c seq.c util.c v_at.c v_ch.c v_cmd.c v_delete.c \
|
||||
v_event.c v_ex.c v_increment.c v_init.c v_itxt.c v_left.c v_mark.c \
|
||||
v_match.c v_paragraph.c v_put.c v_redraw.c v_replace.c v_right.c \
|
||||
v_screen.c v_scroll.c v_search.c v_section.c v_sentence.c v_status.c \
|
||||
v_txt.c v_ulcase.c v_undo.c v_util.c v_word.c v_xchar.c v_yank.c \
|
||||
v_z.c v_zexit.c vi.c vs_line.c vs_msg.c vs_refresh.c vs_relative.c \
|
||||
vs_smap.c vs_split.c
|
||||
|
||||
# For wide char support
|
||||
.if ${USE_WIDECHAR} == "yes"
|
||||
SRCS+= regcomp.c regerror.c regexec.c regfree.c
|
||||
CPPFLAGS+=-I${DIST}/regex -D__REGEX_PRIVATE -DUSE_WIDECHAR
|
||||
.endif
|
||||
|
||||
LINKS= ${BINDIR}/vi ${BINDIR}/ex ${BINDIR}/vi ${BINDIR}/view
|
||||
MLINKS= vi.1 ex.1 vi.1 view.1
|
||||
|
||||
DPSRCS+=options_def.h
|
||||
CLEANFILES+=options_def.h
|
||||
|
||||
options_def.h: options.awk options.c
|
||||
${_MKTARGET_CREATE}
|
||||
${TOOL_AWK} -f ${.ALLSRC} >${.TARGET}
|
||||
|
||||
.include "../Makefile.inc"
|
||||
.include "../../Makefile.inc"
|
||||
|
||||
WARNS= 4
|
||||
|
||||
.PATH: ${DIST}/vi ${DIST}/ex ${DIST}/cl
|
||||
.PATH: ${DIST}/common
|
||||
.PATH: ${DIST}/regex
|
||||
.PATH: ${DIST}/docs/vi.man
|
||||
|
||||
COPTS.exf.c += -Wno-format-nonliteral
|
||||
COPTS.msg.c += -Wno-format-nonliteral
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,291 +0,0 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
/* Id: acconfig.h,v 8.34 2002/01/19 23:01:35 skimo Exp (Berkeley) Date: 2002/01/19 23:01:35 */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
/* Define if you want a debugging version. */
|
||||
/* #undef DEBUG */
|
||||
|
||||
/* Define if you have a System V-style (broken) gettimeofday. */
|
||||
/* #undef HAVE_BROKEN_GETTIMEOFDAY */
|
||||
|
||||
/* Define if you have a Ultrix-style (broken) vdisable. */
|
||||
/* #undef HAVE_BROKEN_VDISABLE */
|
||||
|
||||
/* Define if you have a BSD version of curses. */
|
||||
/* #undef HAVE_BSD_CURSES */
|
||||
|
||||
/* Define if you have wide ncurses(3). */
|
||||
/* #undef HAVE_NCURSESW */
|
||||
|
||||
/* Define if you have the curses(3) waddnwstr function. */
|
||||
/* #undef HAVE_CURSES_ADDNWSTR */
|
||||
|
||||
/* Define if you have the curses(3) waddnstr function. */
|
||||
#define HAVE_CURSES_WADDNSTR 1
|
||||
|
||||
/* Define if you have the curses(3) beep function. */
|
||||
#define HAVE_CURSES_BEEP 1
|
||||
|
||||
/* Define if you have the curses(3) flash function. */
|
||||
#define HAVE_CURSES_FLASH 1
|
||||
|
||||
/* Define if you have the curses(3) idlok function. */
|
||||
#define HAVE_CURSES_IDLOK 1
|
||||
|
||||
/* Define if you have the curses(3) keypad function. */
|
||||
#define HAVE_CURSES_KEYPAD 1
|
||||
|
||||
/* Define if you have the curses(3) newterm function. */
|
||||
#define HAVE_CURSES_NEWTERM 1
|
||||
|
||||
/* Define if you have the curses(3) setupterm function. */
|
||||
#define HAVE_CURSES_SETUPTERM 1
|
||||
|
||||
/* Define if you have the curses(3) tigetstr/tigetnum functions. */
|
||||
#define HAVE_CURSES_TIGETSTR 1
|
||||
|
||||
/* Define if you have the DB __hash_open call in the C library. */
|
||||
/* #undef HAVE_DB_HASH_OPEN */
|
||||
|
||||
/* Define if you have the chsize(2) system call. */
|
||||
/* #undef HAVE_FTRUNCATE_CHSIZE */
|
||||
|
||||
/* Define if you have the ftruncate(2) system call. */
|
||||
#define HAVE_FTRUNCATE_FTRUNCATE 1
|
||||
|
||||
/* Define if you have gcc. */
|
||||
#define HAVE_GCC 1
|
||||
|
||||
/* Define if you have fcntl(2) style locking. */
|
||||
/* #undef HAVE_LOCK_FCNTL */
|
||||
|
||||
/* Define if you have flock(2) style locking. */
|
||||
#define HAVE_LOCK_FLOCK 1
|
||||
|
||||
/* Define is appropriate pango is available */
|
||||
/* #undef HAVE_PANGO */
|
||||
|
||||
/* Define if you want to compile in the Perl interpreter. */
|
||||
/* #undef HAVE_PERL_INTERP */
|
||||
|
||||
/* Define if using pthread. */
|
||||
/* #undef HAVE_PTHREAD */
|
||||
|
||||
#ifndef __minix
|
||||
/* Define if you have the Berkeley style revoke(2) system call. */
|
||||
#define HAVE_REVOKE 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the Berkeley style strsep(3) function. */
|
||||
#define HAVE_STRSEP 1
|
||||
|
||||
/* Define if you have <sys/mman.h> */
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* Define if you have <sys/select.h> */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
#ifndef __minix
|
||||
/* Define if you have the System V style pty calls. */
|
||||
#define HAVE_SYS5_PTY 1
|
||||
#endif
|
||||
|
||||
/* Define if you want to compile in the Tcl interpreter. */
|
||||
/* #undef HAVE_TCL_INTERP */
|
||||
|
||||
/* Define is appropriate zvt is available */
|
||||
/* #undef HAVE_ZVT */
|
||||
|
||||
/* Define if your sprintf returns a pointer, not a length. */
|
||||
/* #undef SPRINTF_RET_CHARPNT */
|
||||
|
||||
/* Define when using db1 */
|
||||
#define USE_DB1 1
|
||||
|
||||
/* Define when using db4 logging */
|
||||
/* #undef USE_DB4_LOGGING */
|
||||
|
||||
/* Define when dynamically loading DB 3 */
|
||||
/* #undef USE_DYNAMIC_LOADING */
|
||||
|
||||
/* Define when iconv can be used */
|
||||
#define USE_ICONV 1
|
||||
|
||||
/* Define when perl's setenv should be used */
|
||||
/* #undef USE_PERL_SETENV */
|
||||
|
||||
/* Define when using S-Lang */
|
||||
/* #undef USE_SLANG_CURSES */
|
||||
|
||||
/* Define when using wide characters */
|
||||
/* #undef USE_WIDECHAR */
|
||||
|
||||
/* Define if you have <ncurses.h> */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
|
||||
/* Define when fprintf prototype not in an obvious place */
|
||||
/* #undef NEED_FPRINTF_PROTO */
|
||||
|
||||
/* Define to 1 if you have the `bsearch' function. */
|
||||
#define HAVE_BSEARCH 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#define HAVE_FORK 1
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `iswblank' function. */
|
||||
#define HAVE_ISWBLANK 1
|
||||
|
||||
/* Define to 1 if you have the `memcpy' function. */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* Define to 1 if you have the `memchr' function. */
|
||||
#define HAVE_MEMCHR 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `mkstemp' function. */
|
||||
#define HAVE_MKSTEMP 1
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
/* Define to 1 if you have the <ncursesw/ncurses.h> header file. */
|
||||
/* #undef HAVE_NCURSESW_NCURSES_H */
|
||||
|
||||
/* Define to 1 if you have the <ncurses.h> header file. */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#define HAVE_SETENV 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strpbrk' function. */
|
||||
#define HAVE_STRPBRK 1
|
||||
|
||||
/* Define to 1 if you have the `strsep' function. */
|
||||
#define HAVE_STRSEP 1
|
||||
|
||||
/* Define to 1 if `st_blksize' is member of `struct stat'. */
|
||||
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
|
||||
|
||||
/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
|
||||
`HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
|
||||
#define HAVE_ST_BLKSIZE 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `unsetenv' function. */
|
||||
#define HAVE_UNSETENV 1
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#define HAVE_VFORK 1
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#define HAVE_WORKING_FORK 1
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#define HAVE_WORKING_VFORK 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "vi"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.81.6"
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef mode_t */
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
/* #undef vfork */
|
||||
@@ -1,49 +0,0 @@
|
||||
/* Id: pathnames.h.in,v 8.5 2000/04/21 21:26:21 skimo Exp (Berkeley) Date: 2000/04/21 21:26:21 */
|
||||
|
||||
#ifndef _PATH_BSHELL
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DB3
|
||||
#define _PATH_DB3 ""
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_EXRC
|
||||
#define _PATH_EXRC ".exrc"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_MSGCAT
|
||||
#define _PATH_MSGCAT "./"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_NEXRC
|
||||
#define _PATH_NEXRC ".nexrc"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_PRESERVE
|
||||
#define _PATH_PRESERVE "/var/tmp/vi.recover"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_SYSV_PTY
|
||||
#define _PATH_SYSV_PTY "/dev/ptmx"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_SENDMAIL
|
||||
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_SYSEXRC
|
||||
#define _PATH_SYSEXRC "/etc/vi.exrc"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TAGS
|
||||
#define _PATH_TAGS "tags"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TMP
|
||||
#define _PATH_TMP "/tmp"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TTY
|
||||
#define _PATH_TTY "/dev/tty"
|
||||
#endif
|
||||
@@ -1,201 +0,0 @@
|
||||
/* Id: port.h.in,v 8.15 2001/01/01 20:26:48 skimo Exp (Berkeley) Date: 2001/01/01 20:26:48 */
|
||||
|
||||
/*
|
||||
* Declare the basic types, if they aren't already declared. Named and
|
||||
* some system's db.h files protect them with __BIT_TYPES_DEFINED__.
|
||||
*/
|
||||
#ifndef __BIT_TYPES_DEFINED__
|
||||
#define __BIT_TYPES_DEFINED__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* Handle function prototypes. This steps on name space that vi doesn't
|
||||
* control, but all of the other solutions are worse.
|
||||
*/
|
||||
#undef __P
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define __P(protos) protos /* ANSI C prototypes */
|
||||
#else
|
||||
#define __P(protos) () /* K&R C preprocessor */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* Some versions of System V changed the number of arguments to gettimeofday
|
||||
* without changing the name.
|
||||
*/
|
||||
#ifdef HAVE_BROKEN_GETTIMEOFDAY
|
||||
#define gettimeofday(tv, tz) gettimeofday(tv)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* If we don't have mmap, we fake it with read and write, but we'll
|
||||
* still need the header information.
|
||||
*/
|
||||
#ifndef HAVE_SYS_MMAN_H
|
||||
#define MAP_SHARED 1 /* share changes */
|
||||
#define MAP_PRIVATE 2 /* changes are private */
|
||||
#define PROT_READ 0x1 /* pages can be read */
|
||||
#define PROT_WRITE 0x2 /* pages can be written */
|
||||
#define PROT_EXEC 0x4 /* pages can be executed */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.1 names for file descriptors.
|
||||
*/
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDIN_FILENO 0 /* ANSI C #defines */
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.1 names for seek settings.
|
||||
*/
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_SET 0 /* POSIX 1003.1 seek values */
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hack _POSIX_VDISABLE to \377 since Ultrix doesn't honor _POSIX_VDISABLE
|
||||
* (treats it as ^@). The symptom is that the ^@ keystroke immediately
|
||||
* drops core.
|
||||
*/
|
||||
#ifdef HAVE_BROKEN_VDISABLE
|
||||
#undef _POSIX_VDISABLE
|
||||
#define _POSIX_VDISABLE ((unsigned char)'\377')
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.1 tty disabling character.
|
||||
*/
|
||||
#ifndef _POSIX_VDISABLE
|
||||
#define _POSIX_VDISABLE 0 /* Some systems used 0. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* 4.4BSD extension to only set the software termios bits.
|
||||
*/
|
||||
#ifndef TCSASOFT /* 4.4BSD extension. */
|
||||
#define TCSASOFT 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.1 maximum path length.
|
||||
*/
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef PATH_MAX
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* MIN, MAX, historically in <sys/param.h>
|
||||
*/
|
||||
#ifndef MAX
|
||||
#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
||||
#endif
|
||||
|
||||
#ifndef USE_DB1
|
||||
/*
|
||||
* XXX
|
||||
* "DB" isn't always portable, and we want the private information.
|
||||
*/
|
||||
#define DB L__DB
|
||||
#undef pgno_t /* IRIX has its own version. */
|
||||
#define pgno_t L__db_pgno_t
|
||||
#endif /* USE_DB1 */
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* 4.4BSD extension to provide lock values in the open(2) call.
|
||||
*/
|
||||
#ifndef O_EXLOCK
|
||||
#define O_EXLOCK 0
|
||||
#endif
|
||||
|
||||
#ifndef O_SHLOCK
|
||||
#define O_SHLOCK 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.1 bad file format errno.
|
||||
*/
|
||||
#ifndef EFTYPE
|
||||
#define EFTYPE EINVAL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* POSIX 1003.2 RE length limit.
|
||||
*/
|
||||
#ifndef _POSIX2_RE_DUP_MAX
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* 4.4BSD extension to determine if a program dropped core from the exit
|
||||
* status.
|
||||
*/
|
||||
#ifndef WCOREDUMP
|
||||
#define WCOREDUMP(a) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* Endian-ness of the machine.
|
||||
*/
|
||||
#if !defined(LITTLE_ENDIAN)
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
#if !defined(BIG_ENDIAN)
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
#if !defined(BYTE_ORDER)
|
||||
#if WORDS_BIGENDIAN == 1
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMCPY
|
||||
#define memcpy memmove
|
||||
#endif
|
||||
|
||||
#ifdef NEED_FPRINTF_PROTO
|
||||
extern int fprintf( FILE *, const char *, ... );
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
#define VI_DB_THREAD DB_THREAD
|
||||
#else
|
||||
#define VI_DB_THREAD 0
|
||||
#endif
|
||||
@@ -1,101 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.6 2008/10/25 22:27:39 apb Exp $
|
||||
#
|
||||
# @(#)Makefile 8.29 (Berkeley) 10/19/96
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include "../Makefile.inc"
|
||||
|
||||
.PATH: ${DIST}/catalog
|
||||
|
||||
CATALOG= dutch english french german ru_RU.KOI8-R spanish swedish
|
||||
VI_FILES= ${DIST}/cl/*.c ${DIST}/common/*.c \
|
||||
${DIST}/ex/*.c ${DIST}/vi/*.c
|
||||
FILES= ${CATALOG}
|
||||
FILESDIR= /usr/share/nvi/catalog
|
||||
|
||||
HOSTPROG= dump
|
||||
SRCS= dump.c
|
||||
|
||||
CLEANFILES+= ${CATALOG} english.base *.check __ck1 __ck2
|
||||
|
||||
realall: ${CATALOG}
|
||||
|
||||
${CATALOG}: ${CATALOG:S/$/.base/}
|
||||
@echo "... $@"; \
|
||||
rm -f $@; \
|
||||
if test -f $@.base; then \
|
||||
f=$@.base; \
|
||||
else \
|
||||
f=${DIST}/catalog/$@.base; \
|
||||
fi; \
|
||||
sort -u $$f | \
|
||||
${TOOL_AWK} '{ \
|
||||
if ($$1 == 1) { \
|
||||
print "\nMESSAGE NUMBER 1 IS NOT LEGAL"; \
|
||||
exit 1; \
|
||||
} \
|
||||
if (++nline > $$1) { \
|
||||
print "DUPLICATE MESSAGE NUMBER " $$1; \
|
||||
exit 1; \
|
||||
} \
|
||||
for (; nline < $$1; ++nline) \
|
||||
print ""; \
|
||||
print $0; \
|
||||
}' | \
|
||||
${TOOL_SED} -e '1s/^/VI_MESSAGE_CATALOG/' \
|
||||
-e '/"/s/^[^"]*"//' \
|
||||
-e '1!s/"$$/X/' > $@; \
|
||||
if grep DUPLICATE $@ > /dev/null; then \
|
||||
grep DUPLICATE $@; \
|
||||
fi; \
|
||||
if grep 'NOT LEGAL' $@ > /dev/null; then \
|
||||
grep 'NOT LEGAL' $@; \
|
||||
fi
|
||||
|
||||
CHK= dutch.check english.check french.check german.check \
|
||||
ru_RU.KOI8-R.check spanish.check swedish.check
|
||||
check: ${CHK}
|
||||
${CHK}: ${CATALOG}
|
||||
@echo "... $@"; \
|
||||
f=${DIST}/catalog/`basename $@ .check`; \
|
||||
(echo "Unused message id's (this is okay):"; \
|
||||
${TOOL_AWK} '{ \
|
||||
while (++nline < $$1) \
|
||||
printf "%03d\n", nline; \
|
||||
}' < ${DIST}/catalog/$$f.base; \
|
||||
echo =========================; \
|
||||
echo "MISSING ERROR MESSAGES (Please add!):"; \
|
||||
${TOOL_AWK} '{print $$1}' < $$f.base | sort -u > __ck1; \
|
||||
${TOOL_AWK} '{print $$1}' < english.base | sort -u > __ck2; \
|
||||
comm -13 __ck1 __ck2; \
|
||||
echo =========================; \
|
||||
echo "Extra error messages (just delete them):"; \
|
||||
comm -23 __ck1 __ck2; \
|
||||
echo =========================; \
|
||||
echo "MESSAGES WITH THE SAME MESSAGE ID's (FIX!):"; \
|
||||
for j in \
|
||||
`${TOOL_SED} '/^$$/d' < $$f.base | sort -u | \
|
||||
${TOOL_AWK} '{print $$1}' | uniq -d`; do \
|
||||
egrep $$j $$f.base; \
|
||||
done; \
|
||||
echo =========================; \
|
||||
echo "Duplicate messages, both id and message (this is okay):"; \
|
||||
${TOOL_SED} '/^$$/d' < $$f.base | sort | uniq -c | \
|
||||
${TOOL_AWK} '$$1 != 1 { print $$0 }' | sort -n; \
|
||||
echo =========================; \
|
||||
echo "Duplicate messages, just message (this is okay):"; \
|
||||
${TOOL_SED} '/^$$/d' < $$f | sort | uniq -c | \
|
||||
${TOOL_AWK} '$$1 != 1 { print $$0 }' | sort -n; \
|
||||
echo =========================) > $@
|
||||
|
||||
english.base: dump ${VI_FILES} #Makefile
|
||||
${_MKTARGET_CREATE}
|
||||
./dump ${VI_FILES} |\
|
||||
${TOOL_SED} -e '/|/!d' \
|
||||
-e 's/|/ "/' \
|
||||
-e 's/^"//' \
|
||||
-e 's/\\"/"/g' |\
|
||||
sort -n > $@
|
||||
|
||||
.include <bsd.hostprog.mk>
|
||||
@@ -1,5 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.1 2008/09/02 09:25:39 christos Exp $
|
||||
|
||||
SUBDIR= USD.doc info
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
@@ -1,5 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.1 2008/09/02 09:25:39 christos Exp $
|
||||
|
||||
SUBDIR= edit exref vi.ref vitut
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user