From owner-freebsd-bugs Tue Sep 18 1:40:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3414637B419 for ; Tue, 18 Sep 2001 01:40:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8I8e1B82894; Tue, 18 Sep 2001 01:40:01 -0700 (PDT) (envelope-from gnats) Received: from lion.com.ua (lion.com.ua [213.133.161.130]) by hub.freebsd.org (Postfix) with ESMTP id 953C537B414 for ; Tue, 18 Sep 2001 01:39:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lion.com.ua (8.11.4/8.11.4) with ESMTP id f8I8dDF72293 for ; Tue, 18 Sep 2001 11:39:16 +0300 (EEST) (envelope-from sa@simon.org.ua) Message-Id: <20010918113631.I72277-100000@lion.com.ua> Date: Tue, 18 Sep 2001 11:39:12 +0300 (EEST) From: Andrey Simonenko To: Subject: bin/30641: Patch for games/grdc Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30641 >Category: bin >Synopsis: Patch for games/grdc >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Sep 18 01:40:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Andrey Simonenko >Release: FreeBSD 4.4-RC i386 >Organization: >Environment: System: FreeBSD 4.4-RC i386 >Description: grdc(8) outputs big digital clock. Color of digits is red, if grdc(8) is used on b/w display, then it is hard to see something. This patch adds new flag to grdc(8): -b, which changes color of digits to b/w. Also arguments checking is improved. In this patch type of "sigtermed" variable is changed from "int" to "voilatile sig_atomic_t", because "sigtermed" variable is changed in signal handler. In this patch also one fprintf(stderr) function is changed to appropriate errx(3) function. >How-To-Repeat: Apply following patch. >Fix: diff -ru /usr/src/games/grdc/grdc.6 grdc/grdc.6 --- /usr/src/games/grdc/grdc.6 Mon Dec 5 19:29:59 1994 +++ grdc/grdc.6 Mon Sep 17 02:40:22 2001 @@ -3,7 +3,7 @@ grdc \- grand digital clock (curses) .SH SYNOPSIS .B grdc -[-s] [ +[-sb] [ .I n ] .SH DESCRIPTION @@ -18,5 +18,8 @@ .B -s flag makes digits scroll as they change. In this curses mode implementation, the scrolling option has trouble keeping up. +The optional +.B -b +flag changes color of digits to b/w (useful option for b/w displays). .SH AUTHOR Amos Shapir, modified for curses by John Lupien. diff -ru /usr/src/games/grdc/grdc.c grdc/grdc.c --- /usr/src/games/grdc/grdc.c Sun Dec 12 03:04:17 1999 +++ grdc/grdc.c Mon Sep 17 20:26:14 2001 @@ -1,18 +1,23 @@ /* * Grand digital clock for curses compatible terminals - * Usage: grdc [-s] [n] -- run for n seconds (default infinity) + * Usage: grdc [-sb] [n] -- run for n seconds (default infinity) * Flags: -s: scroll + * -b: b/w output * * modified 10-18-89 for curses (jrl) * 10-18-89 added signal handling + * 09-17-2001 added -b flag, improved arguments checking * * $FreeBSD: src/games/grdc/grdc.c,v 1.8 1999/12/12 03:04:17 billf Exp $ */ +#include +#include #include #include #include #include +#include #ifndef NONPOSIX #include #endif @@ -31,9 +36,9 @@ 074717, 074757, 071111, 075757, 075717, 002020 }; long old[6], next[6], new[6], mask; -char scrol; +int scrol = 0, bw = 0; -int sigtermed=0; +volatile sig_atomic_t sigtermed = 0; int hascolor = 0; @@ -56,6 +61,32 @@ long t, a; int i, j, s, k; int n = 0; +int opt; + + opterr = 0; + while ( (opt = getopt(argc, argv, "sb")) != -1) + switch (opt) { + case 's': + scrol = 1; + break; + case 'b': + bw = 1; + break; + case '?': + errx(1, "invalid switch -%c", optopt); + break; + default: + err(1, "getopt"); + } + if (optind < argc) { + if (optind == argc - 1) { + for (i = 0; i < strlen(argv[optind]); ++i) + if (isdigit(argv[optind][i]) == 0) + errx(1, "incorrect number of seconds \"%s\"", argv[optind]); + n = atoi(argv[optind]); + } else + errx(1, "too many arguments \"%s\"", argv[optind + 1]); + } initscr(); @@ -71,20 +102,19 @@ if(hascolor) { start_color(); - init_pair(1, COLOR_BLACK, COLOR_RED); - init_pair(2, COLOR_RED, COLOR_BLACK); + if (bw) { + init_pair(1, COLOR_BLACK, COLOR_WHITE); + init_pair(2, COLOR_WHITE, COLOR_BLACK); + } else { + init_pair(1, COLOR_BLACK, COLOR_RED); + init_pair(2, COLOR_RED, COLOR_BLACK); + } init_pair(3, COLOR_WHITE, COLOR_BLACK); attrset(COLOR_PAIR(2)); } clear(); refresh(); - while(--argc > 0) { - if(**++argv == '-') - scrol = 1; - else - n = atoi(*argv); - } if(hascolor) { attrset(COLOR_PAIR(3)); @@ -155,8 +185,7 @@ clear(); refresh(); endwin(); - fprintf(stderr, "grdc terminated by signal %d\n", sigtermed); - exit(1); + errx(1, "terminated by signal %d", sigtermed); } } while(--n); standend(); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message