[BACK]Return to mandoc.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mandoc.c between version 1.6 and 1.7

version 1.6, 2009/10/31 06:10:58 version 1.7, 2009/11/02 06:22:45
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #if defined(__linux__) || defined(__MINT__)
   # define _GNU_SOURCE /* strptime() */
   #endif
   
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
Line 21 
Line 25 
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
   #include <time.h>
   
 #include "libmandoc.h"  #include "libmandoc.h"
   
   static int       a2time(time_t *, const char *, const char *);
   
   
 int  int
 mandoc_special(const char *p)  mandoc_special(const char *p)
 {  {
Line 163  mandoc_strdup(const char *ptr)
Line 171  mandoc_strdup(const char *ptr)
   
         return(p);          return(p);
 }  }
   
   
   static int
   a2time(time_t *t, const char *fmt, const char *p)
   {
           struct tm        tm;
           char            *pp;
   
           memset(&tm, 0, sizeof(struct tm));
   
           pp = strptime(p, fmt, &tm);
           if (NULL != pp && '\0' == *pp) {
                   *t = mktime(&tm);
                   return(1);
           }
   
           return(0);
   }
   
   
   /*
    * Convert from a manual date string (see mdoc(7) and man(7)) into a
    * date according to the stipulated date type.
    */
   time_t
   mandoc_a2time(int flags, const char *p)
   {
           time_t           t;
   
           if (MTIME_MDOCDATE & flags) {
                   if (0 == strcmp(p, "$" "Mdocdate$"))
                           return(time(NULL));
                   if (a2time(&t, "$" "Mdocdate: %b %d %Y $", p))
                           return(t);
           }
   
           if (MTIME_CANONICAL & flags || MTIME_REDUCED & flags)
                   if (a2time(&t, "%b %d, %Y", p))
                           return(t);
   
           if (MTIME_ISO_8601 & flags)
                   if (a2time(&t, "%Y-%m-%d", p))
                           return(t);
   
           if (MTIME_REDUCED & flags) {
                   if (a2time(&t, "%d, %Y", p))
                           return(t);
                   if (a2time(&t, "%Y", p))
                           return(t);
           }
   
           return(0);
   }
   

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

CVSweb