diff options
author | joerg <joerg@pkgsrc.org> | 2006-10-08 16:24:26 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2006-10-08 16:24:26 +0000 |
commit | 464d79b780ce657f08ca6ea5371353e5a00fb92c (patch) | |
tree | 2a49ecb4bae9ed93d5684a5bfb349a4851dd6eb0 | |
parent | 8e70144a8501cb7d51ec26884b9fbfea0d66eeb9 (diff) | |
download | pkgsrc-464d79b780ce657f08ca6ea5371353e5a00fb92c.tar.gz |
Newer versions of NetBSD have the plague-spot called strndup.
While here, also use errx from the system on BSDs and don't
segfault in strndup if malloc failed.
From Don Woodstock in #netbsd-code.
-rw-r--r-- | graphics/gimp1-base/files/pdb_self_doc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/graphics/gimp1-base/files/pdb_self_doc.c b/graphics/gimp1-base/files/pdb_self_doc.c index d7f6e408517..bdabaa8d386 100644 --- a/graphics/gimp1-base/files/pdb_self_doc.c +++ b/graphics/gimp1-base/files/pdb_self_doc.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdb_self_doc.c,v 1.1.1.1 2004/03/29 22:06:49 xtraeme Exp $ */ +/* $NetBSD: pdb_self_doc.c,v 1.2 2006/10/08 16:24:26 joerg Exp $ */ /* * C version of pdb_self_doc.el, makes some assumptions about the structure @@ -11,13 +11,15 @@ #include <ctype.h> #ifdef __NetBSD__ -#include <err.h> +#include <sys/param.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifndef __NetBSD__ +#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#include <err.h> +#else #include <stdarg.h> void errx (int rc, char *fmt,...) { @@ -50,12 +52,16 @@ int nprocs; #define wsspan(p) strspn(p, " \t\r\n") +#if !(defined(__NetBSD__) && __NetBSD_Version__ >= 400000000) static char *strndup(const char *x, int len) { char *p = malloc(len + 1); - strncpy(p, x, len); - p[len] = 0; + if(p != NULL) { + strncpy(p, x, len); + p[len] = 0; + } return p; } +#endif static int proccompar(const void *a, const void *b) { return strcmp(((struct procedure *)a)->hlist[0], |