| 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 |
#ifdef __cplusplus |
| 9 |
extern "C" { |
| 10 |
#endif |
| 11 |
|
| 12 |
/* assign strings: a = b */ |
| 13 |
|
| 14 |
#ifdef KR_headers |
| 15 |
VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb; |
| 16 |
#else |
| 17 |
void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb) |
| 18 |
#endif |
| 19 |
{ |
| 20 |
register char *aend, *bend; |
| 21 |
|
| 22 |
aend = a + la; |
| 23 |
|
| 24 |
if(la <= lb) |
| 25 |
#ifndef NO_OVERWRITE |
| 26 |
if (a <= b || a >= b + la) |
| 27 |
#endif |
| 28 |
while(a < aend) |
| 29 |
*a++ = *b++; |
| 30 |
#ifndef NO_OVERWRITE |
| 31 |
else |
| 32 |
for(b += la; a < aend; ) |
| 33 |
*--aend = *--b; |
| 34 |
#endif |
| 35 |
|
| 36 |
else { |
| 37 |
bend = b + lb; |
| 38 |
#ifndef NO_OVERWRITE |
| 39 |
if (a <= b || a >= bend) |
| 40 |
#endif |
| 41 |
while(b < bend) |
| 42 |
*a++ = *b++; |
| 43 |
#ifndef NO_OVERWRITE |
| 44 |
else { |
| 45 |
a += lb; |
| 46 |
while(b < bend) |
| 47 |
*--a = *--bend; |
| 48 |
a += lb; |
| 49 |
} |
| 50 |
#endif |
| 51 |
while(a < aend) |
| 52 |
*a++ = ' '; |
| 53 |
} |
| 54 |
} |
| 55 |
#ifdef __cplusplus |
| 56 |
} |
| 57 |
#endif |