s_copy.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // command to get sanitizer error:
  12. // ya make -tAr --sanitize=address cv/imgclassifiers/danet/tests/minimize_memory_ut/ -F TMinimizeMemoryTest::TestMinimizeMemoryUsageModeTrain
  13. #if defined(__has_feature)
  14. # if __has_feature(address_sanitizer)
  15. __attribute__((no_sanitize("address")))
  16. # endif
  17. #endif
  18. #if defined(__has_feature)
  19. # if __has_feature(memory_sanitizer)
  20. __attribute__((no_sanitize("memory")))
  21. # endif
  22. #endif
  23. #ifdef KR_headers
  24. VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb;
  25. #else
  26. void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb)
  27. #endif
  28. {
  29. register char *aend, *bend;
  30. aend = a + la;
  31. if(la <= lb)
  32. #ifndef NO_OVERWRITE
  33. if (a <= b || a >= b + la)
  34. #endif
  35. while(a < aend)
  36. *a++ = *b++;
  37. #ifndef NO_OVERWRITE
  38. else
  39. for(b += la; a < aend; )
  40. *--aend = *--b;
  41. #endif
  42. else {
  43. bend = b + lb;
  44. #ifndef NO_OVERWRITE
  45. if (a <= b || a >= bend)
  46. #endif
  47. while(b < bend)
  48. *a++ = *b++;
  49. #ifndef NO_OVERWRITE
  50. else {
  51. a += lb;
  52. while(b < bend)
  53. *--a = *--bend;
  54. a += lb;
  55. }
  56. #endif
  57. while(a < aend)
  58. *a++ = ' ';
  59. }
  60. }
  61. #ifdef __cplusplus
  62. }
  63. #endif