Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1318342

Browse files
committed
Eliminate POLLUTE=1 hack for cross-Perl-version compatibility by using
Devel::PPPort instead. Thanks to Gilles Darold for doing the legwork.
1 parent b762a9e commit 1318342

File tree

7 files changed

+592
-15
lines changed

7 files changed

+592
-15
lines changed

src/interfaces/perl5/GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile according to its own ideas and then invoke the rules from
55
# that file.
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/perl5/Attic/GNUmakefile,v 1.2 2000/08/31 16:11:58 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/perl5/Attic/GNUmakefile,v 1.3 2000/10/24 16:59:59 tgl Exp $
88

99
subdir = src/interfaces/perl5
1010
top_builddir = ../../..
@@ -15,7 +15,7 @@ all: Makefile libpq-all
1515
$(MAKE) -f $< all
1616

1717
Makefile: Makefile.PL
18-
$(PERL) $< POLLUTE=1
18+
$(PERL) $<
1919

2020
.PHONY: libpq-all
2121
libpq-all:
@@ -35,7 +35,7 @@ install: Makefile
3535
$(MAKE) -f Makefile clean
3636
POSTGRES_LIB="$(libdir)" \
3737
POSTGRES_INCLUDE="$(includedir)" \
38-
$(PERL) $(srcdir)/Makefile.PL POLLUTE=1
38+
$(PERL) $(srcdir)/Makefile.PL
3939
$(MAKE) -f Makefile all
4040
-@if [ -w "`$(MAKE) --quiet -f Makefile echo-installdir`" ]; then \
4141
$(MAKE) -f Makefile install; \

src/interfaces/perl5/Pg.xs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*-------------------------------------------------------
22
*
3-
* $Id: Pg.xs,v 1.14 2000/03/11 03:08:37 tgl Exp $ with patch for NULs
3+
* $Id: Pg.xs,v 1.15 2000/10/24 17:00:00 tgl Exp $ with patch for NULs
44
*
55
* Copyright (c) 1997, 1998 Edmund Mergl
66
*
@@ -9,6 +9,7 @@
99
#include "EXTERN.h"
1010
#include "perl.h"
1111
#include "XSUB.h"
12+
#include "ppport.h"
1213
#include <string.h>
1314
#include <stdio.h>
1415
#include <fcntl.h>
@@ -581,7 +582,7 @@ PQprint(fout, res, header, align, standard, html3, expanded, pager, fieldSep, ta
581582
ps.caption = caption;
582583
Newz(0, ps.fieldName, items + 1 - 11, char*);
583584
for (i = 11; i < items; i++) {
584-
ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
585+
ps.fieldName[i - 11] = (char *)SvPV(ST(i), PL_na);
585586
}
586587
PQprint(fout, res, &ps);
587588
Safefree(ps.fieldName);
@@ -1252,7 +1253,7 @@ PQfetchrow(res)
12521253
EXTEND(sp, cols);
12531254
while (col < cols) {
12541255
if (PQgetisnull(res->result, res->row, col)) {
1255-
PUSHs(&sv_undef);
1256+
PUSHs(&PL_sv_undef);
12561257
} else {
12571258
char *val = PQgetvalue(res->result, res->row, col);
12581259
PUSHs(sv_2mortal((SV*)newSVpv(val, 0)));
@@ -1292,7 +1293,7 @@ PQprint(res, fout, header, align, standard, html3, expanded, pager, fieldSep, ta
12921293
ps.caption = caption;
12931294
Newz(0, ps.fieldName, items + 1 - 11, char*);
12941295
for (i = 11; i < items; i++) {
1295-
ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
1296+
ps.fieldName[i - 11] = (char *)SvPV(ST(i), PL_na);
12961297
}
12971298
PQprint(fout, res->result, &ps);
12981299
Safefree(ps.fieldName);

src/interfaces/perl5/ppport.h

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
2+
#ifndef _P_P_PORTABILITY_H_
3+
#define _P_P_PORTABILITY_H_
4+
5+
/* Perl/Pollution/Portability Version 1.0007 */
6+
7+
/* Copyright (C) 1999, Kenneth Albanowski. This code may be used and
8+
distributed under the same license as any version of Perl. */
9+
10+
/* For the latest version of this code, please retreive the Devel::PPPort
11+
module from CPAN, contact the author at <kjahds@kjahds.com>, or check
12+
with the Perl maintainers. */
13+
14+
/* If you needed to customize this file for your project, please mention
15+
your changes, and visible alter the version number. */
16+
17+
18+
/*
19+
In order for a Perl extension module to be as portable as possible
20+
across differing versions of Perl itself, certain steps need to be taken.
21+
Including this header is the first major one, then using dTHR is all the
22+
appropriate places and using a PL_ prefix to refer to global Perl
23+
variables is the second.
24+
*/
25+
26+
27+
/* If you use one of a few functions that were not present in earlier
28+
versions of Perl, please add a define before the inclusion of ppport.h
29+
for a static include, or use the GLOBAL request in a single module to
30+
produce a global definition that can be referenced from the other
31+
modules.
32+
33+
Function: Static define: Extern define:
34+
newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
35+
36+
*/
37+
38+
39+
/* To verify whether ppport.h is needed for your module, and whether any
40+
special defines should be used, ppport.h can be run through Perl to check
41+
your source code. Simply say:
42+
43+
perl -x ppport.h *.c *.h *.xs foo/*.c [etc]
44+
45+
The result will be a list of patches suggesting changes that should at
46+
least be acceptable, if not necessarily the most efficient solution, or a
47+
fix for all possible problems. It won't catch where dTHR is needed, and
48+
doesn't attempt to account for global macro or function definitions,
49+
nested includes, typemaps, etc.
50+
51+
In order to test for the need of dTHR, please try your module under a
52+
recent version of Perl that has threading compiled-in.
53+
54+
*/
55+
56+
57+
/*
58+
#!/usr/bin/perl
59+
@ARGV = ("*.xs") if !@ARGV;
60+
%badmacros = %funcs = %macros = (); $replace = 0;
61+
foreach (<DATA>) {
62+
$funcs{$1} = 1 if /Provide:\s+(\S+)/;
63+
$macros{$1} = 1 if /^#\s*define\s+([a-zA-Z0-9_]+)/;
64+
$replace = $1 if /Replace:\s+(\d+)/;
65+
$badmacros{$2}=$1 if $replace and /^#\s*define\s+([a-zA-Z0-9_]+).*?\s+([a-zA-Z0-9_]+)/;
66+
$badmacros{$1}=$2 if /Replace (\S+) with (\S+)/;
67+
}
68+
foreach $filename (map(glob($_),@ARGV)) {
69+
unless (open(IN, "<$filename")) {
70+
warn "Unable to read from $file: $!\n";
71+
next;
72+
}
73+
print "Scanning $filename...\n";
74+
$c = ""; while (<IN>) { $c .= $_; } close(IN);
75+
$need_include = 0; %add_func = (); $changes = 0;
76+
$has_include = ($c =~ /#.*include.*ppport/m);
77+
78+
foreach $func (keys %funcs) {
79+
if ($c =~ /#.*define.*\bNEED_$func(_GLOBAL)?\b/m) {
80+
if ($c !~ /\b$func\b/m) {
81+
print "If $func isn't needed, you don't need to request it.\n" if
82+
$changes += ($c =~ s/^.*#.*define.*\bNEED_$func\b.*\n//m);
83+
} else {
84+
print "Uses $func\n";
85+
$need_include = 1;
86+
}
87+
} else {
88+
if ($c =~ /\b$func\b/m) {
89+
$add_func{$func} =1 ;
90+
print "Uses $func\n";
91+
$need_include = 1;
92+
}
93+
}
94+
}
95+
96+
if (not $need_include) {
97+
foreach $macro (keys %macros) {
98+
if ($c =~ /\b$macro\b/m) {
99+
print "Uses $macro\n";
100+
$need_include = 1;
101+
}
102+
}
103+
}
104+
105+
foreach $badmacro (keys %badmacros) {
106+
if ($c =~ /\b$badmacro\b/m) {
107+
$changes += ($c =~ s/\b$badmacro\b/$badmacros{$badmacro}/gm);
108+
print "Uses $badmacros{$badmacro} (instead of $badmacro)\n";
109+
$need_include = 1;
110+
}
111+
}
112+
113+
if (scalar(keys %add_func) or $need_include != $has_include) {
114+
if (!$has_include) {
115+
$inc = join('',map("#define NEED_$_\n", sort keys %add_func)).
116+
"#include \"ppport.h\"\n";
117+
$c = "$inc$c" unless $c =~ s/#.*include.*XSUB.*\n/$&$inc/m;
118+
} elsif (keys %add_func) {
119+
$inc = join('',map("#define NEED_$_\n", sort keys %add_func));
120+
$c = "$inc$c" unless $c =~ s/^.*#.*include.*ppport.*$/$inc$&/m;
121+
}
122+
if (!$need_include) {
123+
print "Doesn't seem to need ppport.h.\n";
124+
$c =~ s/^.*#.*include.*ppport.*\n//m;
125+
}
126+
$changes++;
127+
}
128+
129+
if ($changes) {
130+
open(OUT,">/tmp/ppport.h.$$");
131+
print OUT $c;
132+
close(OUT);
133+
open(DIFF, "diff -u $filename /tmp/ppport.h.$$|");
134+
while (<DIFF>) { s!/tmp/ppport\.h\.$$!$filename.patched!; print STDOUT; }
135+
close(DIFF);
136+
unlink("/tmp/ppport.h.$$");
137+
} else {
138+
print "Looks OK\n";
139+
}
140+
}
141+
__DATA__
142+
*/
143+
144+
#ifndef PERL_REVISION
145+
# ifndef __PATCHLEVEL_H_INCLUDED__
146+
# include "patchlevel.h"
147+
# endif
148+
# ifndef PERL_REVISION
149+
# define PERL_REVISION (5)
150+
/* Replace: 1 */
151+
# define PERL_VERSION PATCHLEVEL
152+
# define PERL_SUBVERSION SUBVERSION
153+
/* Replace PERL_PATCHLEVEL with PERL_VERSION */
154+
/* Replace: 0 */
155+
# endif
156+
#endif
157+
158+
#define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
159+
160+
#ifndef ERRSV
161+
# define ERRSV perl_get_sv("@",FALSE)
162+
#endif
163+
164+
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
165+
/* Replace: 1 */
166+
# define PL_sv_undef sv_undef
167+
# define PL_sv_yes sv_yes
168+
# define PL_sv_no sv_no
169+
# define PL_na na
170+
# define PL_stdingv stdingv
171+
# define PL_hints hints
172+
# define PL_curcop curcop
173+
# define PL_curstash curstash
174+
# define PL_copline copline
175+
# define PL_Sv Sv
176+
/* Replace: 0 */
177+
#endif
178+
179+
#ifndef dTHR
180+
# ifdef WIN32
181+
# define dTHR extern int Perl___notused
182+
# else
183+
# define dTHR extern int errno
184+
# endif
185+
#endif
186+
187+
#ifndef boolSV
188+
# define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
189+
#endif
190+
191+
#ifndef gv_stashpvn
192+
# define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
193+
#endif
194+
195+
#ifndef newSVpvn
196+
# define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
197+
#endif
198+
199+
#ifndef newRV_inc
200+
/* Replace: 1 */
201+
# define newRV_inc(sv) newRV(sv)
202+
/* Replace: 0 */
203+
#endif
204+
205+
#ifndef newRV_noinc
206+
# ifdef __GNUC__
207+
# define newRV_noinc(sv) \
208+
({ \
209+
SV *nsv = (SV*)newRV(sv); \
210+
SvREFCNT_dec(sv); \
211+
nsv; \
212+
})
213+
# else
214+
# if defined(CRIPPLED_CC) || defined(USE_THREADS)
215+
static SV * newRV_noinc (SV * sv)
216+
{
217+
SV *nsv = (SV*)newRV(sv);
218+
SvREFCNT_dec(sv);
219+
return nsv;
220+
}
221+
# else
222+
# define newRV_noinc(sv) \
223+
((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv)
224+
# endif
225+
# endif
226+
#endif
227+
228+
/* Provide: newCONSTSUB */
229+
230+
/* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
231+
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))
232+
233+
#if defined(NEED_newCONSTSUB)
234+
static
235+
#else
236+
extern void newCONSTSUB _((HV * stash, char * name, SV *sv));
237+
#endif
238+
239+
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
240+
void
241+
newCONSTSUB(stash,name,sv)
242+
HV *stash;
243+
char *name;
244+
SV *sv;
245+
{
246+
U32 oldhints = PL_hints;
247+
HV *old_cop_stash = PL_curcop->cop_stash;
248+
HV *old_curstash = PL_curstash;
249+
line_t oldline = PL_curcop->cop_line;
250+
PL_curcop->cop_line = PL_copline;
251+
252+
PL_hints &= ~HINT_BLOCK_SCOPE;
253+
if (stash)
254+
PL_curstash = PL_curcop->cop_stash = stash;
255+
256+
newSUB(
257+
258+
#if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))
259+
/* before 5.003_22 */
260+
start_subparse(),
261+
#else
262+
# if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22)
263+
/* 5.003_22 */
264+
start_subparse(0),
265+
# else
266+
/* 5.003_23 onwards */
267+
start_subparse(FALSE, 0),
268+
# endif
269+
#endif
270+
271+
newSVOP(OP_CONST, 0, newSVpv(name,0)),
272+
newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
273+
newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
274+
);
275+
276+
PL_hints = oldhints;
277+
PL_curcop->cop_stash = old_cop_stash;
278+
PL_curstash = old_curstash;
279+
PL_curcop->cop_line = oldline;
280+
}
281+
#endif
282+
283+
#endif /* newCONSTSUB */
284+
285+
286+
#endif /* _P_P_PORTABILITY_H_ */

src/pl/plperl/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v 1.4 2000/09/17 13:02:51 petere Exp $
1+
# $Header: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v 1.5 2000/10/24 17:01:05 tgl Exp $
22

33
subdir = src/pl/plperl
44
top_builddir = ../../..
@@ -13,7 +13,7 @@ all: Makefile
1313
Makefile: Makefile.PL
1414
@plperl_installdir='$(plperl_installdir)' \
1515
EXTRA_INCLUDES='-I$(top_srcdir)/src/include $(INCLUDES)' \
16-
$(PERL) $< POLLUTE=1
16+
$(PERL) $<
1717

1818
install: all installdirs
1919
$(MAKE) -f Makefile install

src/pl/plperl/eloglvl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "postgres.h"
2+
13
#include "utils/elog.h"
24

35
/*

0 commit comments

Comments
 (0)