s_copy.c 1.0 KB

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