diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-10 17:02:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-10 17:02:08 -0400 |
commit | c75c6f8d280a3364643fc51f9c9fdf2dee0213c2 (patch) | |
tree | fc08642279184e0c0a59ef5a7ba118ba4d25e80d | |
parent | 95eb4cd4ff0648afc32abbfaacc9718f6b91bf7b (diff) | |
download | postgresql-c75c6f8d280a3364643fc51f9c9fdf2dee0213c2.tar.gz postgresql-c75c6f8d280a3364643fc51f9c9fdf2dee0213c2.zip |
Don't hard-code the input file name in gen_tabcomplete.pl's output.
Use $ARGV[0], that is the specified input file name, in #line
directives generated by gen_tabcomplete.pl. This makes code
coverage reports work properly in the meson build system (where
the input file name will be a relative path).
Also fix up brain fade in the meson build rule for tab-complete.c:
we only need to write the input file name once not twice.
Jacob Champion (some cosmetic adjustments by me)
Discussion: https://postgr.es/m/CAOYmi+=+oWAoi8pqnH0MJQqsSn4ddzqDhqRQJvyiN2aJSWvw2w@mail.gmail.com
-rw-r--r-- | src/bin/psql/gen_tabcomplete.pl | 17 | ||||
-rw-r--r-- | src/bin/psql/meson.build | 4 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/bin/psql/gen_tabcomplete.pl b/src/bin/psql/gen_tabcomplete.pl index 9e4c977cc57..41ba7bbdd61 100644 --- a/src/bin/psql/gen_tabcomplete.pl +++ b/src/bin/psql/gen_tabcomplete.pl @@ -55,8 +55,9 @@ my $outfile = ''; GetOptions('outfile=s' => \$outfile) or die "$0: wrong arguments"; -open my $infh, '<', $ARGV[0] - or die "$0: could not open input file '$ARGV[0]': $!\n"; +my $infile = $ARGV[0]; +open my $infh, '<', $infile + or die "$0: could not open input file '$infile': $!\n"; my $outfh; if ($outfile) @@ -91,7 +92,7 @@ printf $outfh <<EOM; #define SWITCH_CONVERSION_APPLIED -#line 1 "tab-complete.in.c" +#line 1 "${infile}" EOM # Scan input file until we find the data-replacement label line. @@ -114,7 +115,7 @@ my $last_case_label = 0; # with the line numbering of the original, to simplify compiler error message # reading and debugging. my $next_line_no = $. + 1; -$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n"; +$output_code .= "#line ${next_line_no} \"${infile}\"\n"; # Scan until we find the BEGIN GEN_TABCOMPLETE line. # Add the scanned code to $output_code verbatim. @@ -131,7 +132,7 @@ $output_code .= "\t{\n"; # Keep line numbering in sync. $next_line_no = $. + 1; -$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n"; +$output_code .= "#line ${next_line_no} \"${infile}\"\n"; # Scan input file, collecting outer-level else-if conditions # to pass to process_else_if. @@ -190,7 +191,7 @@ $output_code .= "\t}\n"; # Keep line numbering in sync. $next_line_no = $. + 1; -$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n"; +$output_code .= "#line ${next_line_no} \"${infile}\"\n"; # Scan the rest, adding it to $output_code verbatim. while (<$infh>) @@ -245,7 +246,7 @@ sub process_else_if process_match($typ, $cs, $args, $else_if_lineno, $isfirst); $isfirst = 0; # approximate line positioning of AND'd condition - $output_code .= "#line ${end_lineno} \"tab-complete.in.c\"\n"; + $output_code .= "#line ${end_lineno} \"${infile}\"\n"; $output_code .= "\tif ($else_if_line\n"; } elsif ($else_if_line =~ @@ -269,7 +270,7 @@ sub process_else_if if ($end_lineno != $else_if_lineno) { my $next_lineno = $end_lineno + 1; - $output_code .= "#line ${next_lineno} \"tab-complete.in.c\"\n"; + $output_code .= "#line ${next_lineno} \"${infile}\"\n"; } } diff --git a/src/bin/psql/meson.build b/src/bin/psql/meson.build index b7c026c900b..cbc71f7e8ad 100644 --- a/src/bin/psql/meson.build +++ b/src/bin/psql/meson.build @@ -27,8 +27,8 @@ tabcomplete = custom_target('tabcomplete', input: 'tab-complete.in.c', output: 'tab-complete.c', command: [ - perl, files('gen_tabcomplete.pl'), files('tab-complete.in.c'), - '--outfile', '@OUTPUT@', '@INPUT@', + perl, files('gen_tabcomplete.pl'), '@INPUT@', + '--outfile', '@OUTPUT@', ], ) generated_sources += tabcomplete |