]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/libf2c/libF77/s_copy.c
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / libf2c / libF77 / s_copy.c
1 /* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the
2  * target of an assignment to appear on its right-hand side (contrary
3  * to the Fortran 77 Standard, but in accordance with Fortran 90),
4  * as in  a(2:5) = a(4:7) .
5  */
6
7 #include "f2c.h"
8
9 /* assign strings:  a = b */
10
11 void
12 s_copy (register char *a, register char *b, ftnlen la, ftnlen lb)
13 {
14   register char *aend, *bend;
15
16   aend = a + la;
17
18   if (la <= lb)
19 #ifndef NO_OVERWRITE
20     if (a <= b || a >= b + la)
21 #endif
22       while (a < aend)
23         *a++ = *b++;
24 #ifndef NO_OVERWRITE
25     else
26       for (b += la; a < aend;)
27         *--aend = *--b;
28 #endif
29
30   else
31     {
32       bend = b + lb;
33 #ifndef NO_OVERWRITE
34       if (a <= b || a >= bend)
35 #endif
36         while (b < bend)
37           *a++ = *b++;
38 #ifndef NO_OVERWRITE
39       else
40         {
41           a += lb;
42           while (b < bend)
43             *--a = *--bend;
44           a += lb;
45         }
46 #endif
47       while (a < aend)
48         *a++ = ' ';
49     }
50 }