nmh-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-commits] CVS: nmh/uip scansbr.c,1.5,1.6 fmtdump.c,1.5,1.6


From: Jeffrey C Honig <address@hidden>
Subject: [Nmh-commits] CVS: nmh/uip scansbr.c,1.5,1.6 fmtdump.c,1.5,1.6
Date: Sun, 10 Aug 2003 21:20:54 -0400

Update of /cvsroot/nmh/nmh/uip
In directory subversions:/tmp/cvs-serv19427/uip

Modified Files:
        scansbr.c fmtdump.c 
Log Message:
When compiling format strings, nmh attempts to avoid multiple parsing
of address and date fields by only inserting calls to the parse
functions (FT_PARSEADDR and FT_PARSEDATE) for a given component once.
The problem with this method is that the initial invocation may
actually be on a code path that is conditionally executed.  This can
result cached copies of data from the fields in previous messages to
be used.

My solution is to move this optimization from compile time to run time.
Address and Date parsing calls (FT_PARSEADDR and FT_PARSEDATE) will
always be included.  Run time flags are used to prevent these functions
from being run more than once per component per message.

The c_flags field has being converted from a boolean to a bit-field to
facilitate maintenance of the new CT_PARSED value.  The result value
that used to be in this field is now the bit CF_TRUE and the
overloaded use of this field by scan() is now the CT_DATEFAB bit.

Some unneeded flags (CT_ADDRPARSE, CT_MYMBOX) have also been removed.


Index: scansbr.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/scansbr.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** scansbr.c   2 Jul 2002 22:09:15 -0000       1.5
--- scansbr.c   11 Aug 2003 01:20:52 -0000      1.6
***************
*** 332,338 ****
                    adios (NULL, "unable to allocate tws buffer");
                *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
!               datecomp->c_flags = -1;
            } else {
!               datecomp->c_flags = 0;
            }
        }
--- 332,338 ----
                    adios (NULL, "unable to allocate tws buffer");
                *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
!               datecomp->c_flags |= CF_DATEFAB|CF_TRUE;
            } else {
!               datecomp->c_flags &= ~CF_DATEFAB;
            }
        }

Index: fmtdump.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/fmtdump.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** fmtdump.c   2 Jul 2002 22:09:14 -0000       1.5
--- fmtdump.c   11 Aug 2003 01:20:52 -0000      1.6
***************
*** 40,43 ****
--- 40,44 ----
  static char *f_typestr(int);
  static char *c_typestr(int);
+ static char *c_flagsstr(int);
  static void litputs(char *);
  static void litputc(char);
***************
*** 164,168 ****
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %d", fmt->f_comp->c_flags);
                break;
  
--- 165,169 ----
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %s", 
c_flagsstr(fmt->f_comp->c_flags));
                break;
  
***************
*** 196,200 ****
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %d", fmt->f_comp->c_flags);
                break;
  
--- 197,201 ----
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %s", 
c_flagsstr(fmt->f_comp->c_flags));
                break;
  
***************
*** 218,222 ****
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %d", fmt->f_comp->c_flags);
                break;
  
--- 219,223 ----
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %s", 
c_flagsstr(fmt->f_comp->c_flags));
                break;
  
***************
*** 229,233 ****
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %d", fmt->f_comp->c_flags);
                break;
  
--- 230,234 ----
                        printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
                if (fmt->f_comp->c_flags)
!                       printf(", c_flags %s", 
c_flagsstr(fmt->f_comp->c_flags));
                break;
  
***************
*** 453,457 ****
  
        buf[0] = '\0';
!       if (t & ~(CT_ADDR|CT_DATE|CT_MYMBOX|CT_ADDRPARSE))
                printf(buf, "0x%x ", t);
        strcat(buf, "<");
--- 454,458 ----
  
        buf[0] = '\0';
!       if (t & ~(CT_ADDR|CT_DATE))
                printf(buf, "0x%x ", t);
        strcat(buf, "<");
***************
*** 459,468 ****
        FNORD(CT_ADDR, "ADDR");
        FNORD(CT_DATE, "DATE");
-       FNORD(CT_MYMBOX, "MYMBOX");
-       FNORD(CT_ADDRPARSE, "ADDRPARSE");
        strcat(buf, ">");
        return(buf);
- #undef FNORD
  }
  
  static void
--- 460,485 ----
        FNORD(CT_ADDR, "ADDR");
        FNORD(CT_DATE, "DATE");
        strcat(buf, ">");
        return(buf);
  }
+ 
+ static char *
+ c_flagsstr(int t)
+ {
+       register int i;
+       static char buf[64];
+ 
+       buf[0] = '\0';
+       if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB))
+               printf(buf, "0x%x ", t);
+       strcat(buf, "<");
+       i = 0;
+       FNORD(CF_TRUE, "TRUE");
+       FNORD(CF_PARSED, "PARSED");
+       FNORD(CF_DATEFAB, "DATEFAB");
+       strcat(buf, ">");
+       return(buf);
+ }
+ #undef FNORD
  
  static void





reply via email to

[Prev in Thread] Current Thread [Next in Thread]