Skip to content

Commit

Permalink
build: Add strchrnul implementation to fix compilation on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
egmontkob committed Oct 15, 2017
1 parent 71c7835 commit ad6fee1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
1 change: 1 addition & 0 deletions src/vteseq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 2 additions & 11 deletions src/vtespawn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/vteutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
3 changes: 3 additions & 0 deletions src/vteutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ad6fee1

Please sign in to comment.