This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=fbed23421fe867d76e6123d2cf79ffafeed5aafd

commit fbed23421fe867d76e6123d2cf79ffafeed5aafd
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Jul 12 02:14:48 2018 +0200

    libcompat: Add new strchrnul() compat function
---
 configure.ac                           |  1 +
 debian/changelog                       |  1 +
 lib/compat/Makefile.am                 |  5 +++++
 lib/compat/compat.h                    |  6 ++++++
 lib/compat/{unsetenv.c => strchrnul.c} | 18 ++++++++----------
 5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3e0fae7b1..bdf05ffb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,6 +152,7 @@ DPKG_CHECK_COMPAT_FUNCS([\
   getopt \
   getopt_long \
   obstack_free \
+  strchrnul \
   strnlen \
   strndup \
   strerror \
diff --git a/debian/changelog b/debian/changelog
index 38078b2d1..264730e2f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -90,6 +90,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
       type on system's <md5.h> headers.
     - Check for ldconfig command in dpkg only on platforms that do have it.
     - Fix file descriptor leak in start-stop-daemon on AIX.
+    - libcompat: Add new strchrnul() implementation.
   * Perl modules:
     - Check that $tarname is defined before use in Dpkg::Source::Package::V1.
       Thanks to Christoph Biedl <[email protected]>.
diff --git a/lib/compat/Makefile.am b/lib/compat/Makefile.am
index 19ddcef86..4477c27b4 100644
--- a/lib/compat/Makefile.am
+++ b/lib/compat/Makefile.am
@@ -11,6 +11,7 @@ libcompat_test_la_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_LIBCOMPAT=1
 libcompat_test_la_SOURCES = \
        compat.h \
        md5.c md5.h \
+       strchrnul.c \
        strnlen.c \
        strndup.c \
        strsignal.c \
@@ -57,6 +58,10 @@ if !HAVE_STRNLEN
 libcompat_la_SOURCES += strnlen.c
 endif
 
+if !HAVE_STRCHRNUL
+libcompat_la_SOURCES += strchrnul.c
+endif
+
 if !HAVE_STRNDUP
 libcompat_la_SOURCES += strndup.c
 endif
diff --git a/lib/compat/compat.h b/lib/compat/compat.h
index 320ffdbc9..c1aa60180 100644
--- a/lib/compat/compat.h
+++ b/lib/compat/compat.h
@@ -109,6 +109,8 @@ extern "C" {
 #define asprintf test_asprintf
 #undef vasprintf
 #define vasprintf test_vasprintf
+#undef strchrnul
+#define strchrnul test_strchrnul
 #undef strndup
 #define strndup test_strndup
 #undef strnlen
@@ -139,6 +141,10 @@ int vasprintf(char **str, const char *fmt, va_list args)
        LIBCOMPAT_ATTR_VPRINTF(2);
 #endif
 
+#if TEST_LIBCOMPAT || !defined(HAVE_STRCHRNUL)
+char *strchrnul(const char *s, int c);
+#endif
+
 #if TEST_LIBCOMPAT || !defined(HAVE_STRNLEN)
 size_t strnlen(const char *s, size_t n);
 #endif
diff --git a/lib/compat/unsetenv.c b/lib/compat/strchrnul.c
similarity index 79%
copy from lib/compat/unsetenv.c
copy to lib/compat/strchrnul.c
index 4094ae3c5..b072e1ad3 100644
--- a/lib/compat/unsetenv.c
+++ b/lib/compat/strchrnul.c
@@ -1,7 +1,7 @@
 /*
  * libcompat - system compatibility library
  *
- * Copyright © 1995 Ian Jackson <[email protected]>
+ * Copyright © 2018 Guillem Jover <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,16 +24,14 @@
 
 #include "compat.h"
 
-int
-unsetenv(const char *p)
+char *
+strchrnul(const char *s, int c)
 {
-       char *q;
+       char *match;
 
-       q = malloc(strlen(p) + 3);
-       if (!q)
-               return -1;
+       match = strchr(s, c);
+       if (match)
+               return match;
 
-       strcpy(q, p);
-       strcat(q, "=");
-       return putenv(q);
+       return (char *)s + strlen(s);
 }

-- 
Dpkg.Org's dpkg

Reply via email to