[gtk/gtk-3-24] gtk/language-names.c: Fix build on non-GCC/CLang
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] gtk/language-names.c: Fix build on non-GCC/CLang
- Date: Tue, 19 Jun 2018 10:33:34 +0000 (UTC)
commit aa76abbbeb8db13ab8b450581110484fa6b4ffae
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Mar 28 11:59:11 2018 +0800
gtk/language-names.c: Fix build on non-GCC/CLang
Remove g_auto*() usage from these sources and use the traditional
g_free(), as g_auto*() are GCCisms (or CLangisms).
Also, don't include unistd.h unconditionally and stop including
langinfo.h and dirent.h, since they seem to be unused.
Partially cherry-picked from a4c0395343c3969c330cb37efa45ae952ba74b86
https://bugzilla.gnome.org/show_bug.cgi?id=773299
gtk/language-names.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/gtk/language-names.c b/gtk/language-names.c
index 0c0076bbd8..6fa6eaa2f2 100644
--- a/gtk/language-names.c
+++ b/gtk/language-names.c
@@ -2,12 +2,14 @@
#include <stdlib.h>
#include <stdio.h>
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
#include <string.h>
#include <errno.h>
-#include <dirent.h>
#include <locale.h>
-#include <langinfo.h>
#include <sys/stat.h>
#include <glib.h>
@@ -173,9 +175,9 @@ languages_variant_init (const char *variant)
{
gboolean res;
gsize buf_len;
- g_autofree char *buf = NULL;
- g_autofree char *filename = NULL;
- g_autoptr (GError) error = NULL;
+ char *buf = NULL;
+ char *filename = NULL;
+ GError *error = NULL;
bindtextdomain (variant, ISO_CODES_LOCALESDIR);
bind_textdomain_codeset (variant, "UTF-8");
@@ -185,19 +187,24 @@ languages_variant_init (const char *variant)
res = g_file_get_contents (filename, &buf, &buf_len, &error);
if (res)
{
- g_autoptr (GMarkupParseContext) ctx = NULL;
+ GMarkupParseContext *ctx = NULL;
GMarkupParser parser = { languages_parse_start_tag, NULL, NULL, NULL, NULL };
ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
+ g_free (error);
error = NULL;
res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
+ g_free (ctx);
if (!res)
g_warning ("Failed to parse '%s': %s\n", filename, error->message);
}
else
g_warning ("Failed to load '%s': %s\n", filename, error->message);
+
+ g_free (filename);
+ g_free (buf);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]