snprintf()

Поиск
Список
Период
Сортировка
От Kate F
Тема snprintf()
Дата
Msg-id 20070203034018.GH390@cats.meow.at
обсуждение исходный текст
Ответы Re: snprintf()
Список pgsql-hackers
Hello,

I've been implementing a type I needed, and happened to be using
snprintf(), since I have C99 available.
ereport(NOTICE,    (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),    errmsg("%d", snprintf(NULL, 0, "abc"))));

For me, this reports "0". I beieve it should report 3. My system's
snprintf() returns 3. I'm using NetBSD. By including postgres.h and
fmgr.h, does PostgreSQL replace my system's snprintf() prototype with
its own implementation's?

Placing stdio.h above those includes appears to have no effect.

For reference, the relevant part of C99:
 7.19.6.5 2 If n is zero, nothing is written, and s may be a null pointer.
 7.19.6.5 3 The snprintf function returns the number of characters that would have been written had n been sufficiently
large,not counting the terminating null character, or a neg ative value if an encoding error occurred.
 

Regards,

-- 
Kate


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: unixware and --with-ldap
Следующее
От: Tom Lane
Дата:
Сообщение: Re: snprintf()