Re: Converting tab-complete.c's else-if chain to a switch

Jacob Champion <jacob.champion@enterprisedb.com>

From: Jacob Champion <jacob.champion@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>, Thomas Munro <thomas.munro@gmail.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org
Date: 2024-10-10T18:25:18Z
Lists: pgsql-hackers

Attachments

Hi Tom,

Meson's coverage generation is unhappy with the new hardcoded #line
references emitted by gen_tabcomplete.pl:

    genhtml: ERROR: cannot read
/home/jacob/src/postgres/worktree-oauth/build-dev/tab-complete.in.c

I've attached a potential fix which references $ARGV[0] instead, but
it's not really tested beyond "works for me".

While I was root-causing that, I also applied the following hunk to
align Meson's custom_target with the Makefile side:

    @@ -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@',
       ],
     )

--Jacob

Commits

  1. Don't hard-code the input file name in gen_tabcomplete.pl's output.

  2. Avoid possible segfault in psql's tab completion.

  3. Convert tab-complete's long else-if chain to a switch statement.

  4. Prepare tab-complete.c for preprocessing.

  5. Invent "MatchAnyN" option for tab-complete.c's Matches/MatchesCS.