[vte] lib: Move impl for missing libc function to missing.cc



commit 5454a606442d9da5f3042ce87214abeedb3d969e
Author: Christian Persch <chpe src gnome org>
Date:   Mon Apr 27 20:49:04 2020 +0200

    lib: Move impl for missing libc function to missing.cc

 src/missing.cc  | 14 ++++++++++++++
 src/missing.hh  |  5 +++++
 src/vtespawn.cc |  5 ++---
 src/vteutils.cc | 13 -------------
 src/vteutils.h  |  3 ---
 5 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/missing.cc b/src/missing.cc
index f374a466..0ca1da6e 100644
--- a/src/missing.cc
+++ b/src/missing.cc
@@ -145,4 +145,18 @@ fdwalk(int (*cb)(void *data, int fd),
 }
 #endif /* !HAVE_FDWALK */
 
+#ifndef HAVE_STRCHRNUL
+/* Copied from glib */
+char*
+strchrnul(char const* s,
+          int c)
+{
+        char *p = (char *) s;
+        while (*p && (*p != c))
+                ++p;
+
+        return p;
+}
+#endif /* !HAVE_STRCHRNUL */
+
 /* END copied from glib */
diff --git a/src/missing.hh b/src/missing.hh
index e0d49c7e..07422708 100644
--- a/src/missing.hh
+++ b/src/missing.hh
@@ -28,3 +28,8 @@
 int fdwalk(int (*cb)(void* data, int fd),
            void* data);
 #endif
+
+#ifndef HAVE_STRCHRNUL
+char* strchrnul(char const* s,
+                int c);
+#endif
diff --git a/src/vtespawn.cc b/src/vtespawn.cc
index 2bb285a3..c6c61ea1 100644
--- a/src/vtespawn.cc
+++ b/src/vtespawn.cc
@@ -29,17 +29,16 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <string.h>
-#include <stdlib.h>   /* for fdwalk */
+#include <stdlib.h>
 #include <dirent.h>
 
 #include <glib-unix.h>
 #include <gio/gio.h>
 
 #include "vtespawn.hh"
-#include "vteutils.h"  /* for strchrnul on non-GNU systems */
 #include "reaper.hh"
 
-#define _(s) g_dgettext("glib20", s)
+#include "missing.hh"
 
 static gssize
 write_all (int fd, gconstpointer vbuf, gsize to_write)
diff --git a/src/vteutils.cc b/src/vteutils.cc
index 154b854a..bf3866e6 100644
--- a/src/vteutils.cc
+++ b/src/vteutils.cc
@@ -92,16 +92,3 @@ _vte_mkstemp (void)
 
         return fd;
 }
-
-#ifndef HAVE_STRCHRNUL
-/* Copied from glib */
-char *
-strchrnul (const char *s, int c)
-{
-        char *p = (char *) s;
-        while (*p && (*p != c))
-                ++p;
-
-        return p;
-}
-#endif /* !HAVE_STRCHRNUL */
diff --git a/src/vteutils.h b/src/vteutils.h
index 0cc98eb2..999e3bf9 100644
--- a/src/vteutils.h
+++ b/src/vteutils.h
@@ -24,9 +24,6 @@
 G_BEGIN_DECLS
 
 int _vte_mkstemp (void);
-#ifndef HAVE_STRCHRNUL
-char *strchrnul (const char *s, int c);
-#endif
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]