[9.3 bug fix] ECPG does not escape backslashes - Mailing list pgsql-hackers

From MauMau
Subject [9.3 bug fix] ECPG does not escape backslashes
Date
Msg-id A0C361567285450883C37D254F58F054@maumau
Whole thread Raw
Responses Re: [9.3 bug fix] ECPG does not escape backslashes
Re: [9.3 bug fix] ECPG does not escape backslashes
List 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

pgsql-hackers by date:

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