tetris(6): Support the informal standard of allowing setting NO_COLOR

in the environment to disable the use of color. (no-color.org)
This commit is contained in:
nia 2023-07-01 10:51:35 +00:00
parent d644da2ee9
commit d92552c3ea
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: tetris.6,v 1.17 2016/03/12 03:14:59 dholland Exp $ .\" $NetBSD: tetris.6,v 1.18 2023/07/01 10:51:35 nia Exp $
.\" .\"
.\" Copyright (c) 1992, 1993 .\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" @(#)tetris.6 8.1 (Berkeley) 5/31/93 .\" @(#)tetris.6 8.1 (Berkeley) 5/31/93
.\" .\"
.Dd February 18, 2015 .Dd July 1, 2023
.Dt TETRIS 6 .Dt TETRIS 6
.Os .Os
.Sh NAME .Sh NAME
@ -146,6 +146,11 @@ name, score, and how many points were scored on what level.
Scores which are the highest on a given level Scores which are the highest on a given level
are marked with asterisks are marked with asterisks
.Dq * . .Dq * .
.Sh ENVIRONMENT
.Nm
honors the informal standard
.Dv NO_COLOR .
When it is set in the environment, no color will be used.
.Sh FILES .Sh FILES
.Bl -tag -width /var/games/tetris.scoresxx .Bl -tag -width /var/games/tetris.scoresxx
.It /var/games/tetris.scores .It /var/games/tetris.scores

View File

@ -1,4 +1,4 @@
/* $NetBSD: tetris.c,v 1.33 2020/07/21 02:42:05 nia Exp $ */ /* $NetBSD: tetris.c,v 1.34 2023/07/01 10:51:35 nia Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -135,6 +135,7 @@ main(int argc, char *argv[])
int level = 2; int level = 2;
#define NUMKEYS 7 #define NUMKEYS 7
char key_write[NUMKEYS][10]; char key_write[NUMKEYS][10];
char *nocolor_env;
int ch, i, j; int ch, i, j;
int fd; int fd;
@ -182,6 +183,11 @@ main(int argc, char *argv[])
if (argc) if (argc)
usage(); usage();
nocolor_env = getenv("NO_COLOR");
if (nocolor_env != NULL && nocolor_env[0] != '\0')
nocolor = 1;
fallrate = 1000000 / level; fallrate = 1000000 / level;
for (i = 0; i <= (NUMKEYS-1); i++) { for (i = 0; i <= (NUMKEYS-1); i++) {