[9.3 bug fix] ECPG does not escape backslashes

From: "MauMau" <maumau307(at)gmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: [9.3 bug fix] ECPG does not escape backslashes
Date: 2013-07-03 10:22:48
Message-ID: A0C361567285450883C37D254F58F054@maumau
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I happened to find a trivial bug of ECPG while experimenting with 9.3 beta
2. Please find attached the patch to fix this. This is not specific to
9.3. Could you commit and backport this?

[Bug description]
Running "ecpg c:\command\a.pgc" produces the following line in a.c:

#line 1 "c:\command\a.pgc"

Then, compiling the resulting a.c with Visual Studio (cl.exe) issues the
warning:

a.c(8) : warning C4129: 'c' : unrecognized character escape sequence

This is because ecpg doesn't escape \ in the #line string.

[How to fix]
Escape \ in the input file name like this:

#line 1 "c:\\command\\a.pgc"

This is necessary not only on Windows but also on UNIX/Linux. For your
information, running "gcc -E di\\r/a.c" escapes \ and outputs the line:

# 1 "di\\r/a.c"

Regards
MauMau

Attachment Content-Type Size
ecpg_line.patch application/octet-stream 1.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-07-03 10:31:16 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])
Previous Message Brendan Jurd 2013-07-03 10:08:36 Re: proposal: simple date constructor from numeric values