simon-git: puzzles (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Mon Apr 24 10:22:40 BST 2023


TL;DR:
  8168058 GTK save_prefs: fix a wrongly sourced error report.
  bf45304 Support user preferences in the Mac frontend.
  12b2608 Fix bounds check in buffer_append.
  8c96848 emcc.c: missing (void) in a function definition.
  2b6d34a emcc.c: remove savefile_read_ctx.
  43db4aa Support user preferences in the Emscripten frontend.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2023-04-24 10:22:40

commit 81680583fd5af8a1fd9b1ee30d5fa3dfc073832a
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=81680583fd5af8a1fd9b1ee30d5fa3dfc073832a;hp=e080e0e3253a079ac755bb6d21ff08a6ccd96815
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 08:35:42 2023 +0100

    GTK save_prefs: fix a wrongly sourced error report.
    
    After a failed rename(), we should find out what went wrong by looking
    in errno itself, not in wctx->error which reported a problem in the
    previous step.

 gtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit bf453043db68342de85028c7a44cb75262e02ad9
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=bf453043db68342de85028c7a44cb75262e02ad9;hp=81680583fd5af8a1fd9b1ee30d5fa3dfc073832a
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 08:44:40 2023 +0100

    Support user preferences in the Mac frontend.
    
    The low-level load and save routines are basically copy-pasted from
    gtk.c, with only minor changes to deal with the different locally
    appropriate config file location and the lack of savefile_write_ctx.

 osx.m       | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 puzzles.but |   4 +-
 2 files changed, 158 insertions(+), 3 deletions(-)

commit 12b2608b241743314f177e73d8d73b72580d2948
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=12b2608b241743314f177e73d8d73b72580d2948;hp=bf453043db68342de85028c7a44cb75262e02ad9
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 09:56:35 2023 +0100

    Fix bounds check in buffer_append.
    
    We're about to append one character to the buffer _and_ put a \0 after
    it, so we need the buffer to be at least _two_ characters longer than
    where the current position is.
    
    I think this bug would have had a hard time showing up in normal use,
    but I managed to trigger it by completely messing up a prototype
    Emscripten preferences implementation, and a good thing too.

 midend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 8c968483f8df7c30f78ff3998a397697a1699615
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=8c968483f8df7c30f78ff3998a397697a1699615;hp=12b2608b241743314f177e73d8d73b72580d2948
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 09:31:18 2023 +0100

    emcc.c: missing (void) in a function definition.
    
    This isn't C++, ahem.

 emcc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 2b6d34adbd03a6110d4c2a0a0959eb6e30d3936d
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=2b6d34adbd03a6110d4c2a0a0959eb6e30d3936d;hp=8c968483f8df7c30f78ff3998a397697a1699615
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 09:35:45 2023 +0100

    emcc.c: remove savefile_read_ctx.
    
    It wasn't ever used! Looks as if I pasted it in here from one of the
    other implementations, before realising that wasn't how I was going to
    read save files at all.

 emcc.c | 5 -----
 1 file changed, 5 deletions(-)

commit 43db4aa38e83595dc6df245cb952795f9f306ed0
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=43db4aa38e83595dc6df245cb952795f9f306ed0;hp=2b6d34adbd03a6110d4c2a0a0959eb6e30d3936d
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Apr 24 10:17:33 2023 +0100

    Support user preferences in the Emscripten frontend.
    
    Here, user preferences are stored in localStorage, so that they can
    persist when you come back to the same puzzle page later.
    
    localStorage is global across a whole web server, which means we need
    to take care to put our uses of it in a namespace reasonably unlikely
    to collide with unrelated web pages on the same server. Ben suggested
    that a good way to do this would be to store things in localStorage
    under keys derived from location.pathname. In this case I've appended
    a fragment id "#preferences" to that, so that space alongside it
    remains for storing other things we might want in future (such as
    serialised saved-game files used as quick-save slots).
    
    When loading preferences, I've chosen to pass the whole serialised
    preferences buffer from Javascript to C as a single C string argument
    to a callback, rather than reusing the existing system for C to read
    the save file a chunk at a time. Partly that's because preferences
    data is bounded in size whereas saved games can keep growing; also
    it's because the way I'm storing preferences data means it will be a
    UTF-8 string, and I didn't fancy trying to figure out byte offsets in
    the data on the JS side.
    
    I think at this point I should stop keeping a list in the docs of
    which frontends support preferences. Most of the in-tree ones do now,
    and that means the remaining interesting frontends are ones I don't
    have a full list of. At this moment I guess no out-of-tree frontends
    support preferences (unless someone is _very_ quick off the mark), but
    as and when that changes, I won't necessarily know, and don't want to
    have to keep updating the docs when I find out.

 cmake/platforms/emscripten.cmake |  2 +
 emcc.c                           | 84 +++++++++++++++++++++++++++++++++++++++-
 emcclib.js                       | 23 +++++++++++
 emccpre.js                       | 12 ++++++
 html/jspage.pl                   |  1 +
 puzzles.but                      |  8 ++--
 6 files changed, 124 insertions(+), 6 deletions(-)



More information about the tartarus-commits mailing list