Rev 8353 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8353 | Rev 8367 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | 21 | ||
22 | char primbuf[MAX_LINELEN+1]; |
22 | char primbuf[MAX_LINELEN+1]; |
23 | char *primitive[256]; |
23 | char *primitive[256]; |
24 | int primcnt, prepcnt; |
24 | int primcnt, prepcnt; |
25 | 25 | ||
26 | char * |
26 | char *_prim_if(char *p, int type) |
27 | { |
27 | { |
28 | char *p1, *p2, *p3, *p4, *p5, *p6; |
28 | char *p1, *p2, *p3, *p4, *p5, *p6; |
29 | char buf[MAX_LINELEN+1]; |
29 | char buf[MAX_LINELEN+1]; |
30 | p1=find_word_start(p); if(*p1!='{') return p; |
30 | p1=find_word_start(p); if(*p1!='{') return p; |
31 | p2=find_matching(p1+1,'}'); if(p2==NULL) return p; |
31 | p2=find_matching(p1+1,'}'); if(p2==NULL) return p; |
32 | p3=find_word_start(p2+1); if(*p3!='{') return p; |
32 | p3=find_word_start(p2+1); if(*p3!='{') return p; |
33 | p4=find_matching(p3+1,'}'); if(p4==NULL) return p; |
33 | p4=find_matching(p3+1,'}'); if(p4==NULL) return p; |
34 | *p2=0; snprintf(buf,sizeof(buf),"%s",p1+1); subst(buf); |
34 | *p2=0; snprintf(buf,sizeof(buf),"%s",p1+1); subst(buf); |
35 | prepcnt=0; parmprep(buf,pt_text); |
35 | prepcnt=0; parmprep(buf,pt_text); |
- | 36 | switch(type) { |
|
- | 37 | case 0: fprintf(outf," \n!if %s \n",buf); break; |
|
36 | fprintf(outf," \n |
38 | case 1: fprintf(outf," \n!ifval %s \n",buf); |
- | 39 | } |
|
37 | p5=find_word_start(p4+1); |
40 | p5=find_word_start(p4+1); |
38 | if(*p5=='{' && (p6=find_matching(p5+1,'}'))!=NULL) { |
41 | if(*p5=='{' && (p6=find_matching(p5+1,'}'))!=NULL) { |
39 | *p4=elsechar; *p5=' '; *p6=endifchar; |
42 | *p4=elsechar; *p5=' '; *p6=endifchar; |
40 | } |
43 | } |
41 | else *p4=endifchar; |
44 | else *p4=endifchar; |
42 | return p3+1; |
45 | return p3+1; |
43 | } |
46 | } |
- | 47 | ||
- | 48 | char *prim_if(char *p){ return _prim_if(p, 0); } |
|
- | 49 | char *prim_ifval(char *p){ return _prim_if(p, 1);} |
|
44 | 50 | ||
45 | char *prim_while(char *p) |
51 | char *prim_while(char *p) |
46 | { |
52 | { |
47 | char *p1, *p2, *p3, *p4; |
53 | char *p1, *p2, *p3, *p4; |
48 | char buf[MAX_LINELEN+1]; |
54 | char buf[MAX_LINELEN+1]; |
Line 70... | Line 76... | ||
70 | *p4=nextchar; |
76 | *p4=nextchar; |
71 | return p3+1; |
77 | return p3+1; |
72 | } |
78 | } |
73 | 79 | ||
74 | /* check whether the name is a document primitive. */ |
80 | /* check whether the name is a document primitive. */ |
75 | /* for the moment, only def define if for while or as in "msg2wims_primitives" |
81 | /* for the moment, only def define if ifval for while or as in "msg2wims_primitives" |
76 | * description of primitive must be in primitive_dir="docu/primitives" |
82 | * description of primitive must be in primitive_dir="docu/primitives" |
77 | * msg2wims_primitives is defined in two places: |
83 | * msg2wims_primitives is defined in two places: |
78 | * public_html/modules/adm/doc/var.proc and public_html/scripts/docu/mkindex |
84 | * public_html/modules/adm/doc/var.proc and public_html/scripts/docu/mkindex |
79 | * should be elsewhere at least for primitives defined here |
85 | * should be elsewhere at least for primitives defined here |
80 | * that is "def define if for while" |
86 | * that is "def define if ifval for while" |
81 | */ |
87 | */ |
82 | 88 | ||
83 | char *doccheck(char *p) |
89 | char *doccheck(char *p) |
84 | { |
90 | { |
85 | char *pe, *pl, *pv, *pp, namebuf[128], parbuf[8192]; |
91 | char *pe, *pl, *pv, *pp, namebuf[128], parbuf[8192]; |
Line 99... | Line 105... | ||
99 | memmove(parmbuf,pl,pv-pl); parmbuf[pv-pl]=0; |
105 | memmove(parmbuf,pl,pv-pl); parmbuf[pv-pl]=0; |
100 | def(parmbuf); |
106 | def(parmbuf); |
101 | pe=pv+1; return pe; |
107 | pe=pv+1; return pe; |
102 | } |
108 | } |
103 | if(strcmp(namebuf,"if")==0) return prim_if(pe); |
109 | if(strcmp(namebuf,"if")==0) return prim_if(pe); |
- | 110 | if(strcmp(namebuf,"ifval")==0) return prim_ifval(pe); |
|
104 | if(strcmp(namebuf,"for")==0) return prim_for(pe); |
111 | if(strcmp(namebuf,"for")==0) return prim_for(pe); |
105 | if(strcmp(namebuf,"while")==0) return prim_while(pe); |
112 | if(strcmp(namebuf,"while")==0) return prim_while(pe); |
106 | fprintf(outf,"\n!read primitives.phtml %d, %s",primserial++,namebuf); |
113 | fprintf(outf,"\n!read primitives.phtml %d, %s",primserial++,namebuf); |
107 | for(t=0;t<16;t++) { |
114 | for(t=0;t<16;t++) { |
108 | pl=find_word_start(pe); |
115 | pl=find_word_start(pe); |