The NetBSD Project

CVS log for src/games/cgram/cgram.c

[BACK] Up to [cvs.NetBSD.org] / src / games / cgram

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.30: download - view: text, markup, annotated - select for diffs
Wed May 10 12:30:27 2023 UTC (22 months, 2 weeks ago) by rillig
Branches: MAIN
CVS tags: perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, HEAD
Diff to: previous 1.29: preferred, colored
Changes since revision 1.29: +10 -9 lines
cgram: replace comments with code

No binary change.

Revision 1.29: download - view: text, markup, annotated - select for diffs
Sun Jun 12 14:59:44 2022 UTC (2 years, 9 months ago) by rillig
Branches: MAIN
CVS tags: netbsd-10-base, netbsd-10-1-RELEASE, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Diff to: previous 1.28: preferred, colored
Changes since revision 1.28: +3 -2 lines
cgram: allow cursor navigation with KEY_BEG as well

Revision 1.28: download - view: text, markup, annotated - select for diffs
Sat May 14 14:20:10 2022 UTC (2 years, 10 months ago) by rillig
Branches: MAIN
Diff to: previous 1.27: preferred, colored
Changes since revision 1.27: +6 -2 lines
cgram: clear bottom line of the screen at the end

Previously, the prompt line of the shell overwrote only part of the
prompt of cgram, the rest was still visible.

Revision 1.27: download - view: text, markup, annotated - select for diffs
Mon Mar 28 20:00:29 2022 UTC (2 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.26: preferred, colored
Changes since revision 1.26: +6 -12 lines
cgram: define a word as a sequence of letters, not non-whitespace

Pressing Tab or Shift+Tab now advances to the next letter that could be
substituted, it no longer stops at punctuation or digits.  Since only
letters are scrambled, these are most interesting to be edited.

Revision 1.26: download - view: text, markup, annotated - select for diffs
Fri Oct 29 11:45:39 2021 UTC (3 years, 4 months ago) by nia
Branches: MAIN
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +3 -4 lines
cgram(6): realloc(x * y) -> reallocarr

Revision 1.23.2.1: download - view: text, markup, annotated - select for diffs
Mon May 31 22:15:06 2021 UTC (3 years, 9 months ago) by cjep
Branches: cjep_staticlib_x
Diff to: previous 1.23: preferred, colored; next MAIN 1.24: preferred, colored
Changes since revision 1.23: +4 -3 lines
sync with head

Revision 1.25: download - view: text, markup, annotated - select for diffs
Fri May 28 03:55:45 2021 UTC (3 years, 10 months ago) by dholland
Branches: MAIN
CVS tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +3 -3 lines
I don't see any code I wrote left in here.

Revision 1.24: download - view: text, markup, annotated - select for diffs
Fri May 28 03:55:08 2021 UTC (3 years, 10 months ago) by dholland
Branches: MAIN
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +3 -2 lines
Restore return value of main, arbitrarily thrown away in -r1.4.

Revision 1.23: download - view: text, markup, annotated - select for diffs
Sat May 1 20:29:23 2021 UTC (3 years, 10 months ago) by rillig
Branches: MAIN
CVS tags: cjep_staticlib_x-base
Branch point for: cjep_staticlib_x
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +7 -7 lines
cgram: rename local functions

The word 'cleanup' should have been named clean_up all along, but 'done'
is even shorter.

No functional change.

Revision 1.22: download - view: text, markup, annotated - select for diffs
Thu Apr 29 20:17:20 2021 UTC (3 years, 10 months ago) by rillig
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +3 -4 lines
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.

Revision 1.21: download - view: text, markup, annotated - select for diffs
Sun Apr 25 20:38:03 2021 UTC (3 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +18 -19 lines
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.

Revision 1.20: download - view: text, markup, annotated - select for diffs
Sun Apr 25 20:19:19 2021 UTC (3 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +15 -3 lines
cgram: provide usage on incorrect invocation

Revision 1.19: download - view: text, markup, annotated - select for diffs
Sun Apr 25 20:14:29 2021 UTC (3 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +7 -5 lines
cgram: conform to lint's strict bool mode, KNF

Revision 1.18: download - view: text, markup, annotated - select for diffs
Thu Apr 22 14:57:36 2021 UTC (3 years, 11 months ago) by wiz
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +35 -13 lines
cgram: allow providing an input file instead of the random fortune

Revision 1.17: download - view: text, markup, annotated - select for diffs
Fri Feb 26 15:18:40 2021 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +4 -2 lines
cgram: don't beep if the window is resized

Revision 1.16: download - view: text, markup, annotated - select for diffs
Fri Feb 26 15:15:34 2021 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +8 -4 lines
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.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Feb 26 14:55:37 2021 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +8 -4 lines
cgram: make the 'solved' stand out more

Suggested by Weitian LI via [1].

[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736

Revision 1.14: download - view: text, markup, annotated - select for diffs
Mon Feb 22 19:34:07 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +30 -39 lines
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

Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Feb 22 17:36:42 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +117 -49 lines
cgram: add advanced cursor movement with tab, shift+tab, return

Revision 1.12: download - view: text, markup, annotated - select for diffs
Mon Feb 22 16:28:20 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +4 -3 lines
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.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Sun Feb 21 22:21:56 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +12 -8 lines
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE

Revision 1.10: download - view: text, markup, annotated - select for diffs
Sun Feb 21 20:33:42 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +286 -179 lines
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.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Sun Feb 21 17:16:00 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +44 -47 lines
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.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Sun Feb 21 16:50:57 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +41 -12 lines
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.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sun Feb 21 16:37:26 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +1 -1 lines
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.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sun Feb 21 16:05:44 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +17 -16 lines
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.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sun Feb 21 15:42:21 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +6 -5 lines
cgram: sort includes

Revision 1.4: download - view: text, markup, annotated - select for diffs
Sun Feb 21 15:41:04 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +300 -276 lines
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.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Sun Feb 21 13:35:37 2021 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +1 -1 lines
cgram: fix Home key for cursor navigation

Reported by liweitianux via GitHub.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Thu Jul 2 19:11:01 2020 UTC (4 years, 8 months ago) by rillig
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +13 -9 lines
cgram(6): use standard cursor keys, use standard shuffle algorithm

The previous shuffle algorithm asked for 100 random numbers, on average.
The new algorithm asks exactly for 26 random numbers.

Curses predefines numeric constants for keys, and there is no apparent
reason not to use these standard keys for cursor movement.

Revision 1.1.8.2: download - view: text, markup, annotated - select for diffs
Wed Aug 20 00:00:22 2014 UTC (10 years, 7 months ago) by tls
Branches: tls-maxphys
Diff to: previous 1.1.8.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.8.1: +344 -0 lines
Rebase to HEAD as of a few days ago.

Revision 1.1.4.2: download - view: text, markup, annotated - select for diffs
Thu May 22 11:36:22 2014 UTC (10 years, 10 months ago) by yamt
Branches: yamt-pagecache
Diff to: previous 1.1.4.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.4.1: +344 -0 lines
sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")

Revision 1.1.8.1
Sun Aug 4 05:42:47 2013 UTC (11 years, 7 months ago) by tls
Branches: tls-maxphys
FILE REMOVED
Changes since revision 1.1: +0 -344 lines
file cgram.c was added on branch tls-maxphys on 2014-08-20 00:00:22 +0000

Revision 1.1.4.1
Sun Aug 4 05:42:47 2013 UTC (11 years, 7 months ago) by yamt
Branches: yamt-pagecache
FILE REMOVED
Changes since revision 1.1: +0 -344 lines
file cgram.c was added on branch yamt-pagecache on 2014-05-22 11:36:22 +0000

Revision 1.1: download - view: text, markup, annotated - select for diffs
Sun Aug 4 05:42:47 2013 UTC (11 years, 7 months ago) by dholland
Branches: MAIN
CVS tags: yamt-pagecache-base9, tls-maxphys-base, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: yamt-pagecache, tls-maxphys
Add a curses gizmo for solving Sunday-paper-type cryptograms based on
substitution ciphers. It gets the cleartext from fortune. I wrote this
some years ago for my own amusement; a couple people have suggested
that I should import it.

Approved only by groo, so I'm going to wait a couple days to hook it
to the build in case anyone demands it be removed again...

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>