Date: Tue, 9 Feb 2010 21:24:41 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203723 - head/usr.bin/find Message-ID: <201002092124.o19LOgnb085740@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Tue Feb 9 21:24:41 2010 New Revision: 203723 URL: http://svn.freebsd.org/changeset/base/203723 Log: Don't let find(1) depend on struct timeb. This structure is deprecated and only used by ftime(2), which is part of libcompat. The second argument of get_date() is unused, which means we can just remove it entirely. Modified: head/usr.bin/find/extern.h head/usr.bin/find/function.c head/usr.bin/find/getdate.y Modified: head/usr.bin/find/extern.h ============================================================================== --- head/usr.bin/find/extern.h Tue Feb 9 21:01:18 2010 (r203722) +++ head/usr.bin/find/extern.h Tue Feb 9 21:24:41 2010 (r203723) @@ -43,8 +43,7 @@ PLAN *find_formplan(char **); PLAN *not_squish(PLAN *); PLAN *or_squish(PLAN *); PLAN *paren_squish(PLAN *); -struct timeb; -time_t get_date(char *, struct timeb *); +time_t get_date(char *); struct stat; void printlong(char *, char *, struct stat *); int queryuser(char **); Modified: head/usr.bin/find/function.c ============================================================================== --- head/usr.bin/find/function.c Tue Feb 9 21:01:18 2010 (r203722) +++ head/usr.bin/find/function.c Tue Feb 9 21:24:41 2010 (r203723) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include <sys/acl.h> #include <sys/wait.h> #include <sys/mount.h> -#include <sys/timeb.h> #include <dirent.h> #include <err.h> @@ -1155,7 +1154,7 @@ c_newer(OPTION *option, char ***argvp) new = palloc(option); /* compare against what */ if (option->flags & F_TIME2_T) { - new->t_data = get_date(fn_or_tspec, (struct timeb *) 0); + new->t_data = get_date(fn_or_tspec); if (new->t_data == (time_t) -1) errx(1, "Can't parse date/time: %s", fn_or_tspec); } else { Modified: head/usr.bin/find/getdate.y ============================================================================== --- head/usr.bin/find/getdate.y Tue Feb 9 21:01:18 2010 (r203722) +++ head/usr.bin/find/getdate.y Tue Feb 9 21:24:41 2010 (r203723) @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #else /* defined(vms) */ # include <sys/types.h> # include <sys/time.h> -# include <sys/timeb.h> #endif /* !defined(vms) */ #if defined (__STDC__) || defined (USG) @@ -69,7 +68,7 @@ static int yyparse(void); static int yylex(void); static int yyerror(const char *); -time_t get_date(char *, struct timeb *); +time_t get_date(char *); #define EPOCH 1970 #define HOUR(x) ((time_t)(x) * 60) @@ -849,58 +848,50 @@ difftm (struct tm *a, struct tm *b) } time_t -get_date(char *p, struct timeb *now) +get_date(char *p) { - struct tm *tm, gmt; - struct timeb ftz; + struct tm *tm, *gmt_ptr, gmt; + int tzoff; time_t Start; time_t tod; time_t nowtime; bzero (&gmt, sizeof(struct tm)); yyInput = p; - if (now == NULL) { - struct tm *gmt_ptr; - now = &ftz; - (void)time (&nowtime); + (void)time (&nowtime); - gmt_ptr = gmtime (&nowtime); - if (gmt_ptr != NULL) - { - /* Make a copy, in case localtime modifies *tm (I think - that comment now applies to *gmt_ptr, but I am too - lazy to dig into how gmtime and locatime allocate the - structures they return pointers to). */ - gmt = *gmt_ptr; - } - - if (! (tm = localtime (&nowtime))) - return -1; + gmt_ptr = gmtime (&nowtime); + if (gmt_ptr != NULL) + { + /* Make a copy, in case localtime modifies *tm (I think + that comment now applies to *gmt_ptr, but I am too + lazy to dig into how gmtime and locatime allocate the + structures they return pointers to). */ + gmt = *gmt_ptr; + } - if (gmt_ptr != NULL) - 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 = localtime (&nowtime))) + return -1; - if(tm->tm_isdst) - ftz.timezone += 60; - } + if (gmt_ptr != NULL) + tzoff = difftm (&gmt, tm) / 60; else - { - nowtime = now->time; - } + /* 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. */ + tzoff = 0; + + if(tm->tm_isdst) + tzoff += 60; tm = localtime(&nowtime); yyYear = tm->tm_year + 1900; yyMonth = tm->tm_mon + 1; yyDay = tm->tm_mday; - yyTimezone = now->timezone; + yyTimezone = tzoff; yyDSTmode = DSTmaybe; yyHour = 0; yyMinutes = 0; @@ -956,7 +947,7 @@ main(int ac, char *av[]) (void)printf("Enter date, or blank line to exit.\n\t> "); (void)fflush(stdout); while (gets(buff) && buff[0]) { - d = get_date(buff, (struct timeb *)NULL); + d = get_date(buff); if (d == -1) (void)printf("Bad format - couldn't convert.\n"); else
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002092124.o19LOgnb085740>