[vte/vte-0-50] build: Add strchrnul implementation to fix compilation on macOS



commit ad6fee1ad1500c132103711d53d23631bab46ca7
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Oct 15 22:33:22 2017 +0200

    build: Add strchrnul implementation to fix compilation on macOS
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788476
    (cherry picked from commit a4362e96d882e496444c8858963d4d4be4d7b430)

 configure.ac    |    3 +++
 src/vteseq.cc   |    1 +
 src/vtespawn.cc |   13 ++-----------
 src/vteutils.cc |   13 +++++++++++++
 src/vteutils.h  |    3 +++
 5 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 18e14df..42b7acb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -294,6 +294,9 @@ AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid tcgetattr tcsetattr])
 AC_CHECK_FUNCS([pread pwrite])
 AC_CHECK_FUNCS([explicit_bzero])
 
+# Misc string routines.
+AC_CHECK_FUNCS([strchrnul])
+
 # for vtespawn
 AC_CHECK_HEADERS([sys/resource.h])
 AC_CHECK_FUNCS([fdwalk])
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 6876341..7b5b49b 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -31,6 +31,7 @@
 #include <vte/vte.h>
 #include "vteinternal.hh"
 #include "vtegtk.hh"
+#include "vteutils.h"  /* for strchrnul on non-GNU systems */
 #include "caps.h"
 #include "debug.h"
 
diff --git a/src/vtespawn.cc b/src/vtespawn.cc
index df6e23b..55d5ee2 100644
--- a/src/vtespawn.cc
+++ b/src/vtespawn.cc
@@ -40,6 +40,7 @@
 #include <glib-unix.h>
 
 #include "vtespawn.hh"
+#include "vteutils.h"  /* for strchrnul on non-GNU systems */
 #include "reaper.hh"
 
 #define VTE_SPAWN_ERROR_TIMED_OUT (G_SPAWN_ERROR_FAILED + 1000)
@@ -1002,16 +1003,6 @@ script_execute (const gchar *file,
   }
 }
 
-static gchar*
-my_strchrnul (const gchar *str, gchar c)
-{
-  gchar *p = (gchar*) str;
-  while (*p && (*p != c))
-    ++p;
-
-  return p;
-}
-
 static gint
 g_execute (const gchar *file,
            gchar      **argv,
@@ -1082,7 +1073,7 @@ g_execute (const gchar *file,
          char *startp;
 
          path = p;
-         p = my_strchrnul (path, ':');
+         p = strchrnul (path, ':');
 
          if (p == path)
            /* Two adjacent colons, or a colon at the beginning or the end
diff --git a/src/vteutils.cc b/src/vteutils.cc
index 648d185..e683375 100644
--- a/src/vteutils.cc
+++ b/src/vteutils.cc
@@ -96,3 +96,16 @@ _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 999e3bf..0cc98eb 100644
--- a/src/vteutils.h
+++ b/src/vteutils.h
@@ -24,6 +24,9 @@
 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]