ECPG and escape strings

Started by Michael Fuhrover 20 years ago5 messageshackers
Jump to latest
#1Michael Fuhr
mike@fuhr.org

ECPG seems to be a little overzealous with the new escape string syntax:

% cat foo.pgc
int
main(void)
{
putchar('\n');
return 0;
}

% ecpg foo.pgc

% gcc -I`pg_config --includedir` -c foo.c
foo.pgc: In function `main':
foo.pgc:4: `E' undeclared (first use in this function)
foo.pgc:4: (Each undeclared identifier is reported only once
foo.pgc:4: for each function it appears in.)
foo.pgc:4: syntax error before character constant

% cat foo.c
/* Processed by ecpg (4.1.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "foo.pgc"
int
main(void)
{
putchar(E'\n');
return 0;
}

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#2Bruce Momjian
bruce@momjian.us
In reply to: Michael Fuhr (#1)
Re: [HACKERS] ECPG and escape strings

Would someone on the interface list look for a fix to this? Thanks.

---------------------------------------------------------------------------

Michael Fuhr wrote:

ECPG seems to be a little overzealous with the new escape string syntax:

% cat foo.pgc
int
main(void)
{
putchar('\n');
return 0;
}

% ecpg foo.pgc

% gcc -I`pg_config --includedir` -c foo.c
foo.pgc: In function `main':
foo.pgc:4: `E' undeclared (first use in this function)
foo.pgc:4: (Each undeclared identifier is reported only once
foo.pgc:4: for each function it appears in.)
foo.pgc:4: syntax error before character constant

% cat foo.c
/* Processed by ecpg (4.1.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "foo.pgc"
int
main(void)
{
putchar(E'\n');
return 0;
}

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Bruce Momjian
bruce@momjian.us
In reply to: Michael Fuhr (#1)
Re: ECPG and escape strings

It turns out I made a mistake in trying to be too smart about adding E''
escapes for ecpg strings that have backslashes. I have reversed the
attached patch to fix the problem. Thanks for the report.

---------------------------------------------------------------------------

Michael Fuhr wrote:

ECPG seems to be a little overzealous with the new escape string syntax:

% cat foo.pgc
int
main(void)
{
putchar('\n');
return 0;
}

% ecpg foo.pgc

% gcc -I`pg_config --includedir` -c foo.c
foo.pgc: In function `main':
foo.pgc:4: `E' undeclared (first use in this function)
foo.pgc:4: (Each undeclared identifier is reported only once
foo.pgc:4: for each function it appears in.)
foo.pgc:4: syntax error before character constant

% cat foo.c
/* Processed by ecpg (4.1.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "foo.pgc"
int
main(void)
{
putchar(E'\n');
return 0;
}

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/rtmp/difftext/plainDownload+175-152
#4Michael Meskes
meskes@postgresql.org
In reply to: Michael Fuhr (#1)
Re: ECPG and escape strings

On Wed, Aug 03, 2005 at 08:31:25AM -0600, Michael Fuhr wrote:

ECPG seems to be a little overzealous with the new escape string syntax:

This comes from starting the string constant with ESCAPE_STRING_SYNTAX
in case there is '\' inside the string. Actually I have no idea at the
moment how that made it into. I comment it out for the time being. If
anyone knows a reason for this behaviour please tell me and maybe fresh
up my memory.

CVS commit to come as soon as I'm online again.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

#5Bruce Momjian
bruce@momjian.us
In reply to: Michael Meskes (#4)
Re: ECPG and escape strings

Michael Meskes wrote:

On Wed, Aug 03, 2005 at 08:31:25AM -0600, Michael Fuhr wrote:

ECPG seems to be a little overzealous with the new escape string syntax:

This comes from starting the string constant with ESCAPE_STRING_SYNTAX
in case there is '\' inside the string. Actually I have no idea at the
moment how that made it into. I comment it out for the time being. If
anyone knows a reason for this behaviour please tell me and maybe fresh
up my memory.

CVS commit to come as soon as I'm online again.

I have removed that from CVS. It was a bug I introduced.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073