Hackers,
I just noticed that we have some ad-hoc hacks for the
CURL_IGNORE_DEPRECATION macro in the pgindent Perl script, which I find
a bit uncomfortable. Given that we use that macro in a single place,
what do you think about removing that and making a more surgical
intervention to fix pgindent problem with it? I propose the attached.
For context: in curl, that macro is defined like this
#define CURL_IGNORE_DEPRECATION(statements) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
statements \
_Pragma("GCC diagnostic pop")
(with #ifdef guards and whatnot). Because it has a _Pragma after the
statements argument, any uses of this macro must have a terminating
semicolon, which pgindent does not like. (It's also IMO rather
C-unlike). So my approach here is to add another macro to insert that
semicolon where it's needed. Of course, there's nothing we can do with
CURL_IGNORE_DEPRECATION() itself, given that it's upstream from us.
Thoughts?
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
“Cuando no hay humildad las personas se degradan” (A. Christie)
>From 60806ea8dd8fc9a6878cfc8b7f710e470b7a3d67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Tue, 11 Nov 2025 12:32:46 +0100
Subject: [PATCH] Try to do the CURL_IGNORE_DEPRECATION() thing in a less
horrible way
---
src/interfaces/libpq-oauth/oauth-curl.c | 8 +++++---
src/tools/pgindent/pgindent | 14 --------------
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/src/interfaces/libpq-oauth/oauth-curl.c b/src/interfaces/libpq-oauth/oauth-curl.c
index aa50b00d053..4a1e8dc1d89 100644
--- a/src/interfaces/libpq-oauth/oauth-curl.c
+++ b/src/interfaces/libpq-oauth/oauth-curl.c
@@ -1919,6 +1919,8 @@ start_request(struct async_ctx *actx)
#define CURL_IGNORE_DEPRECATION(x) x
#endif
+#define PG_CURL_IGNORE_DEPRECATION(x) CURL_IGNORE_DEPRECATION(x;)
+
/*
* Drives the multi handle towards completion. The caller should have already
* set up an asynchronous request via start_request().
@@ -1950,9 +1952,9 @@ drive_request(struct async_ctx *actx)
* https://curl.se/mail/lib-2024-11/0028.html
*
*/
- CURL_IGNORE_DEPRECATION(
- err = curl_multi_socket_all(actx->curlm, &actx->running);
- )
+ PG_CURL_IGNORE_DEPRECATION(err =
+ curl_multi_socket_all(actx->curlm,
+ &actx->running));
if (err)
{
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index b7d71808924..d14da3f01a9 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -245,14 +245,6 @@ sub pre_indent
# Protect wrapping in CATALOG()
$source =~ s!^(CATALOG\(.*)$!/*$1*/!gm;
- # Treat a CURL_IGNORE_DEPRECATION() as braces for the purposes of
- # indentation. (The recursive regex comes from the perlre documentation; it
- # matches balanced parentheses as group $1 and the contents as group $2.)
- my $curlopen = '{ /* CURL_IGNORE_DEPRECATION */';
- my $curlclose = '} /* CURL_IGNORE_DEPRECATION */';
- $source =~
- s!^[ \t]+CURL_IGNORE_DEPRECATION(\(((?:(?>[^()]+)|(?1))*)\))!$curlopen$2$curlclose!gms;
-
return $source;
}
@@ -267,12 +259,6 @@ sub post_indent
$source =~ s!^/\* Open extern "C" \*/$!{!gm;
$source =~ s!^/\* Close extern "C" \*/$!}!gm;
- # Restore the CURL_IGNORE_DEPRECATION() macro, keeping in mind that our
- # markers may have been re-indented.
- $source =~
- s!{[ \t]+/\* CURL_IGNORE_DEPRECATION \*/!CURL_IGNORE_DEPRECATION(!gm;
- $source =~ s!}[ \t]+/\* CURL_IGNORE_DEPRECATION \*/!)!gm;
-
## Comments
# Undo change of dash-protected block comments
--
2.47.3