|
@ -1,4 +1,4 @@ |
|
|
/* $OpenBSD: strftime.c,v 1.3 1996/03/09 02:42:58 niklas Exp $ */ |
|
|
|
|
|
|
|
|
/* $OpenBSD: strftime.c,v 1.4 1996/03/25 21:17:36 tholo Exp $ */ |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* Copyright (c) 1989 The Regents of the University of California. |
|
|
* Copyright (c) 1989 The Regents of the University of California. |
|
@ -35,7 +35,7 @@ |
|
|
|
|
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint) |
|
|
#if defined(LIBC_SCCS) && !defined(lint) |
|
|
/*static char *sccsid = "from: @(#)strftime.c 5.11 (Berkeley) 2/24/91";*/ |
|
|
/*static char *sccsid = "from: @(#)strftime.c 5.11 (Berkeley) 2/24/91";*/ |
|
|
static char *rcsid = "$Id: strftime.c,v 1.3 1996/03/09 02:42:58 niklas Exp $"; |
|
|
|
|
|
|
|
|
static char *rcsid = "$Id: strftime.c,v 1.4 1996/03/25 21:17:36 tholo Exp $"; |
|
|
#endif /* LIBC_SCCS and not lint */ |
|
|
#endif /* LIBC_SCCS and not lint */ |
|
|
|
|
|
|
|
|
#include <sys/localedef.h> |
|
|
#include <sys/localedef.h> |
|
@ -46,8 +46,10 @@ static char *rcsid = "$Id: strftime.c,v 1.3 1996/03/09 02:42:58 niklas Exp $"; |
|
|
|
|
|
|
|
|
static size_t gsize; |
|
|
static size_t gsize; |
|
|
static char *pt; |
|
|
static char *pt; |
|
|
static int _add(), _conv(), _secs(); |
|
|
|
|
|
static size_t _fmt(); |
|
|
|
|
|
|
|
|
static int _add __P((const char *)); |
|
|
|
|
|
static int _secs __P((const struct tm *)); |
|
|
|
|
|
static int _conv __P((int, int, char)); |
|
|
|
|
|
static size_t _fmt __P((const char *, const struct tm *)); |
|
|
|
|
|
|
|
|
size_t |
|
|
size_t |
|
|
strftime(s, maxsize, format, t) |
|
|
strftime(s, maxsize, format, t) |
|
@ -74,8 +76,8 @@ strftime(s, maxsize, format, t) |
|
|
((t)->tm_wday ? (t)->tm_wday - 1 : 6)) / 7) |
|
|
((t)->tm_wday ? (t)->tm_wday - 1 : 6)) / 7) |
|
|
static size_t |
|
|
static size_t |
|
|
_fmt(format, t) |
|
|
_fmt(format, t) |
|
|
register char *format; |
|
|
|
|
|
struct tm *t; |
|
|
|
|
|
|
|
|
register const char *format; |
|
|
|
|
|
const struct tm *t; |
|
|
{ |
|
|
{ |
|
|
for (; *format; ++format) { |
|
|
for (; *format; ++format) { |
|
|
if (*format == '%') { |
|
|
if (*format == '%') { |
|
@ -276,7 +278,7 @@ _fmt(format, t) |
|
|
|
|
|
|
|
|
static int |
|
|
static int |
|
|
_secs(t) |
|
|
_secs(t) |
|
|
struct tm *t; |
|
|
|
|
|
|
|
|
const struct tm *t; |
|
|
{ |
|
|
{ |
|
|
static char buf[15]; |
|
|
static char buf[15]; |
|
|
register time_t s; |
|
|
register time_t s; |
|
@ -292,9 +294,13 @@ _secs(t) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int |
|
|
static int |
|
|
|
|
|
#if __STDC__ |
|
|
|
|
|
_conv(int n, int digits, char pad) |
|
|
|
|
|
#else |
|
|
_conv(n, digits, pad) |
|
|
_conv(n, digits, pad) |
|
|
int n, digits; |
|
|
int n, digits; |
|
|
char pad; |
|
|
char pad; |
|
|
|
|
|
#endif |
|
|
{ |
|
|
{ |
|
|
static char buf[10]; |
|
|
static char buf[10]; |
|
|
register char *p; |
|
|
register char *p; |
|
@ -308,7 +314,7 @@ _conv(n, digits, pad) |
|
|
|
|
|
|
|
|
static int |
|
|
static int |
|
|
_add(str) |
|
|
_add(str) |
|
|
register char *str; |
|
|
|
|
|
|
|
|
register const char *str; |
|
|
{ |
|
|
{ |
|
|
for (;; ++pt, --gsize) { |
|
|
for (;; ++pt, --gsize) { |
|
|
if (!gsize) |
|
|
if (!gsize) |
|
|