s_cat.c
Go to the documentation of this file.
00001 /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the
00002  * target of a concatenation to appear on its right-hand side (contrary
00003  * to the Fortran 77 Standard, but in accordance with Fortran 90).
00004  */
00005 
00006 #include "f2c.h"
00007 #ifndef NO_OVERWRITE
00008 #include "stdio.h"
00009 #undef abs
00010 #ifdef KR_headers
00011  extern char *F77_aloc();
00012  extern void free();
00013  extern void exit_();
00014 #else
00015 #undef min
00016 #undef max
00017 #include "stdlib.h"
00018 extern
00019 #ifdef __cplusplus
00020         "C"
00021 #endif
00022         char *F77_aloc(ftnlen, const char*);
00023 #endif
00024 #include "string.h"
00025 #endif /* NO_OVERWRITE */
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031  VOID
00032 #ifdef KR_headers
00033 s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnint rnp[], *np; ftnlen ll;
00034 #else
00035 s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll)
00036 #endif
00037 {
00038         ftnlen i, nc;
00039         char *rp;
00040         ftnlen n = *np;
00041 #ifndef NO_OVERWRITE
00042         ftnlen L, m;
00043         char *lp0, *lp1;
00044 
00045         lp0 = 0;
00046         lp1 = lp;
00047         L = ll;
00048         i = 0;
00049         while(i < n) {
00050                 rp = rpp[i];
00051                 m = rnp[i++];
00052                 if (rp >= lp1 || rp + m <= lp) {
00053                         if ((L -= m) <= 0) {
00054                                 n = i;
00055                                 break;
00056                                 }
00057                         lp1 += m;
00058                         continue;
00059                         }
00060                 lp0 = lp;
00061                 lp = lp1 = F77_aloc(L = ll, "s_cat");
00062                 break;
00063                 }
00064         lp1 = lp;
00065 #endif /* NO_OVERWRITE */
00066         for(i = 0 ; i < n ; ++i) {
00067                 nc = ll;
00068                 if(rnp[i] < nc)
00069                         nc = rnp[i];
00070                 ll -= nc;
00071                 rp = rpp[i];
00072                 while(--nc >= 0)
00073                         *lp++ = *rp++;
00074                 }
00075         while(--ll >= 0)
00076                 *lp++ = ' ';
00077 #ifndef NO_OVERWRITE
00078         if (lp0) {
00079                 memcpy(lp0, lp1, L);
00080                 free(lp1);
00081                 }
00082 #endif
00083         }
00084 #ifdef __cplusplus
00085 }
00086 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:56