rename getdate to parsedate to avoid conflict with posix function

This commit is contained in:
christos 2006-11-20 20:33:02 +00:00
parent 3d79fd04f9
commit 61261c8531
3 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.52 2006/11/17 22:10:23 christos Exp $ # $NetBSD: Makefile,v 1.53 2006/11/20 20:33:02 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93 # @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes USE_SHLIBDIR= yes
@ -8,21 +8,21 @@ USE_SHLIBDIR= yes
WARNS=3 WARNS=3
LIB= util LIB= util
CPPFLAGS+=-DLIBC_SCCS CPPFLAGS+=-DLIBC_SCCS
SRCS= efun.c getbootfile.c getdate.y getlabelsector.c getmaxpartitions.c \ SRCS= efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \
getmntopts.c getrawpartition.c \ getmntopts.c getrawpartition.c \
disklabel_dkcksum.c disklabel_scan.c \ disklabel_dkcksum.c disklabel_scan.c \
if_media.c \ if_media.c \
login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \ login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \
logwtmp.c logwtmpx.c opendisk.c \ logwtmp.c logwtmpx.c opendisk.c parsedate.y \
passwd.c pw_scan.c pw_policy.c pidfile.c pidlock.c pty.c \ passwd.c pw_scan.c pw_policy.c pidfile.c pidlock.c pty.c \
secure_path.c snprintb.c sockaddr_snprintf.c ttyaction.c ttymsg.c secure_path.c snprintb.c sockaddr_snprintf.c ttyaction.c ttymsg.c
MAN= efun.3 getbootfile.3 getdate.3 getlabelsector.3 getmaxpartitions.3 \ MAN= efun.3 getbootfile.3 getlabelsector.3 getmaxpartitions.3 \
getmntopts.3 \ getmntopts.3 \
getrawpartition.3 \ getrawpartition.3 \
login.3 login_cap.3 loginx.3 \ login.3 login_cap.3 loginx.3 \
disklabel_dkcksum.3 disklabel_scan.3 \ disklabel_dkcksum.3 disklabel_scan.3 \
opendisk.3 openpty.3 pidfile.3 pidlock.3 \ opendisk.3 openpty.3 parsedate.3 pidfile.3 pidlock.3 \
pw_getconf.3 pw_init.3 pw_lock.3 pw_policy.3 secure_path.3 \ pw_getconf.3 pw_init.3 pw_lock.3 pw_policy.3 secure_path.3 \
snprintb.3 sockaddr_snprintf.3 ttyaction.3 \ snprintb.3 sockaddr_snprintf.3 ttyaction.3 \
ttymsg.3 util.3 ttymsg.3 util.3

View File

@ -1,4 +1,4 @@
.\" $NetBSD: getdate.3,v 1.1 2006/11/17 22:10:23 christos Exp $ .\" $NetBSD: parsedate.3,v 1.1 2006/11/20 20:33:02 christos Exp $
.\" .\"
.\" Copyright (c) 2006 The NetBSD Foundation, Inc. .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -35,20 +35,20 @@
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd November 17, 2006 .Dd November 17, 2006
.Dt getdate 3 .Dt parsedate 3
.Os .Os
.Sh NAME .Sh NAME
.Nm getdate .Nm parsedate
.Nd date parsing function .Nd date parsing function
.Sh LIBRARY .Sh LIBRARY
.Lb libutil .Lb libutil
.Sh SYNOPSIS .Sh SYNOPSIS
.In util.h .In util.h
.Ft time_t .Ft time_t
.Fn getdate "const char *datestr" "const time_t *time" "const int *tzoff" .Fn parsedate "const char *datestr" "const time_t *time" "const int *tzoff"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm getdate .Nm parsedate
function parses a datetime from function parses a datetime from
.Ar datestr .Ar datestr
described in english relative to an optional described in english relative to an optional
@ -236,7 +236,7 @@ Relative items are also supported:
.It +2 years .It +2 years
.El .El
.Sh RETURN VALUES .Sh RETURN VALUES
.Fn getdate .Fn parsedate
returns the number of seconds passed since the Epoch, or returns the number of seconds passed since the Epoch, or
.Dv -1 .Dv -1
if the date could not be parsed properly. if the date could not be parsed properly.
@ -244,14 +244,14 @@ if the date could not be parsed properly.
.Xr date 1 , .Xr date 1 ,
.Xr eeprom 8 . .Xr eeprom 8 .
.Sh HISTORY .Sh HISTORY
The parser used The parser used in
.Fn getdate .Fn parsedate
was originally written by Steven M. Bellovin while at the University was originally written by Steven M. Bellovin while at the University
of North Carolina at Chapel Hill. Later tweaked by a couple of of North Carolina at Chapel Hill. Later tweaked by a couple of
people on Usenet. Completely overhauled by Rich $alz and Jim Berets people on Usenet. Completely overhauled by Rich $alz and Jim Berets
in August, 1990. in August, 1990.
.Pp .Pp
The The
.Fn getdate .Fn parsedate
function first appeared in function first appeared in
.Nx 4.0 . .Nx 4.0 .

View File

@ -18,7 +18,7 @@
#include <time.h> #include <time.h>
#include <util.h> #include <util.h>
/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS /* NOTES on rebuilding parsedate.c (particularly for inclusion in CVS
releases): releases):
We don't want to mess with all the portability hassles of alloca. We don't want to mess with all the portability hassles of alloca.
@ -28,12 +28,12 @@
is to use byacc instead of bison, which should generate a portable is to use byacc instead of bison, which should generate a portable
parser. I played with adding "#define alloca dont_use_alloca", to parser. I played with adding "#define alloca dont_use_alloca", to
give an error if the parser generator uses alloca (and thus detect give an error if the parser generator uses alloca (and thus detect
unportable getdate.c's), but that seems to cause as many problems unportable parsedate.c's), but that seems to cause as many problems
as it solves. */ as it solves. */
#define yyparse getdate_yyparse #define yyparse parsedate_yyparse
#define yylex getdate_yylex #define yylex parsedate_yylex
#define yyerror getdate_yyerror #define yyerror parsedate_yyerror
#define EPOCH 1970 #define EPOCH 1970
#define HOUR(x) ((time_t)(x) * 60) #define HOUR(x) ((time_t)(x) * 60)
@ -859,7 +859,7 @@ difftm (struct tm *a, struct tm *b)
} }
time_t time_t
getdate(const char *p, const time_t *now, const int *zone) parsedate(const char *p, const time_t *now, const int *zone)
{ {
struct tm gmt, local, *gmt_ptr, *tm; struct tm gmt, local, *gmt_ptr, *tm;
time_t nowt; time_t nowt;
@ -954,7 +954,7 @@ main(ac, av)
(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 (gets(buff) && buff[0]) { while (gets(buff) && buff[0]) {
d = getdate(buff, NULL, NULL); d = parsedate(buff, NULL, NULL);
if (d == -1) if (d == -1)
(void)printf("Bad format - couldn't convert.\n"); (void)printf("Bad format - couldn't convert.\n");
else else