From ef3be213fc42e197660440efe977979368a2d512 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 10 May 2023 18:10:11 -0700 Subject: [PATCH] Add compatibility code for g_string_free_and_steal() in glib before 2.76. Thanks to Jeremy Lavergne for reporting this bug. Bug #64178. --- configure.ac | 1 + src/ui/gui/automake.mk | 21 ++++++++++++++-- src/ui/gui/{glibfix.h => include/glib.in.h} | 27 +++++++++++++++------ src/ui/gui/psppire-dialog-action-recode.c | 1 - src/ui/gui/psppire-format.c | 1 - src/ui/gui/psppire-val-chooser.c | 1 - 6 files changed, 40 insertions(+), 12 deletions(-) rename src/ui/gui/{glibfix.h => include/glib.in.h} (69%) diff --git a/configure.ac b/configure.ac index 84f355dd05..2af7cd4214 100644 --- a/configure.ac +++ b/configure.ac @@ -158,6 +158,7 @@ if test "$with_gui" != "no"; then fi +gl_NEXT_HEADERS([glib.h]) gl_NEXT_HEADERS([gtk/gtk.h]) dnl Checks needed for psql reader diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 5f0d3acad1..2eee1558cf 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -159,7 +159,6 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/executor.h \ src/ui/gui/find-dialog.c \ src/ui/gui/find-dialog.h \ - src/ui/gui/glibfix.h \ src/ui/gui/goto-case-dialog.c \ src/ui/gui/goto-case-dialog.h \ src/ui/gui/helper.c \ @@ -394,6 +393,7 @@ src/ui/gui/resources.c: src/ui/gui/resources.xml cat $@,out >> $@,tmp $(RM) $@,out mv $@,tmp $@ +EXTRA_DIST += src/ui/gui/resources.xml src/ui/gui/psppire-marshal.c: src/ui/gui/marshaller-list $(AM_V_GEN)echo '#include ' > $@ @@ -428,7 +428,24 @@ src/ui/gui/include/gtk/gtk.h: src/ui/gui/include/gtk/gtk.in.h } > $@-t && \ mv $@-t $@ CLEANFILES += src/ui/gui/include/gtk/gtk.h -EXTRA_DIST += src/ui/gui/include/gtk/gtk.in.h src/ui/gui/resources.xml +EXTRA_DIST += src/ui/gui/include/gtk/gtk.in.h + +# wrapper +src_ui_gui_psppire_CPPFLAGS += $(AM_CPPFLAGS) -Isrc/ui/gui/include +BUILT_SOURCES += src/ui/gui/include/glib.h +src/ui/gui/include/glib.h: src/ui/gui/include/glib.in.h + @$(MKDIR_P) src/ui/gui/include + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + $(SED) -e 's|%''INCLUDE_NEXT''%|$(INCLUDE_NEXT)|g' \ + -e 's|%''PRAGMA_SYSTEM_HEADER''%|$(PRAGMA_SYSTEM_HEADER)|g' \ + -e 's|%''PRAGMA_COLUMNS''%|$(PRAGMA_COLUMNS)|g' \ + -e 's|%''NEXT_GLIB_H''%|$(NEXT_GLIB_H)|g' \ + < $(srcdir)/src/ui/gui/include/glib.in.h; \ + } > $@-t && \ + mv $@-t $@ +CLEANFILES += src/ui/gui/include/glib.h +EXTRA_DIST += src/ui/gui/include/glib.in.h include $(top_srcdir)/src/ui/gui/icons/automake.mk diff --git a/src/ui/gui/glibfix.h b/src/ui/gui/include/glib.in.h similarity index 69% rename from src/ui/gui/glibfix.h rename to src/ui/gui/include/glib.in.h index 3cb1cf5735..b87cb97c1e 100644 --- a/src/ui/gui/glibfix.h +++ b/src/ui/gui/include/glib.in.h @@ -1,9 +1,9 @@ -/* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2022 Free Software Foundation +/* Wrapper for . + Copyright (C) 2023 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -12,12 +12,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ -#ifndef __GLIBFIX_H__ -#define __GLIBFIX_H__ +#ifndef PSPP_GLIB_H +#define PSPP_GLIB_H -#include +#if __GNUC__ >= 3 +%PRAGMA_SYSTEM_HEADER% +#endif +%PRAGMA_COLUMNS% + +#%INCLUDE_NEXT% %NEXT_GLIB_H% /* Workaround for g_memdup2 which is introduced in glib 2.67.3 for earlier versions of glib @@ -44,4 +49,12 @@ g_memdup2 (gconstpointer mem, } #endif +#if !GLIB_CHECK_VERSION(2, 76, 0) +static inline gchar * +g_string_free_and_steal (GString *string) +{ + return g_string_free (string, FALSE); +} #endif + +#endif /* PSPP_GLIB_H */ diff --git a/src/ui/gui/psppire-dialog-action-recode.c b/src/ui/gui/psppire-dialog-action-recode.c index 3b7165f5cb..9598cb7052 100644 --- a/src/ui/gui/psppire-dialog-action-recode.c +++ b/src/ui/gui/psppire-dialog-action-recode.c @@ -31,7 +31,6 @@ #include "helper.h" #include -#include "ui/gui/glibfix.h" #include "gettext.h" #define _(msgid) gettext (msgid) diff --git a/src/ui/gui/psppire-format.c b/src/ui/gui/psppire-format.c index 1dde74fb00..71cd4ffda9 100644 --- a/src/ui/gui/psppire-format.c +++ b/src/ui/gui/psppire-format.c @@ -16,7 +16,6 @@ #include #include "ui/gui/psppire-format.h" -#include "ui/gui/glibfix.h" static gpointer psppire_format_copy (gpointer boxed) diff --git a/src/ui/gui/psppire-val-chooser.c b/src/ui/gui/psppire-val-chooser.c index 543fb3f246..95f193ec0d 100644 --- a/src/ui/gui/psppire-val-chooser.c +++ b/src/ui/gui/psppire-val-chooser.c @@ -22,7 +22,6 @@ #include "psppire-val-chooser.h" #include "libpspp/str.h" -#include "ui/gui/glibfix.h" #include "ui/syntax-gen.h" -- 2.30.2