Subversion Repositories wimsdev

Rev

Rev 8122 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8122 Rev 8161
Line 32... Line 32...
32
 
32
 
33
 
33
 
34
const char *codechar="_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
34
const char *codechar="_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
35
 
35
 
36
#include "symtext.h"
36
#include "symtext.h"
37
#include "../../Lib/liblines.c"
-
 
38
 
37
 
39
struct block blockbuf[MAX_BLOCKS];
38
struct block blockbuf[MAX_BLOCKS];
40
int nextblock;
39
int nextblock;
41
listtype listbuf[MAX_LISTS];
40
listtype listbuf[MAX_LISTS];
42
int nextlist;
41
int nextlist;
Line 45... Line 44...
45
 
44
 
46
struct poolstruct poolbuf[MAX_POOLS];
45
struct poolstruct poolbuf[MAX_POOLS];
47
int nextpool;
46
int nextpool;
48
 
47
 
49
int options;
48
int options;
50
#define op_nocase    (1<<0)
-
 
51
#define op_deaccent  (1<<1)
-
 
52
#define op_reaccent  (1<<2)
-
 
53
#define op_nopunct   (1<<3)
-
 
54
#define op_nomath    (1<<4)
-
 
55
#define op_noparenth (1<<5)
-
 
56
#define op_nocs      (1<<6)
-
 
57
#define op_noquote   (1<<7)
-
 
58
#define op_matchall  (1<<8)
-
 
59
#define op_alphaonly (1<<9)
-
 
60
#define op_alnumonly (1<<10)
-
 
61
 
49
 
62
char cmdbuf[256], stbuf[MAX_LINELEN+1], textbuf[MAX_LINELEN+1];
50
char cmdbuf[256], stbuf[MAX_LINELEN+1], textbuf[MAX_LINELEN+1];
63
char wbuf[MAX_LINELEN+1];
51
char wbuf[MAX_LINELEN+1];
64
char cmdparm[1024];
52
char cmdparm[1024];
65
char defbuf[MAX_LINELEN+1];
53
char defbuf[MAX_LINELEN+1];
66
char style[MAX_NAMELEN+1];
54
char style[MAX_NAMELEN+1];
67
char styledir[MAX_FNAME+1];
55
char styledir[MAX_FNAME+1];
68
char optionbuf[1024];
56
char optionbuf[1024];
69
char outbuf[4096];
57
char outbuf[OUTSIZE];
70
char *outptr, *wptr;
58
char *outptr, *wptr;
71
int debug;
59
int debug;
72
 
60
 
73
enum {
61
enum {
74
    cmd_none, cmd_comp, cmd_debug, cmd_random, cmd_1, cmd_wordlist
62
    cmd_none, cmd_comp, cmd_debug, cmd_random, cmd_1, cmd_wordlist
Line 97... Line 85...
97
    va_start(vp,msg);
85
    va_start(vp,msg);
98
    vsnprintf(buf,sizeof(buf),msg,vp);
86
    vsnprintf(buf,sizeof(buf),msg,vp);
99
    va_end(vp);
87
    va_end(vp);
100
    printf("ERROR\n%s\n",buf);
88
    printf("ERROR\n%s\n",buf);
101
    exit(1);
89
    exit(1);
102
}
-
 
103
 
-
 
104
void _error(char *msg)
-
 
105
{
-
 
106
    error(msg);
-
 
107
}
90
}
108
 
91
 
109
/* read-in a file into buffer. Use open() and read().
92
/* read-in a file into buffer. Use open() and read().
110
 * Return buffer address which will be malloc'ed if buf=NULL.
93
 * Return buffer address which will be malloc'ed if buf=NULL.
111
 */
94
 */
Line 119... Line 102...
119
    if(stat(fname,&st)) return NULL;
102
    if(stat(fname,&st)) return NULL;
120
    l=st.st_size; if(l<0) return NULL;
103
    l=st.st_size; if(l<0) return NULL;
121
    if(l>=buflen) {
104
    if(l>=buflen) {
122
     if(buflen<MAX_LINELEN) l=buflen-1;
105
     if(buflen<MAX_LINELEN) l=buflen-1;
123
     else error("file_too_long %s",fname);
106
     else error("file_too_long %s",fname);
124
    }
107
    }
125
    fd=open(fname,O_RDONLY); if(fd==-1) return NULL;
108
    fd=open(fname,O_RDONLY); if(fd==-1) return NULL;
126
    if(buf==NULL) bf=xmalloc(l+8); else {bf=buf;if(l==0) {t=1; l=buflen-1;}}
109
    if(buf==NULL) bf=xmalloc(l+8); else {bf=buf;if(l==0) {t=1; l=buflen-1;}}
127
    lc=read(fd,bf,l); close(fd);
110
    lc=read(fd,bf,l); close(fd);
128
    if(lc<0 || lc>l || (lc!=l && t==0))
111
    if(lc<0 || lc>l || (lc!=l && t==0))
129
      {if(buf==NULL) free(bf); else buf[0]=0; return NULL;}
112
      {if(buf==NULL) free(bf); else buf[0]=0; return NULL;}
Line 148... Line 131...
148
      if(*p3==' ') {
131
      if(*p3==' ') {
149
         p3=find_word_start(p3);
132
         p3=find_word_start(p3);
150
         switch(*p3) {
133
         switch(*p3) {
151
            case '"': {
134
            case '"': {
152
              p4=strchr(p3+1,'"');
135
              p4=strchr(p3+1,'"');
153
              goto tested;
136
              goto tested;
154
            }
137
            }
155
            case '(': {
138
            case '(': {
156
              p4=find_matching(p3+1,')');
139
              p4=find_matching(p3+1,')');
157
              goto tested;
140
              goto tested;
158
            }
141
            }
159
            case '[': {
142
            case '[': {
Line 208... Line 191...
208
     memmove(value,p2,p3-p2); value[p3-p2]=0;
191
     memmove(value,p2,p3-p2); value[p3-p2]=0;
209
     strip_trailing_spaces(value); return;
192
     strip_trailing_spaces(value); return;
210
    }
193
    }
211
nothing:
194
nothing:
212
    value[0]=0; return;
195
    value[0]=0; return;
213
}
196
}
214
 
197
 
215
char fnbuf[MAX_FNAME+1];
198
char fnbuf[MAX_FNAME+1];
216
 
199
 
217
/* make a filename and check length */
200
/* make a filename and check length */
218
char *mkfname(char buf[], char *s,...)
201
char *mkfname(char buf[], char *s,...)
219
{
202
{
220
    va_list vp;
203
    va_list vp;
221
    char *p;
204
    char *p;
222
 
205
 
223
    if(buf==NULL) p=fnbuf; else p=buf;
206
    if(buf==NULL) p=fnbuf; else p=buf;
224
    va_start(vp,s);
207
    va_start(vp,s);
225
    vsnprintf(p,MAX_FNAME,s,vp);
208
    vsnprintf(p,MAX_FNAME,s,vp);
226
    va_end(vp);
209
    va_end(vp);
227
    if(strlen(p)>=MAX_FNAME-1) error("name_too_long %.20s",p);
210
    if(strlen(p)>=MAX_FNAME-1) error("name_too_long %.20s",p);
228
    return p;
211
    return p;
229
}
212
}
230
 
-
 
231
 
-
 
232
#include "translate.c"
-
 
233
#include "match.c"
-
 
234
#include "compile.c"
-
 
235
 
213
 
236
void getparms(void)
214
void getparms(void)
237
{
215
{
238
    char *p, *p2, *p3, lbuf[8];
216
    char *p, *p2, *p3, lbuf[8];
239
    char buf[MAX_LINELEN+1], pbuf[MAX_LINELEN+1];
217
    char buf[MAX_LINELEN+1], pbuf[MAX_LINELEN+1];
Line 344... Line 322...
344
    if(verify_order(builtin,builtincnt,sizeof(builtin[0]))) return -1;
322
    if(verify_order(builtin,builtincnt,sizeof(builtin[0]))) return -1;
345
    if(verify_order(cmdlist,cmdcnt,sizeof(cmdlist[0]))) return -1;
323
    if(verify_order(cmdlist,cmdcnt,sizeof(cmdlist[0]))) return -1;
346
 
324
 
347
    return 0;
325
    return 0;
348
}
326
}
349
void (*string_modify)(char *start, char *bad_beg, char *bad_end, char *good,...)=string_modify1;
-
 
350
 
327
 
351
int main(int argc, char *argv[])
328
int main(int argc, char *argv[])
352
{
329
{
353
    int i, n, mat;
330
    int i, n, mat;
354
    char *p1, *p2;
331
    char *p1, *p2;
Line 359... Line 336...
359
         printf("Table orders OK.\n");
336
         printf("Table orders OK.\n");
360
         return 0;
337
         return 0;
361
      }
338
      }
362
      else return 1;
339
      else return 1;
363
    }
340
    }
364
    error1=error2=_error; debug=0;
341
    debug=0;
365
    wptr=wbuf; wbuf[0]=0;
342
    wptr=wbuf; wbuf[0]=0;
366
    getparms();
343
    getparms();
367
    Mnext=Mbuf; Mcnt=0;
344
    Mnext=Mbuf; Mcnt=0;
368
    switch(cmd) {
345
    switch(cmd) {
369
      case cmd_comp: {
346
      case cmd_comp: {