]> git.pld-linux.org Git - packages/bsddate.git/blame - bsddate-linux.patch
- new: port of (Free)BSD date(1) with useful -f, -r, -v options
[packages/bsddate.git] / bsddate-linux.patch
CommitLineData
6a20ed51
JB
1diff -Nur date.freebsd/bsdcompat.h date.linux/bsdcompat.h
2--- date.freebsd/bsdcompat.h 1970-01-01 01:00:00.000000000 +0100
3+++ date.linux/bsdcompat.h 2007-11-28 18:11:16.735113034 +0100
4@@ -0,0 +1,43 @@
5+#ifndef _BSDCOMPAT_H
6+#define _BSDCOMPAT_H
7+
8+#define _BSD_SOURCE
9+#define _XOPEN_SOURCE
10+#include <err.h>
11+#include <errno.h>
12+#include <langinfo.h>
13+#include <stdarg.h>
14+#include <string.h>
15+#include <time.h>
16+#include <sys/time.h>
17+
18+#define __FBSDID(x)
19+
20+static inline size_t strlcpy(char *dest, const char *src, size_t n)
21+{
22+ strncpy(dest, src, n-1);
23+ dest[n-1] = 0;
24+ return strlen(src);
25+}
26+
27+static inline void warnc(int code, const char *fmt, ...)
28+{
29+ int saveerrno = errno;
30+ va_list va;
31+ errno = code;
32+ va_start(va, fmt);
33+ vwarn(fmt, va);
34+ va_end(va);
35+ errno = saveerrno;
36+}
37+
38+static inline const char *date_time_fmt(void)
39+{
40+ const char *fmt = nl_langinfo(_DATE_FMT);
41+ if(fmt != NULL)
42+ return fmt;
43+ else
44+ return "%a %b %e %H:%M:%S %Z %Y";
45+}
46+
47+#endif /* _BSDCOMPAT_H */
48diff -Nur date.freebsd/date.1 date.linux/date.1
49--- date.freebsd/date.1 2007-11-28 07:24:41.000000000 +0100
50+++ date.linux/date.1 2007-11-28 17:42:31.472795937 +0100
51@@ -33,10 +33,10 @@
52 .\" $FreeBSD: src/bin/date/date.1,v 1.75 2007/06/02 20:15:59 remko Exp $
53 .\"
54 .Dd June 2, 2007
55-.Dt DATE 1
56+.Dt BSDDATE 1
57 .Os
58 .Sh NAME
59-.Nm date
60+.Nm bsddate
61 .Nd display or set date and time
62 .Sh SYNOPSIS
63 .Nm
64diff -Nur date.freebsd/date.c date.linux/date.c
65--- date.freebsd/date.c 2007-11-28 07:24:41.000000000 +0100
66+++ date.linux/date.c 2007-11-28 18:03:51.945765934 +0100
67@@ -143,7 +143,7 @@
68 if (!rflag && time(&tval) == -1)
69 err(1, "time");
70
71- format = "%+";
72+ format = date_time_fmt();
73
74 /* allow the operands in any order */
75 if (*argv && **argv == '+') {
76diff -Nur date.freebsd/libutil.h date.linux/libutil.h
77--- date.freebsd/libutil.h 1970-01-01 01:00:00.000000000 +0100
78+++ date.linux/libutil.h 2007-11-28 17:45:10.093835235 +0100
79@@ -0,0 +1 @@
80+#include <utmp.h>
81diff -Nur date.freebsd/Makefile date.linux/Makefile
82--- date.freebsd/Makefile 1970-01-01 01:00:00.000000000 +0100
83+++ date.linux/Makefile 2007-11-28 18:17:20.815860813 +0100
84@@ -0,0 +1,12 @@
85+CC=gcc
86+CFLAGS=-O2 -Wall
87+CPPFLAGS=-I. -include bsdcompat.h
88+LDFLAGS=
89+LIBS=-lutil
90+
91+date: date.o netdate.o vary.o
92+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS)
93+
94+date.o: extern.h vary.h libutil.h bsdcompat.h
95+netdate.o: extern.h bsdcompat.h
96+vary.o: vary.h bsdcompat.h
This page took 0.100863 seconds and 4 git commands to generate.