Skip to content

Commit

Permalink
Fix build on Tiger
Browse files Browse the repository at this point in the history
Fixes: https://trac.macports.org/ticket/53421
(cherry picked from commit 70a2ae0)
(cherry picked from commit f267929)
(cherry picked from commit fcdbfd4)
  • Loading branch information
jmroot committed Feb 16, 2017
1 parent b757252 commit dedca69
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/cregistry/sql.c
Expand Up @@ -39,6 +39,12 @@
#include <tcl.h>
#include <time.h>

/*** Keep all SQL compatible with SQLite 3.1.3 as shipped with Tiger.
*** (Conditionally doing things a better way when possible based on
*** SQLITE_VERSION_NUMBER is OK.)
***/


/**
* Executes a null-terminated list of queries. Pass it a list of queries, it'll
* execute them. This is mainly intended for initialization, when you have a
Expand Down Expand Up @@ -387,7 +393,11 @@ int update_db(sqlite3* db, reg_error* errPtr) {
/* Delete the file_binary index, since it's a low-quality index
* according to https://www.sqlite.org/queryplanner-ng.html#howtofix */
static char* version_1_201_queries[] = {
#if SQLITE_VERSION_NUMBER >= 3003000
"DROP INDEX IF EXISTS registry.file_binary",
#else
"DROP INDEX registry.file_binary",
#endif
"UPDATE registry.metadata SET value = '1.201' WHERE key = 'version'",
"COMMIT",
NULL
Expand Down
4 changes: 3 additions & 1 deletion src/pextlib1.0/Makefile.in
Expand Up @@ -21,7 +21,6 @@ OBJS= \
setmode.o \
sha1cmd.o \
sha256cmd.o \
sip_copy_proc.o \
strcasecmp.o \
strsed.o \
system.o \
Expand All @@ -30,6 +29,9 @@ OBJS= \
uid.o \
vercomp.o \
xinstall.o
ifeq (@TRACEMODE_SUPPORT@,1)
OBJS+=sip_copy_proc.o
endif
ifneq (@ac_cv_func_strlcat@,yes)
OBJS+=strlcat.o
endif
Expand Down
8 changes: 5 additions & 3 deletions src/pextlib1.0/Pextlib.c
Expand Up @@ -36,14 +36,16 @@
#include <config.h>
#endif

/* required for strdup(3) on Linux and OS X */
#ifndef __APPLE__
/* required for strdup(3) on Linux */
#define _XOPEN_SOURCE 600L
/* required for clearenv(3)/setenv(3)/unsetenv(3) on Linux */
#define _BSD_SOURCE
/* required for clearenv(3)/setenv(3)/unsetenv(3) on OS X */
#define _DARWIN_C_SOURCE
/* required for vasprintf(3) on Linux */
#define _GNU_SOURCE
#endif
/* required for clearenv(3)/setenv(3)/unsetenv(3) on OS X */
#define _DARWIN_C_SOURCE

#include <sys/resource.h>
#include <sys/types.h>
Expand Down
7 changes: 4 additions & 3 deletions src/pextlib1.0/adv-flock.c
Expand Up @@ -33,10 +33,11 @@
#include <config.h>
#endif

/* needed to get struct sigaction on some platforms */
#ifndef __APPLE__
/* needed to get struct sigaction on some platforms, but
hides flock on OS X */
#define _XOPEN_SOURCE 500L
/* the above hides flock on OS X without _DARWIN_C_SOURCE */
#define _DARWIN_C_SOURCE
#endif

#if HAVE_SYS_FILE_H
#include <sys/file.h>
Expand Down
5 changes: 3 additions & 2 deletions src/pextlib1.0/mktemp.c
Expand Up @@ -33,12 +33,13 @@
#include <config.h>
#endif

#ifndef __APPLE__
/* required for strdup(3)/mkdtemp(3) on Linux */
/* hides mkdtemp(3) on OS X */
#define _XOPEN_SOURCE 700L
/* required for mktemp(3) if _XOPEN_SOURCE >= 600L on Linux */
#define _BSD_SOURCE
/* required for mkdtemp(3) on OS X */
#define _DARWIN_C_SOURCE
#endif

#include <errno.h>
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions src/pextlib1.0/realpath.c
Expand Up @@ -35,6 +35,7 @@

/* required for PATH_MAX and realpath(3) */
#define _XOPEN_SOURCE 500
#define _DARWIN_C_SOURCE

#include <tcl.h>

Expand Down
18 changes: 15 additions & 3 deletions src/pextlib1.0/system.c
Expand Up @@ -35,10 +35,11 @@
#include <config.h>
#endif

#ifndef __APPLE__
/* required for fdopen(3)/seteuid(2), among others */
/* hides fgetln(3) on OS X */
#define _XOPEN_SOURCE 600
/* required for fgetln(3) on OS X */
#define _DARWIN_C_SOURCE
#endif

#include <tcl.h>

Expand All @@ -58,9 +59,12 @@
#include <signal.h>

#include "system.h"
#include "sip_copy_proc.h"
#include "Pextlib.h"

#if HAVE_TRACEMODE_SUPPORT
#include "sip_copy_proc.h"
#endif

#if HAVE_CRT_EXTERNS_H
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
Expand Down Expand Up @@ -265,13 +269,21 @@ int SystemCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Ob
args[4] = "-c";
args[5] = cmdstring;
args[6] = NULL;
#if HAVE_TRACEMODE_SUPPORT
sip_copy_execve(sandbox_exec_path, args, environ);
#else
execve(sandbox_exec_path, args, environ);
#endif
} else {
args[0] = "sh";
args[1] = "-c";
args[2] = cmdstring;
args[3] = NULL;
#if HAVE_TRACEMODE_SUPPORT
sip_copy_execve("/bin/sh", args, environ);
#else
execve("/bin/sh", args, environ);
#endif
}
exit(128);
/*NOTREACHED*/
Expand Down

0 comments on commit dedca69

Please sign in to comment.