From 3ee8d38682ac59ff81a1b9335a665a2c98e37733 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Sat, 11 Jul 2015 23:56:25 -0700
Subject: [PATCH 01/10] header: treat Wine like MinGW

---
 http_parser.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/http_parser.h b/http_parser.h
index eb71bf99..d2878fdb 100644
--- a/http_parser.h
+++ b/http_parser.h
@@ -30,7 +30,7 @@ extern "C" {
 #define HTTP_PARSER_VERSION_PATCH 0
 
 #include <sys/types.h>
-#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
+#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
 #include <BaseTsd.h>
 #include <stddef.h>
 typedef __int8 int8_t;
@@ -144,7 +144,7 @@ enum flags
 
 
 /* Map for errno-related constants
- * 
+ *
  * The provided argument should be a macro that takes 2 arguments.
  */
 #define HTTP_ERRNO_MAP(XX)                                           \

From 91cba2ae73047c584fee253c794b089ca41d0201 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:07:44 -0700
Subject: [PATCH 02/10] Undo style change

---
 http_parser.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/http_parser.h b/http_parser.h
index d2878fdb..e1582581 100644
--- a/http_parser.h
+++ b/http_parser.h
@@ -144,7 +144,7 @@ enum flags
 
 
 /* Map for errno-related constants
- *
+ * 
  * The provided argument should be a macro that takes 2 arguments.
  */
 #define HTTP_ERRNO_MAP(XX)                                           \

From 814f3629f8c295118e4269af2a042ecd601d82dd Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:11:40 -0700
Subject: [PATCH 03/10] header: Split if statement into 2 lines

---
 http_parser.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/http_parser.h b/http_parser.h
index e1582581..604c29ee 100644
--- a/http_parser.h
+++ b/http_parser.h
@@ -30,7 +30,8 @@ extern "C" {
 #define HTTP_PARSER_VERSION_PATCH 0
 
 #include <sys/types.h>
-#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
+#if defined(_WIN32) && !defined(__MINGW32__) && \
+  (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
 #include <BaseTsd.h>
 #include <stddef.h>
 typedef __int8 int8_t;

From ce76d8cf2f012eaf65ef961386dbd1bcf90c2820 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:17:02 -0700
Subject: [PATCH 04/10] Makefile: support PLATFORM=wine

---
 Makefile | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 62009ffd..a414fe17 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@
 # IN THE SOFTWARE.
 
 PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
+HELPER ?=
+BINEXT ?=
 ifeq (darwin,$(PLATFORM))
 SONAME ?= libhttp_parser.2.5.0.dylib
 SOEXT ?= dylib
@@ -26,6 +28,13 @@ else
 SONAME ?= libhttp_parser.so.2.5.0
 SOEXT ?= so
 endif
+
+ifeq (wine,$(PLATFORM))
+CC = winegcc
+BINEXT = .exe.so
+HELPER = wine
+endif
+
 CC?=gcc
 AR?=ar
 
@@ -58,8 +67,8 @@ LDFLAGS_LIB += -Wl,-soname=$(SONAME)
 endif
 
 test: test_g test_fast
-	./test_g
-	./test_fast
+	$(HELPER) test_g$(BINEXT)
+	$(HELPER) test_fast$(BINEXT)
 
 test_g: http_parser_g.o test_g.o
 	$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
@@ -86,7 +95,7 @@ http_parser.o: http_parser.c http_parser.h Makefile
 	$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
 
 test-run-timed: test_fast
-	while(true) do time ./test_fast > /dev/null; done
+	while(true) do time $(HELPER) ./test_fast$(BINEXT) > /dev/null; done
 
 test-valgrind: test_g
 	valgrind ./test_g
@@ -107,10 +116,10 @@ url_parser_g: http_parser_g.o contrib/url_parser.c
 	$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@
 
 parsertrace: http_parser.o contrib/parsertrace.c
-	$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace
+	$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT)
 
 parsertrace_g: http_parser_g.o contrib/parsertrace.c
-	$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g
+	$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT)
 
 tags: http_parser.c http_parser.h test.c
 	ctags $^
@@ -133,7 +142,8 @@ uninstall:
 clean:
 	rm -f *.o *.a tags test test_fast test_g \
 		http_parser.tar libhttp_parser.so.* \
-		url_parser url_parser_g parsertrace parsertrace_g
+		url_parser url_parser_g parsertrace parsertrace_g \
+		*.exe *.exe.so
 
 contrib/url_parser.c:	http_parser.h
 contrib/parsertrace.c:	http_parser.h

From 8b7bdb84872a23ca27319ee5bb2e32c9a2a4ad61 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:31:31 -0700
Subject: [PATCH 05/10] .travis.yml: add `make PLATFORM=wine`

---
 .travis.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 4b038e6e..d9041497 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,8 @@
+before_install:
+  - "sudo add-apt-repository ppa:ubuntu-wine/ppa"
+  - "sudo apt-get update"
+  - "sudo apt-get install wine1.6"
+
 language: c
 
 compiler:
@@ -6,6 +11,7 @@ compiler:
 
 script:
   - "make"
+  - "make PLATFORM=wine"
 
 notifications:
   email: false

From 7ff02a3622845c74623676e322adf3d50d8c78c7 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:37:32 -0700
Subject: [PATCH 06/10] .travis.yml: Fix before_install for non-interactive

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d9041497..9c034430 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
 before_install:
-  - "sudo add-apt-repository ppa:ubuntu-wine/ppa"
-  - "sudo apt-get update"
+  - "sudo add-apt-repository ppa:ubuntu-wine/ppa -y"
+  - "sudo apt-get update -q"
   - "sudo apt-get install wine1.6"
 
 language: c

From 71bdcfea6a6302a95b1ca5423a3420143a6a24f5 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:43:07 -0700
Subject: [PATCH 07/10] Makefile: Fix relative paths for tests

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a414fe17..718f2b61 100644
--- a/Makefile
+++ b/Makefile
@@ -67,8 +67,8 @@ LDFLAGS_LIB += -Wl,-soname=$(SONAME)
 endif
 
 test: test_g test_fast
-	$(HELPER) test_g$(BINEXT)
-	$(HELPER) test_fast$(BINEXT)
+	$(HELPER) ./test_g$(BINEXT)
+	$(HELPER) ./test_fast$(BINEXT)
 
 test_g: http_parser_g.o test_g.o
 	$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@

From cec064684ad7006af8c6827ca6e8e741f5d5a0a1 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Fri, 17 Jul 2015 15:43:36 -0700
Subject: [PATCH 08/10] .travis.yml: Run `make clean` before running make again

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 9c034430..c279ca36 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,7 @@ compiler:
 
 script:
   - "make"
+  - "make clean"
   - "make PLATFORM=wine"
 
 notifications:

From 2381bf642dfd08c23589b852fe6779b3c63f0fa5 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Sun, 19 Jul 2015 15:14:23 -0700
Subject: [PATCH 09/10] .travis.yml: Remove Wine test

---
 .travis.yml | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c279ca36..4b038e6e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,3 @@
-before_install:
-  - "sudo add-apt-repository ppa:ubuntu-wine/ppa -y"
-  - "sudo apt-get update -q"
-  - "sudo apt-get install wine1.6"
-
 language: c
 
 compiler:
@@ -11,8 +6,6 @@ compiler:
 
 script:
   - "make"
-  - "make clean"
-  - "make PLATFORM=wine"
 
 notifications:
   email: false

From 1912799772efc7137bf78d24dcd7a5cd78ee9487 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Sun, 19 Jul 2015 23:13:22 -0700
Subject: [PATCH 10/10] Makefile: use else ifneq

---
 Makefile | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 718f2b61..7d4a31ce 100644
--- a/Makefile
+++ b/Makefile
@@ -24,15 +24,13 @@ BINEXT ?=
 ifeq (darwin,$(PLATFORM))
 SONAME ?= libhttp_parser.2.5.0.dylib
 SOEXT ?= dylib
-else
-SONAME ?= libhttp_parser.so.2.5.0
-SOEXT ?= so
-endif
-
-ifeq (wine,$(PLATFORM))
+else ifeq (wine,$(PLATFORM))
 CC = winegcc
 BINEXT = .exe.so
 HELPER = wine
+else
+SONAME ?= libhttp_parser.so.2.5.0
+SOEXT ?= so
 endif
 
 CC?=gcc