Subversion Repositories wimsdev

Rev

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

Rev 15336 Rev 15375
Line 25... Line 25...
25
 
25
 
26
#define MAX_LANGS    MAX_LANGUAGES
26
#define MAX_LANGS    MAX_LANGUAGES
27
#define MAX_MODULES    65536
27
#define MAX_MODULES    65536
28
char *moduledir=    "public_html/modules";
28
char *moduledir=    "public_html/modules";
29
char *sheetdir=     "public_html/bases/sheet";
29
char *sheetdir=     "public_html/bases/sheet";
-
 
30
char *glossarydir=  "public_html/scripts/data/glossary";
30
char *dicdir=       "public_html/bases";
31
char *dicdir=       "public_html/bases";
31
char *outdir=       "public_html/bases/site2";
32
char *outdir=       "public_html/bases/site2";
32
char *sheetoutdir=  "public_html/bases/sheet/index";
33
char *sheetoutdir=  "public_html/bases/sheet/index";
-
 
34
char *glossaryoutdir=  "public_html/scripts/data/glossary/index";
33
char *maindic=      "sys/words";
35
char *maindic=      "sys/words";
34
char *groupdic=     "sys/wgrp/wgrp";
36
char *groupdic=     "sys/wgrp/wgrp";
35
char *suffixdic=    "sys/suffix";
37
char *suffixdic=    "sys/suffix";
36
char *domaindic=    "sys/domaindic";
38
char *domaindic=    "sys/domaindic";
37
char *ignoredic=    "sys/indignore";
39
char *ignoredic=    "sys/indignore";
Line 160... Line 162...
160
  char *pp;
162
  char *pp;
161
  for(pp=strchr(p,','); pp; pp=strchr(pp+1,','))
163
  for(pp=strchr(p,','); pp; pp=strchr(pp+1,','))
162
    string_modify3(p,pp,pp+1,", ");
164
    string_modify3(p,pp,pp+1,", ");
163
}
165
}
164
 
166
 
-
 
167
/* _getdef from lines.c except the error msg*/
165
void _getdef(char buf[], char *name, char value[])
168
void _getdef(char buf[], char *name, char value[])
166
{
169
{
167
  char *p1, *p2, *p3;
170
  char *p1, *p2, *p3, *p4;
168
 
171
 
169
  value[0]=0;
172
  if(*name==0) goto nothing;      /* this would create segfault. */
170
  for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) {
173
  for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) {
171
    p2=find_word_start(p1+strlen(name));
174
    p2=find_word_start(p1+strlen(name));
172
    if((p1>buf && !isspace(*(p1-1))) || *p2!='=') continue;
175
    if((p1>buf && !isspace(*(p1-1))) || *p2!='=') continue;
173
    p3=p1; while(p3>buf && isspace(*(p3-1)) && *(p3-1)!='\n') p3--;
176
    p3=p1; while(p3>buf && *(p3-1)!='\n') p3--;
-
 
177
    p3=find_word_start(p3);
174
    if(p3>buf && *(p3-1)!='\n') continue;
178
    if(p3<p1 && *p3!='!') continue;
-
 
179
    if(p3<p1) {
-
 
180
      p3++; p4=find_word_end(p3);
-
 
181
      if(find_word_start(p4)!=p1) continue;
-
 
182
      if(p4-p3!=3 || (strncmp(p3,"set",3)!=0 &&
175
    p3=strchr(p2,'\n');
183
           strncmp(p3,"let",3)!=0 &&
-
 
184
           strncmp(p3,"def",3)!=0)) {
-
 
185
        if(p4-p3!=6 || strncmp(p3,"define",6)!=0) continue;
-
 
186
      }
-
 
187
    }
-
 
188
    p2++;p3=strchr(p2,'\n'); if(p3==NULL) p3=p2+strlen(p2);
176
    p2=find_word_start(p2+1);
189
    p2=find_word_start(p2);
177
    if(p3 <= p2) continue;
190
    if(p2>p3) goto nothing;
178
    snprintf(value,MAX_LINELEN,"%s",p2);
191
    /*if(p3-p2>=MAX_LINELEN) user_error("cmd_output_too_long");*/
179
    if(p3!=NULL && p3-p2<MAX_LINELEN) value[p3-p2]=0;
192
    memmove(value,p2,p3-p2); value[p3-p2]=0;
180
    strip_trailing_spaces2(value);
193
    strip_trailing_spaces(value); return;
181
    break;
-
 
182
  }
194
  }
-
 
195
nothing:
-
 
196
  value[0]=0; return;
183
}
197
}
184
 
198
 
185
/*  Get variable definition from a file.
199
/*  Get variable definition from a file.
186
 * Result stored in buffer value of length MAX_LINELEN.
200
 * Result stored in buffer value of length MAX_LINELEN.
187
 */
201
 */
Line 310... Line 324...
310
    l=p2-p1; if(*p2) *p2++=0;
324
    l=p2-p1; if(*p2) *p2++=0;
311
    for(i=0;i<langcnt;i++) if(strncasecmp(lang[i],p1,2)==0) break;
325
    for(i=0;i<langcnt;i++) if(strncasecmp(lang[i],p1,2)==0) break;
312
    if(i<langcnt) thislang=i; else continue;
326
    if(i<langcnt) thislang=i; else continue;
313
    mod[modcnt].name=p1;
327
    mod[modcnt].name=p1;
314
    mod[modcnt].langs[0]=thislang;
328
    mod[modcnt].langs[0]=thislang;
-
 
329
    mod[modcnt].langcnt=1;
-
 
330
    modcnt++;
-
 
331
  }
-
 
332
}
-
 
333
 
-
 
334
void gprep(void)
-
 
335
{
-
 
336
  char *p1,*p2,*s;
-
 
337
  int l,i;
-
 
338
  modcnt=0;
-
 
339
  s=getenv("glist"); if(s==NULL) return;
-
 
340
  l=strlen(s); if(l<0 || l>100*MAX_LINELEN) return;
-
 
341
  mlist=xmalloc(l+16); ovlstrcpy(mlist,s);
-
 
342
  for(p1=find_word_start(mlist); *p1 && modcnt<MAX_MODULES; p1=find_word_start(p2)) {
-
 
343
    p2=find_word_end(p1);
-
 
344
    if(*p2) *p2++=0;
-
 
345
    s=strchr(p1,'/');
-
 
346
    if(s != NULL) s=strchr(s+1,'/');
-
 
347
    if(s==NULL) {
-
 
348
      fprintf(stderr,"modind: no language %s\n",p1); exit(1);
-
 
349
    }
-
 
350
    s++;
-
 
351
    for(i=0;i<langcnt;i++) if(strncasecmp(lang[i],s,2)==0) break;
-
 
352
    if(i==langcnt) continue;
-
 
353
    mod[modcnt].name=p1;
-
 
354
    mod[modcnt].langs[0]=i;
315
    mod[modcnt].langcnt=1;
355
    mod[modcnt].langcnt=1;
316
    modcnt++;
356
    modcnt++;
317
  }
357
  }
318
}
358
}
319
 
359
 
Line 327... Line 367...
327
  "title", "description",
367
  "title", "description",
328
  "duration", "severity",
368
  "duration", "severity",
329
  "level", "domain",
369
  "level", "domain",
330
  "keywords", "reserved1", "reserved2", "information"
370
  "keywords", "reserved1", "reserved2", "information"
331
};
371
};
-
 
372
/* correspond to the order of sheetindex */
-
 
373
char *glindex[]={
-
 
374
  "gl_title", "gl_description",
-
 
375
  "", "",
-
 
376
  "gl_level", "gl_domain",
-
 
377
  "gl_keywords","","",""};
-
 
378
 
332
#define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0]))
379
#define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0]))
333
char sindbuf[SHEETINDEX_NO][MAX_LINELEN+1];
380
char gsindbuf[SHEETINDEX_NO][MAX_LINELEN+1];
-
 
381
 
-
 
382
/* do not modify the order, correspond to the order in the sheet file */
334
enum{s_title, s_description,
383
enum{s_title, s_description,
335
      s_duration, s_severity,
384
      s_duration, s_severity,
336
      s_level, s_domain,
385
      s_level, s_domain,
337
      s_keywords, s_reserved1, s_reserved2,
386
      s_keywords, s_reserved1, s_reserved2,
338
      s_information
387
      s_information
Line 400... Line 449...
400
 
449
 
401
  snprintf(fbuf,sizeof(fbuf),"%s/%s.def",sheetdir,mod[serial].name);
450
  snprintf(fbuf,sizeof(fbuf),"%s/%s.def",sheetdir,mod[serial].name);
402
  indf=fopen(fbuf,"r"); if(indf==NULL) return -1;
451
  indf=fopen(fbuf,"r"); if(indf==NULL) return -1;
403
  l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf);
452
  l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf);
404
  if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1;
453
  if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1;
405
  for(i=0;i<SHEETINDEX_NO;i++) sindbuf[i][0]=0;
454
  for(i=0;i<SHEETINDEX_NO;i++) gsindbuf[i][0]=0;
406
  for(i=0,p1=find_word_start(ibuf);
455
  for(i=0,p1=find_word_start(ibuf);
407
      i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0;
456
      i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0;
408
      i++,p1=p2) {
457
      i++,p1=p2) {
409
    p2=strchr(p1,'\n');
458
    p2=strchr(p1,'\n');
410
    if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
459
    if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
411
    p1=find_word_start(p1); strip_trailing_spaces2(p1);
460
    p1=find_word_start(p1); strip_trailing_spaces2(p1);
412
    snprintf(sindbuf[i],MAX_LINELEN,"%s",p1);
461
    snprintf(gsindbuf[i],MAX_LINELEN,"%s",p1);
413
  }
462
  }
414
  p2=strstr(p1,"\n:"); if(p2==NULL) p2=p1+strlen(p1);
463
  p2=strstr(p1,"\n:"); if(p2==NULL) p2=p1+strlen(p1);
415
  else *p2=0;
464
  else *p2=0;
416
  p1=find_word_start(p1); strip_trailing_spaces2(p1);
465
  p1=find_word_start(p1); strip_trailing_spaces2(p1);
417
  for(p2=p1;*p2;p2++) if(*p2=='\n') *p2=' ';
466
  for(p2=p1;*p2;p2++) if(*p2=='\n') *p2=' ';
418
  ovlstrcpy(sindbuf[s_information],p1);
467
  ovlstrcpy(gsindbuf[s_information],p1);
-
 
468
  return 0;
-
 
469
}
-
 
470
 
-
 
471
int glossary_index(int serial)
-
 
472
{
-
 
473
  char fbuf[MAX_LINELEN+1], ibuf[MAX_LINELEN+1];
-
 
474
  FILE *indf;
-
 
475
  int i,l;
-
 
476
  snprintf(fbuf,sizeof(fbuf),"%s/%s",glossarydir,mod[serial].name);
-
 
477
  indf=fopen(fbuf,"r");
-
 
478
  l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf);
-
 
479
  if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1;
-
 
480
  for(i=0;i<SHEETINDEX_NO;i++) {
-
 
481
    _getdef(ibuf,glindex[i],gsindbuf[i]);
-
 
482
  }
419
  return 0;
483
  return 0;
420
}
484
}
421
 
485
 
422
unsigned char categories[16];
486
unsigned char categories[16];
423
char taken[MAX_LINELEN+1];
487
char taken[MAX_LINELEN+1];
Line 476... Line 540...
476
  i_title,i_description,i_category,i_domain,i_keywords,
540
  i_title,i_description,i_category,i_domain,i_keywords,
477
  i_require,i_author,
541
  i_require,i_author,
478
  i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl,
542
  i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl,
479
  i_title_ca,i_title_en,i_title_fr,i_title_it,i_title_nl
543
  i_title_ca,i_title_en,i_title_fr,i_title_it,i_title_nl
480
  };
544
  };
481
  #define trcnt (sizeof(trlist)/sizeof(trlist[0]))
545
  int trcnt=sizeof(trlist)/sizeof(trlist[0]);
482
  char *p1, *p2, *pp, *q, buf[MAX_LINELEN+1], lbuf[16];
546
  char *p1, *p2, *pp, *q, buf[MAX_LINELEN+1], lbuf[16];
483
  FILE *f;
547
  FILE *f;
484
 
548
 
485
  if(module_index(name)) return;
549
  if(module_index(name)) return;
486
  towords(indbuf[i_category]);
550
  towords(indbuf[i_category]);
Line 616... Line 680...
616
  char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1];
680
  char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1];
617
 
681
 
618
  for(j=0;j<langcnt;j++) {
682
  for(j=0;j<langcnt;j++) {
619
    snprintf(namebuf,sizeof(namebuf),"%s/weight.%s",outdir,lang[j]);
683
    snprintf(namebuf,sizeof(namebuf),"%s/weight.%s",outdir,lang[j]);
620
    weightf=fopen(namebuf,"w");
684
    weightf=fopen(namebuf,"w");
621
    snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]);
685
    snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]);
622
    snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]);
686
    snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]);
623
    snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]);
687
    snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]);
624
    snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]);
688
    snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]);
625
    suffix_dic(sdic); prepare_dic(gdic);
689
    suffix_dic(sdic); prepare_dic(gdic);
626
    gdicbuf=dicbuf; gentrycount=entrycount;
690
    gdicbuf=dicbuf; gentrycount=entrycount;
627
    memmove(gentry,entry,gentrycount*sizeof(entry[0]));
691
    memmove(gentry,entry,gentrycount*sizeof(entry[0]));
628
    prepare_dic(mdic);
692
    prepare_dic(mdic);
629
    mdicbuf=dicbuf; mentrycount=entrycount;
693
    mdicbuf=dicbuf; mentrycount=entrycount;
630
    memmove(mentry,entry,mentrycount*sizeof(entry[0]));
694
    memmove(mentry,entry,mentrycount*sizeof(entry[0]));
631
    prepare_dic(ddic);
695
    prepare_dic(ddic);
632
    ddicbuf=dicbuf; dentrycount=entrycount;
696
    ddicbuf=dicbuf; dentrycount=entrycount;
633
    memmove(dentry,entry,dentrycount*sizeof(entry[0]));
697
    memmove(dentry,entry,dentrycount*sizeof(entry[0]));
634
    unknown_type=unk_leave; translate(ignore[j]);
698
    unknown_type=unk_leave; translate(ignore[j]);
Line 650... Line 714...
650
    if(mentrycount>0) free(mdicbuf);
714
    if(mentrycount>0) free(mdicbuf);
651
    if(gentrycount>0) free(gdicbuf);
715
    if(gentrycount>0) free(gdicbuf);
652
    if(suffixcnt>0) free(sufbuf);
716
    if(suffixcnt>0) free(sufbuf);
653
    if(dentrycount>0) free(ddicbuf);
717
    if(dentrycount>0) free(ddicbuf);
654
    if(weightf) fclose(weightf);
718
    if(weightf) fclose(weightf);
655
  }
719
  }
656
}
720
}
657
 
721
 
658
/* FIXME ? differences with appenditem - use fprintf instead of  snprintf */
722
/* FIXME ? differences with appenditem - use fprintf instead of  snprintf */
659
void sappenditem(char *word, int lind, int serial, int weight)
723
void sappenditem(char *word, int lind, int serial, int weight)
660
{
724
{
661
  int ll;
725
  int ll;
662
  char *p;
726
  char *p;
Line 672... Line 736...
672
  ovlstrcpy(taken+takenlen,word);
736
  ovlstrcpy(taken+takenlen,word);
673
  takenlen+=ll; tweight+=weight;
737
  takenlen+=ll; tweight+=weight;
674
  fprintf(indf,"%s:%d?%d\n",word,serial,weight);
738
  fprintf(indf,"%s:%d?%d\n",word,serial,weight);
675
}
739
}
676
 
740
 
677
void onesheet(int serial, int lind)
741
void onesg(int serial, int lind, int index(int))
678
{
742
{
679
  int i;
743
  int i;
680
  unsigned char trlist[]={
744
  unsigned char trlist[]={
681
  s_title,s_description,s_domain,s_keywords,s_information
745
    s_title,s_description,s_domain,s_keywords,s_information
682
  };
746
  };
683
  #define trcnt (sizeof(trlist)/sizeof(trlist[0]))
747
  int rcnt=sizeof(trlist)/sizeof(trlist[0]);
684
  char *p1, *p2, buf[MAX_LINELEN+1];
748
  char *p1, *p2, buf[MAX_LINELEN+1];
685
 
749
 
686
  if(sheet_index(serial)) return;
750
  if(index(serial)) return;
687
  fprintf(listf,"%s\n",mod[serial].name+3);
751
  fprintf(listf,"%s\n",mod[serial].name);
688
  fprintf(titf,"%d:%s\n",serial,sindbuf[s_title]);
752
  fprintf(titf,"%d:%s\n",serial,gsindbuf[s_title]);
689
  fprintf(descf,"%d:%s\n",serial,sindbuf[s_description]);
753
  fprintf(descf,"%d:%s\n",serial,gsindbuf[s_description]);
690
  fprintf(remf,"%d:%s\n",serial,sindbuf[s_information]);
754
  fprintf(remf,"%d:%s\n",serial,gsindbuf[s_information]);
691
  fprintf(titlef,"%s:%s\n",mod[serial].name,sindbuf[s_title]);
755
  fprintf(titlef,"%s:%s\n",mod[serial].name,gsindbuf[s_title]);
692
 
756
 
693
  entrycount=dentrycount; dicbuf=ddicbuf;
757
  entrycount=dentrycount; dicbuf=ddicbuf;
694
  memmove(entry,dentry,dentrycount*sizeof(entry[0]));
758
  memmove(entry,dentry,dentrycount*sizeof(entry[0]));
695
  unknown_type=unk_leave;
759
  unknown_type=unk_leave;
696
  for(i=0;i<trcnt;i++) {
760
  for(i=0;i<rcnt;i++) {
697
    detag(sindbuf[trlist[i]]);
761
    detag(gsindbuf[trlist[i]]);
698
    deaccent2(sindbuf[trlist[i]]);
762
    deaccent2(gsindbuf[trlist[i]]);
699
    comma(sindbuf[trlist[i]]);
763
    comma(gsindbuf[trlist[i]]);
700
    singlespace2(sindbuf[trlist[i]]);
764
    singlespace2(gsindbuf[trlist[i]]);
701
    translate(sindbuf[trlist[i]]);
765
    translate(gsindbuf[trlist[i]]);
702
  }
766
  }
703
 
767
 
704
  entrycount=mentrycount; dicbuf=mdicbuf;
768
  entrycount=mentrycount; dicbuf=mdicbuf;
705
  memmove(entry,mentry,mentrycount*sizeof(entry[0]));
769
  memmove(entry,mentry,mentrycount*sizeof(entry[0]));
706
  unknown_type=unk_leave;
770
  unknown_type=unk_leave;
707
  for(i=0;i<trcnt;i++) {
771
  for(i=0;i<rcnt;i++) {
708
    suffix_translate(sindbuf[trlist[i]]);
772
    suffix_translate(gsindbuf[trlist[i]]);
709
    translate(sindbuf[trlist[i]]);
773
    translate(gsindbuf[trlist[i]]);
710
  }
774
  }
711
  taken[0]=0; takenlen=tweight=0;
775
  taken[0]=0; takenlen=tweight=0;
712
  ovlstrcpy(buf,sindbuf[s_title]); towords(buf);
776
  ovlstrcpy(buf,gsindbuf[s_title]); towords(buf);
713
  for(p1=find_word_start(buf);*p1;
777
  for(p1=find_word_start(buf);*p1;
714
      p1=find_word_start(p2)) {
778
      p1=find_word_start(p2)) {
715
    p2=find_word_end(p1); if(*p2) *p2++=0;
779
    p2=find_word_end(p1); if(*p2) *p2++=0;
716
    sappenditem(p1,lind,serial,4);
780
    sappenditem(p1,lind,serial,4);
717
  }
781
  }
718
  snprintf(buf,sizeof(buf),"%s %s %s %s",
782
  snprintf(buf,sizeof(buf),"%s %s %s %s",
719
         sindbuf[s_description],sindbuf[s_keywords],
783
         gsindbuf[s_description],gsindbuf[s_keywords],
720
         sindbuf[s_domain],sindbuf[s_information]);
784
         gsindbuf[s_domain],gsindbuf[s_information]);
721
  towords(buf);
785
  towords(buf);
722
  for(p1=find_word_start(buf);*p1;
786
  for(p1=find_word_start(buf);*p1;p1=find_word_start(p2)) {
723
  p1=find_word_start(p2)) {
-
 
724
  p2=find_word_end(p1); if(*p2) *p2++=0;
787
    p2=find_word_end(p1); if(*p2) *p2++=0;
725
  sappenditem(p1,lind,serial,2);
788
    sappenditem(p1,lind,serial,2);
726
  }
789
  }
727
  entrycount=gentrycount; dicbuf=gdicbuf;
790
  entrycount=gentrycount; dicbuf=gdicbuf;
728
  memmove(entry,gentry,gentrycount*sizeof(entry[0]));
791
  memmove(entry,gentry,gentrycount*sizeof(entry[0]));
729
  unknown_type=unk_delete;
792
  unknown_type=unk_delete;
730
  ovlstrcpy(buf,sindbuf[s_title]); translate(buf);
793
  ovlstrcpy(buf,gsindbuf[s_title]); translate(buf);
731
  for(p1=find_word_start(buf); *p1;
794
  for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
732
  p1=find_word_start(p2)) {
-
 
733
  p2=strchr(p1,',');
795
    p2=strchr(p1,',');
734
  if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
796
    if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
735
  if(strlen(p1)<=0) continue;
797
    if(strlen(p1)<=0) continue;
736
  sappenditem(p1,lind,serial,4);
798
    sappenditem(p1,lind,serial,4);
737
  }
799
  }
738
  unknown_type=unk_leave;
800
  unknown_type=unk_leave;
739
  snprintf(buf,sizeof(buf),"%s, %s",
801
  snprintf(buf,sizeof(buf),"%s, %s",
740
       sindbuf[s_keywords],
802
       gsindbuf[s_keywords],
741
       sindbuf[s_domain]);
803
       gsindbuf[s_domain]);
742
  translate(buf);
804
  translate(buf);
743
  for(p1=find_word_start(buf); *p1;
805
  for(p1=find_word_start(buf); *p1;
744
  p1=find_word_start(p2)) {
806
  p1=find_word_start(p2)) {
745
    p2=strchr(p1,',');
807
    p2=strchr(p1,',');
746
    if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
808
    if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1);
Line 748... Line 810...
748
    sappenditem(p1,lind,serial,2);
810
    sappenditem(p1,lind,serial,2);
749
  }
811
  }
750
  fprintf(weightf,"%d:%d\n",serial,tweight);
812
  fprintf(weightf,"%d:%d\n",serial,tweight);
751
}
813
}
752
 
814
 
753
void sheets(void)
815
void sgs(char *outdir, int index(int))
754
{
816
{
755
  int i,j;
817
  int i,j;
756
  char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1];
818
  char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1];
757
  char buf[MAX_LINELEN+1];
819
  char buf[MAX_LINELEN+1];
758
 
820
 
759
  for(j=0;j<langcnt;j++) {
821
  for(j=0;j<langcnt;j++) {
760
    snprintf(buf,sizeof(buf),"%s/title.%s",sheetoutdir,lang[j]);
822
    snprintf(buf,sizeof(buf),"%s/title.%s",outdir,lang[j]);
761
    titf=fopen(buf,"w");
823
    titf=fopen(buf,"w");
762
    snprintf(buf,sizeof(buf),"%s/description.%s",sheetoutdir,lang[j]);
824
    snprintf(buf,sizeof(buf),"%s/description.%s",outdir,lang[j]);
763
    descf=fopen(buf,"w");
825
    descf=fopen(buf,"w");
764
    snprintf(buf,sizeof(buf),"%s/%s",sheetoutdir,lang[j]);
826
    snprintf(buf,sizeof(buf),"%s/%s",outdir,lang[j]);
765
    indf=fopen(buf,"w");
827
    indf=fopen(buf,"w");
766
    snprintf(buf,sizeof(buf),"%s/list.%s",sheetoutdir,lang[j]);
828
    snprintf(buf,sizeof(buf),"%s/list.%s",outdir,lang[j]);
767
    listf=fopen(buf,"w");
829
    listf=fopen(buf,"w");
768
    snprintf(buf,sizeof(buf),"%s/weight.%s",sheetoutdir,lang[j]);
830
    snprintf(buf,sizeof(buf),"%s/weight.%s",outdir,lang[j]);
769
    weightf=fopen(buf,"w");
831
    weightf=fopen(buf,"w");
770
    snprintf(buf,sizeof(buf),"%s/addr.%s",sheetoutdir,lang[j]);
832
    snprintf(buf,sizeof(buf),"%s/addr.%s",outdir,lang[j]);
771
    addrf=fopen(buf,"w");
833
    addrf=fopen(buf,"w");
772
    snprintf(buf,sizeof(buf),"%s/information.%s",sheetoutdir,lang[j]);
834
    snprintf(buf,sizeof(buf),"%s/information.%s",outdir,lang[j]);
773
    remf=fopen(buf,"w");
835
    remf=fopen(buf,"w");
774
    snprintf(buf,sizeof(buf),"%s/serial.%s",sheetoutdir,lang[j]);
836
    snprintf(buf,sizeof(buf),"%s/serial.%s",outdir,lang[j]);
775
    serialf=fopen(buf,"w");
837
    serialf=fopen(buf,"w");
776
    snprintf(buf,sizeof(buf),"%s/tit.%s",sheetoutdir,lang[j]);
838
    snprintf(buf,sizeof(buf),"%s/tit.%s",outdir,lang[j]);
777
    titlef=fopen(buf,"w");
839
    titlef=fopen(buf,"w");
778
    if(!titlef || !serialf || !remf || !addrf || !weightf || !listf
840
    if(!titlef || !serialf || !remf || !addrf || !weightf || !listf
779
      || !indf || !descf || !titf ) {
841
      || !indf || !descf || !titf ) {
780
    fprintf(stderr,"modind: error creating output files for sheet %s.\n",sheetoutdir); exit(1);
842
    fprintf(stderr,"modind: error creating output files for %s.\n",outdir); exit(1);
781
    }
843
    }
782
    snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]);
844
    snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]);
783
    snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]);
845
    snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]);
784
    snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]);
846
    snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]);
785
    snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]);
847
    snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]);
Line 793... Line 855...
793
    ddicbuf=dicbuf; dentrycount=entrycount;
855
    ddicbuf=dicbuf; dentrycount=entrycount;
794
    memmove(dentry,entry,dentrycount*sizeof(entry[0]));
856
    memmove(dentry,entry,dentrycount*sizeof(entry[0]));
795
    unknown_type=unk_leave; translate(ignore[j]);
857
    unknown_type=unk_leave; translate(ignore[j]);
796
    for(i=0;i<modcnt;i++) {
858
    for(i=0;i<modcnt;i++) {
797
      if(mod[i].langs[0]!=j) continue;
859
      if(mod[i].langs[0]!=j) continue;
798
      fprintf(addrf,"%d:%s\n",i,mod[i].name+3);
860
      fprintf(addrf,"%d:%s\n",i,mod[i].name);
799
      fprintf(serialf,"%s:%d\n",mod[i].name+3,i);
861
      fprintf(serialf,"%s:%d\n",mod[i].name,i);
800
      onesheet(i,j);
862
      onesg(i,j,index);
801
    }
863
    }
802
    if(mentrycount>0) free(mdicbuf);
864
    if(mentrycount>0) free(mdicbuf);
803
    if(gentrycount>0) free(gdicbuf);
865
    if(gentrycount>0) free(gdicbuf);
804
    if(suffixcnt>0) free(sufbuf);
866
    if(suffixcnt>0) free(sufbuf);
805
    if(dentrycount>0) free(ddicbuf);
867
    if(dentrycount>0) free(ddicbuf);
Line 815... Line 877...
815
  mentry=xmalloc(entry_size);
877
  mentry=xmalloc(entry_size);
816
  prep();
878
  prep();
817
  if(modcnt>0) modules();
879
  if(modcnt>0) modules();
818
  clean();
880
  clean();
819
  sprep();
881
  sprep();
820
  if(modcnt>0) sheets();
882
  if(modcnt>0) sgs(sheetoutdir,sheet_index);
-
 
883
  clean();
-
 
884
  gprep();
-
 
885
  if(modcnt>0) sgs(glossaryoutdir,glossary_index);
821
  return 0;
886
  return 0;
822
}
887
}
823
 
-