Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
not.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define revno   (sizeof(revtab)/sizeof(revtab[0]))

Functions

void _not (char *p)
void req_not (void)

Variables

struct {
char * orig
char * reverse
revtab []

Define Documentation

#define revno   (sizeof(revtab)/sizeof(revtab[0]))

Definition at line 32 of file not.c.


Function Documentation

void _not ( char *  p)

Definition at line 35 of file not.c.

{
    char buf1[MAX_LINELEN+1], bufr[MAX_LINELEN+1];
    char buft[16];
    int commas[MAX_COMMAS], cmcnt;
    char *pp;
    int i, l;
    
    snprintf(buf1,sizeof(buf1),"%s",find_word_start(p));
    retype:
    if(buf1[0]==0) {*p=0; return;} /* empty */
    strip_trailing_spaces(buf1);
    switch(_type(buf1,commas,&cmcnt)) {
       case exp_paren: {
           if(buf1[0]=='(' && find_matching(buf1+1,')')==buf1+strlen(buf1)-1) {
              buf1[strlen(buf1)-1]=0; strcpy(buf1,find_word_start(buf1+1));
              goto retype;
           }
           snprintf(p,MAX_LINELEN,"not %s",buf1); return;
       }
       case exp_not: {
           if(strncasecmp(buf1,"not",3)!=0) error("Syntax error.");
           pp=find_word_start(buf1+3);
           if(*pp=='(' && find_matching(pp+1,')')==pp+strlen(pp)-1) {
              pp++; *(pp+strlen(pp)-1)=0;
           }
           snprintf(p,MAX_LINELEN,"%s",pp); return;
       }
       case exp_ineq:
       case exp_eq: {
           if(cmcnt!=2 || commas[1]-commas[0]>4) error("Syntax error.");
           memmove(buft,buf1+commas[0],commas[1]-commas[0]);
           buft[commas[1]-commas[0]]=0;
           for(i=0;i<revno && strcmp(buft,revtab[i].orig)!=0;i++);
           if(i>=revno) error("Software bug: bad sign.");
           string_modify(buf1,buf1+commas[0],buf1+commas[1],revtab[i].reverse);
           snprintf(p,MAX_LINELEN,"%s",buf1);
           return;
       }
       case exp_and: {
           if(cmcnt<2 || (cmcnt&1)!=0) error("Syntax error.");
           commas[cmcnt]=strlen(buf1);
           memmove(bufr,buf1,commas[0]); bufr[commas[0]]=0;
           _not(bufr); snprintf(p,MAX_LINELEN,"%s",bufr); l=strlen(p);
           for(i=1;i<=cmcnt/2;i++) {
              memmove(bufr,buf1+commas[2*i-1],commas[2*i]-commas[2*i-1]);
              bufr[commas[2*i]-commas[2*i-1]]=0;
              _not(bufr);
              snprintf(p+l,MAX_LINELEN-l," or %s",bufr); l=strlen(p);
           }
           return;
       }
       case exp_or: {
           int commas2[MAX_COMMAS], cmcnt2;
           if(cmcnt<2 || (cmcnt&1)!=0) error("Syntax error.");
           commas[cmcnt]=strlen(buf1);
           memmove(bufr,buf1,commas[0]); bufr[commas[0]]=0;
           _not(bufr); 
           if(_type(bufr,commas2,&cmcnt2)!=exp_or)
             snprintf(p,MAX_LINELEN,"%s",bufr); 
           else snprintf(p,MAX_LINELEN,"(%s)",bufr); 
           l=strlen(p);
           for(i=1;i<=cmcnt/2;i++) {
              memmove(bufr,buf1+commas[2*i-1],commas[2*i]-commas[2*i-1]);
              bufr[commas[2*i]-commas[2*i-1]]=0;
              _not(bufr);
              if(_type(bufr,commas2,&cmcnt2)!=exp_or)
                snprintf(p+l,MAX_LINELEN-l," and %s",bufr); 
              else snprintf(p+l,MAX_LINELEN-l," and (%s)",bufr); 
              l=strlen(p);
           }
           return;
       }
       case exp_imply: {
           
           
       }
       case exp_quantifier: {
           
           
       }
       default: {
           snprintf(p,MAX_LINELEN,"not(%s)",buf1); return;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void req_not ( void  )

Definition at line 123 of file not.c.

{
    int i;
    char *p, *ld;
    char nbuf[MAX_LINELEN+1];
    if(objlinecnt<2) return;
    for(i=1;i<objlinecnt;i++) {
       thisobjline=i; p=find_word_start(objline[i]);
       linelogdir=0; ld="";
       if(*p=='>') {
           if(logdir<0) continue;
           ld=">"; p=find_word_start(p+1); linelogdir=1;
       }
       else if(*p=='<') {
           if(logdir>0) continue;
           ld="<"; p=find_word_start(p+1); linelogdir=-1;
       }
       thislinelen=strlen(p); if(thislinelen<=0) continue;
       snprintf(nbuf,sizeof(nbuf),"%s",p);
       _not(nbuf); printf("%s %s\n",ld, nbuf);
    }

}

Here is the call graph for this function:


Variable Documentation

struct { ... } revtab[]