aboutsummaryrefslogtreecommitdiffstats
path: root/main/geeqie/musl-fixes.patch
blob: 2293069e34519ea249f970a05d705f9df80020ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From d09b06c05c61cc675726a440f9cc787807024bb8 Mon Sep 17 00:00:00 2001
From: Dmitry Marakasov <>
Date: Sat, 3 Aug 2019 12:34:42 +0100
Subject: [PATCH] Fix #703: Fix build on non-glibc platforms

https://github.com/BestImageViewer/geeqie/pull/703
---
 src/pan-view/pan-util.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/pan-view/pan-util.c b/src/pan-view/pan-util.c
index 3fd5cc89..317660bb 100644
--- a/src/pan-view/pan-util.c
+++ b/src/pan-view/pan-util.c
@@ -82,6 +82,12 @@ gint pan_date_value(time_t d, PanDateLengthType length)
 	return -1;
 }
 
+#if defined(__GLIBC_PREREQ)
+# if __GLIBC_PREREQ(2, 27)
+#  define HAS_GLIBC_STRFTIME_EXTENSIONS
+# endif
+#endif
+
 gchar *pan_date_value_string(time_t d, PanDateLengthType length)
 {
 	struct tm td;
@@ -99,7 +105,7 @@ gchar *pan_date_value_string(time_t d, PanDateLengthType length)
 			format = "%A %e";
 			break;
 		case PAN_DATE_LENGTH_MONTH:
-#if __GLIBC_PREREQ(2, 27)
+#if defined(HAS_GLIBC_STRFTIME_EXTENSIONS) || defined(__FreeBSD__)
 			format = "%OB %Y";
 #else
 			format = "%B %Y";
-- 
2.11.0

From 7176df818593263a57996c729f933f21b7228afc Mon Sep 17 00:00:00 2001
From: Colin Clark <colin.clark@cclark.uk>
Date: Sat, 3 Aug 2019 12:25:16 +0100
Subject: [PATCH] Fix #683: Build fails on macOS due to use of
 _NL_TIME_FIRST_WEEKDAY

https://github.com/BestImageViewer/geeqie/issues/683
---
 configure.ac | 15 +++++++++++++++
 src/misc.c   | 22 +++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f376d074..65df946c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -656,6 +656,21 @@ AC_SUBST(DJVU_LIBS)
 
 AM_CONDITIONAL(HAVE_MARKDOWN, [ "$(command -v markdown)" ])
 
+# _NL_TIME_FIRST_WEEKDAY support
+# note that it is an enum and not a define
+# ----------------------------------------------------------------------
+
+AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
+AC_TRY_LINK([#include <langinfo.h>], [
+char c;
+c = *((unsigned char *)  nl_langinfo(_NL_TIME_FIRST_WEEKDAY));
+], nl_ok=yes, nl_ok=no)
+AC_MSG_RESULT($nl_ok)
+if test "$nl_ok" = "yes"; then
+  AC_DEFINE([HAVE__NL_TIME_FIRST_WEEKDAY], [1],
+      [Define if _NL_TIME_FIRST_WEEKDAY is available])
+fi
+
 # ----------------------------------------------------------------------
 
 AH_TOP([
diff --git a/src/misc.c b/src/misc.c
index d780795d..85c87658 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -23,6 +23,7 @@
 #include "ui_fileops.h"
 
 #include <langinfo.h>
+#include <locale.h>
 
 gdouble get_zoom_increment(void)
 {
@@ -243,13 +244,32 @@ int runcmd(gchar *cmd)
  * @brief Returns integer representing first_day_of_week
  * @returns Integer in range 1 to 7
  * 
- * Uses current locale to get first day of week
+ * Uses current locale to get first day of week.
+ * If _NL_TIME_FIRST_WEEKDAY is not available, ISO 8601
+ * states first day of week is Monday.
+ * USA, Mexico and Canada (and others) use Sunday as first day of week.
  * 
  * Sunday == 1
  */
 gint date_get_first_day_of_week()
 {
+	gchar *dot;
+	gchar *current_locale;
+
+#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
 	return nl_langinfo(_NL_TIME_FIRST_WEEKDAY)[0];
+#else
+	current_locale = setlocale(LC_ALL, NULL);
+	dot = strstr(current_locale, ".");
+	if ((strncmp(dot - 2, "US", 2) == 0) || (strncmp(dot - 2, "MX", 2) == 0) || (strncmp(dot - 2, "CA", 2) == 0))
+		{
+		return 1;
+		}
+	else
+		{
+		return 2;
+		}
+#endif
 }
 
 /**
-- 
2.11.0