PQerrorMessage: suppress trailing new line?

Started by fkater@googlemail.comalmost 19 years ago3 messagesgeneral
Jump to latest
#1fkater@googlemail.com
fkater@googlemail.com

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

#2Andrej Ricnik-Bay
andrej.groups@gmail.com
In reply to: fkater@googlemail.com (#1)
Re: PQerrorMessage: suppress trailing new line?

On 4/24/07, Felix Kater <fkater@googlemail.com> 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

#3fkater@googlemail.com
fkater@googlemail.com
In reply to: Andrej Ricnik-Bay (#2)
Re: PQerrorMessage: suppress trailing new line?

On Tue, 24 Apr 2007 11:14:43 +1200
"Andrej Ricnik-Bay" <andrej.groups@gmail.com> wrote:

On 4/24/07, Felix Kater <fkater@googlemail.com> 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:
<message text><newline><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