Redo patches with latest fixes
This commit is contained in:
parent
70b9a71759
commit
aad35fa9ba
3 changed files with 287 additions and 40 deletions
|
|
@ -1,30 +1,119 @@
|
|||
From 27adad6e289e92da8cbf770ddebfc9287588a429 Mon Sep 17 00:00:00 2001
|
||||
From: leigh123linux <leigh123linux@googlemail.com>
|
||||
Date: Sat, 1 Apr 2017 16:56:38 +0100
|
||||
Subject: [PATCH] fix 'format not a string literal, format string not checked'
|
||||
error with gcc-7
|
||||
From 96a50bc803949eaee393cd1499f57830ccbe88d3 Mon Sep 17 00:00:00 2001
|
||||
From: JosephMcc <mccullarjoseph@gmail.com>
|
||||
Date: Sat, 1 Apr 2017 12:06:22 -0700
|
||||
Subject: [PATCH] time-plugin: Use GDateTime
|
||||
|
||||
https://github.com/GNOME/gedit/commit/121f02a3ea066565eeae5dd42868f822ecce4924
|
||||
---
|
||||
plugins/time/xed-time-plugin.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
plugins/time/xed-time-plugin.c | 58 ++++++++----------------------------------
|
||||
1 file changed, 10 insertions(+), 48 deletions(-)
|
||||
|
||||
diff --git a/plugins/time/xed-time-plugin.c b/plugins/time/xed-time-plugin.c
|
||||
index 3fd3840..a7ffc0f 100644
|
||||
index 3fd3840..7d2983e 100644
|
||||
--- a/plugins/time/xed-time-plugin.c
|
||||
+++ b/plugins/time/xed-time-plugin.c
|
||||
@@ -346,12 +346,15 @@ get_time (const gchar* format)
|
||||
clock = time (NULL);
|
||||
now = localtime (&clock);
|
||||
@@ -29,10 +29,6 @@
|
||||
#endif
|
||||
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
do
|
||||
#include <string.h>
|
||||
-#include <time.h>
|
||||
-
|
||||
-#include "xed-time-plugin.h"
|
||||
-#include <xed/xed-app.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <glib.h>
|
||||
@@ -43,6 +39,8 @@
|
||||
#include <libpeas-gtk/peas-gtk-configurable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
+#include <xed/xed-app.h>
|
||||
+#include "xed-time-plugin.h"
|
||||
|
||||
#define XED_TIME_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XED_TYPE_TIME_PLUGIN, \
|
||||
@@ -71,7 +69,6 @@ static const gchar *formats[] =
|
||||
"%a %d %b %Y %H:%M:%S",
|
||||
"%d/%m/%Y",
|
||||
"%d/%m/%y",
|
||||
- "%D",
|
||||
"%A %d %B %Y",
|
||||
"%A %B %d %Y",
|
||||
"%Y-%m-%d",
|
||||
@@ -88,9 +85,7 @@ static const gchar *formats[] =
|
||||
"%I.%M %p",
|
||||
"%d/%m/%Y %H:%M:%S",
|
||||
"%d/%m/%y %H:%M:%S",
|
||||
-#if __GLIBC__ >= 2
|
||||
"%a, %d %b %Y %H:%M:%S %z",
|
||||
-#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -319,58 +314,25 @@ get_custom_format (XedTimePlugin *plugin)
|
||||
}
|
||||
|
||||
static gchar *
|
||||
-get_time (const gchar* format)
|
||||
+get_time (const gchar *format)
|
||||
{
|
||||
- gchar *out = NULL;
|
||||
- gchar *out_utf8 = NULL;
|
||||
- time_t clock;
|
||||
- struct tm *now;
|
||||
- size_t out_length = 0;
|
||||
- gchar *locale_format;
|
||||
+ gchar *out;
|
||||
+ GDateTime *now;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
- if (strlen (format) == 0)
|
||||
+ if (*format == '\0')
|
||||
{
|
||||
out_length += 255;
|
||||
out = g_realloc (out, out_length);
|
||||
return g_strdup (" ");
|
||||
}
|
||||
while (strftime (out, out_length, locale_format, now) == 0);
|
||||
+#pragma GCC diagnostic pop
|
||||
|
||||
g_free (locale_format);
|
||||
- locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
|
||||
- if (locale_format == NULL)
|
||||
- {
|
||||
- return g_strdup (" ");
|
||||
- }
|
||||
-
|
||||
- clock = time (NULL);
|
||||
- now = localtime (&clock);
|
||||
-
|
||||
- do
|
||||
- {
|
||||
- out_length += 255;
|
||||
- out = g_realloc (out, out_length);
|
||||
- }
|
||||
- while (strftime (out, out_length, locale_format, now) == 0);
|
||||
-
|
||||
- g_free (locale_format);
|
||||
-
|
||||
- if (g_utf8_validate (out, -1, NULL))
|
||||
- {
|
||||
- out_utf8 = out;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- out_utf8 = g_locale_to_utf8 (out, -1, NULL, NULL, NULL);
|
||||
- g_free (out);
|
||||
-
|
||||
- if (out_utf8 == NULL)
|
||||
- {
|
||||
- out_utf8 = g_strdup (" ");
|
||||
- }
|
||||
- }
|
||||
+ now = g_date_time_new_now_local ();
|
||||
+ out = g_date_time_format (now, format);
|
||||
+ g_date_time_unref (now);
|
||||
|
||||
- return out_utf8;
|
||||
+ return out;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue