-# $OpenBSD: Makefile,v 1.12 2012/04/12 17:00:11 espie Exp $
+# $OpenBSD: Makefile,v 1.13 2014/05/12 19:11:19 espie Exp $
# -DEXTENDED
# if you want the paste & spaste macros.
CDIAGFLAGS=-W -Wall -Wstrict-prototypes -pedantic \
-Wno-unused -Wno-char-subscripts -Wno-sign-compare
-LDADD= -ly -ll -lm
-DPADD= ${LIBY} ${LIBL} ${LIBM}
+LDADD= -ly -ll -lm -lutil
+DPADD= ${LIBY} ${LIBL} ${LIBM} ${LIBUTIL}
SRCS= eval.c expr.c look.c main.c misc.c gnum4.c trace.c tokenizer.l parser.y
MAN= m4.1
-/* $OpenBSD: extern.h,v 1.53 2014/04/28 12:34:11 espie Exp $ */
+/* $OpenBSD: extern.h,v 1.54 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
/*-
extern void pbstr(const char *);
extern void pushback(int);
extern void *xalloc(size_t, const char *, ...);
-extern void *xallocarray(size_t, size_t, const char *, ...);
+extern void *xcalloc(size_t, size_t, const char *, ...);
extern void *xrealloc(void *, size_t, const char *, ...);
extern void *xreallocarray(void *, size_t, size_t, const char *, ...);
extern char *xstrdup(const char *);
-/* $OpenBSD: gnum4.c,v 1.44 2014/04/28 12:34:11 espie Exp $ */
+/* $OpenBSD: gnum4.c,v 1.45 2014/05/12 19:11:19 espie Exp $ */
/*
* Copyright (c) 1999 Marc Espie
if (error != 0)
exit_regerror(error, &re);
- pmatch = xallocarray(re.re_nsub+1, sizeof(regmatch_t), NULL);
+ pmatch = xreallocarray(NULL, re.re_nsub+1, sizeof(regmatch_t),
+ NULL);
do_subst(argv[2], &re,
argc > 4 && argv[4] != NULL ? argv[4] : "", pmatch);
free(pmatch);
if (error != 0)
exit_regerror(error, &re);
- pmatch = xallocarray(re.re_nsub+1, sizeof(regmatch_t), NULL);
+ pmatch = xreallocarray(NULL, re.re_nsub+1, sizeof(regmatch_t), NULL);
if (argc == 4 || argv[4] == NULL)
do_regexpindex(argv[2], &re, pmatch);
else
-/* $OpenBSD: look.c,v 1.22 2010/09/07 19:58:09 marco Exp $ */
+/* $OpenBSD: look.c,v 1.23 2014/05/12 19:11:19 espie Exp $ */
/*
* Copyright (c) 1989, 1993
#include "stdd.h"
#include "extern.h"
-static void *hash_alloc(size_t, void *);
-static void hash_free(void *, size_t, void *);
+static void *hash_calloc(size_t, size_t, void *);
+static void hash_free(void *, void *);
static void *element_alloc(size_t, void *);
static void setup_definition(struct macro_definition *, const char *,
const char *);
static struct ohash_info macro_info = {
offsetof(struct ndblock, name),
- NULL, hash_alloc, hash_free, element_alloc };
+ NULL, hash_calloc, hash_free, element_alloc };
struct ohash macros;
/* Support routines for hash tables. */
void *
-hash_alloc(s, u)
- size_t s;
- void *u UNUSED;
+hash_calloc(size_t n, size_t s, void *u UNUSED)
{
- void *storage = xalloc(s, "hash alloc");
- if (storage)
- memset(storage, 0, s);
+ void *storage = xcalloc(n, s, "hash alloc");
return storage;
}
void
-hash_free(p, s, u)
- void *p;
- size_t s UNUSED;
- void *u UNUSED;
+hash_free(void *p, void *u UNUSED)
{
free(p);
}
void *
-element_alloc(s, u)
- size_t s;
- void *u UNUSED;
+element_alloc(size_t s, void *u UNUSED)
{
return xalloc(s, "element alloc");
}
-/* $OpenBSD: main.c,v 1.82 2014/04/28 12:34:11 espie Exp $ */
+/* $OpenBSD: main.c,v 1.83 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
initspaces();
STACKMAX = INITSTACKMAX;
- mstack = xallocarray(STACKMAX, sizeof(stae), NULL);
+ mstack = xreallocarray(NULL, STACKMAX, sizeof(stae), NULL);
sstack = xalloc(STACKMAX, NULL);
maxout = 0;
}
}
} else if (t == EOF) {
- if (sp > -1 && ilevel <= 0) {
+ if (!mimic_gnu /* you can puke right there */
+ && sp > -1 && ilevel <= 0) {
warnx( "unexpected end of input, unclosed parenthesis:");
dump_stack(paren, PARLEV);
exit(1);
-/* $OpenBSD: misc.c,v 1.43 2014/04/28 12:34:11 espie Exp $ */
+/* $OpenBSD: misc.c,v 1.44 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
}
void *
-xallocarray(size_t s1, size_t s2, const char *fmt, ...)
+xcalloc(size_t n, size_t s, const char *fmt, ...)
{
- void *p;
-
- if (s1 && SIZE_MAX / s1 < s2) {
- errno = ENOMEM;
- p = NULL;
- } else {
- p = malloc(s1 * s2);
- }
+ void *p = calloc(n, s);
if (p == NULL) {
if (fmt == NULL)
- err(1, "malloc");
+ err(1, "calloc");
else {
va_list va;
void *
xreallocarray(void *old, size_t s1, size_t s2, const char *fmt, ...)
{
- void *p;
-
- if (s1 && SIZE_MAX / s1 < s2) {
- errno = ENOMEM;
- p = NULL;
- } else {
- p = realloc(old, s1 * s2);
- }
+ void *p = reallocarray(old, s1, s2);
if (p == NULL) {
free(old);
if (fmt == NULL)
- err(1, "realloc");
+ err(1, "reallocarray");
else {
va_list va;
-# $OpenBSD: Makefile,v 1.57 2014/03/22 10:36:22 espie Exp $
+# $OpenBSD: Makefile,v 1.58 2014/05/12 19:11:19 espie Exp $
PROG= make
CFLAGS+= -I${.OBJDIR} -I${.CURDIR}
CDEFS+=-DHAS_EXTENDED_GETCWD
#CDEFS+=-DHAS_STATS
+DPADD += ${LIBUTIL}
+LDADD += -lutil
CFLAGS+=${CDEFS}
HOSTCFLAGS+=${CDEFS}
error.c for.c init.c job.c lowparse.c main.c make.c memory.c parse.c \
parsevar.c str.c stats.c suff.c targ.c targequiv.c timestamp.c \
var.c varmodifiers.c varname.c
-SRCS+= lstAddNew.c lstAppend.c lstConcat.c lstConcatDestroy.c \
- lstDeQueue.c lstDestroy.c lstDupl.c lstFindFrom.c lstForEachFrom.c \
- lstInsert.c lstMember.c lstRemove.c lstReplace.c lstRequeue.c lstSucc.c
-.PATH: ${.CURDIR}/lst.lib
+
+.include "${.CURDIR}/lst.lib/Makefile.inc"
CLEANFILES+=generate generate.o regress.o check
-CLEANFILES+=${LIBOBJS} libohash.a
CLEANFILES+= varhashconsts.h condhashconsts.h nodehashconsts.h
beforedepend: varhashconsts.h condhashconsts.h nodehashconsts.h
nodehashconsts.h: generate
${.OBJDIR}/generate 3 0 >$@.tmp && mv $@.tmp $@
-generate: generate.c stats.c memory.c
- ${HOSTCC} ${LDSTATIC} -o ${.TARGET} ${HOSTCFLAGS} ${.ALLSRC} ${LDADD}
+generate: generate.c stats.c memory.c ${DPADD}
+ ${HOSTCC} ${HOSTCFLAGS} ${LDSTATIC} -o ${.TARGET} ${.ALLSRC} ${LDFLAGS} ${LDADD}
+
+CHECKOBJS = regress.o str.o memory.o buf.o
-check: regress.o str.o memory.o buf.o
- ${CC} -o ${.TARGET} ${CFLAGS} ${.ALLSRC} ${LDADD}
+check: ${CHECKOBJS} ${DPADD}
+ ${CC} -o ${.TARGET} ${CFLAGS} ${CHECKOBJS} ${LDADD}
regress: check
${.OBJDIR}/check
-/* $OpenBSD: arch.c,v 1.82 2013/11/22 15:47:35 espie Exp $ */
+/* $OpenBSD: arch.c,v 1.83 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */
/*
static struct ohash_info members_info = {
offsetof(struct arch_member, name), NULL,
- hash_alloc, hash_free, element_alloc
+ hash_calloc, hash_free, element_alloc
};
static struct ohash_info arch_info = {
- offsetof(Arch, name), NULL, hash_alloc, hash_free, element_alloc
+ offsetof(Arch, name), NULL, hash_calloc, hash_free, element_alloc
};
-/* $OpenBSD: dir.c,v 1.63 2013/05/22 12:14:08 espie Exp $ */
+/* $OpenBSD: dir.c,v 1.64 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */
/*
/* PathEntry kept on knownDirectories */
static struct ohash_info dir_info = {
- offsetof(struct PathEntry, name), NULL, hash_alloc, hash_free,
+ offsetof(struct PathEntry, name), NULL, hash_calloc, hash_free,
element_alloc
};
/* file names kept in a path entry */
static struct ohash_info file_info = {
- 0, NULL, hash_alloc, hash_free, element_alloc
+ 0, NULL, hash_calloc, hash_free, element_alloc
};
static struct ohash_info stamp_info = {
- offsetof(struct file_stamp, name), NULL, hash_alloc, hash_free,
+ offsetof(struct file_stamp, name), NULL, hash_calloc, hash_free,
element_alloc
};
#ifndef GARRAY_H
#define GARRAY_H
-/* $OpenBSD: garray.h,v 1.7 2014/04/22 08:26:31 espie Exp $ */
+/* $OpenBSD: garray.h,v 1.8 2014/05/12 19:11:19 espie Exp $ */
/* Growable array implementation */
/*
do { \
if ((l)->n >= (l)->size) { \
(l)->size *= 2; \
- (l)->a = emult_realloc((l)->a, \
+ (l)->a = ereallocarray((l)->a, \
(l)->size, sizeof(struct GNode *)); \
MAY_INCREASE_STATS; \
} \
--- /dev/null
+# $OpenBSD: Makefile.inc,v 1.1 2014/05/12 19:11:20 espie Exp $
+
+.PATH: ${.CURDIR}/lst.lib
+CFLAGS += -I${.CURDIR}/lst.lib
+HOSTCFLAGS += -I${.CURDIR}/lst.lib
+
+SRCS+= lstAddNew.c lstAppend.c lstConcat.c lstConcatDestroy.c \
+ lstDeQueue.c lstDestroy.c lstDupl.c lstFindFrom.c lstForEachFrom.c \
+ lstInsert.c lstMember.c lstRemove.c lstReplace.c lstRequeue.c lstSucc.c
--- /dev/null
+#ifndef _LST_H_
+#define _LST_H_
+
+/* $OpenBSD: lst.h,v 1.1 2014/05/12 19:11:20 espie Exp $ */
+/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)lst.h 8.1 (Berkeley) 6/6/93
+ */
+
+/*-
+ * lst.h --
+ * Header for using the list library
+ */
+
+/* These data structures are PRIVATE !!!
+ * Here for efficiency, so that some functions can be recoded as inlines,
+ * and so that lst headers don't need dynamic allocation most of the time. */
+struct ListNode_ {
+ struct ListNode_ *prevPtr; /* previous element in list */
+ struct ListNode_ *nextPtr; /* next in list */
+ void *datum; /* datum associated with this element */
+};
+
+#ifndef LIST_TYPE
+#include "lst_t.h"
+#endif
+
+typedef void (*SimpleProc)(void *);
+typedef int (*FindProc)(void *, void *);
+typedef int (*ForEachNodeWhileProc)(LstNode, void *);
+typedef int (*FindProcConst)(void *, const void *);
+typedef void (*ForEachProc)(void *, void *);
+typedef void *(*DuplicateProc)(void *);
+
+/*
+ * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
+ * not to be freed.
+ * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
+ */
+#define NOFREE ((SimpleProc) 0)
+#define NOCOPY ((DuplicateProc) 0)
+
+/*
+ * Creation/destruction functions
+ */
+/* Create a new list */
+#define Lst_Init(l) (l)->firstPtr = (l)->lastPtr = NULL
+/* Static lists are already okay */
+#define Static_Lst_Init(l)
+
+/* Duplicate an existing list */
+extern Lst Lst_Clone(Lst, Lst, DuplicateProc);
+/* Destroy an old one */
+extern void Lst_Destroy(LIST *, SimpleProc);
+/* True if list is empty */
+#define Lst_IsEmpty(l) ((l)->firstPtr == NULL)
+
+/*
+ * Functions to modify a list
+ */
+/* Insert an element before another */
+extern void Lst_Insert(Lst, LstNode, void *);
+extern void Lst_AtFront(Lst, void *);
+/* Insert an element after another */
+extern void Lst_Append(Lst, LstNode, void *);
+extern void Lst_AtEnd(Lst, void *);
+/* Remove an element */
+extern void Lst_Remove(Lst, LstNode);
+/* Replace a node with a new value */
+extern void Lst_Replace(LstNode, void *);
+/* Concatenate two lists, destructive. */
+extern void Lst_ConcatDestroy(Lst, Lst);
+/* Concatenate two lists, non-destructive. */
+extern void Lst_Concat(Lst, Lst);
+/* requeue element already in list at front of list */
+extern void Lst_Requeue(Lst, LstNode);
+
+/*
+ * Node-specific functions
+ */
+/* Return first element in list */
+/* Return last element in list */
+/* Return successor to given element */
+extern LstNode Lst_Succ(LstNode);
+
+/*
+ * Functions for entire lists
+ */
+/* Find an element starting from somewhere */
+extern LstNode Lst_FindFrom(LstNode, FindProc, void *);
+/*
+ * See if the given datum is on the list. Returns the LstNode containing
+ * the datum
+ */
+extern LstNode Lst_Member(Lst, void *);
+/* Apply a function to elements of a lst starting from a certain point. */
+extern void Lst_ForEachFrom(LstNode, ForEachProc, void *);
+extern void Lst_Every(Lst, SimpleProc);
+
+extern void Lst_ForEachNodeWhile(Lst, ForEachNodeWhileProc, void *);
+
+extern bool Lst_AddNew(Lst, void *);
+/*
+ * for using the list as a queue
+ */
+/* Place an element at tail of queue */
+#define Lst_EnQueue Lst_AtEnd
+#define Lst_QueueNew Lst_AddNew
+
+/*
+ * for using the list as a stack
+ */
+#define Lst_Push Lst_AtFront
+#define Lst_Pop Lst_DeQueue
+
+/* Remove an element from head of queue */
+extern void * Lst_DeQueue(Lst);
+
+#define Lst_Datum(ln) ((ln)->datum)
+#define Lst_First(l) ((l)->firstPtr)
+#define Lst_Last(l) ((l)->lastPtr)
+#define Lst_ForEach(l, proc, d) Lst_ForEachFrom(Lst_First(l), proc, d)
+#define Lst_Find(l, cProc, d) Lst_FindFrom(Lst_First(l), cProc, d)
+#define Lst_Adv(ln) ((ln)->nextPtr)
+#define Lst_Rev(ln) ((ln)->prevPtr)
+
+
+/* Inlines are preferable to macros here because of the type checking. */
+#ifdef HAS_INLINES
+static INLINE LstNode
+Lst_FindConst(Lst l, FindProcConst cProc, const void *d)
+{
+ return Lst_FindFrom(Lst_First(l), (FindProc)cProc, (void *)d);
+}
+
+static INLINE LstNode
+Lst_FindFromConst(LstNode ln, FindProcConst cProc, const void *d)
+{
+ return Lst_FindFrom(ln, (FindProc)cProc, (void *)d);
+}
+#else
+#define Lst_FindConst(l, cProc, d) \
+ Lst_FindFrom(Lst_First(l), (FindProc)cProc, (void *)d)
+#define Lst_FindFromConst(ln, cProc, d) \
+ Lst_FindFrom(ln, (FindProc)cProc, (void *)d)
+#endif
+
+#endif /* _LST_H_ */
--- /dev/null
+/* $OpenBSD: lst_t.h,v 1.1 2014/05/12 19:11:20 espie Exp $ */
+
+/*
+ * Copyright (c) 2001 Marc Espie.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
+ * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+typedef struct List_ {
+ LstNode firstPtr; /* first node in list */
+ LstNode lastPtr; /* last node in list */
+} LIST;
+
+#define LIST_TYPE
-/* $OpenBSD: memory.c,v 1.9 2013/04/23 14:32:53 espie Exp $ */
+/* $OpenBSD: memory.c,v 1.10 2014/05/12 19:11:19 espie Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
}
void *
-emult_realloc(void *ptr, size_t s1, size_t s2)
+ereallocarray(void *ptr, size_t s1, size_t s2)
{
- size_t size;
-
- if (s1 && SIZE_MAX / s1 < s2) {
- errno = ENOMEM;
- enocmem(s1, s2);
- }
- size = s1 * s2;
- if ((ptr = realloc(ptr, size)) == NULL)
+ if ((ptr = reallocarray(ptr, s1, s2)) == NULL)
enocmem(s1, s2);
return ptr;
}
/* Support routines for hash tables. */
void *
-hash_alloc(size_t s, void *u UNUSED)
+hash_calloc(size_t n, size_t s, void *u UNUSED)
{
- return ecalloc(s, 1);
+ return ecalloc(n, s);
}
void
-hash_free(void *p, size_t s UNUSED, void *u UNUSED)
+hash_free(void *p, void *u UNUSED)
{
free(p);
}
#ifndef MEMORY_H
#define MEMORY_H
-/* $OpenBSD: memory.h,v 1.7 2010/07/19 19:46:44 espie Exp $ */
+/* $OpenBSD: memory.h,v 1.8 2014/05/12 19:11:19 espie Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
extern char *estrdup(const char *);
extern void *erealloc(void *, size_t);
extern void *ecalloc(size_t, size_t);
-extern void *emult_realloc(void *, size_t, size_t);
+extern void *ereallocarray(void *, size_t, size_t);
extern int eunlink(const char *);
extern void esetenv(const char *, const char *);
* definition for cross-builds on deficient systems */
#define efree free
-extern void *hash_alloc(size_t, void *);
-extern void hash_free(void *, size_t, void *);
+extern void *hash_calloc(size_t, size_t, void *);
+extern void hash_free(void *, void *);
extern void *element_alloc(size_t, void *);
struct ohash;
-/* $OpenBSD: str.c,v 1.29 2014/04/22 08:26:31 espie Exp $ */
+/* $OpenBSD: str.c,v 1.30 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: str.c,v 1.13 1996/11/06 17:59:23 christos Exp $ */
/*-
*t++ = '\0';
if (argc == argmax) {
argmax *= 2; /* ramp up fast */
- argv = emult_realloc(argv,
+ argv = ereallocarray(argv,
(argmax + 1), sizeof(char *));
}
argv[argc++] = start;
-/* $OpenBSD: suff.c,v 1.87 2014/01/06 12:08:18 espie Exp $ */
+/* $OpenBSD: suff.c,v 1.88 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
static struct ohash_info suff_info = {
offsetof(struct Suff_, name), NULL,
- hash_alloc, hash_free, element_alloc
+ hash_calloc, hash_free, element_alloc
};
/*
-/* $OpenBSD: targ.c,v 1.74 2013/05/30 08:58:38 espie Exp $ */
+/* $OpenBSD: targ.c,v 1.75 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */
/*
static struct ohash targets; /* hash table of targets */
struct ohash_info gnode_info = {
- offsetof(GNode, name), NULL, hash_alloc, hash_free, element_alloc
+ offsetof(GNode, name), NULL, hash_calloc, hash_free, element_alloc
};
#define Targ_FindConstantNode(n, f) Targ_FindNodeh(n, sizeof(n), K_##n, f)
-/* $OpenBSD: targequiv.c,v 1.4 2013/04/23 14:32:53 espie Exp $ */
+/* $OpenBSD: targequiv.c,v 1.5 2014/05/12 19:11:19 espie Exp $ */
/*
* Copyright (c) 2007-2008 Marc Espie.
*
};
static struct ohash_info equiv_info = {
- offsetof(struct equiv_list, name), NULL, hash_alloc, hash_free,
+ offsetof(struct equiv_list, name), NULL, hash_calloc, hash_free,
element_alloc
};
-/* $OpenBSD: var.c,v 1.97 2014/01/29 23:53:20 espie Exp $ */
+/* $OpenBSD: var.c,v 1.98 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
static struct ohash_info var_info = {
offsetof(Var, name),
NULL,
- hash_alloc, hash_free, element_alloc
+ hash_calloc, hash_free, element_alloc
};
static int classify_var(const char *, const char **, uint32_t *);
-/* $OpenBSD: varmodifiers.c,v 1.36 2014/04/22 08:26:31 espie Exp $ */
+/* $OpenBSD: varmodifiers.c,v 1.37 2014/05/12 19:11:19 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
const char *start, *end;
n = 1024; /* start at 1024 words */
- t = ecalloc(n, sizeof(struct Name));
+ t = ereallocarray(NULL, n, sizeof(struct Name));
start = s;
end = start;
for (i = 0;; i++) {
if (i == n) {
n *= 2;
- t = emult_realloc(t, n, sizeof(struct Name));
+ t = ereallocarray(t, n, sizeof(struct Name));
}
start = iterate_words(&end);
if (start == NULL)
-# $OpenBSD: Makefile,v 1.76 2014/04/18 10:00:48 schwarze Exp $
+# $OpenBSD: Makefile,v 1.77 2014/05/12 19:11:20 espie Exp $
.include <bsd.own.mk>
CFLAGS += -DVERSION=\"1.13.0\"
CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter
-LDADD += -lsqlite3
+DPADD += ${LIBUTIL}
+LDADD += -lsqlite3 -lutil
SRCS= mandoc.c mandoc_aux.c read.c \
roff.c tbl.c tbl_opts.c tbl_layout.c tbl_data.c eqn.c
-/* $Id: mandocdb.c,v 1.105 2014/05/07 16:18:57 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.106 2014/05/12 19:11:20 espie Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
static void dbprune(void);
static void filescan(const char *);
static void *hash_alloc(size_t, void *);
-static void hash_free(void *, size_t, void *);
-static void *hash_halloc(size_t, void *);
+static void hash_free(void *, void *);
+static void *hash_calloc(size_t, size_t, void *);
static void mlink_add(struct mlink *, const struct stat *);
static void mlink_check(struct mpage *, struct mlink *);
static void mlink_free(struct mlink *);
memset(&dirs, 0, sizeof(struct manpaths));
mpages_info.alloc = mlinks_info.alloc = hash_alloc;
- mpages_info.halloc = mlinks_info.halloc = hash_halloc;
- mpages_info.hfree = mlinks_info.hfree = hash_free;
+ mpages_info.calloc = mlinks_info.calloc = hash_calloc;
+ mpages_info.free = mlinks_info.free = hash_free;
mpages_info.key_offset = offsetof(struct mpage, inodev);
mlinks_info.key_offset = offsetof(struct mlink, file);
enum mandoclevel lvl;
str_info.alloc = hash_alloc;
- str_info.halloc = hash_halloc;
- str_info.hfree = hash_free;
+ str_info.calloc = hash_calloc;
+ str_info.free = hash_free;
str_info.key_offset = offsetof(struct str, key);
if (0 == nodb)
}
static void *
-hash_halloc(size_t sz, void *arg)
+hash_calloc(size_t n, size_t sz, void *arg)
{
- return(mandoc_calloc(1, sz));
+ return(mandoc_calloc(n, sz));
}
static void *
}
static void
-hash_free(void *p, size_t sz, void *arg)
+hash_free(void *p, void *arg)
{
free(p);
-/* $Id: mansearch.c,v 1.26 2014/04/23 21:06:33 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.27 2014/05/12 19:11:20 espie Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
static char *buildoutput(sqlite3 *, sqlite3_stmt *,
uint64_t, uint64_t);
static void *hash_alloc(size_t, void *);
-static void hash_free(void *, size_t, void *);
-static void *hash_halloc(size_t, void *);
+static void hash_free(void *, void *);
+static void *hash_calloc(size_t, size_t, void *);
static struct expr *exprcomp(const struct mansearch *,
int, char *[]);
static void exprfree(struct expr *);
unsigned int idx;
size_t i, j, cur, maxres;
- memset(&info, 0, sizeof(struct ohash_info));
-
- info.halloc = hash_halloc;
+ info.calloc = hash_calloc;
info.alloc = hash_alloc;
- info.hfree = hash_free;
+ info.free = hash_free;
info.key_offset = offsetof(struct match, pageid);
*sz = cur = maxres = 0;
}
static void *
-hash_halloc(size_t sz, void *arg)
+hash_calloc(size_t nmemb, size_t sz, void *arg)
{
- return(mandoc_calloc(1, sz));
+ return(mandoc_calloc(nmemb, sz));
}
static void *
}
static void
-hash_free(void *p, size_t sz, void *arg)
+hash_free(void *p, void *arg)
{
free(p);
-# $OpenBSD: Makefile,v 1.5 2001/07/19 10:20:01 espie Exp $
+# $OpenBSD: Makefile,v 1.6 2014/05/12 19:11:20 espie Exp $
-PROG= tsort
+PROG = tsort
+SRCS = tsort.c
-CDIAGFLAGS=-Wall -Wno-char-subscripts -Wstrict-prototypes -pedantic -W
+CDIAGFLAGS = -Wall -Wno-char-subscripts -Wstrict-prototypes -pedantic -W
+DPADD += ${LIBUTIL}
+LDADD += -lutil
.include <bsd.prog.mk>
-/* $OpenBSD: tsort.c,v 1.22 2013/11/27 00:13:24 deraadt Exp $ */
+/* $OpenBSD: tsort.c,v 1.23 2014/05/12 19:11:20 espie Exp $ */
/* ex:ts=8 sw=4:
*
* Copyright (c) 1999-2004 Marc Espie <espie@openbsd.org>
#define erealloc(n, s) emem(realloc(n, s))
-static void *hash_alloc(size_t, void *);
-static void hash_free(void *, size_t, void *);
+static void *hash_calloc(size_t, size_t, void *);
+static void hash_free(void *, void *);
static void* entry_alloc(size_t, void *);
static void *emalloc(size_t);
static void *emem(void *);
#define DEBUG_TRAVERSE 0
static struct ohash_info node_info = {
- offsetof(struct node, k), NULL, hash_alloc, hash_free, entry_alloc };
+ offsetof(struct node, k), NULL, hash_calloc, hash_free, entry_alloc };
int main(int, char *[]);
}
static void *
-hash_alloc(size_t s, void *u UNUSED)
+hash_calloc(size_t n, size_t s, void *u UNUSED)
{
- return emem(calloc(s, 1));
+ return emem(calloc(n, s));
}
static void
-hash_free(void *p, size_t s UNUSED, void *u UNUSED)
+hash_free(void *p, void *u UNUSED)
{
free(p);
}