rename getdate to parsedate to avoid conflict with posix function
This commit is contained in:
parent
3d79fd04f9
commit
61261c8531
|
@ -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
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
|
@ -8,21 +8,21 @@ USE_SHLIBDIR= yes
|
|||
WARNS=3
|
||||
LIB= util
|
||||
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 \
|
||||
disklabel_dkcksum.c disklabel_scan.c \
|
||||
if_media.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 \
|
||||
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 \
|
||||
getrawpartition.3 \
|
||||
login.3 login_cap.3 loginx.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 \
|
||||
snprintb.3 sockaddr_snprintf.3 ttyaction.3 \
|
||||
ttymsg.3 util.3
|
||||
|
|
|
@ -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.
|
||||
.\" All rights reserved.
|
||||
|
@ -35,20 +35,20 @@
|
|||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd November 17, 2006
|
||||
.Dt getdate 3
|
||||
.Dt parsedate 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm getdate
|
||||
.Nm parsedate
|
||||
.Nd date parsing function
|
||||
.Sh LIBRARY
|
||||
.Lb libutil
|
||||
.Sh SYNOPSIS
|
||||
.In util.h
|
||||
.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
|
||||
The
|
||||
.Nm getdate
|
||||
.Nm parsedate
|
||||
function parses a datetime from
|
||||
.Ar datestr
|
||||
described in english relative to an optional
|
||||
|
@ -236,7 +236,7 @@ Relative items are also supported:
|
|||
.It +2 years
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
.Fn getdate
|
||||
.Fn parsedate
|
||||
returns the number of seconds passed since the Epoch, or
|
||||
.Dv -1
|
||||
if the date could not be parsed properly.
|
||||
|
@ -244,14 +244,14 @@ if the date could not be parsed properly.
|
|||
.Xr date 1 ,
|
||||
.Xr eeprom 8 .
|
||||
.Sh HISTORY
|
||||
The parser used
|
||||
.Fn getdate
|
||||
The parser used in
|
||||
.Fn parsedate
|
||||
was originally written by Steven M. Bellovin while at the University
|
||||
of North Carolina at Chapel Hill. Later tweaked by a couple of
|
||||
people on Usenet. Completely overhauled by Rich $alz and Jim Berets
|
||||
in August, 1990.
|
||||
.Pp
|
||||
The
|
||||
.Fn getdate
|
||||
.Fn parsedate
|
||||
function first appeared in
|
||||
.Nx 4.0 .
|
|
@ -18,7 +18,7 @@
|
|||
#include <time.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):
|
||||
|
||||
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
|
||||
parser. I played with adding "#define alloca dont_use_alloca", to
|
||||
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. */
|
||||
|
||||
#define yyparse getdate_yyparse
|
||||
#define yylex getdate_yylex
|
||||
#define yyerror getdate_yyerror
|
||||
#define yyparse parsedate_yyparse
|
||||
#define yylex parsedate_yylex
|
||||
#define yyerror parsedate_yyerror
|
||||
|
||||
#define EPOCH 1970
|
||||
#define HOUR(x) ((time_t)(x) * 60)
|
||||
|
@ -859,7 +859,7 @@ difftm (struct tm *a, struct tm *b)
|
|||
}
|
||||
|
||||
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;
|
||||
time_t nowt;
|
||||
|
@ -954,7 +954,7 @@ main(ac, av)
|
|||
(void)printf("Enter date, or blank line to exit.\n\t> ");
|
||||
(void)fflush(stdout);
|
||||
while (gets(buff) && buff[0]) {
|
||||
d = getdate(buff, NULL, NULL);
|
||||
d = parsedate(buff, NULL, NULL);
|
||||
if (d == -1)
|
||||
(void)printf("Bad format - couldn't convert.\n");
|
||||
else
|
Loading…
Reference in New Issue