s_copy.c

来自「InsightToolkit-1.4.0(有大量的优化算法程序)」· C语言 代码 · 共 54 行

C
54
字号
/* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the
 * target of an assignment to appear on its right-hand side (contrary
 * to the Fortran 77 Standard, but in accordance with Fortran 90),
 * as in  a(2:5) = a(4:7) .
 */

#include "f2c.h"
#include "netlib.h"

/* assign strings:  a = b */

#ifdef KR_headers
VOID s_copy(a, b, la, lb) register char *a; register const char *b; ftnlen la, lb;
#else
void s_copy(register char *a, register const char *b, ftnlen la, ftnlen lb)
#endif
{
        register char *aend;
        register const char *bend;

        aend = a + la;

        if(la <= lb)
#ifndef NO_OVERWRITE
                if (a <= b || a >= b + la)
#endif
                        while(a < aend)
                                *a++ = *b++;
#ifndef NO_OVERWRITE
                else
                        for(b += la; a < aend; )
                                *--aend = *--b;
#endif

        else {
                bend = b + lb;
#ifndef NO_OVERWRITE
                if (a <= b || a >= bend)
#endif
                        while(b < bend)
                                *a++ = *b++;
#ifndef NO_OVERWRITE
                else {
                        a += lb;
                        while(b < bend)
                                *--a = *--bend;
                        a += lb;
                        }
#endif
                while(a < aend)
                        *a++ = ' ';
                }
        }

⌨️ 快捷键说明

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