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


Default branch: MAIN


Revision 1.30 / (download) - annotate - [select for diffs], Wed May 10 12:30:27 2023 UTC (11 months ago) by rillig
Branch: MAIN
CVS Tags: HEAD
Changes since 1.29: +10 -9 lines
Diff to previous 1.29 (colored)

cgram: replace comments with code

No binary change.

Revision 1.29 / (download) - annotate - [select for diffs], Sun Jun 12 14:59:44 2022 UTC (22 months ago) by rillig
Branch: MAIN
CVS Tags: netbsd-10-base, 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
Changes since 1.28: +3 -2 lines
Diff to previous 1.28 (colored)

cgram: allow cursor navigation with KEY_BEG as well

Revision 1.28 / (download) - annotate - [select for diffs], Sat May 14 14:20:10 2022 UTC (23 months ago) by rillig
Branch: MAIN
Changes since 1.27: +6 -2 lines
Diff to previous 1.27 (colored)

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) - annotate - [select for diffs], Mon Mar 28 20:00:29 2022 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.26: +6 -12 lines
Diff to previous 1.26 (colored)

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) - annotate - [select for diffs], Fri Oct 29 11:45:39 2021 UTC (2 years, 5 months ago) by nia
Branch: MAIN
Changes since 1.25: +3 -4 lines
Diff to previous 1.25 (colored)

cgram(6): realloc(x * y) -> reallocarr

Revision 1.23.2.1 / (download) - annotate - [select for diffs], Mon May 31 22:15:06 2021 UTC (2 years, 10 months ago) by cjep
Branch: cjep_staticlib_x
Changes since 1.23: +4 -3 lines
Diff to previous 1.23 (colored) next main 1.24 (colored)

sync with head

Revision 1.25 / (download) - annotate - [select for diffs], Fri May 28 03:55:45 2021 UTC (2 years, 10 months ago) by dholland
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1
Changes since 1.24: +3 -3 lines
Diff to previous 1.24 (colored)

I don't see any code I wrote left in here.

Revision 1.24 / (download) - annotate - [select for diffs], Fri May 28 03:55:08 2021 UTC (2 years, 10 months ago) by dholland
Branch: MAIN
Changes since 1.23: +3 -2 lines
Diff to previous 1.23 (colored)

Restore return value of main, arbitrarily thrown away in -r1.4.

Revision 1.23 / (download) - annotate - [select for diffs], Sat May 1 20:29:23 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
CVS Tags: cjep_staticlib_x-base
Branch point for: cjep_staticlib_x
Changes since 1.22: +7 -7 lines
Diff to previous 1.22 (colored)

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) - annotate - [select for diffs], Thu Apr 29 20:17:20 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.21: +3 -4 lines
Diff to previous 1.21 (colored)

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) - annotate - [select for diffs], Sun Apr 25 20:38:03 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.20: +18 -19 lines
Diff to previous 1.20 (colored)

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) - annotate - [select for diffs], Sun Apr 25 20:19:19 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.19: +15 -3 lines
Diff to previous 1.19 (colored)

cgram: provide usage on incorrect invocation

Revision 1.19 / (download) - annotate - [select for diffs], Sun Apr 25 20:14:29 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.18: +7 -5 lines
Diff to previous 1.18 (colored)

cgram: conform to lint's strict bool mode, KNF

Revision 1.18 / (download) - annotate - [select for diffs], Thu Apr 22 14:57:36 2021 UTC (2 years, 11 months ago) by wiz
Branch: MAIN
Changes since 1.17: +35 -13 lines
Diff to previous 1.17 (colored)

cgram: allow providing an input file instead of the random fortune

Revision 1.17 / (download) - annotate - [select for diffs], Fri Feb 26 15:18:40 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.16: +4 -2 lines
Diff to previous 1.16 (colored)

cgram: don't beep if the window is resized

Revision 1.16 / (download) - annotate - [select for diffs], Fri Feb 26 15:15:34 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.15: +8 -4 lines
Diff to previous 1.15 (colored)

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) - annotate - [select for diffs], Fri Feb 26 14:55:37 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.14: +8 -4 lines
Diff to previous 1.14 (colored)

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) - annotate - [select for diffs], Mon Feb 22 19:34:07 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.13: +30 -39 lines
Diff to previous 1.13 (colored)

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) - annotate - [select for diffs], Mon Feb 22 17:36:42 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.12: +117 -49 lines
Diff to previous 1.12 (colored)

cgram: add advanced cursor movement with tab, shift+tab, return

Revision 1.12 / (download) - annotate - [select for diffs], Mon Feb 22 16:28:20 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.11: +4 -3 lines
Diff to previous 1.11 (colored)

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) - annotate - [select for diffs], Sun Feb 21 22:21:56 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.10: +12 -8 lines
Diff to previous 1.10 (colored)

cgram: allow navigation with KEY_PPAGE and KEY_NPAGE

Revision 1.10 / (download) - annotate - [select for diffs], Sun Feb 21 20:33:42 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.9: +286 -179 lines
Diff to previous 1.9 (colored)

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) - annotate - [select for diffs], Sun Feb 21 17:16:00 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.8: +44 -47 lines
Diff to previous 1.8 (colored)

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) - annotate - [select for diffs], Sun Feb 21 16:50:57 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.7: +41 -12 lines
Diff to previous 1.7 (colored)

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) - annotate - [select for diffs], Sun Feb 21 16:37:26 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.6: +1 -1 lines
Diff to previous 1.6 (colored)

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) - annotate - [select for diffs], Sun Feb 21 16:05:44 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.5: +17 -16 lines
Diff to previous 1.5 (colored)

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) - annotate - [select for diffs], Sun Feb 21 15:42:21 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.4: +6 -5 lines
Diff to previous 1.4 (colored)

cgram: sort includes

Revision 1.4 / (download) - annotate - [select for diffs], Sun Feb 21 15:41:04 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.3: +300 -276 lines
Diff to previous 1.3 (colored)

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) - annotate - [select for diffs], Sun Feb 21 13:35:37 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.2: +1 -1 lines
Diff to previous 1.2 (colored)

cgram: fix Home key for cursor navigation

Reported by liweitianux via GitHub.

Revision 1.2 / (download) - annotate - [select for diffs], Thu Jul 2 19:11:01 2020 UTC (3 years, 9 months ago) by rillig
Branch: MAIN
Changes since 1.1: +13 -9 lines
Diff to previous 1.1 (colored)

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) - annotate - [select for diffs], Wed Aug 20 00:00:22 2014 UTC (9 years, 7 months ago) by tls
Branch: tls-maxphys
Changes since 1.1.8.1: +344 -0 lines
Diff to previous 1.1.8.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

Rebase to HEAD as of a few days ago.

Revision 1.1.4.2 / (download) - annotate - [select for diffs], Thu May 22 11:36:22 2014 UTC (9 years, 10 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.1.4.1: +344 -0 lines
Diff to previous 1.1.4.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

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 (10 years, 8 months ago) by tls
Branch: tls-maxphys
Changes since 1.1: +0 -344 lines
FILE REMOVED

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 (10 years, 8 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.1: +0 -344 lines
FILE REMOVED

file cgram.c was added on branch yamt-pagecache on 2014-05-22 11:36:22 +0000

Revision 1.1 / (download) - annotate - [select for diffs], Sun Aug 4 05:42:47 2013 UTC (10 years, 8 months ago) by dholland
Branch: 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-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-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...

This form allows you to request diff's 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.




CVSweb <webmaster@jp.NetBSD.org>