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
|
||||
|
||||
PROG= column
|
||||
WARNS= 4
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.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
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
|
||||
#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 */
|
||||
|
||||
#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 <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#define TAB 8
|
||||
|
||||
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 maketbl(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
|
||||
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
|
||||
SRCS= crunchgen.c crunched_skel.c
|
||||
@ -8,6 +8,10 @@ crunched_skel.c: mkskel.sh crunched_main.c
|
||||
${_MKTARGET_CREATE}
|
||||
${HOST_SH} ${.ALLSRC} >${.TARGET}
|
||||
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.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
|
||||
* All Rights Reserved.
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#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
|
||||
|
||||
#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 <errno.h>
|
||||
#include <err.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -115,8 +116,6 @@ void out_of_memory(void);
|
||||
void add_string(strlst_t **listp, char *str);
|
||||
int is_dir(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() */
|
||||
|
||||
@ -164,13 +163,13 @@ main(int argc, char **argv)
|
||||
case 'O': oneobj = 0; break;
|
||||
case 'o': useobjs = 1, oneobj = 0; break;
|
||||
|
||||
case 'm': estrlcpy(outmkname, optarg, sizeof(outmkname)); break;
|
||||
case 'c': estrlcpy(outcfname, optarg, sizeof(outcfname)); break;
|
||||
case 'e': estrlcpy(execfname, optarg, sizeof(execfname)); break;
|
||||
case 'd': estrlcpy(dbg, optarg, sizeof(dbg)); break;
|
||||
case 'm': (void)estrlcpy(outmkname, optarg, sizeof(outmkname)); break;
|
||||
case 'c': (void)estrlcpy(outcfname, optarg, sizeof(outcfname)); break;
|
||||
case 'e': (void)estrlcpy(execfname, optarg, sizeof(execfname)); break;
|
||||
case 'd': (void)estrlcpy(dbg, optarg, sizeof(dbg)); break;
|
||||
|
||||
case 'D': estrlcpy(topdir, optarg, sizeof(topdir)); break;
|
||||
case 'L': estrlcpy(libdir, optarg, sizeof(libdir)); break;
|
||||
case 'D': (void)estrlcpy(topdir, optarg, sizeof(topdir)); break;
|
||||
case 'L': (void)estrlcpy(libdir, optarg, sizeof(libdir)); break;
|
||||
case 'v': add_string(&vars, optarg); break;
|
||||
|
||||
case '?':
|
||||
@ -188,15 +187,15 @@ main(int argc, char **argv)
|
||||
* generate filenames
|
||||
*/
|
||||
|
||||
estrlcpy(infilename, argv[0], sizeof(infilename));
|
||||
(void)estrlcpy(infilename, argv[0], sizeof(infilename));
|
||||
getcwd(curdir, MAXPATHLEN);
|
||||
|
||||
/* confname = `basename infilename .conf` */
|
||||
|
||||
if ((p = strrchr(infilename, '/')) != NULL)
|
||||
estrlcpy(confname, p + 1, sizeof(confname));
|
||||
(void)estrlcpy(confname, p + 1, sizeof(confname));
|
||||
else
|
||||
estrlcpy(confname, infilename, sizeof(confname));
|
||||
(void)estrlcpy(confname, infilename, sizeof(confname));
|
||||
if ((p = strrchr(confname, '.')) != NULL && !strcmp(p, ".conf"))
|
||||
*p = '\0';
|
||||
|
||||
@ -273,7 +272,7 @@ parse_one_file(char *filename)
|
||||
|
||||
(void)snprintf(line, sizeof(line), "reading %s", filename);
|
||||
status(line);
|
||||
estrlcpy(curfilename, filename, sizeof(curfilename));
|
||||
(void)estrlcpy(curfilename, filename, sizeof(curfilename));
|
||||
|
||||
if ((cf = fopen(curfilename, "r")) == NULL) {
|
||||
perror(curfilename);
|
||||
@ -350,14 +349,14 @@ add_srcdirs(int argc, char **argv)
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '/')
|
||||
estrlcpy(tmppath, argv[i], sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, argv[i], sizeof(tmppath));
|
||||
else {
|
||||
if (topdir[0] == '\0')
|
||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
else
|
||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
estrlcat(tmppath, argv[i], sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, argv[i], sizeof(tmppath));
|
||||
}
|
||||
if (is_dir(tmppath))
|
||||
add_string(&srcdirs, tmppath);
|
||||
@ -470,11 +469,11 @@ add_special(int argc, char **argv)
|
||||
} else {
|
||||
char tmppath[MAXPATHLEN];
|
||||
if (topdir[0] == '\0')
|
||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
else
|
||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
estrlcat(tmppath, argv[3], sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, argv[3], sizeof(tmppath));
|
||||
if ((p->srcdir = strdup(tmppath)) == NULL)
|
||||
out_of_memory();
|
||||
}
|
||||
@ -603,11 +602,11 @@ fillin_program(prog_t *p)
|
||||
} else {
|
||||
char tmppath[MAXPATHLEN];
|
||||
if (topdir[0] == '\0')
|
||||
estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, curdir, sizeof(tmppath));
|
||||
else
|
||||
estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
estrlcat(tmppath, path, sizeof(tmppath));
|
||||
(void)estrlcpy(tmppath, topdir, sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, "/", sizeof(tmppath));
|
||||
(void)estrlcat(tmppath, path, sizeof(tmppath));
|
||||
if ((p->srcdir = strdup(tmppath)) == NULL)
|
||||
out_of_memory();
|
||||
}
|
||||
@ -1146,21 +1145,3 @@ is_nonempty_file(char *pathname)
|
||||
|
||||
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
|
||||
|
||||
.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
|
||||
.PATH: ${NETBSDSRCDIR}/bin/ls
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.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
|
||||
@ -34,7 +34,6 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
void brace_subst __P((char *, char **, char *, int *));
|
||||
void *emalloc __P((unsigned int));
|
||||
PLAN *find_create __P((char ***));
|
||||
int find_execute __P((PLAN *, 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
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
|
||||
#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 /* 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 <tzfile.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "find.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
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94";
|
||||
#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 /* not lint */
|
||||
|
||||
@ -127,21 +127,6 @@ queryuser(argv)
|
||||
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 --
|
||||
* 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
|
||||
|
||||
PROG= hexdump
|
||||
@ -7,6 +7,9 @@ MAN= hexdump.1 od.1
|
||||
WFORMAT= 1
|
||||
WARNS= 2
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.ifndef HOSTPROG
|
||||
LINKS= ${BINDIR}/hexdump ${BINDIR}/od
|
||||
.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
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
|
||||
#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 /* 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 <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "hexdump.h"
|
||||
|
||||
@ -238,8 +239,8 @@ get(void)
|
||||
u_char *tmpp;
|
||||
|
||||
if (!curp) {
|
||||
curp = emalloc(blocksize);
|
||||
savp = emalloc(blocksize);
|
||||
curp = ecalloc(blocksize, 1);
|
||||
savp = ecalloc(blocksize, 1);
|
||||
} else {
|
||||
tmpp = curp;
|
||||
curp = savp;
|
||||
@ -357,20 +358,3 @@ doskip(const char *fname, int statok)
|
||||
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
|
||||
@ -91,12 +91,10 @@ void conv_u(PR *, u_char *);
|
||||
void display(void);
|
||||
void doskip(const char *, int);
|
||||
/*void err(const char *, ...);*/
|
||||
void *emalloc(int);
|
||||
void escape(char *);
|
||||
u_char *get(void);
|
||||
void newsyntax(int, char ***);
|
||||
int next(char **);
|
||||
void nomem(void);
|
||||
void oldsyntax(int, char ***);
|
||||
void rewrite(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
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
|
||||
#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 /* 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 <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "hexdump.h"
|
||||
|
||||
@ -284,10 +285,9 @@ posixtypes(char const *type_string)
|
||||
break;
|
||||
if (odf->type == 0)
|
||||
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,
|
||||
4 * nbytes - odf->minwidth, "", odf->format);
|
||||
if (fmt == NULL) nomem();
|
||||
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
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
|
||||
#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 /* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "hexdump.h"
|
||||
|
||||
@ -145,8 +146,7 @@ add(const char *fmt)
|
||||
for (savep = ++p; *p != '"';)
|
||||
if (*p++ == 0)
|
||||
badfmt(fmt);
|
||||
if (!(tfu->fmt = malloc(p - savep + 1)))
|
||||
nomem();
|
||||
tfu->fmt = emalloc(p - savep + 1);
|
||||
(void) strncpy(tfu->fmt, savep, p - savep);
|
||||
tfu->fmt[p - savep] = '\0';
|
||||
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>
|
||||
|
||||
@ -8,4 +8,7 @@ SRCS= iconv.c
|
||||
CPPFLAGS+= -I. -I${.CURDIR} -I${NETBSDSRCDIR}/lib/libc
|
||||
MAN= iconv.1
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.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,
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#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 */
|
||||
|
||||
#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 <unistd.h>
|
||||
#include <err.h>
|
||||
#include <util.h>
|
||||
|
||||
static void usage(void) __attribute__((__unused__));
|
||||
static char *estrdup(const char *);
|
||||
static int scmp(const void *, const void *);
|
||||
static void show_codesets(void);
|
||||
static void do_conv(const char *, FILE *, const char *, const char *, int, int);
|
||||
@ -53,15 +53,6 @@ usage(void)
|
||||
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
|
||||
*/
|
||||
|
@ -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
|
||||
|
||||
PROG= make
|
||||
@ -31,6 +31,9 @@ CPPFLAGS+= ${CPPFLAGS_${.TARGET}} -DMAKE_NATIVE
|
||||
main.o: ${OBJS:Nmain.o} ${MAKEFILE}
|
||||
COPTS.var.c+= -Wno-cast-qual
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
# A simple unit-test driver to help catch regressions
|
||||
accept test:
|
||||
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
|
||||
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#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 /* not lint */
|
||||
#endif
|
||||
@ -1341,13 +1341,13 @@ Check_Cwd(const char **argv)
|
||||
*
|
||||
* Results:
|
||||
* 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:
|
||||
* The string must be freed by the caller.
|
||||
*/
|
||||
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 */
|
||||
int fds[2]; /* Pipe streams */
|
||||
@ -1360,7 +1360,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
||||
int cc;
|
||||
|
||||
|
||||
*err = NULL;
|
||||
*errnum = NULL;
|
||||
|
||||
if (!shellName)
|
||||
Shell_Init();
|
||||
@ -1376,7 +1376,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
||||
* Open a pipe for fetching its output
|
||||
*/
|
||||
if (pipe(fds) == -1) {
|
||||
*err = "Couldn't create pipe for \"%s\"";
|
||||
*errnum = "Couldn't create pipe for \"%s\"";
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -1403,7 +1403,7 @@ Cmd_Exec(const char *cmd, const char **err)
|
||||
/*NOTREACHED*/
|
||||
|
||||
case -1:
|
||||
*err = "Couldn't exec \"%s\"";
|
||||
*errnum = "Couldn't exec \"%s\"";
|
||||
goto bad;
|
||||
|
||||
default:
|
||||
@ -1437,10 +1437,10 @@ Cmd_Exec(const char *cmd, const char **err)
|
||||
Buf_Destroy(buf, FALSE);
|
||||
|
||||
if (cc == 0)
|
||||
*err = "Couldn't read shell's output for \"%s\"";
|
||||
*errnum = "Couldn't read shell's output for \"%s\"";
|
||||
|
||||
if (status)
|
||||
*err = "\"%s\" returned non-zero status";
|
||||
*errnum = "\"%s\" returned non-zero status";
|
||||
|
||||
/*
|
||||
* Null-terminate the result, convert newlines to spaces and
|
||||
@ -1596,6 +1596,7 @@ Finish(int errors)
|
||||
Fatal("%d error%s", errors, errors == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
#ifndef __NetBSD__
|
||||
/*
|
||||
* emalloc --
|
||||
* malloc, but die on error.
|
||||
@ -1646,6 +1647,7 @@ enomem(void)
|
||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
@ -88,6 +88,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#ifdef BSD4_4
|
||||
# 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
|
||||
@ -115,10 +115,14 @@ void Punt(const char *, ...)
|
||||
void DieHorribly(void) __attribute__((__noreturn__));
|
||||
int PrintAddr(ClientData, ClientData);
|
||||
void Finish(int);
|
||||
#ifndef __NetBSD__
|
||||
char *estrdup(const char *);
|
||||
void *emalloc(size_t);
|
||||
void *erealloc(void *, size_t);
|
||||
void enomem(void);
|
||||
#else
|
||||
#include <err.h>
|
||||
#endif
|
||||
int eunlink(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
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
#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.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 /* not lint */
|
||||
#endif
|
||||
@ -1206,17 +1206,17 @@ ParseDoDependency(char *line)
|
||||
* allow on this line...
|
||||
*/
|
||||
if (specType != Not && specType != ExPath) {
|
||||
Boolean warn = FALSE;
|
||||
Boolean warning = FALSE;
|
||||
|
||||
while (*cp && (ParseIsEscaped(lstart, cp) ||
|
||||
((*cp != '!') && (*cp != ':')))) {
|
||||
if (ParseIsEscaped(lstart, cp) ||
|
||||
(*cp != ' ' && *cp != '\t')) {
|
||||
warn = TRUE;
|
||||
warning = TRUE;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
if (warn) {
|
||||
if (warning) {
|
||||
Parse_Error(PARSE_WARNING, "Extra target ignored");
|
||||
}
|
||||
} else {
|
||||
@ -1734,7 +1734,7 @@ Parse_DoVar(char *line, GNode *ctxt)
|
||||
Var_Set(line, cp, ctxt, 0);
|
||||
} else if (type == VAR_SHELL) {
|
||||
char *res;
|
||||
const char *err;
|
||||
const char *error;
|
||||
|
||||
if (strchr(cp, '$') != NULL) {
|
||||
/*
|
||||
@ -1746,12 +1746,12 @@ Parse_DoVar(char *line, GNode *ctxt)
|
||||
freeCp = TRUE;
|
||||
}
|
||||
|
||||
res = Cmd_Exec(cp, &err);
|
||||
res = Cmd_Exec(cp, &error);
|
||||
Var_Set(line, res, ctxt, 0);
|
||||
free(res);
|
||||
|
||||
if (err)
|
||||
Parse_Error(PARSE_WARNING, err, cp);
|
||||
if (error)
|
||||
Parse_Error(PARSE_WARNING, error, cp);
|
||||
} else {
|
||||
/*
|
||||
* 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
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
#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.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 /* not lint */
|
||||
#endif
|
||||
@ -144,7 +144,7 @@ __RCSID("$NetBSD: var.c,v 1.112 2006/07/28 17:08:55 sjg Exp $");
|
||||
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
|
||||
* identical string instances...
|
||||
*/
|
||||
@ -232,7 +232,7 @@ typedef struct {
|
||||
int tvarLen;
|
||||
char *str; /* string to expand */
|
||||
int strLen;
|
||||
int err; /* err for not defined */
|
||||
int errnum; /* errnum for not defined */
|
||||
} VarLoop_t;
|
||||
|
||||
#ifndef NO_REGEX
|
||||
@ -1219,14 +1219,14 @@ VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
VarREError(int err, regex_t *pat, const char *str)
|
||||
VarREError(int errnum, regex_t *pat, const char *str)
|
||||
{
|
||||
char *errbuf;
|
||||
int errlen;
|
||||
|
||||
errlen = regerror(err, pat, 0, 0);
|
||||
errlen = regerror(errnum, pat, 0, 0);
|
||||
errbuf = emalloc(errlen);
|
||||
regerror(err, pat, errbuf, errlen);
|
||||
regerror(errnum, pat, errbuf, errlen);
|
||||
Error("%s: %s", str, errbuf);
|
||||
free(errbuf);
|
||||
}
|
||||
@ -1397,7 +1397,7 @@ VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
|
||||
|
||||
if (word && *word) {
|
||||
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 (addSpace && *s != '\n')
|
||||
Buf_AddByte(buf, ' ');
|
||||
@ -1716,7 +1716,7 @@ VarUniq(const char *str)
|
||||
*/
|
||||
static char *
|
||||
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)
|
||||
{
|
||||
const char *cp;
|
||||
@ -1760,7 +1760,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
|
||||
* delimiter, assume it's a variable
|
||||
* 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);
|
||||
if (freeIt)
|
||||
free(freeIt);
|
||||
@ -1978,7 +1978,7 @@ VarChangeCase(char *str, int upper)
|
||||
static char *
|
||||
ApplyModifiers(char *nstr, const char *tstr,
|
||||
int startc, int endc,
|
||||
Var *v, GNode *ctxt, Boolean err,
|
||||
Var *v, GNode *ctxt, Boolean errnum,
|
||||
int *lengthPtr, void **freePtr)
|
||||
{
|
||||
const char *start;
|
||||
@ -2008,7 +2008,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
char *rval;
|
||||
int rlen;
|
||||
|
||||
rval = Var_Parse(tstr, ctxt, err, &rlen, &freeIt);
|
||||
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
|
||||
|
||||
if (DEBUG(VAR)) {
|
||||
printf("Got '%s' from '%.*s'%.*s\n",
|
||||
@ -2022,9 +2022,9 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
nstr = ApplyModifiers(nstr, rval,
|
||||
0, 0,
|
||||
v, ctxt, err, &used, freePtr);
|
||||
v, ctxt, errnum, &used, freePtr);
|
||||
if (nstr == var_Error
|
||||
|| (nstr == varNoError && err == 0)
|
||||
|| (nstr == varNoError && errnum == 0)
|
||||
|| strlen(rval) != (size_t) used) {
|
||||
if (freeIt)
|
||||
free(freeIt);
|
||||
@ -2087,7 +2087,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
delim = BRCLOSE;
|
||||
pattern.flags = 0;
|
||||
|
||||
pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim, NULL,
|
||||
&pattern.rightLen,
|
||||
NULL);
|
||||
@ -2136,13 +2136,13 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
cp = ++tstr;
|
||||
delim = '@';
|
||||
if ((loop.tvar = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((loop.tvar = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim,
|
||||
&flags, &loop.tvarLen,
|
||||
NULL)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if ((loop.str = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((loop.str = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim,
|
||||
&flags, &loop.strLen,
|
||||
NULL)) == NULL)
|
||||
@ -2151,7 +2151,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
termc = *cp;
|
||||
delim = '\0';
|
||||
|
||||
loop.err = err;
|
||||
loop.errnum = errnum;
|
||||
loop.ctxt = ctxt;
|
||||
newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand,
|
||||
(ClientData)&loop);
|
||||
@ -2193,7 +2193,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
int len;
|
||||
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);
|
||||
if (freeIt)
|
||||
free(freeIt);
|
||||
@ -2260,7 +2260,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
delim = '!';
|
||||
|
||||
cp = ++tstr;
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim,
|
||||
NULL, &pattern.rightLen,
|
||||
NULL)) == NULL)
|
||||
@ -2290,7 +2290,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
cp = tstr+1; /* point to char after '[' */
|
||||
delim = ']'; /* look for closing ']' */
|
||||
estr = VarGetPattern(ctxt, &parsestate,
|
||||
err, &cp, delim,
|
||||
errnum, &cp, delim,
|
||||
NULL, NULL, NULL);
|
||||
if (estr == NULL)
|
||||
goto cleanup; /* report missing ']' */
|
||||
@ -2581,7 +2581,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
}
|
||||
if ((cp2 = strchr(pattern, '$'))) {
|
||||
cp2 = pattern;
|
||||
pattern = Var_Subst(NULL, cp2, ctxt, err);
|
||||
pattern = Var_Subst(NULL, cp2, ctxt, errnum);
|
||||
if (copy)
|
||||
free(cp2);
|
||||
copy = TRUE;
|
||||
@ -2618,14 +2618,14 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
}
|
||||
|
||||
cp = tstr;
|
||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim,
|
||||
&pattern.flags,
|
||||
&pattern.leftLen,
|
||||
NULL)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim, NULL,
|
||||
&pattern.rightLen,
|
||||
&pattern)) == NULL)
|
||||
@ -2675,7 +2675,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
cp = ++tstr;
|
||||
delim = ':';
|
||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim, NULL,
|
||||
&pattern.leftLen,
|
||||
NULL)) == NULL)
|
||||
@ -2683,7 +2683,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
/* BROPEN or PROPEN */
|
||||
delim = endc;
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, err,
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
|
||||
&cp, delim, NULL,
|
||||
&pattern.rightLen,
|
||||
NULL)) == NULL)
|
||||
@ -2725,12 +2725,12 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
cp = tstr;
|
||||
|
||||
if ((re = VarGetPattern(ctxt, &parsestate, err, &cp, delim,
|
||||
if ((re = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim,
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
|
||||
err, &cp, delim, NULL,
|
||||
errnum, &cp, delim, NULL,
|
||||
NULL, NULL)) == NULL){
|
||||
free(re);
|
||||
goto cleanup;
|
||||
@ -2904,12 +2904,12 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
delim='=';
|
||||
cp = tstr;
|
||||
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
|
||||
err, &cp, delim, &pattern.flags,
|
||||
errnum, &cp, delim, &pattern.flags,
|
||||
&pattern.leftLen, NULL)) == NULL)
|
||||
goto cleanup;
|
||||
delim = endc;
|
||||
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
|
||||
err, &cp, delim, NULL, &pattern.rightLen,
|
||||
errnum, &cp, delim, NULL, &pattern.rightLen,
|
||||
&pattern)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -2992,7 +2992,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
* Input:
|
||||
* str The string to parse
|
||||
* 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
|
||||
* freePtr OUT: TRUE if caller should free result
|
||||
*
|
||||
@ -3011,7 +3011,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
*/
|
||||
/* coverity[+alloc : arg-*4] */
|
||||
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)
|
||||
{
|
||||
const char *tstr; /* Pointer into str */
|
||||
@ -3075,7 +3075,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
/*
|
||||
* Error
|
||||
*/
|
||||
return (err ? var_Error : varNoError);
|
||||
return (errnum ? var_Error : varNoError);
|
||||
} else {
|
||||
haveModifier = FALSE;
|
||||
tstr = &str[1];
|
||||
@ -3083,7 +3083,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
}
|
||||
} else if (str[1] == '\0') {
|
||||
*lengthPtr = 1;
|
||||
return (err ? var_Error : varNoError);
|
||||
return (errnum ? var_Error : varNoError);
|
||||
} else {
|
||||
Buffer buf; /* Holds the variable name */
|
||||
|
||||
@ -3104,7 +3104,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
if (*tstr == '$') {
|
||||
int rlen;
|
||||
void *freeIt;
|
||||
char *rval = Var_Parse(tstr, ctxt, err, &rlen, &freeIt);
|
||||
char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
|
||||
if (rval != NULL) {
|
||||
Buf_AddBytes(buf, strlen(rval), (Byte *)rval);
|
||||
}
|
||||
@ -3246,7 +3246,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
return(pstr);
|
||||
} else {
|
||||
Buf_Destroy(buf, TRUE);
|
||||
return (err ? var_Error : varNoError);
|
||||
return (errnum ? var_Error : varNoError);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -3281,7 +3281,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
*/
|
||||
nstr = (char *)Buf_GetAll(v->val, NULL);
|
||||
if (strchr(nstr, '$') != NULL) {
|
||||
nstr = Var_Subst(NULL, nstr, ctxt, err);
|
||||
nstr = Var_Subst(NULL, nstr, ctxt, errnum);
|
||||
*freePtr = nstr;
|
||||
}
|
||||
|
||||
@ -3296,7 +3296,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
||||
tstr++;
|
||||
|
||||
nstr = ApplyModifiers(nstr, tstr, startc, endc,
|
||||
v, ctxt, err, &used, freePtr);
|
||||
v, ctxt, errnum, &used, freePtr);
|
||||
tstr += used;
|
||||
*lengthPtr = tstr - start + 1;
|
||||
} 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
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.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
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#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 */
|
||||
|
||||
#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 <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void enomem(void);
|
||||
static void *emalloc(size_t);
|
||||
static void *erealloc(void *, size_t);
|
||||
#include <util.h>
|
||||
|
||||
static size_t *get_shuffle(size_t);
|
||||
static void usage(void);
|
||||
@ -57,42 +54,6 @@ static size_t get_number(const char *, int);
|
||||
|
||||
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 --
|
||||
* 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
|
||||
WARNS= 3
|
||||
@ -6,4 +6,7 @@ NOMAN= 1
|
||||
SRCS= spellprog.c look.c
|
||||
BINDIR= /usr/libexec
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.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 */
|
||||
|
||||
@ -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 <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
@ -106,7 +107,6 @@ static int suffix(char *, size_t);
|
||||
static int vowel(int);
|
||||
static const char *lookuppref(char **, char *);
|
||||
static char *skipv(char *);
|
||||
static char *estrdup(const char *);
|
||||
static void ise(void);
|
||||
static void print_word(FILE *);
|
||||
static void ztos(char *);
|
||||
@ -789,16 +789,6 @@ ztos(char *st)
|
||||
*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.
|
||||
* Returns 1 if found, 0 if not.
|
||||
|
Loading…
Reference in New Issue
Block a user