Subversion Repositories wimsdev

Rev

Rev 8161 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8161 Rev 8195
Line 75... Line 75...
75
    {"words",   cmd_wordlist}
75
    {"words",   cmd_wordlist}
76
};
76
};
77
#define cmdcnt (sizeof(cmdlist)/sizeof(cmdlist[0]))
77
#define cmdcnt (sizeof(cmdlist)/sizeof(cmdlist[0]))
78
int cmd;
78
int cmd;
79
 
79
 
80
void error(char *msg,...)
80
void sym_error(char *msg,...)
81
{
81
{
82
    va_list vp;
82
    va_list vp;
83
    char buf[1024];
83
    char buf[1024];
84
 
84
 
85
    va_start(vp,msg);
85
    va_start(vp,msg);
Line 101... Line 101...
101
    t=0; if(buf) buf[0]=0;
101
    t=0; if(buf) buf[0]=0;
102
    if(stat(fname,&st)) return NULL;
102
    if(stat(fname,&st)) return NULL;
103
    l=st.st_size; if(l<0) return NULL;
103
    l=st.st_size; if(l<0) return NULL;
104
    if(l>=buflen) {
104
    if(l>=buflen) {
105
     if(buflen<MAX_LINELEN) l=buflen-1;
105
     if(buflen<MAX_LINELEN) l=buflen-1;
106
     else error("file_too_long %s",fname);
106
     else sym_error("file_too_long %s",fname);
107
    }
107
    }
108
    fd=open(fname,O_RDONLY); if(fd==-1) return NULL;
108
    fd=open(fname,O_RDONLY); if(fd==-1) return NULL;
109
    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;}}
110
    lc=read(fd,bf,l); close(fd);
110
    lc=read(fd,bf,l); close(fd);
111
    if(lc<0 || lc>l || (lc!=l && t==0))
111
    if(lc<0 || lc>l || (lc!=l && t==0))
Line 185... Line 185...
185
         }
185
         }
186
     }
186
     }
187
     p2++;p3=strchr(p2,'\n'); if(p3==NULL) p3=p2+strlen(p2);
187
     p2++;p3=strchr(p2,'\n'); if(p3==NULL) p3=p2+strlen(p2);
188
     p2=find_word_start(p2);
188
     p2=find_word_start(p2);
189
     if(p2>p3) goto nothing;
189
     if(p2>p3) goto nothing;
190
     if(p3-p2>=MAX_LINELEN) error("string_too_long def %s",name);
190
     if(p3-p2>=MAX_LINELEN) sym_error("string_too_long def %s",name);
191
     memmove(value,p2,p3-p2); value[p3-p2]=0;
191
     memmove(value,p2,p3-p2); value[p3-p2]=0;
192
     strip_trailing_spaces(value); return;
192
     strip_trailing_spaces(value); return;
193
    }
193
    }
194
nothing:
194
nothing:
195
    value[0]=0; return;
195
    value[0]=0; return;
Line 205... Line 205...
205
 
205
 
206
    if(buf==NULL) p=fnbuf; else p=buf;
206
    if(buf==NULL) p=fnbuf; else p=buf;
207
    va_start(vp,s);
207
    va_start(vp,s);
208
    vsnprintf(p,MAX_FNAME,s,vp);
208
    vsnprintf(p,MAX_FNAME,s,vp);
209
    va_end(vp);
209
    va_end(vp);
210
    if(strlen(p)>=MAX_FNAME-1) error("name_too_long %.20s",p);
210
    if(strlen(p)>=MAX_FNAME-1) sym_error("name_too_long %.20s",p);
211
    return p;
211
    return p;
212
}
212
}
213
 
213
 
214
void getparms(void)
214
void getparms(void)
215
{
215
{
Line 237... Line 237...
237
    if(p2>p && p2-p<sizeof(stbuf)) {
237
    if(p2>p && p2-p<sizeof(stbuf)) {
238
     memmove(stbuf,p,p2-p); stbuf[p2-p]=0;
238
     memmove(stbuf,p,p2-p); stbuf[p2-p]=0;
239
    }
239
    }
240
    i=search_list(cmdlist,cmdcnt,sizeof(cmdlist[0]),cmdbuf);
240
    i=search_list(cmdlist,cmdcnt,sizeof(cmdlist[0]),cmdbuf);
241
    if(i>=0) cmd=cmdlist[i].value;
241
    if(i>=0) cmd=cmdlist[i].value;
242
    else error("bad_command %.20s",cmdbuf);
242
    else sym_error("bad_command %.20s",cmdbuf);
243
    snprintf(cmdparm,sizeof(cmdparm),"%s",p2);
243
    snprintf(cmdparm,sizeof(cmdparm),"%s",p2);
244
 
244
 
245
    options=0;
245
    options=0;
246
    p=getenv("w_module_language"); if(p==NULL) p="";
246
    p=getenv("w_module_language"); if(p==NULL) p="";
247
    snprintf(lbuf,sizeof(lbuf),"%2s",p);
247
    snprintf(lbuf,sizeof(lbuf),"%2s",p);
Line 270... Line 270...
270
                snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",p,lbuf,style);
270
                snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",p,lbuf,style);
271
                if(stat(styledir,&st)) styledir[0]=0;
271
                if(stat(styledir,&st)) styledir[0]=0;
272
             }
272
             }
273
             if(styledir[0]==0) {      /* check default */
273
             if(styledir[0]==0) {      /* check default */
274
                snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",defaultdir,lbuf,style);
274
                snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",defaultdir,lbuf,style);
275
                if(stat(styledir,&st)) error("style_not_found %s",style);
275
                if(stat(styledir,&st)) sym_error("style_not_found %s",style);
276
             }
276
             }
277
          }
277
          }
278
      }
278
      }
279
      if(styledir[0]) {            /* get def */
279
      if(styledir[0]) {            /* get def */
280
          readfile(styledir,defbuf,sizeof(defbuf));
280
          readfile(styledir,defbuf,sizeof(defbuf));