首页 新闻 会员 周边

glibc中函数的定义

0
悬赏园豆:15 [已解决问题] 解决于 2013-10-21 13:19

char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
char c;

/* Find the end of the string. */
do
c = *s1++;
while (c != '\0');

/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;

do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');

return dest;
}

请问红色部分为什么要那么写,这个glibc中完整函数定义

问题补充:

/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <string.h>
#include <memcopy.h>

#undef strcat

/* Append SRC on the end of DEST. */
char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
char c;

/* Find the end of the string. */
do
c = *s1++;
while (c != '\0');

/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;

do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');

return dest;
}
libc_hidden_builtin_def (strcat)

没出没的主页 没出没 | 初学一级 | 园豆:8
提问于:2013-10-18 11:33
< >
分享
最佳答案
0

那是很久以前c语言还没标准化的时候参数的写法。

收获园豆:10
嗷嗷 | 小虾三级 |园豆:757 | 2013-10-18 17:09
其他回答(2)
0

能否贴完整点,红色部分语法都有错误。

Launcher | 园豆:45045 (高人七级) | 2013-10-18 11:43
0

旧的语法而已。

收获园豆:5
notfound1211 | 园豆:195 (初学一级) | 2013-10-20 18:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册