move.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 49 行

C
49 行
字号
static char Sccsid[] "@(#)move	3.1";/*	Copies `n' characters from string `a' to string `b'.*/struct { int *ip; };char *move(a,b,n)char *a,*b;unsigned n;{	register char *x, *y;	register int m;	/*		Test for non-zero number of characters to move	*/	if (m=n) {		x = a;		y = b;		/*			Compare the low order bits of the two pointers			If both are equal (both even or both odd) then			move words instead of bytes		*/		if (((x^y)&(char *)1) == 0) {			/*				If both odd move one byte to make both even			*/			if (x&(char *)1) {				*y++ = *x++;				n--;			}			/*				Add one to n/2 so that we can use --m instead				of m--; --m is more efficient			*/			for (m=n/2+1; --m; )				*(y.ip)++ = *(x.ip)++;			m = n&1;		}		/*			Add one to m so that we can use --m instead of m--;			--m is more eficient.		*/		for (++m; --m; ) *y++ = *x++;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?