changeset 560:ecb158cbdd67

util: fix fmemopen leftover
author David Demelier <markand@malikania.fr>
date Wed, 08 Mar 2023 20:23:00 +0100
parents ba0cca39e4ca
children 7732e789bcdd
files libmlk-util/mlk/util/fmemopen.c libmlk-util/mlk/util/openbsd/basename.c libmlk-util/mlk/util/openbsd/dirname.c libmlk-util/mlk/util/openbsd/strlcat.c libmlk-util/mlk/util/openbsd/strlcpy.c libmlk-util/mlk/util/util.c
diffstat 6 files changed, 55 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/libmlk-util/mlk/util/fmemopen.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/fmemopen.c	Wed Mar 08 20:23:00 2023 +0100
@@ -17,7 +17,8 @@
  */
 
 #include "sysconfig.h"
-#include "util.h"
+
+#include <stdio.h>
 
 #if !defined(MLK_HAVE_FMEMOPEN)
 
@@ -80,4 +81,12 @@
 
 #endif
 
+#else
+
+FILE *
+mlk_util_fmemopen(void *buf, size_t len, const char *type)
+{
+	return fmemopen(buf, len, type);
+}
+
 #endif
--- a/libmlk-util/mlk/util/openbsd/basename.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/basename.c	Wed Mar 08 20:23:00 2023 +0100
@@ -22,6 +22,10 @@
 #include <limits.h>
 #include <string.h>
 
+#if defined(MLK_HAVE_LIBGEN_H)
+#       include <libgen.h>
+#endif
+
 #if !defined(MLK_HAVE_BASENAME)
 
 char *
@@ -67,4 +71,12 @@
 	return (bname);
 }
 
+#else
+
+char *
+mlk_util_basename(char *path)
+{
+	return basename(path);
+}
+
 #endif
--- a/libmlk-util/mlk/util/openbsd/dirname.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/dirname.c	Wed Mar 08 20:23:00 2023 +0100
@@ -22,6 +22,10 @@
 #include <limits.h>
 #include <string.h>
 
+#if defined(MLK_HAVE_LIBGEN_H)
+#       include <libgen.h>
+#endif
+
 #if !defined(MLK_HAVE_DIRNAME)
 
 char *
@@ -71,4 +75,12 @@
 	return (dname);
 }
 
+#else
+
+char *
+mlk_util_dirname(char *path)
+{
+	return dirname(path);
+}
+
 #endif
--- a/libmlk-util/mlk/util/openbsd/strlcat.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/strlcat.c	Wed Mar 08 20:23:00 2023 +0100
@@ -16,11 +16,11 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "sysconfig.h"
+
 #include <stddef.h>
 #include <string.h>
 
-#include "sysconfig.h"
-
 #if !defined(MLK_HAVE_STRLCAT)
 
 /*
@@ -58,4 +58,12 @@
 	return(dlen + (src - osrc));	/* count does not include NUL */
 }
 
+#else
+
+size_t
+mlk_util_strlcat(char *dst, const char *src, size_t dstsz)
+{
+	return strlcat(dst, src, dstsz);
+}
+
 #endif
--- a/libmlk-util/mlk/util/openbsd/strlcpy.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/strlcpy.c	Wed Mar 08 20:23:00 2023 +0100
@@ -16,9 +16,10 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <stddef.h>
+#include "sysconfig.h"
 
-#include "sysconfig.h"
+#include <stddef.h>
+#include <string.h>
 
 #if !defined(MLK_HAVE_STRLCPY)
 
@@ -52,4 +53,12 @@
 	return(src - osrc - 1);	/* count does not include NUL */
 }
 
+#else
+
+size_t
+mlk_util_strlcpy(char *dst, const char *src, size_t dstsz)
+{
+	return strlcpy(dst, src, dstsz);
+}
+
 #endif
--- a/libmlk-util/mlk/util/util.c	Wed Mar 08 20:01:00 2023 +0100
+++ b/libmlk-util/mlk/util/util.c	Wed Mar 08 20:23:00 2023 +0100
@@ -16,17 +16,10 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include "sysconfig.h"
-
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-
-#if defined(MLK_HAVE_LIBGEN_H)
-#       include <libgen.h>
-#endif
 
 void
 mlk_util_die(const char *fmt, ...)
@@ -40,59 +33,3 @@
 	va_end(ap);
 	exit(1);
 }
-
-/*
- * The following functions are just wrapper for the native system routine if they
- * are available on the system, otherwise the symbol will be implemented in
- * openbsd/<name>.c
- */
-
-#if defined(MLK_HAVE_STRLCPY)
-
-size_t
-mlk_util_strlcpy(char *dst, const char *src, size_t dstsz)
-{
-	return strlcpy(dst, src, dstsz);
-}
-
-#endif
-
-#if defined(MLK_HAVE_STRLCAT)
-
-size_t
-mlk_util_strlcat(char *dst, const char *src, size_t dstsz)
-{
-	return strlcat(dst, src, dstsz);
-}
-
-#endif
-
-#if defined(MLK_HAVE_BASENAME)
-
-char *
-mlk_util_basename(char *path)
-{
-	return basename(path);
-}
-
-#endif
-
-#if defined(MLK_HAVE_DIRNAME)
-
-char *
-mlk_util_dirname(char *path)
-{
-	return dirname(path);
-}
-
-#endif
-
-#if defined(MLK_HAVE_FMEMOPEN)
-
-FILE *
-mlk_util_fmemopen(void *buf, size_t len, const char *type)
-{
-	return fmemopen(buf, len, type);
-}
-
-#endif