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

Commit3849fe7

Browse files
committed
Replace Gen_dummy_probes.sed with Gen_dummy_probes.pl
To generate a dummy probes.h file when dtrace is not available, we hadtwo different scripts: A sed version, which is the original version,and a Perl version, which was generated by s2p. This split wasnecessary because Perl was not a mandatory build dependency on Unix,but sed was not guaranteed to be available on Windows.(The Meson build system used the sed version even on Windows, whichwas probably incorrect and probably would have had to be fixed beforeelevating that build system from experimental status.)As of721856f, Perl is a required build dependency, so this splitis no longer necessary. We can just use the Perl script in all buildenvironments and remove a whole bunch of infrastructure to keep thetwo variants in sync.The new Gen_dummy_probes.pl is not the version generated by s2p but anew implementation written by hand by adapting the sed version to Perlsyntax.Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/3fd0f1bc-4483-4ba9-8aa0-64765b052039@eisentraut.org
1 parent1e3f461 commit3849fe7

File tree

8 files changed

+26
-339
lines changed

8 files changed

+26
-339
lines changed

‎.gitattributes‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ README.*conflict-marker-size=32
1414
*.data-whitespace
1515
contrib/pgcrypto/sql/pgp-armor.sqlwhitespace=-blank-at-eol
1616
src/backend/catalog/sql_features.txtwhitespace=space-before-tab,blank-at-eof,-blank-at-eol
17-
src/backend/utils/Gen_dummy_probes.pl.prologwhitespace=-blank-at-eof
1817

1918
# Test output files that contain extra whitespace
2019
*.out-whitespace
Lines changed: 22 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -1,259 +1,28 @@
1-
#! /usr/bin/perl -w
21
#-------------------------------------------------------------------------
2+
# Perl script to create dummy probes.h file when dtrace is not available
33
#
4-
# Gen_dummy_probes.pl
5-
# Perl script that generates probes.h file when dtrace is not available
6-
#
7-
# Portions Copyright (c) 2008-2023, PostgreSQL Global Development Group
8-
#
9-
#
10-
# IDENTIFICATION
11-
# src/backend/utils/Gen_dummy_probes.pl
12-
#
13-
# This program was generated by running perl's s2p over Gen_dummy_probes.sed
4+
# Copyright (c) 2008-2023, PostgreSQL Global Development Group
145
#
6+
# src/backend/utils/Gen_dummy_probes.pl
157
#-------------------------------------------------------------------------
168

17-
# turn off perlcritic for autogenerated code
18-
## no critic
19-
20-
$0 =~s/^.*?(\w+)[\.\w+]*$/$1/;
21-
229
use strict;
23-
use Symbol;
24-
use varsqw{ $isEOF $Hold %wFiles @Q $CondReg
25-
$doAutoPrint $doOpenWrite $doPrint};
26-
$doAutoPrint = 1;
27-
$doOpenWrite = 1;
28-
29-
# prototypes
30-
subopenARGV();
31-
subgetsARGV(;\$);
32-
subeofARGV();
33-
subprintQ();
34-
35-
# Run: the sed loop reading input and applying the script
36-
#
37-
subRun()
38-
{
39-
my ($h,$icnt,$s,$n);
40-
41-
# hack (not unbreakable :-/) to avoid // matching an empty string
42-
my$z ="\000";
43-
$z =~/$z/;
44-
45-
# Initialize.
46-
openARGV();
47-
$Hold ='';
48-
$CondReg = 0;
49-
$doPrint =$doAutoPrint;
50-
CYCLE:
51-
while (getsARGV())
52-
{
53-
chomp();
54-
$CondReg = 0;# cleared on t
55-
BOS:;
56-
57-
# /^[ ]*probe /!d
58-
unless (m /^[\t]*probe/s)
59-
{
60-
$doPrint = 0;
61-
goto EOS;
62-
}
63-
64-
# s/^[ ]*probe \([^(]*\)\(.*\);/\1\2/
65-
{
66-
$s =s /^[ \t]*probe ([^(]*)(.*);/${1}${2}/s;
67-
$CondReg ||=$s;
68-
}
69-
70-
# s/__/_/g
71-
{
72-
$s =s /__/_/sg;
73-
$CondReg ||=$s;
74-
}
75-
76-
# y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
77-
{y{abcdefghijklmnopqrstuvwxyz}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}; }
78-
79-
# s/^/#define TRACE_POSTGRESQL_/
80-
{
81-
$s =s /^/#define TRACE_POSTGRESQL_/s;
82-
$CondReg ||=$s;
83-
}
84-
85-
# s/([^,)]\{1,\})/(INT1)/
86-
{
87-
$s =s /\([^,)]+\)/(INT1)/s;
88-
$CondReg ||=$s;
89-
}
90-
91-
# s/([^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2)/
92-
{
93-
$s =s /\([^,)]+, [^,)]+\)/(INT1, INT2)/s;
94-
$CondReg ||=$s;
95-
}
96-
97-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3)/
98-
{
99-
$s =s /\([^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3)/s;
100-
$CondReg ||=$s;
101-
}
102-
103-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4)/
104-
{
105-
$s =
106-
s /\([^,)]+, [^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3, INT4)/s;
107-
$CondReg ||=$s;
108-
}
109-
110-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5)/
111-
{
112-
$s =
113-
s /\([^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3, INT4, INT5)/s;
114-
$CondReg ||=$s;
115-
}
116-
117-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6)/
118-
{
119-
$s =
120-
s /\([^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3, INT4, INT5, INT6)/s;
121-
$CondReg ||=$s;
122-
}
123-
124-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6, INT7)/
125-
{
126-
$s =
127-
s /\([^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3, INT4, INT5, INT6, INT7)/s;
128-
$CondReg ||=$s;
129-
}
130-
131-
# s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)/
132-
{
133-
$s =
134-
s /\([^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+, [^,)]+\)/(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)/s;
135-
$CondReg ||=$s;
136-
}
137-
138-
# s/$/ do {} while (0)/
139-
{
140-
$s =s /$/do {}while (0)/s;
141-
$CondReg ||=$s;
142-
}
143-
144-
# P
145-
{
146-
if (/^(.*)/) {print$1,"\n"; }
147-
}
148-
149-
# s/(.*$/_ENABLED() (0)/
150-
{
151-
$s =s /\(.*$/_ENABLED() (0)/s;
152-
$CondReg ||=$s;
153-
}
154-
EOS:if ($doPrint)
155-
{
156-
print$_,"\n";
157-
}
158-
else
159-
{
160-
$doPrint =$doAutoPrint;
161-
}
162-
printQ()if@Q;
163-
}
164-
165-
exit(0);
166-
}
167-
Run();
168-
169-
# openARGV: open 1st input file
170-
#
171-
subopenARGV()
172-
{
173-
unshift(@ARGV,'-')unless@ARGV;
174-
my$file =shift(@ARGV);
175-
open(ARG,"<$file")
176-
||die("$0: can't open$file for reading ($!)\n");
177-
$isEOF = 0;
178-
}
179-
180-
# getsARGV: Read another input line into argument (default: $_).
181-
# Move on to next input file, and reset EOF flag $isEOF.
182-
subgetsARGV(;\$)
183-
{
184-
my$argref =@_ ?shift() : \$_;
185-
while ($isEOF || !defined($$argref = <ARG>))
186-
{
187-
close(ARG);
188-
return 0unless@ARGV;
189-
my$file =shift(@ARGV);
190-
open(ARG,"<$file")
191-
||die("$0: can't open$file for reading ($!)\n");
192-
$isEOF = 0;
193-
}
194-
1;
195-
}
196-
197-
# eofARGV: end-of-file test
198-
#
199-
subeofARGV()
200-
{
201-
return@ARGV == 0 && ($isEOF =eof(ARG));
202-
}
203-
204-
# makeHandle: Generates another file handle for some file (given by its path)
205-
# to be written due to a w command or an s command's w flag.
206-
submakeHandle($)
207-
{
208-
my ($path) =@_;
209-
my$handle;
210-
if (!exists($wFiles{$path}) ||$wFiles{$path}eq'')
211-
{
212-
$handle =$wFiles{$path} = gensym();
213-
if ($doOpenWrite)
214-
{
215-
if (!open($handle,">$path"))
216-
{
217-
die("$0: can't open$path for writing: ($!)\n");
218-
}
219-
}
220-
}
221-
else
222-
{
223-
$handle =$wFiles{$path};
224-
}
225-
return$handle;
226-
}
227-
228-
# printQ: Print queued output which is either a string or a reference
229-
# to a pathname.
230-
subprintQ()
231-
{
232-
formy$q (@Q)
233-
{
234-
if (ref($q))
235-
{
236-
237-
# flush open w files so that reading this file gets it all
238-
if (exists($wFiles{$$q}) &&$wFiles{$$q}ne'')
239-
{
240-
open($wFiles{$$q},">>$$q");
241-
}
242-
243-
# copy file to stdout: slow, but safe
244-
if (open(RF,"<$$q"))
245-
{
246-
while (defined(my$line = <RF>))
247-
{
248-
print$line;
249-
}
250-
close(RF);
251-
}
252-
}
253-
else
254-
{
255-
print$q;
256-
}
257-
}
258-
undef(@Q);
259-
}
10+
use warnings;
11+
12+
m/^\s*probe/ ||next;
13+
s/^\s*probe ([^(]*)(.*);/$1$2/;
14+
s/__/_/g;
15+
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;
16+
s/^/#define TRACE_POSTGRESQL_/;
17+
s/\([^,)]{1,}\)/(INT1)/;
18+
s/\([^,)]{1,}, [^,)]{1,}\)/(INT1, INT2)/;
19+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3)/;
20+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3, INT4)/;
21+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3, INT4, INT5)/;
22+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3, INT4, INT5, INT6)/;
23+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3, INT4, INT5, INT6, INT7)/;
24+
s/\([^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}, [^,)]{1,}\)/(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)/;
25+
s/$/ do {} while (0)/;
26+
print;
27+
s/\(.*$/_ENABLED() (0)/;
28+
print;

‎src/backend/utils/Gen_dummy_probes.pl.prolog‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎src/backend/utils/Gen_dummy_probes.sed‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎src/backend/utils/Makefile‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ probes.h: postprocess_dtrace.sed probes.h.tmp
6363
probes.h.tmp: probes.d
6464
$(DTRACE) -C -h -s$< -o$@
6565
else
66-
probes.h: Gen_dummy_probes.sed probes.d
67-
sed -f$^>$@
66+
probes.h: Gen_dummy_probes.pl probes.d
67+
$(PERL) -n$^>$@
6868
endif
6969

7070
# These generated headers must be symlinked into src/include/.
@@ -76,17 +76,6 @@ $(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h
7676
done
7777
touch$@
7878

79-
# Recipe for rebuilding the Perl version of Gen_dummy_probes
80-
# Nothing depends on it, so it will never be called unless explicitly requested
81-
# The last two lines of the recipe format the script according to our
82-
# standard and put back some blank lines for improved readability.
83-
Gen_dummy_probes.pl: Gen_dummy_probes.sed Gen_dummy_probes.pl.prolog
84-
cp$(srcdir)/Gen_dummy_probes.pl.prolog$@
85-
s2p -f$<| sed -e 1,3d -e'/# #/ d' -e'$$d'>>$@
86-
perltidy --profile=$(srcdir)/../../tools/pgindent/perltidyrc$@
87-
perl -pi -e'!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\
88-
-e'$$lb = m/^\n/;'$@
89-
9079
.PHONY: install-data
9180
install-data: errcodes.txt installdirs
9281
$(INSTALL_DATA)$(srcdir)/errcodes.txt'$(DESTDIR)$(datadir)/errcodes.txt'

‎src/backend/utils/README.Gen_dummy_probes‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp