X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fdtimep.lex;h=83edbffe7d3ba82795c7c2eb8537a351eeec64ac;hp=133a9ab18eff82de60cd5a3a52c4547696a52c83;hb=db62cda50055368e5f4ac51df787053f70706c30;hpb=6e5da31c92f5a3fa38e010052c5a7743bfe1cf11 diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 133a9ab..83edbff 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -1,8 +1,9 @@ -/* dtimep.lex exceeds the default table capacities for some old versions - * of lex (and the minimum defaults as specified by POSIX). The following - * choices meet or exceed the lex defaults for older SunOS4.x, Solaris, - * HPUX, and AIX. - */ +/* +** dtimep.lex exceeds the default table capacities for some old versions +** of lex (and the minimum defaults as specified by POSIX). The following +** choices meet or exceed the lex defaults for older SunOS4.x, Solaris, +** HPUX, and AIX. +*/ %e4000 %p7000 %n2500 @@ -11,27 +12,30 @@ #include #include - /* Since we're looking at a string at a time, don't worry about - * wrapping to the next buffer. - */ +/* +** Since we're looking at a string at a time, don't worry about +** wrapping to the next buffer. +*/ #define yywrap() 1 #define YY_SKIP_YYWRAP #define YY_NO_INPUT - /* This is the tricky thing that makes this function cool. We - * replace the traditional int yylex(void) declaration with our - * dparsetime() declaration, essentially piggy-backing off the - * utility of the yylex() function and adding what we need to make - * the parsing function useful to us. - */ +/* +** This is the tricky thing that makes this function cool. We +** replace the traditional int yylex(void) declaration with our +** dparsetime() declaration, essentially piggy-backing off the +** utility of the yylex() function and adding what we need to make +** the parsing function useful to us. +*/ #define YY_DECL struct tws *dparsetime(char *lexstr) - /* yyerminate() is called after the input string is matched to - * completion (actually, when the lexer reaches an EOF). The only - * thing that really needs to be in this macro function is the - * return call, which must be substituted inline into dparsetime. - */ +/* +** yyerminate() is called after the input string is matched to +** completion (actually, when the lexer reaches an EOF). The only +** thing that really needs to be in this macro function is the +** return call, which must be substituted inline into dparsetime. +*/ #define yyterminate() (void)yy_delete_buffer(lexhandle); \ if(!(tw.tw_flags & TW_SUCC)) { \ @@ -44,20 +48,20 @@ return(&tw) /* - * Patchable flag that says how to interpret NN/NN/NN dates. When - * true, we do it European style: DD/MM/YY. When false, we do it - * American style: MM/DD/YY. Of course, these are all non-RFC822 - * compliant. - */ +** Patchable flag that says how to interpret NN/NN/NN dates. When +** true, we do it European style: DD/MM/YY. When false, we do it +** American style: MM/DD/YY. Of course, these are all non-RFC822 +** compliant. +*/ int europeandate = 0; /* - * Table to convert month names to numeric month. We use the - * fact that the low order 5 bits of the sum of the 2nd & 3rd - * characters of the name is a hash with no collisions for the 12 - * valid month names. (The mask to 5 bits maps any combination of - * upper and lower case into the same hash value). - */ +** Table to convert month names to numeric month. We use the +** fact that the low order 5 bits of the sum of the 2nd & 3rd +** characters of the name is a hash with no collisions for the 12 +** valid month names. (The mask to 5 bits maps any combination of +** upper and lower case into the same hash value). +*/ static int month_map[] = { 0, 6, /* 1 - Jul */ @@ -91,11 +95,12 @@ static int month_map[] = { }; /* - * Lookup table for day-of-week using the same hash trick as for above name-of- - * month table, but using the first and second character, not second and third. - * - * Compute index into table using: (day_name[0] & 7) + (day_name[1] & 4) - */ +** Lookup table for day-of-week using the same hash trick as for above +** name-of-month table, but using the first and second character, not +** second and third. +** +** Compute index into table using: (day_name[0] & 7) + (day_name[1] & 4) +*/ static int day_map[] = { 0, 0, @@ -111,15 +116,16 @@ static int day_map[] = { 3 /*11 - Wed */ }; -/* The SET* macros will parse for the appropriate field, and leave the - * cp pointer at the first character after the desired field. Be - * careful with variable-length fields or alpha-num mixes. - - * The SKIP* macros skip over characters of a particular class and - * leave cp at the position of the first character that doesn't match - * that class. Correspondingly, SKIPTO* skips until it reaches a - * character of a particular class. - */ +/* +** The SET* macros will parse for the appropriate field, and leave the +** cp pointer at the first character after the desired field. Be +** careful with variable-length fields or alpha-num mixes. +** +** The SKIP* macros skip over characters of a particular class and +** leave cp at the position of the first character that doesn't match +** that class. Correspondingly, SKIPTO* skips until it reaches a +** character of a particular class. +*/ #define INIT() { cp = yytext;} #define SETWDAY() { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)]; \ @@ -193,11 +199,11 @@ MONTH ({jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec}) 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 - * the middle term here. yyterminate() resolves the actual - * issues with 2-digit years. - */ +** The year can either be 2 digits, or 4. However, after +** Y2K, we found that some MUA were reporting the year 100, hence +** the middle term here. yyterminate() resolves the actual +** issues with 2-digit years. +*/ YEAR (({d}{d})|(1{d}{d})|({d}{4})) @@ -209,9 +215,10 @@ nl [ \t\n()] %% %{ - /* This section begins the definition of dparsetime(). - * Put here any local variable definitions and initializations */ - + /* + ** This section begins the definition of dparsetime(). + ** Put here any local variable definitions and initializations + */ YY_BUFFER_STATE lexhandle; register unsigned char *cp; @@ -300,15 +307,15 @@ nl [ \t\n()] {D}("-"|"/"){D}("-"|"/"){YEAR}{W}{TIME} { INIT(); if(europeandate) { - /* DD/MM/YY */ - SETDAY(); - SKIPTOD(); - SETMON_NUM(); + /* DD/MM/YY */ + SETDAY(); + SKIPTOD(); + SETMON_NUM(); } else { - /* MM/DD/YY */ - SETMON_NUM(); - SKIPTOD(); - SETDAY(); + /* MM/DD/YY */ + SETMON_NUM(); + SKIPTOD(); + SETDAY(); } SKIPTOD(); SETYEAR(); @@ -372,12 +379,13 @@ nl [ \t\n()] .|\n %% -/* This is a portable way to squash a warning about the yyunput() - * function being static but never used. It costs us a tiny amount - * of extra code in the binary but the other options are: - * "%option nounput" which is flex-specific - * makefile hackery just to compile dtimep.c with different flags - */ +/* +** This is a portable way to squash a warning about the yyunput() +** function being static but never used. It costs us a tiny amount +** of extra code in the binary but the other options are: +** "%option nounput" which is flex-specific +** makefile hackery just to compile dtimep.c with different flags +*/ void dtimep_yyunput(int c) { unput(c);