Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / s_cat.c
1 /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the
2  * target of a concatenation to appear on its right-hand side (contrary
3  * to the Fortran 77 Standard, but in accordance with Fortran 90).
4  */
5
6 #include "clapack.h"
7 #include "stdio.h"
8 #undef abs
9 #undef min
10 #undef max
11 #include "stdlib.h"
12 #include "string.h"
13
14 void s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll)
15 {
16     ftnlen i, nc;
17     char *rp;
18     ftnlen n = *np;
19     ftnlen L, m;
20     char *lp0, *lp1;
21
22     lp0 = 0;
23     lp1 = lp;
24     L = ll;
25     i = 0;
26     while(i < n) {
27         rp = rpp[i];
28         m = rnp[i++];
29         if (rp >= lp1 || rp + m <= lp) {
30             if ((L -= m) <= 0) {
31                 n = i;
32                 break;
33             }
34             lp1 += m;
35             continue;
36         }
37         lp0 = lp;
38         lp = lp1 = F77_aloc(L = ll, "s_cat");
39         break;
40     }
41     lp1 = lp;
42     for(i = 0 ; i < n ; ++i) {
43         nc = ll;
44         if(rnp[i] < nc)
45             nc = rnp[i];
46         ll -= nc;
47         rp = rpp[i];
48         while(--nc >= 0)
49             *lp++ = *rp++;
50     }
51     while(--ll >= 0)
52         *lp++ = ' ';
53     if (lp0) {
54         memcpy(lp0, lp1, L);
55         free(lp1);
56     }
57 }