当前位置: 技术问答>linux和unix
标准库问题
来源: 互联网 发布时间:2015-03-22
本文导语: 我想找ansi c的标准库 想看它的函数是怎么写的 可不是glibc呀 它也用了标准库的。 | glib-2.2.5 sysdefs/generic/strcpy.c /* Copy SRC to DEST. */ char * strcpy (dest, src) char *dest; const ch...
我想找ansi c的标准库 想看它的函数是怎么写的
可不是glibc呀 它也用了标准库的。
可不是glibc呀 它也用了标准库的。
|
glib-2.2.5
sysdefs/generic/strcpy.c
/* Copy SRC to DEST. */
char *
strcpy (dest, src)
char *dest;
const char *src;
{
reg_char c;
char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
size_t n;
do
{
c = *s++;
s[off] = c;
}
while (c != '');
n = s - src;
(void) CHECK_BOUNDS_HIGH (src + n);
(void) CHECK_BOUNDS_HIGH (dest + n);
return dest;
}
sysdefs/generic/strcpy.c
/* Copy SRC to DEST. */
char *
strcpy (dest, src)
char *dest;
const char *src;
{
reg_char c;
char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
size_t n;
do
{
c = *s++;
s[off] = c;
}
while (c != '');
n = s - src;
(void) CHECK_BOUNDS_HIGH (src + n);
(void) CHECK_BOUNDS_HIGH (dest + n);
return dest;
}