pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/gimp1-base/files Newer versions of NetBSD hav...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c69314d0e77d
branches:  trunk
changeset: 519719:c69314d0e77d
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sun Oct 08 16:24:26 2006 +0000

description:
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.

diffstat:

 graphics/gimp1-base/files/pdb_self_doc.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r f355bce2db20 -r c69314d0e77d graphics/gimp1-base/files/pdb_self_doc.c
--- a/graphics/gimp1-base/files/pdb_self_doc.c  Sun Oct 08 14:51:57 2006 +0000
+++ b/graphics/gimp1-base/files/pdb_self_doc.c  Sun Oct 08 16:24:26 2006 +0000
@@ -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 @@
 
 #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],



Home | Main Index | Thread Index | Old Index