Subversion Repositories wimsdev

Rev

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

Rev 18108 Rev 18493
Line 1272... Line 1272...
1272
}
1272
}
1273
 
1273
 
1274
/* returns intersection of 2 lists */
1274
/* returns intersection of 2 lists */
1275
void calc_listintersect(char *p)
1275
void calc_listintersect(char *p)
1276
{
1276
{
1277
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1],lout[MAX_LINELEN+2];
1277
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1];
1278
  char *cut[MAX_LIST];
1278
  char *cut[MAX_LIST],*cut1[MAX_LIST],*cuts[MAX_LIST];
1279
  char *pp, *ll;
1279
  char *pp, *ll;
1280
  int i,n;
1280
  int i,j,k,n,m,s=0;
1281
 
-
 
1282
  pp=wordchr(p,"and");
1281
  pp=wordchr(p,"and");
1283
  if(pp==NULL) module_error("syntax_error");
1282
  if(pp==NULL) module_error("syntax_error");
1284
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("and"));
1283
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("and"));
1285
  lout[0]=lout[1]=0; substit(l1); substit(l2);
1284
  substit(l1); substit(l2);
1286
  n=cutitems(l1,cut,MAX_LIST); if(n<=0) {*p=0; return;}
1285
  n=cutitems(l2,cut,MAX_LIST); if(n<=0) {*p=0; return;}
-
 
1286
  m=cutitems(l1,cut1,MAX_LIST);
1287
  for(i=0;i<n;i++) {
1287
  for(i=0;i<n;i++) {
1288
    ll=cut[i];
1288
    ll=cut[i];
-
 
1289
    for(k=0;k<m;k++)
1289
    if(ll[0] && itemchr(l2,ll)!=NULL && itemchr(lout,ll)==NULL &&
1290
      if(!strcmp(cut1[k],ll)) break;
-
 
1291
    if (k==m) continue;
-
 
1292
    for(j=0;j<s;j++)
1290
      strlen(lout)+strlen(ll)<MAX_LINELEN-2) {
1293
      if(!strcmp(cuts[j],ll)) break;
1291
      strcat(lout,",");strcat(lout,ll);
1294
    if (j==s) cuts[s++]=ll;
1292
    }
1295
  }
1293
  }
1296
  p[0]=0;
-
 
1297
  for(i=0;i<s;i++){
-
 
1298
    if(i) strcat(p,",");
-
 
1299
    if(strlen(p)+strlen(cuts[i])<MAX_LINELEN-2)
1294
  ovlstrcpy(p,lout+1);
1300
    strcat(p,cuts[i]);
-
 
1301
  }
1295
}
1302
}
1296
 
1303
 
1297
/* returns union of 2 lists */
1304
/* returns union of 2 lists */
1298
void calc_listunion(char *p)
1305
void calc_listunion(char *p)
1299
{
1306
{
1300
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1],lout[MAX_LINELEN+2];
1307
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1];
1301
  char *cut[MAX_LIST];
1308
  char *cut[MAX_LIST],*cut1[MAX_LIST],*cuts[MAX_LIST];
1302
  char *pp, *ll;
1309
  char *pp, *ll;
1303
  int i,n;
1310
  int i,j,k,n,m,s=0;
1304
 
-
 
1305
  pp=wordchr(p,"and");
1311
  pp=wordchr(p,"and");
1306
  if(pp==NULL) module_error("syntax_error");
1312
  if(pp==NULL) module_error("syntax_error");
1307
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("and"));
1313
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("and"));
1308
  lout[0]=lout[1]=0; substit(l1); substit(l2);
1314
  substit(l1); substit(l2);
1309
  n=cutitems(l1,cut,MAX_LIST); for(i=0;i<n;i++) {
1315
  n=cutitems(l2,cut,MAX_LIST); if(n<=0) {*p=0; return;}
-
 
1316
  m=cutitems(l1,cut1,MAX_LIST);
-
 
1317
  for(i=0;i<n;i++) {
1310
    ll=cut[i];
1318
    ll=cut[i];
1311
    if(ll[0] && itemchr(lout,ll)==NULL &&
1319
    for(j=0;j<s;j++)
1312
        strlen(lout)+strlen(ll)<MAX_LINELEN-2) {
1320
      if(!strcmp(cuts[j],ll)) break;
1313
      strcat(lout,",");strcat(lout,ll);
1321
    if (j==s) cuts[s++]=ll;
1314
    }
-
 
1315
  }
1322
  }
1316
  n=cutitems(l2,cut,MAX_LIST); for(i=0;i<n;i++) {
1323
  for(k=0;k<m;k++) {
1317
    ll=cut[i];
1324
    ll=cut1[k];
1318
    if(ll[0] && itemchr(lout,ll)==NULL &&
1325
    for(j=0;j<s;j++)
1319
        strlen(lout)+strlen(ll)<MAX_LINELEN-2) {
1326
      if(!strcmp(cuts[j],ll)) break;
1320
      strcat(lout,",");strcat(lout,ll);
1327
    if(j==s) cuts[s++]=ll;
1321
    }
1328
  }
-
 
1329
  p[0]=0;
-
 
1330
  for(i=0;i<s;i++){
-
 
1331
    if(i) strcat(p,",");
-
 
1332
    if(strlen(p)+strlen(cuts[i])<MAX_LINELEN-2)
-
 
1333
    strcat(p,cuts[i]);
1322
  }
1334
  }
1323
  ovlstrcpy(p,lout+1);
-
 
1324
}
1335
}
1325
 
1336
 
1326
/* returns items of list2 not in list1 */
1337
/* returns items of list2 not in list1 */
1327
void calc_listcomplement(char *p)
1338
void calc_listcomplement(char *p)
1328
{
1339
{
1329
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1],lout[MAX_LINELEN+2];
1340
  char l1[MAX_LINELEN+1],l2[MAX_LINELEN+1];
1330
  char *cut[MAX_LIST];
1341
  char *cut[MAX_LIST],*cut1[MAX_LIST],*cuts[MAX_LIST];
1331
  char *pp, *ll;
1342
  char *pp, *ll;
1332
  int i,n;
1343
  int i,j,k,n,m,s=0;
1333
 
-
 
1334
  pp=wordchr(p,"in");
1344
  pp=wordchr(p,"in");
1335
  if(pp==NULL) module_error("syntax_error");
1345
  if(pp==NULL) module_error("syntax_error");
1336
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("in"));
1346
  *pp=0;ovlstrcpy(l1,p); ovlstrcpy(l2,pp+strlen("in"));
1337
  lout[0]=lout[1]=0; substit(l1); substit(l2);
1347
  substit(l1); substit(l2);
1338
  n=cutitems(l2,cut,MAX_LIST); if(n<=0) {*p=0; return;}
1348
  n=cutitems(l2,cut,MAX_LIST); if(n<=0) {*p=0; return;}
-
 
1349
  m=cutitems(l1,cut1,MAX_LIST);
1339
  for(i=0;i<n;i++) {
1350
  for(i=0;i<n;i++) {
1340
    ll=cut[i];
1351
    ll=cut[i];
-
 
1352
    for(j=0;j<s;j++)
1341
    if(ll[0] && itemchr(l1,ll)==NULL && itemchr(lout,ll)==NULL &&
1353
      if(!strcmp(cuts[j],ll)) break;
-
 
1354
    for(k=0;k<m;k++)
1342
        strlen(lout)+strlen(ll)<MAX_LINELEN-2) {
1355
      if(!strcmp(cut1[k],ll)) break;
1343
      strcat(lout,",");strcat(lout,ll);
1356
    if(j==s && k==m) cuts[s++]=ll;
1344
    }
1357
  }
-
 
1358
  p[0]=0;
-
 
1359
  for(i=0;i<s;i++){
-
 
1360
    if(i) strcat(p,",");
-
 
1361
    if(strlen(p)+strlen(cuts[i])<MAX_LINELEN-2)
-
 
1362
    strcat(p,cuts[i]);
1345
  }
1363
  }
1346
  ovlstrcpy(p,lout+1);
-
 
1347
}
1364
}
1348
 
1365
 
1349
/* Consult a dictionary to translate a string */
1366
/* Consult a dictionary to translate a string */
1350
/*
1367
/*
1351
void calc_dictionary(char *p)
1368
void calc_dictionary(char *p)