File: apply.c

package info (click to toggle)
magnus 20060324-5.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 19,436 kB
  • ctags: 20,462
  • sloc: cpp: 130,217; ansic: 37,090; tcl: 10,970; perl: 1,109; makefile: 966; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (144 lines) | stat: -rw-r--r-- 4,354 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* File apply.c */
#ifdef __DI
#include "tcyacc.h"
#endif
#include "apply.h"
Void
tc_apply(hcoset, beg, end, defflg, tc_pvar)
Int     hcoset;
Int     *beg;
Int     *end;
Logical	defflg;
struct  tc_str_vars     *tc_pvar;
{
#include "tc_void.h"
register Int	*forscan;
register Int	*backscan;
register Int	col;
register Int	i;
register Int	j;
register Int	ifront;
register Int	iback;
register Int 	ji;
register Int	k;
register Int	*ct;
register Int 	ncol;
/*
* subroutine to apply haselgrove-leech-trotter's method to a word
* starting at beg to end , applying coset
* hcoset at the beginning and end of the word and if defflg is .true.
* defining cosets to complete the tracing out of the word if needed.
*/

	{ Init; }
	ifront = iback = hcoset;
/* forward scan */
	for(forscan = beg; forscan <= end; forscan++) {
                i = CT(ifront, *forscan);

                if (i)
                	ifront = i;
                else
                	break;
        }
        if (Incomplete)
/* backward scan */
        for(backscan = end; backscan >= forscan; backscan--) {
                j = *backscan;
                ji = INV_TO_COL[j];
                i = CT(iback, ji);
                if (i)
                        iback = i;
                else if(backscan == forscan) {
/* the backward scan has only one gap so note the deduction to complete
* the cycle, and check for a new coincidence.
*/
                        CT(iback, ji) = ifront;
#ifdef __DI
        if (DIAG[7]) {
        int n,*pt_d;
        char ch;
        n = COL_TO_GEN[ji];
        fprintf(fout,"**** SD %d*",Addr2Num(iback));
        if(n < 0) {
                ch = Gen_st[-n].gen;
                fprintf(fout,"%c",toupper(ch));
        } else {
                ch = Gen_st[n].gen;
                fprintf(fout,"%c",ch);
        }
        fprintf(fout,"=%d",Addr2Num(ifront));
        fprintf(fout," S [");
        for(pt_d = beg; pt_d <= end; pt_d++) {
                n = COL_TO_GEN[*pt_d];
                if (pt_d == backscan)
                        fprintf(fout," ");
                if(n < 0) {
                        ch = Gen_st[-n].gen;
                        fprintf(fout,"%c",toupper(ch));
                } else {
                        ch = Gen_st[n].gen;
                        fprintf(fout,"%c",ch);
                }
        }
        fprintf(fout,"]\n");
        }
#endif
                        if(!VeryFirst) {
                                Save_ded(iback, ji);
			}
			if (CT(ifront, j)) {
                                ifront = CT(ifront, j);
                        } else {
                                CT(ifront, j) = iback;
                                ifront = iback;
                        }
                 } else if (defflg) {
/* obtain the next coset available sequentially. */
			if (&CT(NEXTDF,NCOL) >= DED_PT || NALIVE >= MAXROW) {
                                        Space_overflow;
			}
                        {       Get_cos(k);  }
                        { Fill_vac_in_rel(iback, ji, k,j); }
#ifdef __DI
        if (DIAG[7]) {
        int n,*pt_d;
        char ch;
        n = COL_TO_GEN[ji];
        fprintf(fout,"**** S  %d*",Addr2Num(iback));
        if(n < 0) {
                ch = Gen_st[-n].gen;
                fprintf(fout,"%c",toupper(ch));
        } else {
                ch = Gen_st[n].gen;
                fprintf(fout,"%c",ch);
        }
        fprintf(fout,"=%d",Addr2Num(k));
        fprintf(fout," S [");
        for(pt_d = beg; pt_d <= end; pt_d++) {
                n = COL_TO_GEN[*pt_d];
                if (pt_d == backscan)
                        fprintf(fout," ");
                if(n < 0) {
                        ch = Gen_st[-n].gen;
                        fprintf(fout,"%c",toupper(ch));
                } else {
                        ch = Gen_st[n].gen;
                        fprintf(fout,"%c",ch);
                }
        }
        fprintf(fout,"]\n");
        }
#endif
                        iback = k;
                } else 
/* in the case of defflg == FALSE do not define new cosets. */
			return; 
	} /* end of 'for(backscan.....)' */
/* -------------------------------------------------------------------
 * end of the relator scan, so note the equivalence of ifront and iback.  
*/
        if (ifront != iback) 
                tc_coinc(ifront, iback, tc_pvar);
	return;
}