coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-06 11:28:09
Commit911e33a0feeb786216ef67c96c5b47106df01ab2
Parent7b4e9b3c2ae70dbb628c8c4dc985ba8114d71bb9

sleep: Use libokv error reporting

Diffstat

M src/sleep.c | 21 +++++++++++----------

1 files changed, 11 insertions, 10 deletions

diff --git a/src/sleep.c b/src/sleep.c
index 1d3c5d2..fff098a 100644
--- a/src/sleep.c
+++ b/src/sleep.c
@@ -1,4 +1,4 @@
-// sleep.c, version 1.0.0
+// sleep.c, version 1.0.1
 // OMKOV coreutils implementation of POSIX sleep
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,20 +33,21 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
 #include "optget.h"
 
+#include <error.h>
+
 #include <unistd.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <string.h>
+
+#define VERSION "1.0.1"
 
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) {
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -54,22 +55,22 @@ int main(int argc, char *argv[]) {
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; int o;
-	while ((o = optget(&opt, argv, 1)) != -1) switch (o) {
+	while ((o = optget(&opt, av, 1)) != -1) switch (o) {
 	case 256: { help(); return 0; }
 	case 257: { version(); return 0; }
 	default: { return 1; }
 	}
 
-	if (opt.ind == argc) { error(1, "%s: missing operand", argv[0]); }
+	if (opt.ind == ac) { error(1, "missing operand"); }
 
-	register uintmax_t n = 0, d; register char *p = argv[1];
+	register uintmax_t n = 0, d; register char *p = av[1];
 	for (; *p >= '0' && *p <= '9'; ++p) {
 		d = (uintmax_t)*p - '0';
 		if (n > (UINTMAX_MAX - d) / 10) { break; }
 		n = n * 10 + d;
 	}
 
-	if (*p) { error(1, "%s: %s: invalid time interval", argv[0], argv[1]); }
+	if (*p) { error(1, "%s: invalid time interval", av[1]); }
 
 	return (int)sleep(n);
 }
@@ -84,7 +85,7 @@ static void help(void) {
 }
 
 static void version(void) {
-	puts("OMKOV coreutils sleep, version 1.0.0");
+	puts("OMKOV coreutils sleep, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");