Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit032627e

Browse files
committed
Clean up PL/Perl's handling of the _() macro.
Perl likes to redefine the _() macro:#ifdef CAN_PROTOTYPE#define_(args) args#else ...There was lots not to like about the way we dealt with this before:1. Instead of taking care of the conflict centrally in plperl.h, weexpected every one of its ever-growing number of includers to do so.This is duplicative and error-prone in itself, plus it means thatplperl.h fails to meet the expectation of being compilable standalone,resulting in macro-redefinition warnings in cpluspluscheck.2. We left _() with its Perl definition, meaning that if someone triedto use it in any Perl-related extension, it would silently fail toprovide run-time translation. I don't see any live bugs of this ilk,but it's clearly a hard-to-notice bug waiting to happen.So fix that by centralizing the cleanup logic, making it match whatwe're already doing for other macro conflicts with Perl. Since we onlyexpect plperl.h to be included by extensions not core code, we shouldredefine _() as dgettext() not gettext().
1 parent135063e commit032627e

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

‎contrib/hstore_plperl/hstore_plperl.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#include"postgres.h"
22

3-
#undef _
4-
53
#include"fmgr.h"
4+
#include"hstore/hstore.h"
65
#include"plperl.h"
76
#include"plperl_helpers.h"
8-
#include"hstore/hstore.h"
97

108
PG_MODULE_MAGIC;
119

‎contrib/jsonb_plperl/jsonb_plperl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
#include<math.h>
44

5-
/* Defined by Perl */
6-
#undef _
7-
85
#include"fmgr.h"
96
#include"plperl.h"
107
#include"plperl_helpers.h"

‎src/pl/plperl/SPI.xs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
/* this must be first: */
1111
#include"postgres.h"
1212

13-
/* Defined by Perl */
14-
#undef _
15-
1613
/* perl stuff */
1714
#definePG_NEED_PERL_XSUB_H
1815
#include"plperl.h"

‎src/pl/plperl/Util.xs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212

1313
/* this must be first: */
1414
#include"postgres.h"
15+
1516
#include"fmgr.h"
1617
#include"utils/builtins.h"
1718
#include"utils/bytea.h"/* for byteain & byteaout */
1819

19-
/* Defined by Perl */
20-
#undef _
21-
2220
/* perl stuff */
2321
#definePG_NEED_PERL_XSUB_H
2422
#include"plperl.h"

‎src/pl/plperl/plperl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
#include"postgres.h"
99

10-
/* Defined by Perl */
11-
#undef _
12-
1310
/* system stuff */
1411
#include<ctype.h>
1512
#include<fcntl.h>

‎src/pl/plperl/plperl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
#undef vprintf
3939
#undef printf
4040

41+
/*
42+
* Perl scribbles on the "_" macro too.
43+
*/
44+
#undef _
45+
4146
/*
4247
* ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's
4348
* __inline__. Translate to something MSVC recognizes. Also, perl.h sometimes
@@ -140,6 +145,16 @@
140145
#definevprintfpg_vprintf
141146
#defineprintf(...)pg_printf(__VA_ARGS__)
142147

148+
/*
149+
* Put back "_" too; but rather than making it just gettext() as the core
150+
* code does, make it dgettext() so that the right things will happen in
151+
* loadable modules (if they've set up TEXTDOMAIN correctly). Note that
152+
* we can't just set TEXTDOMAIN here, because this file is used by more
153+
* extensions than just PL/Perl itself.
154+
*/
155+
#undef _
156+
#define_(x) dgettext(TEXTDOMAIN, x)
157+
143158
/* put back the definition of isnan if needed */
144159
#ifdef_MSC_VER
145160
#ifndefisnan

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp