Commit Graph

2153 Commits

Author SHA1 Message Date
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
christos
e8edee0bb7 remove error(1) comments 2020-11-10 23:32:33 +00:00
christos
17184abace Antivaxer support. 2020-11-10 23:03:22 +00:00
christos
b90df07acf can't have config.h and config.H in case-preserving but case-folding file-systems. 2020-11-10 22:56:49 +00:00
christos
ccdf7d95e3 don't segv if the terminal is too big. 2020-11-10 22:52:45 +00:00
christos
e123ae1b57 pray-tell where are you trying to write? 2020-11-10 22:52:32 +00:00
christos
e7d77274fb Time warp forward 34 years so that it compiles (but not work) 2020-11-10 22:42:19 +00:00
kamil
deb8b2cb72 Remove the smap.* files
They are generated during the build.
2020-11-10 11:29:29 +00:00
kamil
2710a02cd6 Integrate Warp Kit into the NetBSD build
Fix the build and make it install and run with minimal required changes.
2020-11-10 08:49:08 +00:00
kamil
653de20730 Reset CVS keywords 2020-11-10 00:02:11 +00:00
kamil
59ba73f691 Add Warp Kit, Version 7.0 by Larry Wall
Warp is a real-time space war game that doesn't get boring very quickly.
Read warp.doc and the manual page for more information.

games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
world via NetBSD. Its remnants were still mentioned in games/Makefile.

Larry Wall, the original author and the copyright holder, generously
donated the game and copyright to The NetBSD Foundation, Inc.

Import the game sources as-is from 4.3BSD-Reno, with the cession
of the copyright and license to BSD-2-clause NetBSD-style.

Signed-off-by: Larry Wall <larry@wall.org>
Signed-off-by: Kamil Rytarowski <kamil@netbsd.org>
2020-11-09 23:37:05 +00:00
dholland
386c99328f Restore the catman joke.
It needs the (8), or it fails to work for people who don't know or had
forgotten catman(8) was ever a thing.

as the de facto fortunes editor and also I think the person who added
that fortune in the first place, and given the discussion in
tech-userlevel, I think I get to do this.
2020-11-09 03:23:14 +00:00
kamil
fa5b5b5087 Revert to the original phrasing, but remove the man 8 section reference.
catman is a historical Unix tool.
2020-11-09 00:46:00 +00:00
kamil
dfc109fe43 catman(8) is a past thing 2020-11-08 17:37:29 +00:00