freebsd-skq/contrib/libf2c/libF77/s_copy.c

51 lines
893 B
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
/* 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"
/* assign strings: a = b */
2003-07-11 03:42:19 +00:00
void
s_copy (register char *a, register char *b, ftnlen la, ftnlen lb)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
register char *aend, *bend;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
aend = a + la;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
if (la <= lb)
1999-09-18 10:51:31 +00:00
#ifndef NO_OVERWRITE
2003-07-11 03:42:19 +00:00
if (a <= b || a >= b + la)
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
while (a < aend)
*a++ = *b++;
1999-09-18 10:51:31 +00:00
#ifndef NO_OVERWRITE
2003-07-11 03:42:19 +00:00
else
for (b += la; a < aend;)
*--aend = *--b;
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
else
{
bend = b + lb;
1999-09-18 10:51:31 +00:00
#ifndef NO_OVERWRITE
2003-07-11 03:42:19 +00:00
if (a <= b || a >= bend)
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
while (b < bend)
*a++ = *b++;
1999-09-18 10:51:31 +00:00
#ifndef NO_OVERWRITE
2003-07-11 03:42:19 +00:00
else
{
a += lb;
while (b < bend)
*--a = *--bend;
a += lb;
1999-09-18 10:51:31 +00:00
}
2003-07-11 03:42:19 +00:00
#endif
while (a < aend)
*a++ = ' ';
}
}