ecpg_prepoc_check_rules_cleanup.patch
application/octet-stream
Filename: ecpg_prepoc_check_rules_cleanup.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/interfaces/ecpg/preproc/check_rules.pl | 0 | 0 |
diff --git a/src/interfaces/ecpg/preproc/check_rules.pl b/src/interfaces/ecpg/preproc/check_rules.pl
index 5e2b65f..853dfbb 100755
*** a/src/interfaces/ecpg/preproc/check_rules.pl
--- b/src/interfaces/ecpg/preproc/check_rules.pl
***************
*** 1,83 ****
#!/usr/bin/perl
! # src/interfaces/ecpg/preproc/check_rules.pl
# test parser generater for ecpg
# call with backend parser as stdin
#
! # Copyright (c) 2009-2011, PostgreSQL Global Development Group
#
# Written by Michael Meskes <meskes@postgresql.org>
#
# Placed under the same license as PostgreSQL.
#
! if (@ARGV) {
! $path = $ARGV[0];
! $parser = $ARGV[1];
! }
! $[ = 1; # set array base to 1
! if ($path eq '') { $path = "."; }
! $filename = $path . "/ecpg.addons";
! if ($parser eq '') { $parser = "../../../backend/parser/gram.y"; }
! $replace_line{'ExecuteStmtEXECUTEnameexecute_param_clause'} = 'EXECUTE prepared_name execute_param_clause execute_rest';
! $replace_line{'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause'} = 'CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause';
! $replace_line{'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt'} = 'PREPARE prepared_name prep_type_clause AS PreparableStmt';
- $block = '';
- $ret = 0;
- $yaccmod = 0;
- $brace_indent = 0;
! open GRAM, $parser or die $!;
! while (<GRAM>) {
! chomp; # strip record separator
! if (/^%%/) {
! $yaccmode++;
! }
! if ($yaccmode != 1) {
! next;
! }
! $S = $_;
! $prec = 0;
! # Make sure any braces are split
! $S =~ s/{/ { /g;
! $S =~ s/}/ } /g;
! # Any comments are split
! $S =~ s#[/][*]# /* #g;
! $S =~ s#[*][/]# */ #g;
! # Now split the line into individual fields
! $n = (@arr = split(' ', $S));
! # Go through each field in turn
! for ($fieldIndexer = 1; $fieldIndexer <= $n; $fieldIndexer++) {
! if ($arr[$fieldIndexer] eq '*/' && $comment) {
! $comment = 0;
! next;
! }
! elsif ($comment) {
next;
}
! elsif ($arr[$fieldIndexer] eq '/*') {
# start of a multiline comment
$comment = 1;
next;
}
! elsif ($arr[$fieldIndexer] eq '//') {
next;
}
! elsif ($arr[$fieldIndexer] eq '}') {
$brace_indent--;
next;
}
! elsif ($arr[$fieldIndexer] eq '{') {
$brace_indent++;
next;
}
--- 1,73 ----
#!/usr/bin/perl
! # $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/check_rules.pl,v 1.2 2010/01/02 16:58:11 momjian Exp $
# test parser generater for ecpg
# call with backend parser as stdin
#
! # Copyright (c) 2009-2010, PostgreSQL Global Development Group
#
# Written by Michael Meskes <meskes@postgresql.org>
#
# Placed under the same license as PostgreSQL.
#
! use strict;
! use warnings;
! our ($path, $parser) = @ARGV;
! $path = '.' if $path eq '';
! $filename = "$path/ecpg.addons";
! $parser = "../../../backend/parser/gram.y" if $parser eq '';
! our %replace_line = (
! ExecuteStmtEXECUTEnameexecute_param_clause => 'ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest',
! ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause => 'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEprepared_nameexecute_param_clause',
! PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt => 'PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt'
! );
! our %found;
! my $block = '';
! my ($comment, $brace_indent) = (0, 0);
! open my $gram, '<', $parser or die $!;
! # Skip to yaccmode
! 1 while <$gram> !~ /^%%/;
! while (<$gram>) {
! chomp; # strip record separator
! # End of yaccmode
! last if (/^%%/);
! # Make sure any braces and comments are split as individual tokens
! s#([{}]|/\*|\*/)# $1 #g;
!
! # Make sure non-term id's are split with their trailing colon as one token
! s/\s+(:\s)/$1/g;
! s/\s+:$/:/;
! # Go through each token in turn
! foreach my $tok (split(/\s+/, $_)) {
! if ($comment) {
! $comment = 0 if $tok eq '*/';
next;
}
! if ($tok eq '/*') {
# start of a multiline comment
$comment = 1;
next;
}
! if ($tok eq '//') {
next;
}
! if ($tok eq '}') {
$brace_indent--;
next;
}
! if ($tok eq '{') {
$brace_indent++;
next;
}
*************** while (<GRAM>) {
*** 86,135 ****
next;
}
! if ($arr[$fieldIndexer] eq ';' || $arr[$fieldIndexer] eq '|') {
$block = $non_term_id . $block;
! if ($replace_line{$block}) {
! $block = &generate_block($replace_line{$block});
! }
! $found{$block} = 'found';
$block = '';
}
! elsif (($arr[$fieldIndexer] =~ '[A-Za-z0-9]+:') || $arr[$fieldIndexer + 1] eq ':') {
! $non_term_id = $arr[$fieldIndexer];
$non_term_id =~ s/://g;
}
else {
! $block = $block . $arr[$fieldIndexer];
}
}
! }
! close GRAM;
! open ECPG, $filename or die $!;
! line: while (<ECPG>) {
! chomp; # strip record separator
! @Fld = split(' ', $_, -1);
! if (!/^ECPG:/) {
! next line;
! }
! if ($found{$Fld[2]} ne 'found') {
! printf $Fld[2] . " is not used for building parser!\n";
$ret = 1;
}
}
! close ECPG;
exit $ret;
-
- sub generate_block {
- local($line) = @_;
- $block = $non_term_id . $line;
- $block =~ s/ //g;
- $s = "\\|", $block =~ s/$s//g;
- return $block;
- }
--- 76,113 ----
next;
}
! if ($tok eq ';' || $tok eq '|') {
$block = $non_term_id . $block;
! $block = $replace_line{$block} if exists $replace_line{$block};
! $found{$block} = 1;
$block = '';
}
! elsif ($tok =~ '[A-Za-z0-9]+:') {
! $non_term_id = $tok;
$non_term_id =~ s/://g;
}
else {
! $block = $block . $tok;
}
}
! }
! close $gram;
! our $ret = 0;
! open my $ecpg, '<', $filename or die $!;
! while (<$ecpg>) {
! chomp; # strip record separator
! next unless m/^ECPG:\s+(\S+)/;
! if (not exists $found{$1}) {
! print "$1 is not used for building parser!\n";
$ret = 1;
}
}
! close $ecpg;
exit $ret;