[ecpg bug]: can not use single '*' in multi-line comment after c preprocessor directives

From: "Winter Loo" <winterloo(at)126(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [ecpg bug]: can not use single '*' in multi-line comment after c preprocessor directives
Date: 2024-09-25 07:36:48
Message-ID: 577fa287.6e4e.192281c7d38.Coremail.winterloo@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

The following code fails to pass the ecpg compilation, although it is accepted by the gcc compiler.

```
#if ABC /* this is a multi-line
* comment including single star character */
int a = 1;
#endif
```

The issue arises from the first '*' in the second line. Upon its removal, the ecpg compiler functions properly.

```
#if ABC /* this is a multi-line
comment without single star character */
int a = 1;
#endif
```

The problem has been identified as a bug in the `cppline` definition within the `pgc.l` file.

```
cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+\/)|.|\\{space}*{newline})*{newline}
```
[Source](https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/ecpg/preproc/pgc.l;h=f3c03482aec61956691f30426f61510920c5c702;hb=HEAD#l461)

More specifically, the bug originates from the regex pattern for the C block code comment.

```
\/\*[^*/]*\*+\/
```

Attempting another example:

```
#if ABC /* hello * world */
int a = 1;
#endif
```

This time, the ecpg compiler also functions correctly.

Confused! I am uncertain how to rectify the regex. I hope someone can address this bug.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2024-09-25 08:12:27 Re: AIO writes vs hint bits vs checksums
Previous Message Richard Guo 2024-09-25 07:12:57 Re: Eager aggregation, take 3