c@427: /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the c@427: * target of a concatenation to appear on its right-hand side (contrary c@427: * to the Fortran 77 Standard, but in accordance with Fortran 90). c@427: */ c@427: c@427: #include "f2c.h" c@427: #ifndef NO_OVERWRITE c@427: #include "stdio.h" c@427: #undef abs c@427: #ifdef KR_headers c@427: extern char *F77_aloc(); c@427: extern void free(); c@427: extern void exit_(); c@427: #else c@427: #undef min c@427: #undef max c@427: #include "stdlib.h" c@427: extern c@427: #ifdef __cplusplus c@427: "C" c@427: #endif c@427: char *F77_aloc(ftnlen, const char*); c@427: #endif c@427: #include "string.h" c@427: #endif /* NO_OVERWRITE */ c@427: c@427: #ifdef __cplusplus c@427: extern "C" { c@427: #endif c@427: c@427: VOID c@427: #ifdef KR_headers c@427: s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnint rnp[], *np; ftnlen ll; c@427: #else c@427: s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll) c@427: #endif c@427: { c@427: ftnlen i, nc; c@427: char *rp; c@427: ftnlen n = *np; c@427: #ifndef NO_OVERWRITE c@427: ftnlen L, m; c@427: char *lp0, *lp1; c@427: c@427: lp0 = 0; c@427: lp1 = lp; c@427: L = ll; c@427: i = 0; c@427: while(i < n) { c@427: rp = rpp[i]; c@427: m = rnp[i++]; c@427: if (rp >= lp1 || rp + m <= lp) { c@427: if ((L -= m) <= 0) { c@427: n = i; c@427: break; c@427: } c@427: lp1 += m; c@427: continue; c@427: } c@427: lp0 = lp; c@427: lp = lp1 = F77_aloc(L = ll, "s_cat"); c@427: break; c@427: } c@427: lp1 = lp; c@427: #endif /* NO_OVERWRITE */ c@427: for(i = 0 ; i < n ; ++i) { c@427: nc = ll; c@427: if(rnp[i] < nc) c@427: nc = rnp[i]; c@427: ll -= nc; c@427: rp = rpp[i]; c@427: while(--nc >= 0) c@427: *lp++ = *rp++; c@427: } c@427: while(--ll >= 0) c@427: *lp++ = ' '; c@427: #ifndef NO_OVERWRITE c@427: if (lp0) { c@427: memcpy(lp0, lp1, L); c@427: free(lp1); c@427: } c@427: #endif c@427: } c@427: #ifdef __cplusplus c@427: } c@427: #endif