From 8e25ce4e5763c74864587b0a78217eb20c299afe Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Fri, 18 Sep 2015 07:16:20 -0400
Subject: [PATCH 1/2] Fix build for debian stretch

Fixes #182
---
 CMakeLists.txt  | 1 +
 sway/commands.c | 1 +
 sway/main.c     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index afad8123..09f37d6d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.5)
 project(sway C)
 set(CMAKE_C_FLAGS "-g")
 set(CMAKE_C_STANDARD 99)
+SET(CMAKE_C_EXTENSIONS OFF)
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
 add_definitions("-Wall -Wextra -Wno-unused-parameter")
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
diff --git a/sway/commands.c b/sway/commands.c
index e79746ae..71eb9d70 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <sys/types.h>
 #include "stringop.h"
 #include "layout.h"
 #include "focus.h"
diff --git a/sway/main.c b/sway/main.c
index e03588ea..97243f99 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -3,6 +3,7 @@
 #include <stdbool.h>
 #include <wlc/wlc.h>
 #include <sys/wait.h>
+#include <sys/types.h>
 #include <signal.h>
 #include <getopt.h>
 #include "layout.h"

From 318e1be240574e316094e5ea73d32e9f9a1f7c04 Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Fri, 18 Sep 2015 07:27:35 -0400
Subject: [PATCH 2/2] Fix warnings introduced by prior commit

---
 include/stringop.h | 5 +++++
 sway/commands.c    | 1 +
 sway/container.c   | 2 ++
 sway/log.c         | 4 +---
 sway/main.c        | 1 +
 sway/stringop.c    | 8 ++++++++
 sway/workspace.c   | 1 +
 7 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/stringop.h b/include/stringop.h
index dde50f13..f9f3130c 100644
--- a/include/stringop.h
+++ b/include/stringop.h
@@ -2,6 +2,11 @@
 #define _SWAY_STRINGOP_H
 #include "list.h"
 
+#if !HAVE_DECL_SETENV
+// Not sure why we need to provide this
+extern int setenv(const char *, const char *, int);
+#endif
+
 // array of whitespace characters to use for delims
 extern const char *whitespace;
 
diff --git a/sway/commands.c b/sway/commands.c
index 71eb9d70..68bdff2c 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
diff --git a/sway/container.c b/sway/container.c
index ef0e6c55..85b169a1 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -1,7 +1,9 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <strings.h>
+#include <string.h>
 #include "config.h"
+#include "stringop.h"
 #include "container.h"
 #include "workspace.h"
 #include "focus.h"
diff --git a/sway/log.c b/sway/log.c
index cf5c2092..a6582172 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -80,9 +80,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
 		va_end(args);
 
 		fprintf(stderr, ": ");
-		char error[256];
-		strerror_r(errno, error, sizeof(error));
-		fprintf(stderr, "%s", error);
+		fprintf(stderr, "%s", strerror(errno));
 
 		if (colored && isatty(STDERR_FILENO)) {
 			fprintf(stderr, "\x1B[0m");
diff --git a/sway/main.c b/sway/main.c
index 97243f99..66921184 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -7,6 +7,7 @@
 #include <signal.h>
 #include <getopt.h>
 #include "layout.h"
+#include "stringop.h"
 #include "config.h"
 #include "log.h"
 #include "readline.h"
diff --git a/sway/stringop.c b/sway/stringop.c
index 191e40c8..7a2c8317 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -311,3 +311,11 @@ char *join_list(list_t *list, char *separator) {
 
 	return res;
 }
+
+char *strdup(const char *str) {
+	char *dup = malloc(strlen(str) + 1);
+	if (dup) {
+		strcpy(dup, str);
+	}
+	return dup;
+}
diff --git a/sway/workspace.c b/sway/workspace.c
index 658f79bc..c169c1cb 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -2,6 +2,7 @@
 #include <stdbool.h>
 #include <wlc/wlc.h>
 #include <string.h>
+#include <strings.h>
 #include "workspace.h"
 #include "layout.h"
 #include "list.h"