CVS commit: othersrc/usr.bin/sleepto

2021-02-25 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 10:18:38 UTC 2021

Modified Files:
othersrc/usr.bin/sleepto: sleepto.c

Log Message:
Use %lld and cast to "long long" for any time_t's.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/sleepto/sleepto.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/sleepto/sleepto.c
diff -u othersrc/usr.bin/sleepto/sleepto.c:1.2 othersrc/usr.bin/sleepto/sleepto.c:1.3
--- othersrc/usr.bin/sleepto/sleepto.c:1.2	Thu Feb 25 08:42:31 2021
+++ othersrc/usr.bin/sleepto/sleepto.c	Thu Feb 25 10:18:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sleepto.c,v 1.2 2021/02/25 08:42:31 simonb Exp $ */
+/* $NetBSD: sleepto.c,v 1.3 2021/02/25 10:18:38 simonb Exp $ */
 
 #include 
 #include 
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
 	when = parsetime(argc, argv);
 	now = tv.tv_sec;
 
-	printf("sleeping for %ld seconds...\n", when - now);
+	printf("sleeping for %lld seconds...\n", (long long)when - now);
 	ntime.tv_sec = when - now;
 	if (ntime.tv_sec <= 0)
 		return EXIT_SUCCESS;
@@ -53,10 +53,10 @@ main(int argc, char *argv[])
 	while ((rv = nanosleep(, )) != 0) {
 		if (report_requested) {
 			/* Reporting does not bother with nanoseconds. */
-			warnx("about %ld second%s left out of the original %ld",
-			ntime.tv_sec,
+			warnx("about %lld second%s left out of the original %lld",
+			(long long)ntime.tv_sec,
 			ntime.tv_sec == 1 ? "" : "s",
-			original);
+			(long long)original);
 			report_requested = 0;
 		} else
 			break;



CVS commit: othersrc/usr.bin/sleepto

2021-02-25 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 08:42:31 UTC 2021

Modified Files:
othersrc/usr.bin/sleepto: sleepto.c

Log Message:
Adapt rev 1.23 of bin/sleep/sleep.c:

  add SIGINFO support; from freebsd:

  when a SIGINFO is delivered, display the approximate remaining seconds.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.bin/sleepto/sleepto.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/sleepto/sleepto.c
diff -u othersrc/usr.bin/sleepto/sleepto.c:1.1 othersrc/usr.bin/sleepto/sleepto.c:1.2
--- othersrc/usr.bin/sleepto/sleepto.c:1.1	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/sleepto.c	Thu Feb 25 08:42:31 2021
@@ -1,21 +1,34 @@
-/* $NetBSD: sleepto.c,v 1.1 2021/02/25 07:03:57 simonb Exp $ */
+/* $NetBSD: sleepto.c,v 1.2 2021/02/25 08:42:31 simonb Exp $ */
 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "parsetime.h"
+
 #define TIMEFMT	"%R"
 
 static void	usage(void);
 
-extern time_t	parsetime(int, char **);
+static volatile sig_atomic_t report_requested;
+static void
+report_request(int signo __unused)
+{
+
+	report_requested = 1;
+}
+
 
 int
 main(int argc, char *argv[])
 {
+	struct timespec ntime;
 	struct timeval tv;
-	time_t when, now;
+	time_t when, now, original;
+	int rv;
 
 	if (argc < 2)
 		usage();
@@ -30,7 +43,27 @@ main(int argc, char *argv[])
 	now = tv.tv_sec;
 
 	printf("sleeping for %ld seconds...\n", when - now);
-	sleep(when - now);
+	ntime.tv_sec = when - now;
+	if (ntime.tv_sec <= 0)
+		return EXIT_SUCCESS;
+	ntime.tv_nsec = 0;
+
+	original = ntime.tv_sec;
+	signal(SIGINFO, report_request);
+	while ((rv = nanosleep(, )) != 0) {
+		if (report_requested) {
+			/* Reporting does not bother with nanoseconds. */
+			warnx("about %ld second%s left out of the original %ld",
+			ntime.tv_sec,
+			ntime.tv_sec == 1 ? "" : "s",
+			original);
+			report_requested = 0;
+		} else
+			break;
+	}
+
+	if (rv == -1)
+ 		err(EXIT_FAILURE, "nanosleep failed");
 
 	return EXIT_SUCCESS;
 }



CVS commit: othersrc/usr.bin/sleepto

2021-02-25 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 08:40:43 UTC 2021

Modified Files:
othersrc/usr.bin/sleepto: parsetime.c stime.h

Log Message:
Include the "from" CVS tags.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/sleepto/parsetime.c
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.bin/sleepto/stime.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/sleepto/parsetime.c
diff -u othersrc/usr.bin/sleepto/parsetime.c:1.2 othersrc/usr.bin/sleepto/parsetime.c:1.3
--- othersrc/usr.bin/sleepto/parsetime.c:1.2	Thu Feb 25 07:52:27 2021
+++ othersrc/usr.bin/sleepto/parsetime.c	Thu Feb 25 08:40:43 2021
@@ -1,4 +1,5 @@
-/*	$NetBSD: parsetime.c,v 1.2 2021/02/25 07:52:27 simonb Exp $	*/
+/* from	NetBSD: parsetime.c,v 1.20 2019/02/16 17:56:57 kre Exp	*/
+/*	$NetBSD: parsetime.c,v 1.3 2021/02/25 08:40:43 simonb Exp $	*/
 
 /*
  * parsetime.c - parse time for at(1)
@@ -156,7 +157,7 @@ static bool sc_tokplur;	/* scanner - is 
 #if 0
 static char rcsid[] = "$OpenBSD: parsetime.c,v 1.4 1997/03/01 23:40:10 millert Exp $";
 #else
-__RCSID("$NetBSD: parsetime.c,v 1.2 2021/02/25 07:52:27 simonb Exp $");
+__RCSID("$NetBSD: parsetime.c,v 1.3 2021/02/25 08:40:43 simonb Exp $");
 #endif
 #endif
 

Index: othersrc/usr.bin/sleepto/stime.h
diff -u othersrc/usr.bin/sleepto/stime.h:1.1 othersrc/usr.bin/sleepto/stime.h:1.2
--- othersrc/usr.bin/sleepto/stime.h:1.1	Thu Feb 25 07:52:27 2021
+++ othersrc/usr.bin/sleepto/stime.h	Thu Feb 25 08:40:43 2021
@@ -1,4 +1,5 @@
-/*	$NetBSD: stime.h,v 1.1 2021/02/25 07:52:27 simonb Exp $	*/
+/* from	NetBSD: stime.h,v 1.4 2008/04/05 16:26:57 christos Exp	*/
+/*	$NetBSD: stime.h,v 1.2 2021/02/25 08:40:43 simonb Exp $	*/
 
 /*
  * Copyright (c) 1993



CVS commit: othersrc/usr.bin/sleepto

2021-02-24 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 07:52:27 UTC 2021

Modified Files:
othersrc/usr.bin/sleepto: parsetime.c
Added Files:
othersrc/usr.bin/sleepto: stime.h

Log Message:
Catch up on usr.bin/at/parsetime.c revs 1.16 to 1.20.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.bin/sleepto/parsetime.c
cvs rdiff -u -r0 -r1.1 othersrc/usr.bin/sleepto/stime.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/sleepto/parsetime.c
diff -u othersrc/usr.bin/sleepto/parsetime.c:1.1 othersrc/usr.bin/sleepto/parsetime.c:1.2
--- othersrc/usr.bin/sleepto/parsetime.c:1.1	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/parsetime.c	Thu Feb 25 07:52:27 2021
@@ -1,6 +1,6 @@
-/*	$NetBSD: parsetime.c,v 1.1 2021/02/25 07:03:57 simonb Exp $	*/
+/*	$NetBSD: parsetime.c,v 1.2 2021/02/25 07:52:27 simonb Exp $	*/
 
-/* 
+/*
  * parsetime.c - parse time for at(1)
  * Copyright (C) 1993, 1994  Thomas Koenig
  *
@@ -38,8 +38,10 @@
 /* System Headers */
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,76 +50,94 @@
 #include 
 
 #include "parsetime.h"
+#include "stime.h"
 
 /* Structures and unions */
 
-enum {	/* symbols */
+typedef enum { /* symbols */
 	MIDNIGHT, NOON, TEATIME,
 	PM, AM, TOMORROW, TODAY, NOW,
-	MINUTES, HOURS, DAYS, WEEKS,
+	MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS,
 	NUMBER, PLUS, DOT, SLASH, ID, JUNK,
 	JAN, FEB, MAR, APR, MAY, JUN,
 	JUL, AUG, SEP, OCT, NOV, DEC,
-	SUN, MON, TUE, WED, THU, FRI, SAT
-};
+	SUN, MON, TUE, WED, THU, FRI, SAT,
+	TOKEOF	/* EOF marker */
+} tokid_t;
 
 /*
  * parse translation table - table driven parsers can be your FRIEND!
  */
-struct {
+static const struct {
 	const char *name;	/* token name */
-	int value;		/* token id */
-	int plural;		/* is this plural? */
+	tokid_t value;		/* token id */
+	bool plural;		/* is this plural? */
 } Specials[] = {
-	{ "midnight", MIDNIGHT, 0 },	/* 00:00:00 of today or tomorrow */
-	{ "noon", NOON, 0 },		/* 12:00:00 of today or tomorrow */
-	{ "teatime", TEATIME, 0 },	/* 16:00:00 of today or tomorrow */
-	{ "am", AM, 0 },		/* morning times for 0-12 clock */
-	{ "pm", PM, 0 },		/* evening times for 0-12 clock */
-	{ "tomorrow", TOMORROW, 0 },	/* execute 24 hours from time */
-	{ "today", TODAY, 0 },		/* execute today - don't advance time */
-	{ "now", NOW, 0 },		/* opt prefix for PLUS */
-
-	{ "minute", MINUTES, 0 },	/* minutes multiplier */
-	{ "min", MINUTES, 0 },
-	{ "m", MINUTES, 0 },
-	{ "minutes", MINUTES, 1 },	/* (pluralized) */
-	{ "hour", HOURS, 0 },		/* hours ... */
-	{ "hr", HOURS, 0 },		/* abbreviated */
-	{ "h", HOURS, 0 },
-	{ "hours", HOURS, 1 },		/* (pluralized) */
-	{ "day", DAYS, 0 },		/* days ... */
-	{ "d", DAYS, 0 },
-	{ "days", DAYS, 1 },		/* (pluralized) */
-	{ "week", WEEKS, 0 },		/* week ... */
-	{ "w", WEEKS, 0 },
-	{ "weeks", WEEKS, 1 },		/* (pluralized) */
-	{ "jan", JAN, 0 },
-	{ "feb", FEB, 0 },
-	{ "mar", MAR, 0 },
-	{ "apr", APR, 0 },
-	{ "may", MAY, 0 },
-	{ "jun", JUN, 0 },
-	{ "jul", JUL, 0 },
-	{ "aug", AUG, 0 },
-	{ "sep", SEP, 0 },
-	{ "oct", OCT, 0 },
-	{ "nov", NOV, 0 },
-	{ "dec", DEC, 0 },
-	{ "sunday", SUN, 0 },
-	{ "sun", SUN, 0 },
-	{ "monday", MON, 0 },
-	{ "mon", MON, 0 },
-	{ "tuesday", TUE, 0 },
-	{ "tue", TUE, 0 },
-	{ "wednesday", WED, 0 },
-	{ "wed", WED, 0 },
-	{ "thursday", THU, 0 },
-	{ "thu", THU, 0 },
-	{ "friday", FRI, 0 },
-	{ "fri", FRI, 0 },
-	{ "saturday", SAT, 0 },
-	{ "sat", SAT, 0 },
+	{"midnight", MIDNIGHT, false},	/* 00:00:00 of today or tomorrow */
+	{"noon", NOON, false},		/* 12:00:00 of today or tomorrow */
+	{"teatime", TEATIME, false},	/* 16:00:00 of today or tomorrow */
+	{"am", AM, false},		/* morning times for 0-12 clock */
+	{"pm", PM, false},		/* evening times for 0-12 clock */
+	{"tomorrow", TOMORROW, false},	/* execute 24 hours from time */
+	{"today", TODAY, false},		/* execute today - don't advance time */
+	{"now", NOW, false},		/* opt prefix for PLUS */
+
+	{"minute", MINUTES, false},	/* minutes multiplier */
+	{"min", MINUTES, false},
+	{"m", MINUTES, false},
+	{"minutes", MINUTES, true},	/* (pluralized) */
+	{"hour", HOURS, false},		/* hours ... */
+	{"hr", HOURS, false},		/* abbreviated */
+	{"h", HOURS, false},
+	{"hours", HOURS, true},		/* (pluralized) */
+	{"day", DAYS, false},		/* days ... */
+	{"d", DAYS, false},
+	{"days", DAYS, true},		/* (pluralized) */
+	{"week", WEEKS, false},		/* week ... */
+	{"w", WEEKS, false},
+	{"weeks", WEEKS, true},		/* (pluralized) */
+	{ "month", MONTHS, 0 },		/* month ... */
+	{ "months", MONTHS, 1 },	/* (pluralized) */
+	{ "year", YEARS, 0 },		/* year ... */
+	{ "years", YEARS, 1 },		/* (pluralized) */
+	{"jan", JAN, false},
+	{"feb", FEB, false},
+	{"mar", MAR, false},
+	{"apr", APR, false},
+	{"may", MAY, false},
+	{"jun", JUN, false},
+	{"jul", JUL, false},
+	{"aug", AUG, false},
+	{"sep", SEP, 

CVS commit: othersrc/usr.bin/sleepto

2021-02-24 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 07:03:57 UTC 2021

Added Files:
othersrc/usr.bin/sleepto: Makefile parsetime.c parsetime.h sleepto.c
tzfile.h

Log Message:
Jared's sleepto command from Dec 2007 - sleep to an at(1) style time
specification.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/usr.bin/sleepto/Makefile \
othersrc/usr.bin/sleepto/parsetime.c othersrc/usr.bin/sleepto/parsetime.h \
othersrc/usr.bin/sleepto/sleepto.c othersrc/usr.bin/sleepto/tzfile.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: othersrc/usr.bin/sleepto/Makefile
diff -u /dev/null othersrc/usr.bin/sleepto/Makefile:1.1
--- /dev/null	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/Makefile	Thu Feb 25 07:03:57 2021
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2021/02/25 07:03:57 simonb Exp $
+
+PROG=	sleepto
+SRCS=	sleepto.c parsetime.c
+NOMAN=	# defined
+WARNS?=	4
+
+.include 
Index: othersrc/usr.bin/sleepto/parsetime.c
diff -u /dev/null othersrc/usr.bin/sleepto/parsetime.c:1.1
--- /dev/null	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/parsetime.c	Thu Feb 25 07:03:57 2021
@@ -0,0 +1,673 @@
+/*	$NetBSD: parsetime.c,v 1.1 2021/02/25 07:03:57 simonb Exp $	*/
+
+/* 
+ * parsetime.c - parse time for at(1)
+ * Copyright (C) 1993, 1994  Thomas Koenig
+ *
+ * modifications for english-language times
+ * Copyright (C) 1993  David Parsons
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author(s) may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  at [NOW] PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS
+ * /NUMBER [DOT NUMBER] [AM|PM]\ /[MONTH NUMBER [NUMBER]] \
+ * |NOON   | |[TOMORROW]  |
+ * |MIDNIGHT   | |[DAY OF WEEK]   |
+ * \TEATIME/ |NUMBER [SLASH NUMBER [SLASH NUMBER]]|
+ *   \PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS/
+ */
+
+/* System Headers */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "parsetime.h"
+
+/* Structures and unions */
+
+enum {	/* symbols */
+	MIDNIGHT, NOON, TEATIME,
+	PM, AM, TOMORROW, TODAY, NOW,
+	MINUTES, HOURS, DAYS, WEEKS,
+	NUMBER, PLUS, DOT, SLASH, ID, JUNK,
+	JAN, FEB, MAR, APR, MAY, JUN,
+	JUL, AUG, SEP, OCT, NOV, DEC,
+	SUN, MON, TUE, WED, THU, FRI, SAT
+};
+
+/*
+ * parse translation table - table driven parsers can be your FRIEND!
+ */
+struct {
+	const char *name;	/* token name */
+	int value;		/* token id */
+	int plural;		/* is this plural? */
+} Specials[] = {
+	{ "midnight", MIDNIGHT, 0 },	/* 00:00:00 of today or tomorrow */
+	{ "noon", NOON, 0 },		/* 12:00:00 of today or tomorrow */
+	{ "teatime", TEATIME, 0 },	/* 16:00:00 of today or tomorrow */
+	{ "am", AM, 0 },		/* morning times for 0-12 clock */
+	{ "pm", PM, 0 },		/* evening times for 0-12 clock */
+	{ "tomorrow", TOMORROW, 0 },	/* execute 24 hours from time */
+	{ "today", TODAY, 0 },		/* execute today - don't advance time */
+	{ "now", NOW, 0 },		/* opt prefix for PLUS */
+
+	{ "minute", MINUTES, 0 },	/* minutes multiplier */
+	{ "min", MINUTES, 0 },
+	{ "m", MINUTES, 0 },
+	{ "minutes", MINUTES, 1 },	/* (pluralized) */
+	{ "hour", HOURS, 0 },		/* hours ... */
+	{ "hr", HOURS, 0 },		/* abbreviated */
+	{ "h", HOURS, 0 },
+	{ "hours", HOURS, 1 },		/* (pluralized) */
+	{ "day", DAYS, 0 },		/* days ... */
+	{ "d", DAYS, 0 },
+	{ "days", DAYS, 1 },		/* (pluralized) */
+	{ "week", WEEKS, 0 },		/* week ... */
+	{ "w", WEEKS, 0 },
+	{ "weeks", WEEKS, 1 },		/* (pluralized) */
+	{ "jan", JAN, 0 },
+	{ "feb", FEB, 0 },
+	{ "mar", MAR, 0 },
+	{ "apr", APR, 0 },
+	{ "may", MAY, 0 },
+	{ "jun", JUN, 0 },
+	{ "jul", JUL, 0 },
+	{ "aug", AUG, 0 },
+	{ "sep", SEP, 0 },