More programs using efun.
This commit is contained in:
parent
d0fb89015b
commit
cdab3a7a06
@ -1,7 +1,10 @@
|
|||||||
# $NetBSD: Makefile,v 1.5 2006/03/16 16:49:07 christos Exp $
|
# $NetBSD: Makefile,v 1.6 2006/08/26 18:17:41 christos Exp $
|
||||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= column
|
PROG= column
|
||||||
WARNS= 4
|
WARNS= 4
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: column.c,v 1.14 2006/04/09 19:51:23 christos Exp $ */
|
/* $NetBSD: column.c,v 1.15 2006/08/26 18:17:41 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993, 1994
|
* Copyright (c) 1989, 1993, 1994
|
||||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
|
static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
|
||||||
#endif
|
#endif
|
||||||
__RCSID("$NetBSD: column.c,v 1.14 2006/04/09 19:51:23 christos Exp $");
|
__RCSID("$NetBSD: column.c,v 1.15 2006/08/26 18:17:41 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -53,13 +53,11 @@ __RCSID("$NetBSD: column.c,v 1.14 2006/04/09 19:51:23 christos Exp $");
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#define TAB 8
|
#define TAB 8
|
||||||
|
|
||||||
static void c_columnate(void);
|
static void c_columnate(void);
|
||||||
static void *emalloc(size_t);
|
|
||||||
static void *erealloc(void *, size_t);
|
|
||||||
static char *estrdup(const char *);
|
|
||||||
static void input(FILE *);
|
static void input(FILE *);
|
||||||
static void maketbl(void);
|
static void maketbl(void);
|
||||||
static void print(void);
|
static void print(void);
|
||||||
@ -291,37 +289,6 @@ input(FILE *fp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
|
||||||
emalloc(size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if ((p = malloc(size)) == NULL)
|
|
||||||
err(1, "malloc");
|
|
||||||
(void)memset(p, 0, size);
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
|
||||||
erealloc(void *op, size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if ((p = realloc(op, size)) == NULL)
|
|
||||||
err(1, "realloc");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
estrdup(const char *str)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if ((p = strdup(str)) == NULL)
|
|
||||||
err(1, "strdup");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.13 2004/01/03 14:04:27 lukem Exp $
|
# $NetBSD: Makefile,v 1.14 2006/08/26 18:17:42 christos Exp $
|
||||||
|
|
||||||
PROG= crunchgen
|
PROG= crunchgen
|
||||||
SRCS= crunchgen.c crunched_skel.c
|
SRCS= crunchgen.c crunched_skel.c
|
||||||
@ -8,6 +8,10 @@ crunched_skel.c: mkskel.sh crunched_main.c
|
|||||||
${_MKTARGET_CREATE}
|
${_MKTARGET_CREATE}
|
||||||
${HOST_SH} ${.ALLSRC} >${.TARGET}
|
${HOST_SH} ${.ALLSRC} >${.TARGET}
|
||||||
|
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
|
||||||
.ifndef HOSTPROG
|
.ifndef HOSTPROG
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: crunchgen.c,v 1.71 2006/06/13 17:18:56 christos Exp $ */
|
/* $NetBSD: crunchgen.c,v 1.72 2006/08/26 18:17:42 christos Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 University of Maryland
|
* Copyright (c) 1994 University of Maryland
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if !defined(lint)
|
#if !defined(lint)
|
||||||
__RCSID("$NetBSD: crunchgen.c,v 1.71 2006/06/13 17:18:56 christos Exp $");
|
__RCSID("$NetBSD: crunchgen.c,v 1.72 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -48,6 +48,7 @@ __RCSID("$NetBSD: crunchgen.c,v 1.71 2006/06/13 17:18:56 christos Exp $");
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -115,8 +116,6 @@ void out_of_memory(void);
|
|||||||
void add_string(strlst_t **listp, char *str);
|
void add_string(strlst_t **listp, char *str);
|
||||||
int is_dir(char *pathname);
|
int is_dir(char *pathname);
|
||||||
int is_nonempty_file(char *pathname);
|
int is_nonempty_file(char *pathname);
|
||||||
static void estrlcpy(char *, const char *, size_t);
|
|
||||||
static void estrlcat(char *, const char *, size_t);
|
|
||||||
|
|
||||||
/* helper routines for main() */
|
/* helper routines for main() */
|
||||||
|
|
||||||
@ -164,13 +163,13 @@ main(int argc, char **argv)
|
|||||||
case 'O': oneobj = 0; break;
|
case 'O': oneobj = 0; break;
|
||||||
case 'o': useobjs = 1, oneobj = 0; break;
|
case 'o': useobjs = 1, oneobj = 0; break;
|
||||||
|
|
||||||
case 'm': estrlcpy(outmkname, optarg, sizeof(outmkname)); break;
|
case 'm': (void)estrlcpy(outmkname, optarg, sizeof(outmkname)); break;
|
||||||
case 'c': estrlcpy(outcfname, optarg, sizeof(outcfname)); break;
|
case 'c': (void)estrlcpy(outcfname, optarg, sizeof(outcfname)); break;
|
||||||
case 'e': estrlcpy(execfname, optarg, sizeof(execfname)); break;
|
case 'e': (void)estrlcpy(execfname, optarg, sizeof(execfname)); break;
|
||||||
case 'd': estrlcpy(dbg, optarg, sizeof(dbg)); break;
|
case 'd': (void)estrlcpy(dbg, optarg, sizeof(dbg)); break;
|
||||||
|
|
||||||
case 'D': estrlcpy(topdir, optarg, sizeof(topdir)); break;
|
case 'D': (void)estrlcpy(topdir, optarg, sizeof(topdir)); break;
|
||||||
case 'L': estrlcpy(libdir, optarg, sizeof(libdir)); break;
|
case 'L': (void)estrlcpy(libdir, optarg, sizeof(libdir)); break;
|
||||||
case 'v': add_string(&vars, optarg); break;
|
case 'v': add_string(&vars, optarg); break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
@ -188,15 +187,15 @@ main(int argc, char **argv)
|
|||||||
* generate filenames
|
* generate filenames
|
||||||
*/
|
*/
|
||||||
|
|
||||||
estrlcpy(infilename, argv[0], sizeof(infilename));
|
(void)estrlcpy(infilename, argv[0], sizeof(infilename));
|
||||||
getcwd(curdir, MAXPATHLEN);
|
getcwd(curdir, MAXPATHLEN);
|
||||||
|
|
||||||
/* confname = `basename infilename .conf` */
|
/* confname = `basename infilename .conf` */
|
||||||
|
|
||||||
if ((p = strrchr(infilename, '/')) != NULL)
|
if ((p = strrchr(infilename, '/')) != NULL)
|
||||||
estrlcpy(confname, p + 1, sizeof(confname));
|
(void)estrlcpy(confname, p + 1, sizeof(confname));
|
||||||
else
|
else
|
||||||
estrlcpy(confname, infilename, sizeof(confname));
|
(void)estrlcpy(confname, infilename, sizeof(confname));
|
||||||
if ((p = strrchr(confname, '.')) != NULL && !strcmp(p, ".conf"))
|
if ((p = strrchr(confname, '.')) != NULL && !strcmp(p, ".conf"))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
@ -273,7 +272,7 @@ parse_one_file(char *filename)
|
|||||||
|
|
||||||
(void)snprintf(line, sizeof(line), "reading %s", filename);
|
(void)snprintf(line, sizeof(line), "reading %s", filename);
|
||||||
status(line);
|
status(line);
|
||||||
estrlcpy(curfilename, filename, sizeof(curfilename));
|
(void)estrlcpy(curfilename, filename, sizeof(curfilename));
|
||||||
|
|
||||||
if ((cf = fopen(curfilename, "r")) == NULL) {
|
if ((cf = fopen(curfilename, "r")) == NULL) {
|
||||||
perror(curfilename);
|
perror(curfilename);
|
||||||
@ -350,14 +349,14 @@ add_srcdirs(int argc, char **argv)
|
|||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] == '/')
|
if (argv[i][0] == '/')
|
||||||
estrlcpy(tmppath, argv[i], sizeof(tmppath));
|
(void)estrlcpy(tmppath, argv[i], sizeof(tmppath));
|
||||||
else {
|
else {
|
||||||
if (topdir[0] == '\0')
|
if (topdir[0] == '\0')
|
||||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||||
else
|
else
|
||||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||||
estrlcat(tmppath, argv[i], sizeof(tmppath));
|
(void)estrlcat(tmppath, argv[i], sizeof(tmppath));
|
||||||
}
|
}
|
||||||
if (is_dir(tmppath))
|
if (is_dir(tmppath))
|
||||||
add_string(&srcdirs, tmppath);
|
add_string(&srcdirs, tmppath);
|
||||||
@ -470,11 +469,11 @@ add_special(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
char tmppath[MAXPATHLEN];
|
char tmppath[MAXPATHLEN];
|
||||||
if (topdir[0] == '\0')
|
if (topdir[0] == '\0')
|
||||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||||
else
|
else
|
||||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||||
estrlcat(tmppath, argv[3], sizeof(tmppath));
|
(void)estrlcat(tmppath, argv[3], sizeof(tmppath));
|
||||||
if ((p->srcdir = strdup(tmppath)) == NULL)
|
if ((p->srcdir = strdup(tmppath)) == NULL)
|
||||||
out_of_memory();
|
out_of_memory();
|
||||||
}
|
}
|
||||||
@ -603,11 +602,11 @@ fillin_program(prog_t *p)
|
|||||||
} else {
|
} else {
|
||||||
char tmppath[MAXPATHLEN];
|
char tmppath[MAXPATHLEN];
|
||||||
if (topdir[0] == '\0')
|
if (topdir[0] == '\0')
|
||||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||||
else
|
else
|
||||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||||
estrlcat(tmppath, path, sizeof(tmppath));
|
(void)estrlcat(tmppath, path, sizeof(tmppath));
|
||||||
if ((p->srcdir = strdup(tmppath)) == NULL)
|
if ((p->srcdir = strdup(tmppath)) == NULL)
|
||||||
out_of_memory();
|
out_of_memory();
|
||||||
}
|
}
|
||||||
@ -1146,21 +1145,3 @@ is_nonempty_file(char *pathname)
|
|||||||
|
|
||||||
return S_ISREG(buf.st_mode) && buf.st_size > 0;
|
return S_ISREG(buf.st_mode) && buf.st_size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
estrlcpy(char *dst, const char *src, size_t len)
|
|
||||||
{
|
|
||||||
if (strlcpy(dst, src, len) >= len) {
|
|
||||||
errno = ENAMETOOLONG;
|
|
||||||
err(1, "Cannot copy `%s'", src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
estrlcat(char *dst, const char *src, size_t len)
|
|
||||||
{
|
|
||||||
if (strlcat(dst, src, len) >= len) {
|
|
||||||
errno = ENAMETOOLONG;
|
|
||||||
err(1, "Cannot append `%s'", src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.9 2002/09/18 14:00:36 lukem Exp $
|
# $NetBSD: Makefile,v 1.10 2006/08/26 18:17:42 christos Exp $
|
||||||
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
@ -9,4 +9,7 @@ SRCS= find.c function.c ls.c main.c misc.c operator.c option.c stat_flags.c
|
|||||||
CPPFLAGS+= -I${NETBSDSRCDIR}/bin/ls
|
CPPFLAGS+= -I${NETBSDSRCDIR}/bin/ls
|
||||||
.PATH: ${NETBSDSRCDIR}/bin/ls
|
.PATH: ${NETBSDSRCDIR}/bin/ls
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: extern.h,v 1.23 2006/02/20 16:31:02 jschauma Exp $ */
|
/* $NetBSD: extern.h,v 1.24 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993, 1994
|
* Copyright (c) 1991, 1993, 1994
|
||||||
@ -34,7 +34,6 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
void brace_subst __P((char *, char **, char *, int *));
|
void brace_subst __P((char *, char **, char *, int *));
|
||||||
void *emalloc __P((unsigned int));
|
|
||||||
PLAN *find_create __P((char ***));
|
PLAN *find_create __P((char ***));
|
||||||
int find_execute __P((PLAN *, char **));
|
int find_execute __P((PLAN *, char **));
|
||||||
PLAN *find_formplan __P((char **));
|
PLAN *find_formplan __P((char **));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: function.c,v 1.54 2006/05/10 21:53:20 mrg Exp $ */
|
/* $NetBSD: function.c,v 1.55 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@ -37,7 +37,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
|
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: function.c,v 1.54 2006/05/10 21:53:20 mrg Exp $");
|
__RCSID("$NetBSD: function.c,v 1.55 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ __RCSID("$NetBSD: function.c,v 1.54 2006/05/10 21:53:20 mrg Exp $");
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <tzfile.h>
|
#include <tzfile.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include "find.h"
|
#include "find.h"
|
||||||
#include "stat_flags.h"
|
#include "stat_flags.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: misc.c,v 1.12 2003/08/07 11:13:42 agc Exp $ */
|
/* $NetBSD: misc.c,v 1.13 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993, 1994
|
* Copyright (c) 1990, 1993, 1994
|
||||||
@ -37,7 +37,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94";
|
static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: misc.c,v 1.12 2003/08/07 11:13:42 agc Exp $");
|
__RCSID("$NetBSD: misc.c,v 1.13 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -127,21 +127,6 @@ queryuser(argv)
|
|||||||
return (first == 'y');
|
return (first == 'y');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* emalloc --
|
|
||||||
* malloc with error checking.
|
|
||||||
*/
|
|
||||||
void *
|
|
||||||
emalloc(len)
|
|
||||||
u_int len;
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if ((p = malloc(len)) == NULL)
|
|
||||||
err(1, "malloc");
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* show_path --
|
* show_path --
|
||||||
* called on SIGINFO
|
* called on SIGINFO
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.9 2003/05/18 07:57:34 lukem Exp $
|
# $NetBSD: Makefile,v 1.10 2006/08/26 18:17:42 christos Exp $
|
||||||
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= hexdump
|
PROG= hexdump
|
||||||
@ -7,6 +7,9 @@ MAN= hexdump.1 od.1
|
|||||||
WFORMAT= 1
|
WFORMAT= 1
|
||||||
WARNS= 2
|
WARNS= 2
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.ifndef HOSTPROG
|
.ifndef HOSTPROG
|
||||||
LINKS= ${BINDIR}/hexdump ${BINDIR}/od
|
LINKS= ${BINDIR}/hexdump ${BINDIR}/od
|
||||||
.endif
|
.endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: display.c,v 1.19 2006/01/04 01:30:21 perry Exp $ */
|
/* $NetBSD: display.c,v 1.20 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: display.c,v 1.19 2006/01/04 01:30:21 perry Exp $");
|
__RCSID("$NetBSD: display.c,v 1.20 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ __RCSID("$NetBSD: display.c,v 1.19 2006/01/04 01:30:21 perry Exp $");
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
|
|
||||||
@ -238,8 +239,8 @@ get(void)
|
|||||||
u_char *tmpp;
|
u_char *tmpp;
|
||||||
|
|
||||||
if (!curp) {
|
if (!curp) {
|
||||||
curp = emalloc(blocksize);
|
curp = ecalloc(blocksize, 1);
|
||||||
savp = emalloc(blocksize);
|
savp = ecalloc(blocksize, 1);
|
||||||
} else {
|
} else {
|
||||||
tmpp = curp;
|
tmpp = curp;
|
||||||
curp = savp;
|
curp = savp;
|
||||||
@ -357,20 +358,3 @@ doskip(const char *fname, int statok)
|
|||||||
skip -= cnt;
|
skip -= cnt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
emalloc(int allocsize)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if ((p = malloc((u_int)allocsize)) == NULL)
|
|
||||||
nomem();
|
|
||||||
memset(p, 0, allocsize);
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nomem(void)
|
|
||||||
{
|
|
||||||
err(1, NULL);
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: hexdump.h,v 1.9 2006/01/04 01:30:21 perry Exp $ */
|
/* $NetBSD: hexdump.h,v 1.10 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -91,12 +91,10 @@ void conv_u(PR *, u_char *);
|
|||||||
void display(void);
|
void display(void);
|
||||||
void doskip(const char *, int);
|
void doskip(const char *, int);
|
||||||
/*void err(const char *, ...);*/
|
/*void err(const char *, ...);*/
|
||||||
void *emalloc(int);
|
|
||||||
void escape(char *);
|
void escape(char *);
|
||||||
u_char *get(void);
|
u_char *get(void);
|
||||||
void newsyntax(int, char ***);
|
void newsyntax(int, char ***);
|
||||||
int next(char **);
|
int next(char **);
|
||||||
void nomem(void);
|
|
||||||
void oldsyntax(int, char ***);
|
void oldsyntax(int, char ***);
|
||||||
void rewrite(FS *);
|
void rewrite(FS *);
|
||||||
int size(FS *);
|
int size(FS *);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: odsyntax.c,v 1.23 2006/01/04 01:30:21 perry Exp $ */
|
/* $NetBSD: odsyntax.c,v 1.24 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
|
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: odsyntax.c,v 1.23 2006/01/04 01:30:21 perry Exp $");
|
__RCSID("$NetBSD: odsyntax.c,v 1.24 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -49,6 +49,7 @@ __RCSID("$NetBSD: odsyntax.c,v 1.23 2006/01/04 01:30:21 perry Exp $");
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
|
|
||||||
@ -284,10 +285,9 @@ posixtypes(char const *type_string)
|
|||||||
break;
|
break;
|
||||||
if (odf->type == 0)
|
if (odf->type == 0)
|
||||||
errx(1, "%c%d: format not supported", type, nbytes);
|
errx(1, "%c%d: format not supported", type, nbytes);
|
||||||
asprintf(&fmt, "%d/%d \"%*s%s \" \"\\n\"",
|
(void)easprintf(&fmt, "%d/%d \"%*s%s \" \"\\n\"",
|
||||||
16 / nbytes, nbytes,
|
16 / nbytes, nbytes,
|
||||||
4 * nbytes - odf->minwidth, "", odf->format);
|
4 * nbytes - odf->minwidth, "", odf->format);
|
||||||
if (fmt == NULL) nomem();
|
|
||||||
add(fmt);
|
add(fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parse.c,v 1.19 2006/03/30 19:53:58 dsl Exp $ */
|
/* $NetBSD: parse.c,v 1.20 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: parse.c,v 1.19 2006/03/30 19:53:58 dsl Exp $");
|
__RCSID("$NetBSD: parse.c,v 1.20 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -52,6 +52,7 @@ __RCSID("$NetBSD: parse.c,v 1.19 2006/03/30 19:53:58 dsl Exp $");
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
|
|
||||||
@ -145,8 +146,7 @@ add(const char *fmt)
|
|||||||
for (savep = ++p; *p != '"';)
|
for (savep = ++p; *p != '"';)
|
||||||
if (*p++ == 0)
|
if (*p++ == 0)
|
||||||
badfmt(fmt);
|
badfmt(fmt);
|
||||||
if (!(tfu->fmt = malloc(p - savep + 1)))
|
tfu->fmt = emalloc(p - savep + 1);
|
||||||
nomem();
|
|
||||||
(void) strncpy(tfu->fmt, savep, p - savep);
|
(void) strncpy(tfu->fmt, savep, p - savep);
|
||||||
tfu->fmt[p - savep] = '\0';
|
tfu->fmt[p - savep] = '\0';
|
||||||
escape(tfu->fmt);
|
escape(tfu->fmt);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.4 2005/04/24 17:46:06 christos Exp $
|
# $NetBSD: Makefile,v 1.5 2006/08/26 18:17:42 christos Exp $
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
@ -8,4 +8,7 @@ SRCS= iconv.c
|
|||||||
CPPFLAGS+= -I. -I${.CURDIR} -I${NETBSDSRCDIR}/lib/libc
|
CPPFLAGS+= -I. -I${.CURDIR} -I${NETBSDSRCDIR}/lib/libc
|
||||||
MAN= iconv.1
|
MAN= iconv.1
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: iconv.c,v 1.9 2005/04/25 13:57:34 tshiozak Exp $ */
|
/* $NetBSD: iconv.c,v 1.10 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: iconv.c,v 1.9 2005/04/25 13:57:34 tshiozak Exp $");
|
__RCSID("$NetBSD: iconv.c,v 1.10 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -38,9 +38,9 @@ __RCSID("$NetBSD: iconv.c,v 1.9 2005/04/25 13:57:34 tshiozak Exp $");
|
|||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
static void usage(void) __attribute__((__unused__));
|
static void usage(void) __attribute__((__unused__));
|
||||||
static char *estrdup(const char *);
|
|
||||||
static int scmp(const void *, const void *);
|
static int scmp(const void *, const void *);
|
||||||
static void show_codesets(void);
|
static void show_codesets(void);
|
||||||
static void do_conv(const char *, FILE *, const char *, const char *, int, int);
|
static void do_conv(const char *, FILE *, const char *, const char *, int, int);
|
||||||
@ -53,15 +53,6 @@ usage(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
estrdup(const char *str)
|
|
||||||
{
|
|
||||||
char *ptr = strdup(str);
|
|
||||||
if (ptr == NULL)
|
|
||||||
err(EXIT_FAILURE, "Cannot copy string");
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* qsort() helper function
|
* qsort() helper function
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.36 2006/06/15 10:55:02 skrll Exp $
|
# $NetBSD: Makefile,v 1.37 2006/08/26 18:17:42 christos Exp $
|
||||||
# @(#)Makefile 5.2 (Berkeley) 12/28/90
|
# @(#)Makefile 5.2 (Berkeley) 12/28/90
|
||||||
|
|
||||||
PROG= make
|
PROG= make
|
||||||
@ -31,6 +31,9 @@ CPPFLAGS+= ${CPPFLAGS_${.TARGET}} -DMAKE_NATIVE
|
|||||||
main.o: ${OBJS:Nmain.o} ${MAKEFILE}
|
main.o: ${OBJS:Nmain.o} ${MAKEFILE}
|
||||||
COPTS.var.c+= -Wno-cast-qual
|
COPTS.var.c+= -Wno-cast-qual
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
# A simple unit-test driver to help catch regressions
|
# A simple unit-test driver to help catch regressions
|
||||||
accept test:
|
accept test:
|
||||||
cd ${.CURDIR}/unit-tests && ${.MAKE:S,^./,${.CURDIR}/,} TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
|
cd ${.CURDIR}/unit-tests && ${.MAKE:S,^./,${.CURDIR}/,} TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $ */
|
/* $NetBSD: main.c,v 1.129 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,7 +69,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $";
|
static char rcsid[] = "$NetBSD: main.c,v 1.129 2006/08/26 18:17:42 christos Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $");
|
__RCSID("$NetBSD: main.c,v 1.129 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -1341,13 +1341,13 @@ Check_Cwd(const char **argv)
|
|||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* A string containing the output of the command, or the empty string
|
* A string containing the output of the command, or the empty string
|
||||||
* If err is not NULL, it contains the reason for the command failure
|
* If errnum is not NULL, it contains the reason for the command failure
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* The string must be freed by the caller.
|
* The string must be freed by the caller.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
Cmd_Exec(const char *cmd, const char **err)
|
Cmd_Exec(const char *cmd, const char **errnum)
|
||||||
{
|
{
|
||||||
const char *args[4]; /* Args for invoking the shell */
|
const char *args[4]; /* Args for invoking the shell */
|
||||||
int fds[2]; /* Pipe streams */
|
int fds[2]; /* Pipe streams */
|
||||||
@ -1360,7 +1360,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
|||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
|
|
||||||
*err = NULL;
|
*errnum = NULL;
|
||||||
|
|
||||||
if (!shellName)
|
if (!shellName)
|
||||||
Shell_Init();
|
Shell_Init();
|
||||||
@ -1376,7 +1376,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
|||||||
* Open a pipe for fetching its output
|
* Open a pipe for fetching its output
|
||||||
*/
|
*/
|
||||||
if (pipe(fds) == -1) {
|
if (pipe(fds) == -1) {
|
||||||
*err = "Couldn't create pipe for \"%s\"";
|
*errnum = "Couldn't create pipe for \"%s\"";
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,7 +1403,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
|||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
*err = "Couldn't exec \"%s\"";
|
*errnum = "Couldn't exec \"%s\"";
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1437,10 +1437,10 @@ Cmd_Exec(const char *cmd, const char **err)
|
|||||||
Buf_Destroy(buf, FALSE);
|
Buf_Destroy(buf, FALSE);
|
||||||
|
|
||||||
if (cc == 0)
|
if (cc == 0)
|
||||||
*err = "Couldn't read shell's output for \"%s\"";
|
*errnum = "Couldn't read shell's output for \"%s\"";
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
*err = "\"%s\" returned non-zero status";
|
*errnum = "\"%s\" returned non-zero status";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Null-terminate the result, convert newlines to spaces and
|
* Null-terminate the result, convert newlines to spaces and
|
||||||
@ -1596,6 +1596,7 @@ Finish(int errors)
|
|||||||
Fatal("%d error%s", errors, errors == 1 ? "" : "s");
|
Fatal("%d error%s", errors, errors == 1 ? "" : "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __NetBSD__
|
||||||
/*
|
/*
|
||||||
* emalloc --
|
* emalloc --
|
||||||
* malloc, but die on error.
|
* malloc, but die on error.
|
||||||
@ -1646,6 +1647,7 @@ enomem(void)
|
|||||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* enunlink --
|
* enunlink --
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: make.h,v 1.59 2006/03/10 15:53:55 christos Exp $ */
|
/* $NetBSD: make.h,v 1.60 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -88,6 +88,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#ifdef BSD4_4
|
#ifdef BSD4_4
|
||||||
# include <sys/cdefs.h>
|
# include <sys/cdefs.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: nonints.h,v 1.36 2006/03/31 21:58:08 christos Exp $ */
|
/* $NetBSD: nonints.h,v 1.37 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -115,10 +115,14 @@ void Punt(const char *, ...)
|
|||||||
void DieHorribly(void) __attribute__((__noreturn__));
|
void DieHorribly(void) __attribute__((__noreturn__));
|
||||||
int PrintAddr(ClientData, ClientData);
|
int PrintAddr(ClientData, ClientData);
|
||||||
void Finish(int);
|
void Finish(int);
|
||||||
|
#ifndef __NetBSD__
|
||||||
char *estrdup(const char *);
|
char *estrdup(const char *);
|
||||||
void *emalloc(size_t);
|
void *emalloc(size_t);
|
||||||
void *erealloc(void *, size_t);
|
void *erealloc(void *, size_t);
|
||||||
void enomem(void);
|
void enomem(void);
|
||||||
|
#else
|
||||||
|
#include <err.h>
|
||||||
|
#endif
|
||||||
int eunlink(const char *);
|
int eunlink(const char *);
|
||||||
void execError(const char *, const char *);
|
void execError(const char *, const char *);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parse.c,v 1.114 2006/03/31 21:58:08 christos Exp $ */
|
/* $NetBSD: parse.c,v 1.115 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: parse.c,v 1.114 2006/03/31 21:58:08 christos Exp $";
|
static char rcsid[] = "$NetBSD: parse.c,v 1.115 2006/08/26 18:17:42 christos Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: parse.c,v 1.114 2006/03/31 21:58:08 christos Exp $");
|
__RCSID("$NetBSD: parse.c,v 1.115 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -1206,17 +1206,17 @@ ParseDoDependency(char *line)
|
|||||||
* allow on this line...
|
* allow on this line...
|
||||||
*/
|
*/
|
||||||
if (specType != Not && specType != ExPath) {
|
if (specType != Not && specType != ExPath) {
|
||||||
Boolean warn = FALSE;
|
Boolean warning = FALSE;
|
||||||
|
|
||||||
while (*cp && (ParseIsEscaped(lstart, cp) ||
|
while (*cp && (ParseIsEscaped(lstart, cp) ||
|
||||||
((*cp != '!') && (*cp != ':')))) {
|
((*cp != '!') && (*cp != ':')))) {
|
||||||
if (ParseIsEscaped(lstart, cp) ||
|
if (ParseIsEscaped(lstart, cp) ||
|
||||||
(*cp != ' ' && *cp != '\t')) {
|
(*cp != ' ' && *cp != '\t')) {
|
||||||
warn = TRUE;
|
warning = TRUE;
|
||||||
}
|
}
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
if (warn) {
|
if (warning) {
|
||||||
Parse_Error(PARSE_WARNING, "Extra target ignored");
|
Parse_Error(PARSE_WARNING, "Extra target ignored");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1734,7 +1734,7 @@ Parse_DoVar(char *line, GNode *ctxt)
|
|||||||
Var_Set(line, cp, ctxt, 0);
|
Var_Set(line, cp, ctxt, 0);
|
||||||
} else if (type == VAR_SHELL) {
|
} else if (type == VAR_SHELL) {
|
||||||
char *res;
|
char *res;
|
||||||
const char *err;
|
const char *error;
|
||||||
|
|
||||||
if (strchr(cp, '$') != NULL) {
|
if (strchr(cp, '$') != NULL) {
|
||||||
/*
|
/*
|
||||||
@ -1746,12 +1746,12 @@ Parse_DoVar(char *line, GNode *ctxt)
|
|||||||
freeCp = TRUE;
|
freeCp = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Cmd_Exec(cp, &err);
|
res = Cmd_Exec(cp, &error);
|
||||||
Var_Set(line, res, ctxt, 0);
|
Var_Set(line, res, ctxt, 0);
|
||||||
free(res);
|
free(res);
|
||||||
|
|
||||||
if (err)
|
if (error)
|
||||||
Parse_Error(PARSE_WARNING, err, cp);
|
Parse_Error(PARSE_WARNING, error, cp);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Normal assignment -- just do it.
|
* Normal assignment -- just do it.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: var.c,v 1.112 2006/07/28 17:08:55 sjg Exp $ */
|
/* $NetBSD: var.c,v 1.113 2006/08/26 18:17:42 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: var.c,v 1.112 2006/07/28 17:08:55 sjg Exp $";
|
static char rcsid[] = "$NetBSD: var.c,v 1.113 2006/08/26 18:17:42 christos Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: var.c,v 1.112 2006/07/28 17:08:55 sjg Exp $");
|
__RCSID("$NetBSD: var.c,v 1.113 2006/08/26 18:17:42 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -144,7 +144,7 @@ __RCSID("$NetBSD: var.c,v 1.112 2006/07/28 17:08:55 sjg Exp $");
|
|||||||
char var_Error[] = "";
|
char var_Error[] = "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Similar to var_Error, but returned when the 'err' flag for Var_Parse is
|
* Similar to var_Error, but returned when the 'errnum' flag for Var_Parse is
|
||||||
* set false. Why not just use a constant? Well, gcc likes to condense
|
* set false. Why not just use a constant? Well, gcc likes to condense
|
||||||
* identical string instances...
|
* identical string instances...
|
||||||
*/
|
*/
|
||||||
@ -232,7 +232,7 @@ typedef struct {
|
|||||||
int tvarLen;
|
int tvarLen;
|
||||||
char *str; /* string to expand */
|
char *str; /* string to expand */
|
||||||
int strLen;
|
int strLen;
|
||||||
int err; /* err for not defined */
|
int errnum; /* errnum for not defined */
|
||||||
} VarLoop_t;
|
} VarLoop_t;
|
||||||
|
|
||||||
#ifndef NO_REGEX
|
#ifndef NO_REGEX
|
||||||
@ -1219,14 +1219,14 @@ VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
|
|||||||
*-----------------------------------------------------------------------
|
*-----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
VarREError(int err, regex_t *pat, const char *str)
|
VarREError(int errnum, regex_t *pat, const char *str)
|
||||||
{
|
{
|
||||||
char *errbuf;
|
char *errbuf;
|
||||||
int errlen;
|
int errlen;
|
||||||
|
|
||||||
errlen = regerror(err, pat, 0, 0);
|
errlen = regerror(errnum, pat, 0, 0);
|
||||||
errbuf = emalloc(errlen);
|
errbuf = emalloc(errlen);
|
||||||
regerror(err, pat, errbuf, errlen);
|
regerror(errnum, pat, errbuf, errlen);
|
||||||
Error("%s: %s", str, errbuf);
|
Error("%s: %s", str, errbuf);
|
||||||
free(errbuf);
|
free(errbuf);
|
||||||
}
|
}
|
||||||
@ -1397,7 +1397,7 @@ VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
|
|||||||
|
|
||||||
if (word && *word) {
|
if (word && *word) {
|
||||||
Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
|
Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
|
||||||
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->err);
|
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum);
|
||||||
if (s != NULL && *s != '\0') {
|
if (s != NULL && *s != '\0') {
|
||||||
if (addSpace && *s != '\n')
|
if (addSpace && *s != '\n')
|
||||||
Buf_AddByte(buf, ' ');
|
Buf_AddByte(buf, ' ');
|
||||||
@ -1716,7 +1716,7 @@ VarUniq(const char *str)
|
|||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
|
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
|
||||||
int err, const char **tstr, int delim, int *flags,
|
int errnum, const char **tstr, int delim, int *flags,
|
||||||
int *length, VarPattern *pattern)
|
int *length, VarPattern *pattern)
|
||||||
{
|
{
|
||||||
const char *cp;
|
const char *cp;
|
||||||
@ -1760,7 +1760,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
|
|||||||
* delimiter, assume it's a variable
|
* delimiter, assume it's a variable
|
||||||
* substitution and recurse.
|
* substitution and recurse.
|
||||||
*/
|
*/
|
||||||
cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
|
cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
|
||||||
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
||||||
if (freeIt)
|
if (freeIt)
|
||||||
free(freeIt);
|
free(freeIt);
|
||||||
@ -1978,7 +1978,7 @@ VarChangeCase(char *str, int upper)
|
|||||||
static char *
|
static char *
|
||||||
ApplyModifiers(char *nstr, const char *tstr,
|
ApplyModifiers(char *nstr, const char *tstr,
|
||||||
int startc, int endc,
|
int startc, int endc,
|
||||||
Var *v, GNode *ctxt, Boolean err,
|
Var *v, GNode *ctxt, Boolean errnum,
|
||||||
int *lengthPtr, void **freePtr)
|
int *lengthPtr, void **freePtr)
|
||||||
{
|
{
|
||||||
const char *start;
|
const char *start;
|
||||||
@ -2008,7 +2008,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
char *rval;
|
char *rval;
|
||||||
int rlen;
|
int rlen;
|
||||||
|
|
||||||
rval = Var_Parse(tstr, ctxt, err, &rlen, &freeIt);
|
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
|
||||||
|
|
||||||
if (DEBUG(VAR)) {
|
if (DEBUG(VAR)) {
|
||||||
printf("Got '%s' from '%.*s'%.*s\n",
|
printf("Got '%s' from '%.*s'%.*s\n",
|
||||||
@ -2022,9 +2022,9 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
|
|
||||||
nstr = ApplyModifiers(nstr, rval,
|
nstr = ApplyModifiers(nstr, rval,
|
||||||
0, 0,
|
0, 0,
|
||||||
v, ctxt, err, &used, freePtr);
|
v, ctxt, errnum, &used, freePtr);
|
||||||
if (nstr == var_Error
|
if (nstr == var_Error
|
||||||
|| (nstr == varNoError && err == 0)
|
|| (nstr == varNoError && errnum == 0)
|
||||||
|| strlen(rval) != (size_t) used) {
|
|| strlen(rval) != (size_t) used) {
|
||||||
if (freeIt)
|
if (freeIt)
|
||||||
free(freeIt);
|
free(freeIt);
|
||||||
@ -2087,7 +2087,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
delim = BRCLOSE;
|
delim = BRCLOSE;
|
||||||
pattern.flags = 0;
|
pattern.flags = 0;
|
||||||
|
|
||||||
pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim, NULL,
|
&cp, delim, NULL,
|
||||||
&pattern.rightLen,
|
&pattern.rightLen,
|
||||||
NULL);
|
NULL);
|
||||||
@ -2136,13 +2136,13 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
|
|
||||||
cp = ++tstr;
|
cp = ++tstr;
|
||||||
delim = '@';
|
delim = '@';
|
||||||
if ((loop.tvar = VarGetPattern(ctxt, &parsestate, err,
|
if ((loop.tvar = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim,
|
&cp, delim,
|
||||||
&flags, &loop.tvarLen,
|
&flags, &loop.tvarLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((loop.str = VarGetPattern(ctxt, &parsestate, err,
|
if ((loop.str = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim,
|
&cp, delim,
|
||||||
&flags, &loop.strLen,
|
&flags, &loop.strLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
@ -2151,7 +2151,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
termc = *cp;
|
termc = *cp;
|
||||||
delim = '\0';
|
delim = '\0';
|
||||||
|
|
||||||
loop.err = err;
|
loop.errnum = errnum;
|
||||||
loop.ctxt = ctxt;
|
loop.ctxt = ctxt;
|
||||||
newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand,
|
newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand,
|
||||||
(ClientData)&loop);
|
(ClientData)&loop);
|
||||||
@ -2193,7 +2193,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
int len;
|
int len;
|
||||||
void *freeIt;
|
void *freeIt;
|
||||||
|
|
||||||
cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
|
cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
|
||||||
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
|
||||||
if (freeIt)
|
if (freeIt)
|
||||||
free(freeIt);
|
free(freeIt);
|
||||||
@ -2260,7 +2260,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
delim = '!';
|
delim = '!';
|
||||||
|
|
||||||
cp = ++tstr;
|
cp = ++tstr;
|
||||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim,
|
&cp, delim,
|
||||||
NULL, &pattern.rightLen,
|
NULL, &pattern.rightLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
@ -2290,7 +2290,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
cp = tstr+1; /* point to char after '[' */
|
cp = tstr+1; /* point to char after '[' */
|
||||||
delim = ']'; /* look for closing ']' */
|
delim = ']'; /* look for closing ']' */
|
||||||
estr = VarGetPattern(ctxt, &parsestate,
|
estr = VarGetPattern(ctxt, &parsestate,
|
||||||
err, &cp, delim,
|
errnum, &cp, delim,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (estr == NULL)
|
if (estr == NULL)
|
||||||
goto cleanup; /* report missing ']' */
|
goto cleanup; /* report missing ']' */
|
||||||
@ -2581,7 +2581,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
}
|
}
|
||||||
if ((cp2 = strchr(pattern, '$'))) {
|
if ((cp2 = strchr(pattern, '$'))) {
|
||||||
cp2 = pattern;
|
cp2 = pattern;
|
||||||
pattern = Var_Subst(NULL, cp2, ctxt, err);
|
pattern = Var_Subst(NULL, cp2, ctxt, errnum);
|
||||||
if (copy)
|
if (copy)
|
||||||
free(cp2);
|
free(cp2);
|
||||||
copy = TRUE;
|
copy = TRUE;
|
||||||
@ -2618,14 +2618,14 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cp = tstr;
|
cp = tstr;
|
||||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, err,
|
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim,
|
&cp, delim,
|
||||||
&pattern.flags,
|
&pattern.flags,
|
||||||
&pattern.leftLen,
|
&pattern.leftLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim, NULL,
|
&cp, delim, NULL,
|
||||||
&pattern.rightLen,
|
&pattern.rightLen,
|
||||||
&pattern)) == NULL)
|
&pattern)) == NULL)
|
||||||
@ -2675,7 +2675,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
|
|
||||||
cp = ++tstr;
|
cp = ++tstr;
|
||||||
delim = ':';
|
delim = ':';
|
||||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, err,
|
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim, NULL,
|
&cp, delim, NULL,
|
||||||
&pattern.leftLen,
|
&pattern.leftLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
@ -2683,7 +2683,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
|
|
||||||
/* BROPEN or PROPEN */
|
/* BROPEN or PROPEN */
|
||||||
delim = endc;
|
delim = endc;
|
||||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||||
&cp, delim, NULL,
|
&cp, delim, NULL,
|
||||||
&pattern.rightLen,
|
&pattern.rightLen,
|
||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
@ -2725,12 +2725,12 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
|
|
||||||
cp = tstr;
|
cp = tstr;
|
||||||
|
|
||||||
if ((re = VarGetPattern(ctxt, &parsestate, err, &cp, delim,
|
if ((re = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim,
|
||||||
NULL, NULL, NULL)) == NULL)
|
NULL, NULL, NULL)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
|
if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
|
||||||
err, &cp, delim, NULL,
|
errnum, &cp, delim, NULL,
|
||||||
NULL, NULL)) == NULL){
|
NULL, NULL)) == NULL){
|
||||||
free(re);
|
free(re);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2904,12 +2904,12 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
delim='=';
|
delim='=';
|
||||||
cp = tstr;
|
cp = tstr;
|
||||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
|
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
|
||||||
err, &cp, delim, &pattern.flags,
|
errnum, &cp, delim, &pattern.flags,
|
||||||
&pattern.leftLen, NULL)) == NULL)
|
&pattern.leftLen, NULL)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
delim = endc;
|
delim = endc;
|
||||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
|
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
|
||||||
err, &cp, delim, NULL, &pattern.rightLen,
|
errnum, &cp, delim, NULL, &pattern.rightLen,
|
||||||
&pattern)) == NULL)
|
&pattern)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -2992,7 +2992,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
* Input:
|
* Input:
|
||||||
* str The string to parse
|
* str The string to parse
|
||||||
* ctxt The context for the variable
|
* ctxt The context for the variable
|
||||||
* err TRUE if undefined variables are an error
|
* errnum TRUE if undefined variables are an error
|
||||||
* lengthPtr OUT: The length of the specification
|
* lengthPtr OUT: The length of the specification
|
||||||
* freePtr OUT: TRUE if caller should free result
|
* freePtr OUT: TRUE if caller should free result
|
||||||
*
|
*
|
||||||
@ -3011,7 +3011,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||||||
*/
|
*/
|
||||||
/* coverity[+alloc : arg-*4] */
|
/* coverity[+alloc : arg-*4] */
|
||||||
char *
|
char *
|
||||||
Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
|
||||||
void **freePtr)
|
void **freePtr)
|
||||||
{
|
{
|
||||||
const char *tstr; /* Pointer into str */
|
const char *tstr; /* Pointer into str */
|
||||||
@ -3075,7 +3075,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
/*
|
/*
|
||||||
* Error
|
* Error
|
||||||
*/
|
*/
|
||||||
return (err ? var_Error : varNoError);
|
return (errnum ? var_Error : varNoError);
|
||||||
} else {
|
} else {
|
||||||
haveModifier = FALSE;
|
haveModifier = FALSE;
|
||||||
tstr = &str[1];
|
tstr = &str[1];
|
||||||
@ -3083,7 +3083,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
}
|
}
|
||||||
} else if (str[1] == '\0') {
|
} else if (str[1] == '\0') {
|
||||||
*lengthPtr = 1;
|
*lengthPtr = 1;
|
||||||
return (err ? var_Error : varNoError);
|
return (errnum ? var_Error : varNoError);
|
||||||
} else {
|
} else {
|
||||||
Buffer buf; /* Holds the variable name */
|
Buffer buf; /* Holds the variable name */
|
||||||
|
|
||||||
@ -3104,7 +3104,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
if (*tstr == '$') {
|
if (*tstr == '$') {
|
||||||
int rlen;
|
int rlen;
|
||||||
void *freeIt;
|
void *freeIt;
|
||||||
char *rval = Var_Parse(tstr, ctxt, err, &rlen, &freeIt);
|
char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
|
||||||
if (rval != NULL) {
|
if (rval != NULL) {
|
||||||
Buf_AddBytes(buf, strlen(rval), (Byte *)rval);
|
Buf_AddBytes(buf, strlen(rval), (Byte *)rval);
|
||||||
}
|
}
|
||||||
@ -3246,7 +3246,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
return(pstr);
|
return(pstr);
|
||||||
} else {
|
} else {
|
||||||
Buf_Destroy(buf, TRUE);
|
Buf_Destroy(buf, TRUE);
|
||||||
return (err ? var_Error : varNoError);
|
return (errnum ? var_Error : varNoError);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -3281,7 +3281,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
*/
|
*/
|
||||||
nstr = (char *)Buf_GetAll(v->val, NULL);
|
nstr = (char *)Buf_GetAll(v->val, NULL);
|
||||||
if (strchr(nstr, '$') != NULL) {
|
if (strchr(nstr, '$') != NULL) {
|
||||||
nstr = Var_Subst(NULL, nstr, ctxt, err);
|
nstr = Var_Subst(NULL, nstr, ctxt, errnum);
|
||||||
*freePtr = nstr;
|
*freePtr = nstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3296,7 +3296,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||||||
tstr++;
|
tstr++;
|
||||||
|
|
||||||
nstr = ApplyModifiers(nstr, tstr, startc, endc,
|
nstr = ApplyModifiers(nstr, tstr, startc, endc,
|
||||||
v, ctxt, err, &used, freePtr);
|
v, ctxt, errnum, &used, freePtr);
|
||||||
tstr += used;
|
tstr += used;
|
||||||
*lengthPtr = tstr - start + 1;
|
*lengthPtr = tstr - start + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# $NetBSD: Makefile,v 1.1 1998/09/23 21:05:59 perry Exp $
|
# $NetBSD: Makefile,v 1.2 2006/08/26 18:17:43 christos Exp $
|
||||||
|
|
||||||
PROG= shuffle
|
PROG= shuffle
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: shuffle.c,v 1.18 2004/12/01 00:03:45 perry Exp $ */
|
/* $NetBSD: shuffle.c,v 1.19 2006/08/26 18:17:43 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998
|
* Copyright (c) 1998
|
||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: shuffle.c,v 1.18 2004/12/01 00:03:45 perry Exp $");
|
__RCSID("$NetBSD: shuffle.c,v 1.19 2006/08/26 18:17:43 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -45,10 +45,7 @@ __RCSID("$NetBSD: shuffle.c,v 1.18 2004/12/01 00:03:45 perry Exp $");
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
static void enomem(void);
|
|
||||||
static void *emalloc(size_t);
|
|
||||||
static void *erealloc(void *, size_t);
|
|
||||||
|
|
||||||
static size_t *get_shuffle(size_t);
|
static size_t *get_shuffle(size_t);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
@ -57,42 +54,6 @@ static size_t get_number(const char *, int);
|
|||||||
|
|
||||||
int main(int, char *[]);
|
int main(int, char *[]);
|
||||||
|
|
||||||
/*
|
|
||||||
* enomem --
|
|
||||||
* die when out of memory.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
enomem(void)
|
|
||||||
{
|
|
||||||
errx(2, "Cannot allocate memory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* emalloc --
|
|
||||||
* malloc, but die on error.
|
|
||||||
*/
|
|
||||||
static void *
|
|
||||||
emalloc(size_t len)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if ((p = malloc(len)) == NULL)
|
|
||||||
enomem();
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* erealloc --
|
|
||||||
* realloc, but die on error.
|
|
||||||
*/
|
|
||||||
void *
|
|
||||||
erealloc(void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
if ((ptr = realloc(ptr, size)) == NULL)
|
|
||||||
enomem();
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_shuffle --
|
* get_shuffle --
|
||||||
* Construct a random shuffle array of t elements
|
* Construct a random shuffle array of t elements
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.2 2005/06/30 16:25:05 christos Exp $
|
# $NetBSD: Makefile,v 1.3 2006/08/26 18:17:43 christos Exp $
|
||||||
|
|
||||||
PROG= spellprog
|
PROG= spellprog
|
||||||
WARNS= 3
|
WARNS= 3
|
||||||
@ -6,4 +6,7 @@ NOMAN= 1
|
|||||||
SRCS= spellprog.c look.c
|
SRCS= spellprog.c look.c
|
||||||
BINDIR= /usr/libexec
|
BINDIR= /usr/libexec
|
||||||
|
|
||||||
|
LDADD+=-lutil
|
||||||
|
DPADD+=${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: spellprog.c,v 1.4 2005/07/17 17:08:25 christos Exp $ */
|
/* $NetBSD: spellprog.c,v 1.5 2006/08/26 18:17:43 christos Exp $ */
|
||||||
|
|
||||||
/* derived from OpenBSD: spellprog.c,v 1.4 2003/06/03 02:56:16 millert Exp */
|
/* derived from OpenBSD: spellprog.c,v 1.4 2003/06/03 02:56:16 millert Exp */
|
||||||
|
|
||||||
@ -94,6 +94,7 @@ static const char rcsid[] = "$OpenBSD: spellprog.c,v 1.4 2003/06/03 02:56:16 mil
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
@ -106,7 +107,6 @@ static int suffix(char *, size_t);
|
|||||||
static int vowel(int);
|
static int vowel(int);
|
||||||
static const char *lookuppref(char **, char *);
|
static const char *lookuppref(char **, char *);
|
||||||
static char *skipv(char *);
|
static char *skipv(char *);
|
||||||
static char *estrdup(const char *);
|
|
||||||
static void ise(void);
|
static void ise(void);
|
||||||
static void print_word(FILE *);
|
static void print_word(FILE *);
|
||||||
static void ztos(char *);
|
static void ztos(char *);
|
||||||
@ -789,16 +789,6 @@ ztos(char *st)
|
|||||||
*st = 's';
|
*st = 's';
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
estrdup(const char *st)
|
|
||||||
{
|
|
||||||
char *d;
|
|
||||||
|
|
||||||
if ((d = strdup(st)) == NULL)
|
|
||||||
err(1, "strdup");
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up a word in the dictionary.
|
* Look up a word in the dictionary.
|
||||||
* Returns 1 if found, 0 if not.
|
* Returns 1 if found, 0 if not.
|
||||||
|
Loading…
Reference in New Issue
Block a user