From 4027e2bac25ab70c6813dca9901d5c86a6bbc9f7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sun, 9 Apr 2023 22:16:19 +0200 Subject: [PATCH] C99 compatibility fixes Backport an upstream patch to the bundled previous version, and apply a new patch to fix compilation errors with future compilers. Related to: --- postgis-c99-2.patch | 17 ++++++++++++++ postgis-c99.patch | 54 +++++++++++++++++++++++++++++++++++++++++++++ postgis.spec | 10 ++++++++- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 postgis-c99-2.patch create mode 100644 postgis-c99.patch diff --git a/postgis-c99-2.patch b/postgis-c99-2.patch new file mode 100644 index 0000000..457bfce --- /dev/null +++ b/postgis-c99-2.patch @@ -0,0 +1,17 @@ +Include for isnan. This avoids an implicit function +declaration and a build failure with future compilers. + +Submitted upstream: + +diff -ur postgis-3.3.2.orig/loader/shp2pgsql-core.c postgis-3.3.2/loader/shp2pgsql-core.c +--- postgis-3.3.2.orig/loader/shp2pgsql-core.c 2022-11-13 08:09:23.000000000 +0100 ++++ postgis-3.3.2/loader/shp2pgsql-core.c 2023-04-09 22:01:46.377934865 +0200 +@@ -15,6 +15,8 @@ + + #include "../postgis_config.h" + ++#include /* for isnan */ ++ + #include "shp2pgsql-core.h" + #include "../liblwgeom/liblwgeom.h" + #include "../liblwgeom/lwgeom_log.h" /* for LWDEBUG macros */ diff --git a/postgis-c99.patch b/postgis-c99.patch new file mode 100644 index 0000000..cfc363a --- /dev/null +++ b/postgis-c99.patch @@ -0,0 +1,54 @@ +commit ae53a53246ccb26a6e82fede1a4184b41bcf097d +Author: Regina Obe +Date: Sat Feb 19 00:21:01 2022 -0500 + + Fix PG 15 building atoi removed. References #5100 for PostGIS 3.3.0 + +diff -ur postgis-3.3.2.orig/postgis-2.5.5/postgis/gserialized_typmod.c postgis-3.3.2/postgis-2.5.5/postgis/gserialized_typmod.c +--- postgis-3.3.2.orig/postgis-2.5.5/postgis/gserialized_typmod.c 2023-04-09 21:52:47.909294055 +0200 ++++ postgis-3.3.2/postgis-2.5.5/postgis/gserialized_typmod.c 2023-04-09 21:55:24.744826310 +0200 +@@ -35,7 +35,7 @@ + + #include "utils/elog.h" + #include "utils/array.h" +-#include "utils/builtins.h" /* for pg_atoi */ ++#include "utils/builtins.h" /* for cstring_to_text */ + #include "lib/stringinfo.h" /* For binary input */ + #include "catalog/pg_type.h" /* for CSTRINGOID */ + +@@ -267,8 +267,33 @@ + } + if ( i == 1 ) /* SRID */ + { +- int srid = pg_atoi(DatumGetCString(elem_values[i]), +- sizeof(int32), '\0'); ++ char *int_string = DatumGetCString(elem_values[i]); ++ char *endp; ++ long l; ++ int32_t srid; ++ ++ errno = 0; ++ l = strtol(int_string, &endp, 10); ++ ++ if (int_string == endp) ++ ereport(ERROR, ++ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), ++ errmsg("invalid input syntax for type %s: \"%s\"", ++ "integer", int_string))); ++ ++ if (errno == ERANGE || l < INT_MIN || l > INT_MAX) ++ ereport(ERROR, ++ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), ++ errmsg("value \"%s\" is out of range for type %s", int_string, ++ "integer"))); ++ ++ if (*endp != '\0') ++ ereport(ERROR, ++ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), ++ errmsg("invalid input syntax for type %s: \"%s\"", ++ "integer", int_string))); ++ ++ srid = clamp_srid(l); + srid = clamp_srid(srid); + POSTGIS_DEBUGF(3, "srid: %d", srid); + if ( srid != SRID_UNKNOWN ) diff --git a/postgis.spec b/postgis.spec index a24418d..8ccd2ec 100644 --- a/postgis.spec +++ b/postgis.spec @@ -15,7 +15,7 @@ Name: postgis Version: 3.3.2 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Geographic Information Systems Extensions to PostgreSQL License: GPLv2+ @@ -26,6 +26,8 @@ Source3: http://download.osgeo.org/%{name}/source/%{name}-%{prevversion}.t # Add proj8 compatibility to postgis-2.x (needed for upgrade package) Patch1: postgis2-proj8.patch +Patch2: postgis-c99.patch +Patch3: postgis-c99-2.patch %ifnarch armv7hl BuildRequires: SFCGAL-devel @@ -154,9 +156,12 @@ tar xf %{SOURCE0} cd %{name}-%{prevversion} %patch1 -p1 +%patch -P 2 -p2 +%patch -P 3 -p1 ./autogen.sh ) %endif +%patch -P 3 -p1 cp -p %{SOURCE2} . @@ -404,6 +409,9 @@ fi %changelog +* Sun Apr 09 2023 Florian Weimer - 3.3.2-4 +- C99 compatibility fixes + * Fri Jan 20 2023 Fedora Release Engineering - 3.3.2-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild