diff options
| author | Peter Eisentraut | 2025-12-08 14:53:52 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2025-12-08 14:53:52 +0000 |
| commit | 7f88553ceaca4af0e5bd483ab77f9f442578c18a (patch) | |
| tree | afea5b7457b91493a1b98702d024258f267af981 | |
| parent | 804046b39a27973751c920f8f41504697f3f52d5 (diff) | |
Make ecpg parse.pl more robust with braces
When parse.pl processes braces, it does not take into account that
braces could also be their own token if single quoted ('{', '}').
This is not currently used but a future patch wants to make use of it.
This fixes that by using lookaround assertions to detect the quotes.
To make sure all Perl versions in play support this and to avoid
surprises later on, let's give this a spin on the buildfarm now. It
can exist independently of future work.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org
| -rw-r--r-- | src/interfaces/ecpg/preproc/parse.pl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl index f22ca213c21..7e51339f3fc 100644 --- a/src/interfaces/ecpg/preproc/parse.pl +++ b/src/interfaces/ecpg/preproc/parse.pl @@ -256,9 +256,9 @@ sub main $has_if_command = 1 if /^\s*if/; } - # Make sure any braces are split into separate fields - s/{/ { /g; - s/}/ } /g; + # Make sure any (unquoted) braces are split into separate fields + s/(?<!')\{(?!')/ { /g; + s/(?<!')\}(?!')/ } /g; # Likewise for comment start/end markers s|\/\*| /* |g; |
