2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libf2c / libF77 / s_copy.c
bloba91071eccab369c68f690412c2c030902164a1ce
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 */
7 #include "f2c.h"
9 /* assign strings: a = b */
11 void
12 s_copy (register char *a, register char *b, ftnlen la, ftnlen lb)
14 register char *aend, *bend;
16 aend = a + la;
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
30 else
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
41 a += lb;
42 while (b < bend)
43 *--a = *--bend;
44 a += lb;
46 #endif
47 while (a < aend)
48 *a++ = ' ';