|
|
||
|
On Mar 04, 2004, at 16:19, Luiz Henrique de Figueiredo wrote:
I wrote a simple (public-domain) implementation of most of the
functions from
the standard C library that are needed by the Lua core. Unfortunately,
it
does not contain vsprinf, but there must be a public-domain or
MIT-licencsed
implementation of it somewhere.
--lhf
/*
* libc.c
* functions from the standard C library that are needed by the Lua core
*/
char *strncpy(char *d, const char *s, size_t n)
{
char *t=d;
while (n-- && (*t++=*s++)) ;
return d;
}
The ISO C strncpy is required to always write exactly n chars into the destination (null characters are appended). This fact is not nearly well enough known. Presumably you know for sure, but I doubt that Lua relies on this null padding.
Also, many of the prototypes are not C99 compliant, but that is really the standard's fault, not yours.
David Jones