[BACK]Return to date.y CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/date.y between version 1.7 and 1.8

version 1.7, 2005/05/19 04:17:24 version 1.8, 2005/05/20 17:15:49
Line 82 
Line 82 
 static int   yyerror   (const char *, ...);  static int   yyerror   (const char *, ...);
 static int   yylex     (void);  static int   yylex     (void);
 static int   yyparse   (void);  static int   yyparse   (void);
   static int   lookup    (char *);
   
 %}  %}
   
Line 634 
Line 635 
   
   
 static int  static int
 LookupWord(char *buff)  lookup(char *buff)
 {  {
         char            *p, *q;          char            *p, *q;
         int             i, abbrev;          int             i, abbrev;
Line 769 
Line 770 
                                         *p++ = c;                                          *p++ = c;
                         *p = '\0';                          *p = '\0';
                         yyInput--;                          yyInput--;
                         return LookupWord(buff);                          return lookup(buff);
                 }                  }
                 if (c != '(')                  if (c != '(')
                         return *yyInput++;                          return *yyInput++;
Line 807 
Line 808 
             + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec));              + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec));
 }  }
   
   /*
    * cvs_date_parse()
    *
    * Returns the number of seconds since the Epoch corresponding to the date.
    */
 time_t  time_t
 cvs_date_parse(const char *p)  cvs_date_parse(const char *p)
 {  {
Line 821 
Line 827 
                 struct tm *gmt_ptr;                  struct tm *gmt_ptr;
   
                 now = &ftz;                  now = &ftz;
                 (void)time (&nowtime);                  (void)time(&nowtime);
   
                 gmt_ptr = gmtime (&nowtime);                  gmt_ptr = gmtime(&nowtime);
                 if (gmt_ptr != NULL) {                  if (gmt_ptr != NULL) {
                         /* Make a copy, in case localtime modifies *tm (I think                          /* Make a copy, in case localtime modifies *tm (I think
                          * that comment now applies to *gmt_ptr, but I am too                           * that comment now applies to *gmt_ptr, but I am too
Line 833 
Line 839 
                         gmt = *gmt_ptr;                          gmt = *gmt_ptr;
                 }                  }
   
                 if (!(tm = localtime (&nowtime)))                  if (!(tm = localtime(&nowtime)))
                         return (-1);                          return (-1);
   
                 if (gmt_ptr != NULL)                  if (gmt_ptr != NULL)
                         ftz.timezone = difftm (&gmt, tm) / 60;                          ftz.timezone = difftm(&gmt, tm) / 60;
                 else  
                         /* We are on a system like VMS, where the system clock is  
                            in local time and the system has no concept of timezones.  
                            Hopefully we can fake this out (for the case in which the  
                            user specifies no timezone) by just saying the timezone  
                            is zero.  */  
                         ftz.timezone = 0;  
   
                 if(tm->tm_isdst)                  if(tm->tm_isdst)
                         ftz.timezone += 60;                          ftz.timezone += 60;
Line 911 
Line 910 
         (void)printf("Enter date, or blank line to exit.\n\t> ");          (void)printf("Enter date, or blank line to exit.\n\t> ");
         (void)fflush(stdout);          (void)fflush(stdout);
         while (fgets(buff, sizeof(buff), stdin) && buff[0]) {          while (fgets(buff, sizeof(buff), stdin) && buff[0]) {
                 d = get_date(buff, (struct timeb *)NULL);                  d = cvs_date_parse(buff);
                 if (d == -1)                  if (d == -1)
                         (void)printf("Bad format - couldn't convert.\n");                          (void)printf("Bad format - couldn't convert.\n");
                 else                  else

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