diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-02-01 01:37:08 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-02-01 01:37:08 +0000 |
commit | a9fe81af3b8d02e1529b3f1f2a679b93cd9c36e1 (patch) | |
tree | 4b30cdf598ee6a8b24903fba52bb3e0c06bf459b /libf2c/libF77/s_cat.c | |
parent | 9682c2b47acc059592d168a09c7162f2bf333ee2 (diff) | |
download | gcc-a9fe81af3b8d02e1529b3f1f2a679b93cd9c36e1.tar.gz |
* Previous contents of gcc/f/runtime moved into toplevel
"libf2c" directory.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@17568 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libf2c/libF77/s_cat.c')
-rw-r--r-- | libf2c/libF77/s_cat.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libf2c/libF77/s_cat.c b/libf2c/libF77/s_cat.c new file mode 100644 index 00000000000..f462fd24945 --- /dev/null +++ b/libf2c/libF77/s_cat.c @@ -0,0 +1,75 @@ +/* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the + * target of a concatenation to appear on its right-hand side (contrary + * to the Fortran 77 Standard, but in accordance with Fortran 90). + */ + +#include "f2c.h" +#ifndef NO_OVERWRITE +#include <stdio.h> +#undef abs +#ifdef KR_headers + extern char *F77_aloc(); + extern void free(); + extern void G77_exit_0 (); +#else +#undef min +#undef max +#include <stdlib.h> + extern char *F77_aloc(ftnlen, char*); +#endif +#include <string.h> +#endif /* NO_OVERWRITE */ + + VOID +#ifdef KR_headers +s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnlen rnp[], *np, ll; +#else +s_cat(char *lp, char *rpp[], ftnlen rnp[], ftnlen *np, ftnlen ll) +#endif +{ + ftnlen i, nc; + char *rp; + ftnlen n = *np; +#ifndef NO_OVERWRITE + ftnlen L, m; + char *lp0, *lp1; + + lp0 = 0; + lp1 = lp; + L = ll; + i = 0; + while(i < n) { + rp = rpp[i]; + m = rnp[i++]; + if (rp >= lp1 || rp + m <= lp) { + if ((L -= m) <= 0) { + n = i; + break; + } + lp1 += m; + continue; + } + lp0 = lp; + lp = lp1 = F77_aloc(L = ll, "s_cat"); + break; + } + lp1 = lp; +#endif /* NO_OVERWRITE */ + for(i = 0 ; i < n ; ++i) { + nc = ll; + if(rnp[i] < nc) + nc = rnp[i]; + ll -= nc; + rp = rpp[i]; + while(--nc >= 0) + *lp++ = *rp++; + } + while(--ll >= 0) + *lp++ = ' '; +#ifndef NO_OVERWRITE + if (lp0) { + memcpy(lp0, lp1, L); + free(lp1); + } +#endif + } |