File: s_copy.c

package info (click to toggle)
insighttoolkit 3.6.0-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 94,956 kB
  • ctags: 74,981
  • sloc: cpp: 355,621; ansic: 195,070; fortran: 28,713; python: 3,802; tcl: 1,996; sh: 1,175; java: 583; makefile: 415; csh: 184; perl: 175
file content (58 lines) | stat: -rw-r--r-- 1,430 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 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 "v3p_f2c.h"
#ifdef __cplusplus
extern "C" {
#endif

/* assign strings:  a = b */

#ifdef KR_headers
int s_copy(a, b, la, lb) char *a, *b; ftnlen la, lb;
#else
int s_copy(char *a, char *b, ftnlen la, ftnlen lb)
#endif
{
        register char *aend, *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++ = ' ';
                }
        return 0;
        }
#ifdef __cplusplus
}
#endif