]> diplodocus.org Git - nmh/blobdiff - sbr/dtimep.l
seq_del.c: Move interface to own file.
[nmh] / sbr / dtimep.l
index 2b6df17570c472bc0ae4d1e0d738f841e6877149..68f0ea7be346ca64287b0112eba0e86f9193fba5 100644 (file)
 %n2500
 %a5000
 %{
-#include <h/nmh.h>
-#include <h/tws.h>
+#include "h/nmh.h"
+#include "h/mh.h"
+#include "h/utils.h"
+#include "h/tws.h"
 
   /* Since we're looking at a string at a time, don't worry about
    *  wrapping to the next buffer.
 
 #define yyterminate() (void)yy_delete_buffer(lexhandle); \
   if(!(tw.tw_flags & TW_SUCC)) { \
-    return (struct tws *)NULL; \
+    return NULL; \
   } \
   if(tw.tw_year < 1970) \
     tw.tw_year += 1900; \
   if(tw.tw_year < 1970) \
     tw.tw_year += 100; \
-  return(&tw)
+  return &tw
 
 /*
  * Table to convert month names to numeric month.  We use the
@@ -154,10 +156,6 @@ static int day_map[] = {
                        --cp; }
 #define SKIPTOA()    { while ( !isalpha((unsigned char) *cp++) ) ; \
                        --cp; }
-#define SKIPSP()     { while ( isspace((unsigned char) *cp++) ) ; \
-                       --cp; }
-#define SKIPTOSP()   { while ( !isspace((unsigned char) *cp++) ) ; \
-                       --cp; }
 
 # ifdef HAVE_SYS_TIME_H
 #  include <sys/time.h>
@@ -180,32 +178,32 @@ zonehack (struct tws *tw)
 }
 %}
 
-sun    ([Ss]un(day)?)
-mon    ([Mm]on(day)?)
-tue    ([Tt]ue(sday)?)
-wed    ([Ww]ed(nesday)?)
-thu    ([Tt]hu(rsday)?)
-fri    ([Ff]ri(day)?)
-sat    ([Ss]at(urday)?)
+sun    [Ss]un(day)?
+mon    [Mm]on(day)?
+tue    [Tt]ue(sday)?
+wed    [Ww]ed(nesday)?
+thu    [Tt]hu(rsday)?
+fri    [Ff]ri(day)?
+sat    [Ss]at(urday)?
 
-DAY    ({sun}|{mon}|{tue}|{wed}|{thu}|{fri}|{sat})
+DAY    {sun}|{mon}|{tue}|{wed}|{thu}|{fri}|{sat}
 
-jan    ([Jj]an(uary)?)
-feb    ([Ff]eb(ruary)?)
-mar    ([Mm]ar(ch)?)
-apr    ([Aa]pr(il)?)
-may    ([Mm]ay)
-jun    ([Jj]un(e)?)
-jul    ([Jj]ul(y)?)
-aug    ([Aa]ug(ust)?)
-sep    ([Ss]ep(tember)?)
-oct    ([Oo]ct(ober)?)
-nov    ([Nn]ov(ember)?)
-dec    ([Dd]ec(ember)?)
+jan    [Jj]an(uary)?
+feb    [Ff]eb(ruary)?
+mar    [Mm]ar(ch)?
+apr    [Aa]pr(il)?
+may    [Mm]ay
+jun    [Jj]une?
+jul    [Jj]uly?
+aug    [Aa]ug(ust)?
+sep    [Ss]ep(tember)?
+oct    [Oo]ct(ober)?
+nov    [Nn]ov(ember)?
+dec    [Dd]ec(ember)?
 
-MONTH  ({jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec})
+MONTH  {jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec}
 
-TIME    ({D}:{d}{d}(:{d}{d})?)
+TIME    {D}:{d}{d}(:{d}{d})?
 
      /* The year can either be 2 digits, or 4. However, after
        Y2K, we found that some MUA were reporting the year 100, hence
@@ -213,11 +211,11 @@ TIME    ({D}:{d}{d}(:{d}{d})?)
         issues with 2-digit years.
      */
 
-YEAR    (({d}{d})|(1{d}{d})|({d}{4}))
+YEAR    ({d}{d})|(1{d}{d})|({d}{4})
 
-w      ([ \t]*)
-W      ([ \t]+)
-D      ([0-9]?[0-9])
+w      [ \t]*
+W      [ \t]+
+D      [0-9]?[0-9]
 d      [0-9]
 nl      [ \t\n()]
 
@@ -231,7 +229,7 @@ nl      [ \t\n()]
   char *cp;
   static struct tws tw; 
 
-  memset(&tw,0,sizeof(struct tws));
+  ZERO(&tw);
 
   lexhandle = yy_scan_string(lexstr);
 %}
@@ -380,7 +378,8 @@ nl      [ \t\n()]
  *  "%option nounput" which is flex-specific
  *  makefile hackery just to compile dtimep.c with different flags
  */
-void dtimep_yyunput(int c)
+void
+dtimep_yyunput(int c)
 {
     unput(c);
 }