stages: 2/01-busybox: update .config
[dragora.git] / patches / gtk2 / calendar-Use-the-new-OB-format-if-supported.patch
blobfb80513cac4aee180f77e631ab1a91e6312a5ad9
1 From: Rafal Luzynski <digitalfreak@lingonborough.com>
2 Date: Sat, 10 Feb 2018 14:07:56 +0100
3 Subject: calendar: Use the new "%OB" format if supported
5 Due to the recent changes introduced in glibc 2.27 "%OB" is the
6 correct format to obtain a month name as used in the calendar
7 header. The same rule has been working in BSD family (including
8 OS X) since 1990s. This simple hack checks whether "%OB" is supported
9 at runtime and uses it if it is, falls back to the old "%B" otherwise.
11 Bug: #9
12 Origin: upstream, 2.24.33, commit:2ea743ab466703091a44a74e1a4ac7db983c0bca
13 ---
14 gtk/gtkcalendar.c | 19 +++++++++++++++++--
15 1 file changed, 17 insertions(+), 2 deletions(-)
17 diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
18 index 2dd68d6..28baba1 100644
19 --- a/gtk/gtkcalendar.c
20 +++ b/gtk/gtkcalendar.c
21 @@ -689,6 +689,7 @@ gtk_calendar_init (GtkCalendar *calendar)
22 #ifdef G_OS_WIN32
23 wchar_t wbuffer[100];
24 #else
25 + static const char *month_format = NULL;
26 char buffer[255];
27 time_t tmp_time;
28 #endif
29 @@ -714,7 +715,7 @@ gtk_calendar_init (GtkCalendar *calendar)
31 #ifndef G_OS_WIN32
32 tmp_time= (i+3)*86400;
33 - strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
34 + strftime (buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
35 default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
36 #else
37 if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SABBREVDAYNAME1 + (i+6)%7,
38 @@ -730,7 +731,21 @@ gtk_calendar_init (GtkCalendar *calendar)
40 #ifndef G_OS_WIN32
41 tmp_time=i*2764800;
42 - strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
43 + if (G_UNLIKELY (month_format == NULL))
44 + {
45 + buffer[0] = '\0';
46 + month_format = "%OB";
47 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
48 + /* "%OB" is not supported in Linux with glibc < 2.27 */
49 + if (!strcmp (buffer, "%OB") || !strcmp (buffer, "OB") || !strcmp (buffer, ""))
50 + {
51 + month_format = "%B";
52 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
53 + }
54 + }
55 + else
56 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
58 default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
59 #else
60 if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SMONTHNAME1 + i,