blob: b5443e991217fa86502bfa95836d835fe62d0367 [file] [log] [blame]
From 4390f1c84e8fee51fc22468821e6fc158e783053 Mon Sep 17 00:00:00 2001
From: Michael Drake <michael.drake@codethink.co.uk>
Date: Thu, 20 Apr 2017 10:51:07 +0100
Subject: Build: Include gperf-generated code directly.
Previously we built the generated code separatly and then linked to
it. However, this caused problems with certain compilers and gperf
versions. This change includes the generated code directly in
svgtiny.c instead, which is the only place its used.
[Retrieved from:
https://source.netsurf-browser.org/libsvgtiny.git/commit/src?id=4390f1c84e8fee51fc22468821e6fc158e783053]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Dario: make the patch to be applied with fuzz factor 0]
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
src/Makefile | 13 +++++++------
src/colors.gperf | 8 --------
src/svgtiny.c | 3 +++
src/svgtiny_internal.h | 5 -----
4 files changed, 10 insertions(+), 19 deletions(-)
(limited to 'src')
diff --git a/src/Makefile b/src/Makefile
index a979720..fb8a72f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,13 +1,14 @@
# Sources
DIR_SOURCES := svgtiny.c svgtiny_gradient.c svgtiny_list.c
-SOURCES := $(SOURCES) $(BUILDDIR)/src_colors.c
+SOURCES := $(SOURCES)
-$(BUILDDIR)/src_colors.c: src/colors.gperf
+$(DIR)autogenerated_colors.c: src/colors.gperf
$(VQ)$(ECHO) " GPERF: $<"
- $(Q)gperf --output-file=$@.tmp $<
-# Hack for GCC 4.2 compatibility (gperf 3.0.4 solves this properly)
- $(Q)$(SED) -e 's/#ifdef __GNUC_STDC_INLINE__/#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/' $@.tmp >$@
- $(Q)$(RM) $@.tmp
+ $(Q)gperf --output-file=$@ $<
+
+PRE_TARGETS := $(DIR)autogenerated_colors.c
+
+CLEAN_ITEMS := $(DIR)autogenerated_colors.c
include build/makefiles/Makefile.subdir
diff --git a/src/colors.gperf b/src/colors.gperf
index 96d5b9e..a836787 100644
--- a/src/colors.gperf
+++ b/src/colors.gperf
@@ -17,14 +17,6 @@
#include "svgtiny.h"
#include "svgtiny_internal.h"
-/* This unusual define shennanigan is to try and prevent the gperf
- * generated function from being inlined. This is pointless given
- * it (a) is in a separate .c file and (b) has external linkage.
- */
-#ifdef __inline
-#undef __inline
-#define __inline
-#endif
%}
struct svgtiny_named_color;
diff --git a/src/svgtiny.c b/src/svgtiny.c
index 4661a58..bbefb88 100644
--- a/src/svgtiny.c
+++ b/src/svgtiny.c
@@ -17,6 +17,9 @@
#include "svgtiny.h"
#include "svgtiny_internal.h"
+/* Source file generated by `gperf`. */
+#include "autogenerated_colors.c"
+
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
diff --git a/src/svgtiny_internal.h b/src/svgtiny_internal.h
index 158d230..6bf5d64 100644
--- a/src/svgtiny_internal.h
+++ b/src/svgtiny_internal.h
@@ -87,9 +87,4 @@
void *svgtiny_list_push(struct svgtiny_list *list);
void svgtiny_list_free(struct svgtiny_list *list);
-/* colors.gperf */
-const struct svgtiny_named_color *
- svgtiny_color_lookup(register const char *str,
- register unsigned int len);
-
#endif
--
cgit v1.2.1