Re: [GENERAL] PQerrorMessage: suppress trailing new line?

2007-04-24 Thread Felix Kater
On Tue, 24 Apr 2007 11:14:43 +1200
"Andrej Ricnik-Bay" <[EMAIL PROTECTED]> wrote:

> On 4/24/07, Felix Kater <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > the messages returned by PQerrorMessage() contain a trailing new
> > line. So, they doesn't nicely integrate into strings formatted by
> > printf.
> >
> > Is there a way to suppress the trailing new line (except for
> > alloc/copy to a new string)?
> The alloc kind of suggests that you're using C ... is that
> correct?  Either way - please be a bit more specific as to what you're
> trying to achieve by which means.

Sorry (was deep in thoughs while coding...). A bit more detailed:

I am using libpq, the C language pg library. There is a useful function
to return the last error message as human readable text: PQerrorMessage.

While the returned text message is static memory which is good (you
simply print it and don't have to free the memory) there is a trailing
new line character at each text message like this:
<0-byte-terminator>

I find this newline a lot uncommon--since it is easy to add manually if
you really want it, and, however, it is not so easy to get rid of it.

Getting rid of it means: Copying the whole string without the newline,
pass it to the user, who has to free the copied memory after printing
it...

I wanted to know if there is a switch or similar somewhere to get the
messages without newline character.

Thank You
Felix

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] PQerrorMessage: suppress trailing new line?

2007-04-23 Thread Andrej Ricnik-Bay

On 4/24/07, Felix Kater <[EMAIL PROTECTED]> wrote:

Hi,

the messages returned by PQerrorMessage() contain a trailing new line.
So, they doesn't nicely integrate into strings formatted by printf.

Is there a way to suppress the trailing new line (except for
alloc/copy to a new string)?

The alloc kind of suggests that you're using C ... is that
correct?  Either way - please be a bit more specific as to what you're
trying to achieve by which means.



Thank You
Felix

Cheers,
Andrej

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[GENERAL] PQerrorMessage: suppress trailing new line?

2007-04-23 Thread Felix Kater
Hi,

the messages returned by PQerrorMessage() contain a trailing new line.
So, they doesn't nicely integrate into strings formatted by printf.

Is there a way to suppress the trailing new line (except for
alloc/copy to a new string)?

Thank You
Felix

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org/