Re: Text <-> C string

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Text <-> C string
Дата
Msg-id 28064.1206467152@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Text <-> C string  ("Brendan Jurd" <direvus@gmail.com>)
Ответы Re: Text <-> C string  (Bruce Momjian <bruce@momjian.us>)
Re: Text <-> C string  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
"Brendan Jurd" <direvus@gmail.com> writes:
> On 26/03/2008, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ... What I think is more useful is
>> a strlcpy()-like function that copies into a caller-supplied buffer
>> of limited size.  For lack of a better idea I propose defining it
>> *exactly* like strlcpy:
>> 
>> extern size_t textlcpy(char *dst, const text *src, size_t siz);

> I'm all for providing a function with this behaviour, but is
> textlcpy() a bit ambiguous?

Fair enough, I'm not wedded to that name.  Search-and-replace is
still easy enough at this point ...

> A text_to_cstring_with_len() or text_to_cstring_limit() might be more
> to the point, and more consistent with the other functions in the
> family.

Hmm.  The thing that's bothering me is that the length is the size
of the *destination*, which is not like cstring_to_text_with_len,
so using a closely similar name might be confusing.  Of those two
I'd go with text_to_cstring_limit.  Another thought that comes to
mind is

void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)

Anyone have other ideas?
        regards, tom lane


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

Предыдущее
От: "Brendan Jurd"
Дата:
Сообщение: Re: Text <-> C string
Следующее
От: Kurt Roeckx
Дата:
Сообщение: Re: gcc 4.3 breaks ContribCheck in 8.2 and older.