Re: [AD] Unicode (3)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> This wouldn't bloat the library: we would basically have 1 function
> [ustrzncpy()] and 3 wrappers.

Actually 2 functions and 2 wrappers, like with the current code.
This solution will hopefully satisfy everybody: the non 'z' functions are
strictly ANSI C compliant and the 'z' functions are the interesting ones ;-)

Excerpt from the docs:

char *ustrcpy(char *dest, const char *src);
This function copies src (including the terminating NULL character) into
dest. The return value is the value of dest.

char *ustrzcpy(char *dest, int size, const char *src);
This function copies src (including the terminating NULL character) into
dest, whose length in bytes is specified by size and which is guaranteed to
be NULL-terminated. The return value is the value of dest.

char *ustrcat(char *dest, const char *src);
This function concatenates src to the end of dest. The return value is the
value of dest.

char *ustrzcat(char *dest, int size, const char *src);
This function concatenates src to the end of dest, whose length in bytes is
specified by size and which is guaranteed to be NULL-terminated. The return
value is the value of dest.

char *ustrncpy(char *dest, const char *src, int n);
This function is like ustrcpy() except that no more than n characters from
src are copied into dest. If src is shorter than n characters, NULL
characters are appended to dest as padding until n characters have been
written. Note that if src is longer than n characters, dest will not be
NULL-terminated. The return value is the value of dest.

char *ustrzncpy(char *dest, int size, const char *src, int n);
This function is like ustrzcpy() except that no more than n characters from
src are copied into dest. If src is shorter than n characters, NULL
characters are appended to dest as padding until n characters have been
written. Note that dest is guaranteed to be NULL-terminated. The return
value is the value of dest.

char *ustrncat(char *dest, const char *src, int n);
This function is like ustrcat() except that no more than n characters from
src are appended to the end of dest. If the terminating NULL character in
src is reached before n characters have been written, the NULL character is
copied, but no other characters are written. If n characters are written
before a terminating NULL is encountered, the function appends its own NULL
character to dest, so that n+1 characters are written. The return value is
the value of dest.

char *ustrzncat(char *dest, int size, const char *src, int n);
This function is like ustrzcat() except that no more than n characters from
src are appended to the end of dest. If the terminating NULL character in
src is reached before n characters have been written, the NULL character is
copied, but no other characters are written. Note that dest is guaranteed to
be NULL-terminated. The return value is the value of dest.

int usprintf(char *buf, const char *format, ...);
This function writes formatted data into the output buffer. A NULL character
is written to mark the end of the string. Returns the number of characters
written, not including the terminating NULL character.

int uszprintf(char *buf, int size, const char *format, ...);
This function writes formatted data into the output buffer, whose length in
bytes is specified by size and which is guaranteed to be NULL-terminated.
Returns the number of characters that would have been written without
eventual truncation (like with usprintf), not including the terminating NULL
character.

int uvsprintf(char *buf, const char *format, va_list args);
This is like usprintf(), but you pass the variable argument list directly,
instead of the arguments themselves.

int uvszprintf(char *buf, int size, const char *format, va_list args);
This is like uszprintf(), but you pass the variable argument list directly,
instead of the arguments themselves.

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/