run GNU protoize

protect header files
nuke some dead code
regenerate configure script
let silly code die
This commit is contained in:
tg
2004-10-28 11:53:44 +00:00
parent dc7da8ddbf
commit b2de14e57c
46 changed files with 1024 additions and 1991 deletions

100
io.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: io.c,v 1.6 2004/10/28 11:03:23 tg Exp $ */
/** $MirBSD: io.c,v 1.7 2004/10/28 11:53:42 tg Exp $ */
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/*
@ -18,13 +18,7 @@ static int initio_done;
/* A shell error occurred (eg, syntax error, etc.) */
void
#ifdef HAVE_PROTOTYPES
errorf(const char *fmt, ...)
#else
errorf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -43,14 +37,7 @@ errorf(fmt, va_alist)
/* like errorf(), but no unwind is done */
void
#ifdef HAVE_PROTOTYPES
warningf(int fileline, const char *fmt, ...)
#else
warningf(fileline, fmt, va_alist)
int fileline;
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -66,13 +53,7 @@ warningf(fileline, fmt, va_alist)
* (also unwinds environments for special builtins).
*/
void
#ifdef HAVE_PROTOTYPES
bi_errorf(const char *fmt, ...)
#else
bi_errorf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -103,14 +84,7 @@ bi_errorf(fmt, va_alist)
/* Called when something that shouldn't happen does */
void
#ifdef HAVE_PROTOTYPES
internal_errorf(int jump, const char *fmt, ...)
#else
internal_errorf(jump, fmt, va_alist)
int jump;
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -127,8 +101,7 @@ internal_errorf(jump, fmt, va_alist)
/* used by error reporting functions to print "ksh: .kshrc[25]: " */
void
error_prefix(fileline)
int fileline;
error_prefix(int fileline)
{
/* Avoid foo: foo[2]: ... */
if (!fileline || !source || !source->file
@ -143,13 +116,7 @@ error_prefix(fileline)
/* printf to shl_out (stderr) with flush */
void
#ifdef HAVE_PROTOTYPES
shellf(const char *fmt, ...)
#else
shellf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -163,13 +130,7 @@ shellf(fmt, va_alist)
/* printf to shl_stdout (stdout) */
void
#ifdef HAVE_PROTOTYPES
shprintf(const char *fmt, ...)
#else
shprintf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list va;
@ -199,13 +160,7 @@ kshdebug_init_()
/* print to debugging log */
void
# ifdef HAVE_PROTOTYPES
kshdebug_printf_(const char *fmt, ...)
# else
kshdebug_printf_(fmt, va_alist)
const char *fmt;
va_dcl
# endif
{
va_list va;
@ -245,8 +200,7 @@ kshdebug_dump_(str, mem, nbytes)
/* test if we can seek backwards fd (returns 0 or SHF_UNBUF) */
int
can_seek(fd)
int fd;
can_seek(int fd)
{
struct stat statb;
@ -257,7 +211,7 @@ can_seek(fd)
struct shf shf_iob[3];
void
initio()
initio(void)
{
shf_fdopen(1, SHF_WR, shl_stdout); /* force buffer allocation */
shf_fdopen(2, SHF_WR, shl_out);
@ -268,10 +222,7 @@ initio()
/* A dup2() with error checking */
int
ksh_dup2(ofd, nfd, errok)
int ofd;
int nfd;
int errok;
ksh_dup2(int ofd, int nfd, int errok)
{
int ret = dup2(ofd, nfd);
@ -292,9 +243,7 @@ ksh_dup2(ofd, nfd, errok)
* set close-on-exec flag.
*/
int
savefd(fd, noclose)
int fd;
int noclose;
savefd(int fd, int noclose)
{
int nfd;
@ -315,8 +264,7 @@ savefd(fd, noclose)
}
void
restfd(fd, ofd)
int fd, ofd;
restfd(int fd, int ofd)
{
if (fd == 2)
shf_flush(&shf_iob[fd]);
@ -329,8 +277,7 @@ restfd(fd, ofd)
}
void
openpipe(pv)
int *pv;
openpipe(int *pv)
{
if (pipe(pv) < 0)
errorf("can't create pipe - try again");
@ -339,8 +286,7 @@ openpipe(pv)
}
void
closepipe(pv)
int *pv;
closepipe(int *pv)
{
close(pv[0]);
close(pv[1]);
@ -350,10 +296,7 @@ closepipe(pv)
* a string (the X in 2>&X, read -uX, print -uX) into a file descriptor.
*/
int
check_fd(name, mode, emsgp)
char *name;
int mode;
const char **emsgp;
check_fd(char *name, int mode, const char **emsgp)
{
int fd, fl;
@ -408,7 +351,7 @@ check_fd(name, mode, emsgp)
#ifdef KSH
/* Called once from main */
void
coproc_init()
coproc_init(void)
{
coproc.read = coproc.readw = coproc.write = -1;
coproc.njobs = 0;
@ -417,8 +360,7 @@ coproc_init()
/* Called by c_read() when eof is read - close fd if it is the co-process fd */
void
coproc_read_close(fd)
int fd;
coproc_read_close(int fd)
{
if (coproc.read >= 0 && fd == coproc.read) {
coproc_readw_close(fd);
@ -431,8 +373,7 @@ coproc_read_close(fd)
* read pipe, so reads will actually terminate.
*/
void
coproc_readw_close(fd)
int fd;
coproc_readw_close(int fd)
{
if (coproc.readw >= 0 && coproc.read >= 0 && fd == coproc.read) {
close(coproc.readw);
@ -444,8 +385,7 @@ coproc_readw_close(fd)
* when co-process input is dup'd
*/
void
coproc_write_close(fd)
int fd;
coproc_write_close(int fd)
{
if (coproc.write >= 0 && fd == coproc.write) {
close(coproc.write);
@ -457,9 +397,7 @@ coproc_write_close(fd)
* (Used by check_fd() and by c_read/c_print to deal with -p option).
*/
int
coproc_getfd(mode, emsgp)
int mode;
const char **emsgp;
coproc_getfd(int mode, const char **emsgp)
{
int fd = (mode & R_OK) ? coproc.read : coproc.write;
@ -474,8 +412,7 @@ coproc_getfd(mode, emsgp)
* Should be called with SIGCHLD blocked.
*/
void
coproc_cleanup(reuse)
int reuse;
coproc_cleanup(int reuse)
{
/* This to allow co-processes to share output pipe */
if (!reuse || coproc.readw < 0 || coproc.read < 0) {
@ -501,10 +438,7 @@ coproc_cleanup(reuse)
*/
struct temp *
maketemp(ap, type, tlist)
Area *ap;
Temp_type type;
struct temp **tlist;
maketemp(Area *ap, Temp_type type, struct temp **tlist)
{
#ifndef HAVE_MKSTEMP
static unsigned int inc;