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

Diff for /mandoc/mandoc.c between version 1.37 and 1.38

version 1.37, 2011/03/07 01:35:51 version 1.38, 2011/03/15 03:03:54
Line 386  static char *
Line 386  static char *
 time2a(time_t t)  time2a(time_t t)
 {  {
         struct tm        tm;          struct tm        tm;
         char             buf[DATESIZE];          char            *buf, *p;
         char            *p;          size_t           ssz;
         size_t           nsz, rsz;  
         int              isz;          int              isz;
   
         localtime_r(&t, &tm);          localtime_r(&t, &tm);
   
         p = buf;          /*
         rsz = DATESIZE;           * Reserve space:
            * up to 9 characters for the month (September) + blank
            * up to 2 characters for the day + comma + blank
            * 4 characters for the year and a terminating '\0'
            */
           p = buf = mandoc_malloc(10 + 4 + 4 + 1);
   
         if (0 == (nsz = strftime(p, rsz, "%B ", &tm)))          if (0 == (ssz = strftime(p, 10 + 1, "%B ", &tm)))
                 return(NULL);                  goto fail;
           p += (int)ssz;
   
         p += (int)nsz;          if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm.tm_mday)))
         rsz -= nsz;                  goto fail;
   
         if (-1 == (isz = snprintf(p, rsz, "%d, ", tm.tm_mday)))  
                 return(NULL);  
   
         p += isz;          p += isz;
         rsz -= isz;  
   
         return(strftime(p, rsz, "%Y", &tm) ? buf : NULL);          if (0 == strftime(p, 4 + 1, "%Y", &tm))
                   goto fail;
           return(buf);
   
   fail:
           free(buf);
           return(NULL);
 }  }
   
   
Line 430  mandoc_normdate(char *in, mandocmsg msg, void *data, i
Line 436  mandoc_normdate(char *in, mandocmsg msg, void *data, i
                 t = 0;                  t = 0;
         }          }
         out = t ? time2a(t) : NULL;          out = t ? time2a(t) : NULL;
         return(mandoc_strdup(out ? out : in));          return(out ? out : mandoc_strdup(in));
 }  }
   
   

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

CVSweb