Commit Graph

2166 Commits

Author SHA1 Message Date
kre
dabfbe63eb Adapt to recent change to ../snake/pathnames.h 2021-05-12 15:26:44 +00:00
nia
7570066346 snake: Avoid creating definitions prefixed with _ inside a program 2021-05-12 11:08:31 +00:00
rillig
2caa24ffff countmail: remove outdated comments
Using the shell builtin 'read' command was necessarily slow because it
is specified to read a single byte at a time.
2021-05-02 13:10:36 +00:00
rillig
1182a44c59 games: remove trailing whitespace in *.c and *.h 2021-05-02 12:50:43 +00:00
rillig
0527d6d12b fish: remove trailing whitespace 2021-05-02 12:25:55 +00:00
rillig
4dbccc6d68 fish: use arc4random_uniform for drawing random numbers
Thanks nia@ for the hint.
2021-05-02 12:24:59 +00:00
rillig
ac598ab1cf fish: remove modulo bias from random number generation
It probably doesn't matter in practice, but omitting this piece of code
always looks like an oversight.
2021-05-01 21:10:57 +00:00
rillig
6a70979a86 cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done'
is even shorter.

No functional change.
2021-05-01 20:29:23 +00:00
rillig
c6b805dbac caesar: WARNS=6, strict bool mode
The rotation is validated to be nonnegative, therefore use unsigned int
for it.
2021-05-01 20:21:25 +00:00
rillig
c9b39ce704 cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out
less, helping to focus on the missing letters.
2021-04-29 20:17:20 +00:00
rillig
3e4a0edf9f cgram: use ASCII-only implementation of <ctype.h> functions
The function 'encode' already assumes that all letter characters are
contiguous and that there are only 26 letters of each case.  At the
moment, cgram cannot handle UTF-8 anyway since it reads the input
byte-wise, assuming that each byte is exacty one character.
2021-04-25 20:38:03 +00:00
rillig
0721cc8d68 cgram: provide usage on incorrect invocation 2021-04-25 20:19:19 +00:00
rillig
1f36a02f91 cgram: conform to lint's strict bool mode, KNF 2021-04-25 20:14:29 +00:00
wiz
69305a0d1c cgram: allow providing an input file instead of the random fortune 2021-04-22 14:57:36 +00:00
mrg
e6d9bbbe8f one port complains about string overflow here that i can't see. 2021-04-15 01:55:21 +00:00
mrg
4caf7d9e65 avoid duplicating symbols in libterminfo. 2021-04-13 08:06:38 +00:00
mrg
af0a9e8c91 no longer need -Wno-error=implicit-fallthrough.
don't provide common symbols that are in libterminfo now days.
2021-04-13 02:11:39 +00:00
mrg
4c266a5438 properly terminate after using strncpy(). 2021-04-13 01:50:46 +00:00
mrg
18bae9314b avoid leaving off the trailing nul in a literal string. 2021-04-12 09:12:28 +00:00
mrg
84bbce3d17 include bsd.own.mk to be sure NETBSDSRCDIR is set. 2021-04-12 04:19:32 +00:00
mrg
a2d1542565 add some new uses of existing GCC_NO_* variables for warning issues.
remove an no longer relevant for gcc7 workaround (works fine in both
gcc9 and gcc 10.)
2021-04-12 02:54:07 +00:00
rillig
32eb951e74 cgram: don't beep if the window is resized 2021-02-26 15:18:40 +00:00
rillig
550a2d894f cgram: place the 'solved' marker nearer to the text
This way, it cannot be overlooked as easily as before.  It also doesn't
change the position of the keyboard help text anymore.  Only if there is
not enough space, the 'solved' marker is put into the bottom line.
2021-02-26 15:15:34 +00:00
rillig
531f30a38a cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].

[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
2021-02-26 14:55:37 +00:00
rillig
6ec38e5b23 cgram: fix assertion when substituting at the end of the longest line
Reported by Weitian LI via GitHub.

Contrary to the patch suggested in [1], still allow the cursor to be
placed to the very right of the text in a line since that is the usual
behavior of text editors.

Split the function substitute() into two parts:  one that handles the
curses-specific part of checking whether a substitution is possible at
the current cursor position, and one that performs the actual
substitution.  Only the latter is kept in the code section for the
string manipulation functions, the other is moved to the section for
curses code.  Having all the curses code in one place reduces the places
that call beep().  Previously, as well as now, there is a single beep
per invalid key before, but that was not obvious from the previous code.

[1]: https://github.com/DragonFlyBSD/DragonFlyBSD/commit/18d09f18cf4c
2021-02-22 19:34:07 +00:00
rillig
f7c85ecb67 cgram: add advanced cursor movement with tab, shift+tab, return 2021-02-22 17:36:42 +00:00
rillig
47c6585f93 cgram: properly handle input errors
On both NetBSD and Cygwin, a missing /usr/bin/fortune would previously
continue since popen does not return an error (as /bin/sh is found and
can be executed), so the next chance to catch an error is pclose.  At
that point, the shell has already printed an informative error message
about what happened (or what didn't happen), so that cgram does not need
to print an error by itself.
2021-02-22 16:28:20 +00:00
rillig
9510ff87da cgram: allow navigation with KEY_PPAGE and KEY_NPAGE 2021-02-21 22:21:56 +00:00
rillig
1646b19068 cgram: rewrite completely, fixing bugs and style
Fixed bugs:

Do not consider the puzzle solved if all letters in the visible area are
substituted correctly.  To be properly solved, the whole puzzle must be
solved, even those parts that are currently off-screen.

Never place the cursor at the very right edge of the screen since that
does not work well with some terminals.  The maximum valid x coordinate
is COLS - 1.

Add horizontal scrolling.  Make all coordinate handling symmetric in
regard to the horizontal and vertical axes.  Previously, lines longer
than 80 characters could not be seen on the screen.

Improvements:

Remove the arbitrary limit of 128 characters per line.  Even if
fortune(6) may never generate such long lines, the code is easy enough
to adapt to other sources.

Properly clean up the allocated memory.  Previously, only the string
arrays were freed but not the strings themselves.

Stylistic:

Add RCS ID.

Fix ctype functions in lint's strict bool mode.

Avoid excessive calls to strlen whenever the cursor moves.  Given that
the whole screen is redrawn every time a key is pressed, this is an
unnecessary optimization, but the code smelled nevertheless.
2021-02-21 20:33:42 +00:00
rillig
12c09445ec cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.

No functional change, assuming that fortune(6) always spits out less
than 2 gigacharacters of text.
2021-02-21 17:16:00 +00:00
rillig
f21d40b5e2 cgram: consistently use char for characters
Having to convert back and forth between char, unsigned char and int is
confusing.  Just stay with char, until the support for wide characters
is added.

No functional change.
2021-02-21 16:50:57 +00:00
rillig
c414f53223 cgram: fix undefined behavior when pressing function keys
The key codes for function keys are outside of the "range representable
by an unsigned char".  This resulted in parts of the screen being
cleaned.
2021-02-21 16:37:26 +00:00
rillig
905a01e770 cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute().  Before, 0 meant
success, now false means failure.

No functional change.
2021-02-21 16:05:44 +00:00
rillig
43892d8404 cgram: sort includes 2021-02-21 15:42:21 +00:00
rillig
b15c3153c9 cgram: indent
With manual corrections afterwards:

- indent removes empty lines between statement and declaration.  This
  had been a syntax error in C90, since C99 this is common style and
  should be accepted by indent.

- indent didn't format the first line of main for whatever reason, did
  that manually.

- indent removed the empty line above the '/////' separators.  It should
  have left these empty lines as-is.
2021-02-21 15:41:04 +00:00
rillig
0aae6846c3 cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
2021-02-21 13:35:37 +00:00
christos
6fceff0a4e - Don't allocate memory dynamically on the stack (for SSP)
- Don't return errno as exit code
- Fold long lines
2021-01-08 15:16:04 +00:00
jmcneill
8582796087 set the cursor to invisible 2021-01-02 12:12:26 +00:00
jmcneill
b7ebe3f39d trailing whitespace 2021-01-02 12:10:17 +00:00
wiz
a2a2d948d4 Markup/typo fixes. 2021-01-02 08:55:51 +00:00
nat
ad733c96b3 Add testpat(6) to games.
Testpat displays a test pattern in curses(3).
2021-01-02 03:21:39 +00:00
dholland
ce47fd40df speed limit 80 2020-12-06 11:41:47 +00:00
dholland
475cad6763 speed limit 80 2020-12-06 11:35:27 +00:00
rin
f52e729971 roundsleep(): Too many zeros; tv_nsec should be compared with
500 msec, not 5000. Raised by clang for ILP32 archs.
2020-11-21 09:24:02 +00:00
joerg
a5e6526bbc Avoid common symbols. Use __dead. 2020-11-12 22:23:16 +00:00
christos
f5001bc688 Comment out debugging build (it still randomly crashes though) pointed out
by wiz
2020-11-11 20:04:02 +00:00
christos
29ab367558 use strchr, strrchr, random, more lint removal, savefile in /var/games/warp
not /usr/share/games/warp...
2020-11-11 19:55:33 +00:00
christos
b853388890 no need for -lcompat 2020-11-11 19:54:53 +00:00
christos
6ecf74c0f6 - use termios
- enable setgid games
- enable savedir
2020-11-11 17:11:19 +00:00
kamil
ec609ce1aa Fix the old leftover license note
Larry Wall: "I outgrew commercial-free licensing about 30 years ago."
2020-11-11 11:54:42 +00:00