Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
s_cat.c
Go to the documentation of this file.00001 #include "stdlib.h"
00002
00003
00004
00005
00006
00007 #include "f2c.h"
00008 #ifndef NO_OVERWRITE
00009 #include "stdio.h"
00010 #undef abs
00011 #ifdef KR_headers
00012 extern char *F77_aloc();
00013 extern void free();
00014 extern void exit_();
00015 #else
00016 #include "stdlib.h"
00017 extern char *F77_aloc(ftnlen, char*);
00018 #endif
00019 #include "string.h"
00020 #endif
00021
00022 VOID
00023 #ifdef KR_headers
00024 s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnlen rnp[], *np, ll;
00025 #else
00026 s_cat(char *lp, char *rpp[], ftnlen rnp[], ftnlen *np, ftnlen ll)
00027 #endif
00028 {
00029 ftnlen i, nc;
00030 char *rp;
00031 ftnlen n = *np;
00032 #ifndef NO_OVERWRITE
00033 ftnlen L, m;
00034 char *lp0, *lp1;
00035
00036 lp0 = 0;
00037 lp1 = lp;
00038 L = ll;
00039 i = 0;
00040 while(i < n) {
00041 rp = rpp[i];
00042 m = rnp[i++];
00043 if (rp >= lp1 || rp + m <= lp) {
00044 if ((L -= m) <= 0) {
00045 n = i;
00046 break;
00047 }
00048 lp1 += m;
00049 continue;
00050 }
00051 lp0 = lp;
00052 lp = lp1 = F77_aloc(L = ll, "s_cat");
00053 break;
00054 }
00055 lp1 = lp;
00056 #endif
00057 for(i = 0 ; i < n ; ++i) {
00058 nc = ll;
00059 if(rnp[i] < nc)
00060 nc = rnp[i];
00061 ll -= nc;
00062 rp = rpp[i];
00063 while(--nc >= 0)
00064 *lp++ = *rp++;
00065 }
00066 while(--ll >= 0)
00067 *lp++ = ' ';
00068 #ifndef NO_OVERWRITE
00069 if (lp0) {
00070 memcpy(lp0, lp1, L);
00071 free(lp1);
00072 }
00073 #endif
00074 }