Commit Graph

2185 Commits

Author SHA1 Message Date
nia 82d379c3ac describe screenblank(1) 2021-11-26 17:38:07 +00:00
rillig dfa14757fe games/caesar: fix error handling for I/O
The '!= 0' is needed for an upcoming fix to lint's strict bool mode.

The additional text in the error messages is necessary because errx only
outputs the given string, with no details from errno.  Since ferror does
not set errno, no such details are available, so just output a generic
message, which is still better than just "caesar: <stdout>".
2021-11-16 20:42:47 +00:00
nat 3377e30f0d Better display in monochrome. 2021-11-13 20:59:13 +00:00
andvar 369abe069b fix various typos, mainly s/prefered/preferred/ 2021-11-07 20:31:09 +00:00
nia 7a33def692 cgram(6): realloc(x * y) -> reallocarr 2021-10-29 11:45:39 +00:00
nia 5a55ecfc78 atc(6): simplify reallocation logic 2021-10-29 11:44:22 +00:00
nia a373ad5865 sail(6): convert realloc(x * y) to reallocarr 2021-10-29 11:42:34 +00:00
nia dc9fa81fa1 huntd(6): convert malloc(x * y) and realloc(x * y) to reallocarr 2021-10-29 11:40:23 +00:00
andvar a136e22ab6 fix various typos in comments, messages and documentation. 2021-09-19 10:34:06 +00:00
uwe 8632485623 Ken Thompson on the i960. 2021-09-18 14:24:04 +00:00
nia 4e696e9839 person on internet is confused by how to list disks because there's
so much in /dev
2021-09-07 13:29:41 +00:00
nia 793842aae0 moar tips 2021-08-19 14:03:43 +00:00
nia 7134f2b9de Capitalization police. 2021-08-15 08:57:01 +00:00
dholland 06bcde7934 Flush input to EOL correctly in games/fish.
PR 54885 from Mouse, with a somewhat different patch.
2021-07-25 02:00:42 +00:00
dholland a9613397e7 add something 2021-07-11 00:35:05 +00:00
nia d9c389ef8f SIGINFO is a useful tip 2021-06-04 11:18:31 +00:00
nia 629bf65377 add some tips 2021-06-04 10:56:55 +00:00
dholland cfcbafc507 I don't see any code I wrote left in here. 2021-05-28 03:55:45 +00:00
dholland de73752569 Restore return value of main, arbitrarily thrown away in -r1.4. 2021-05-28 03:55:08 +00:00
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