nmh-commits
[Top][All Lists]
Advanced

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

[Nmh-commits] CVS: nmh/sbr fmt_scan.c, 1.7, 1.8 fmt_compile.c, 1.5, 1.6


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

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

Modified Files:
        fmt_scan.c fmt_compile.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: fmt_scan.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/fmt_scan.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** fmt_scan.c  2 Jul 2002 22:09:14 -0000       1.7
--- fmt_scan.c  11 Aug 2003 01:20:52 -0000      1.8
***************
*** 297,300 ****
--- 297,309 ----
      cp = scanl;
      ep = scanl + width - 1;
+ 
+     for (fmt = format; fmt->f_type != FT_DONE; fmt++)
+       switch (fmt->f_type) {
+       case FT_PARSEADDR:
+       case FT_PARSEDATE:
+           fmt->f_comp->c_flags &= ~CF_PARSED;
+           break;
+       }
+ 
      fmt = format;
  
***************
*** 491,495 ****
  
        case FT_LV_COMPFLAG:
!           value = fmt->f_comp->c_flags;
            break;
        case FT_LV_COMP:
--- 500,504 ----
  
        case FT_LV_COMPFLAG:
!           value = (fmt->f_comp->c_flags & CF_TRUE) != 0;
            break;
        case FT_LV_COMP:
***************
*** 711,721 ****
        case FT_PARSEDATE:
            comp = fmt->f_comp;
            if ((sp = comp->c_text) && (tws = dparsetime(sp))) {
                *comp->c_tws = *tws;
!               comp->c_flags = 0;
!           } else if (comp->c_flags >= 0) {
                memset ((char *) comp->c_tws, 0, sizeof *comp->c_tws);
!               comp->c_flags = 1;
            }
            break;
  
--- 720,733 ----
        case FT_PARSEDATE:
            comp = fmt->f_comp;
+           if (comp->c_flags & CF_PARSED)
+               break;
            if ((sp = comp->c_text) && (tws = dparsetime(sp))) {
                *comp->c_tws = *tws;
!               comp->c_flags &= ~CF_TRUE;
!           } else if ((comp->c_flags & CF_DATEFAB) == 0) {
                memset ((char *) comp->c_tws, 0, sizeof *comp->c_tws);
!               comp->c_flags = CF_TRUE;
            }
+           comp->c_flags |= CF_PARSED;
            break;
  
***************
*** 780,783 ****
--- 792,797 ----
        case FT_PARSEADDR:
            comp = fmt->f_comp;
+           if (comp->c_flags & CF_PARSED)
+               break;
            if (comp->c_mn != &fmt_mnull)
                mnfree (comp->c_mn);
***************
*** 787,790 ****
--- 801,805 ----
                while (getname(""))
                    ;
+               comp->c_flags |= CF_PARSED;
            } else {
                while (getname(""))             /* XXX */
***************
*** 806,818 ****
                (mn = getm (sp, NULL, 0, AD_NAME, NULL))) {
                comp->c_mn = mn;
!               comp->c_flags = ismymbox(mn);
                while ((sp = getname(sp)))
!                   if (comp->c_flags == 0 &&
                        (mn = getm (sp, NULL, 0, AD_NAME, NULL)))
!                       comp->c_flags |= ismymbox(mn);
            } else {
                while (getname(""))             /* XXX */
                    ;
!               comp->c_flags = (comp->c_text == 0);
                comp->c_mn = &fmt_mnull;
            }
--- 821,840 ----
                (mn = getm (sp, NULL, 0, AD_NAME, NULL))) {
                comp->c_mn = mn;
!               if (ismymbox(mn))
!                   comp->c_flags |= CF_TRUE;
!               else
!                   comp->c_flags &= ~CF_TRUE;
                while ((sp = getname(sp)))
!                   if ((comp->c_flags & CF_TRUE) == 0 &&
                        (mn = getm (sp, NULL, 0, AD_NAME, NULL)))
!                       if (ismymbox(mn))
!                           comp->c_flags |= CF_TRUE;
            } else {
                while (getname(""))             /* XXX */
                    ;
!               if (comp->c_text == 0)
!                   comp->c_flags |= CF_TRUE;
!               else
!                   comp->c_flags &= ~CF_TRUE;
                comp->c_mn = &fmt_mnull;
            }

Index: fmt_compile.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/fmt_compile.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** fmt_compile.c       2 Jul 2002 22:09:14 -0000       1.5
--- fmt_compile.c       11 Aug 2003 01:20:52 -0000      1.6
***************
*** 424,434 ****
            CERROR("component used as both date and address");
        }
!       if (! (cm->c_type & CT_DATE)) {
!           cm->c_tws = (struct tws *)
!                               calloc((size_t) 1, sizeof(*cm->c_tws));
!           fp->f_type = preprocess;
!           PUTCOMP(sp);
!           cm->c_type |= CT_DATE;
!       }
        break;
  
--- 424,432 ----
            CERROR("component used as both date and address");
        }
!       cm->c_tws = (struct tws *)
!           calloc((size_t) 1, sizeof(*cm->c_tws));
!       fp->f_type = preprocess;
!       PUTCOMP(sp);
!       cm->c_type |= CT_DATE;
        break;
  
***************
*** 438,442 ****
            primed++;
        }
-       cm->c_type |= CT_MYMBOX;
        /* fall through */
      case FT_PARSEADDR:
--- 436,439 ----
***************
*** 444,453 ****
            CERROR("component used as both date and address");
        }
!       if (! (cm->c_type & CT_ADDRPARSE)) {
!           cm->c_mn = &fmt_mnull;
!           fp->f_type = preprocess;
!           PUTCOMP(sp);
!           cm->c_type |= (CT_ADDR | CT_ADDRPARSE);
!       }
        break;
  
--- 441,448 ----
            CERROR("component used as both date and address");
        }
!       cm->c_mn = &fmt_mnull;
!       fp->f_type = preprocess;
!       PUTCOMP(sp);
!       cm->c_type |= CT_ADDR;
        break;
  





reply via email to

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