simon-git: halibut (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sun Aug 15 16:18:55 BST 2021


TL;DR:
  d55aa26 Revise tree234 comparison API.
  47fa6ab Refactor global variables into a 'psdata' struct.

Repository:     https://git.tartarus.org/simon/halibut.git
On the web:     https://git.tartarus.org/?p=simon/halibut.git
Branch updated: main
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2021-08-15 16:18:55

commit d55aa26f69b39b42973baa4964f8ccb42bfd416e
web diff https://git.tartarus.org/?p=simon/halibut.git;a=commitdiff;h=d55aa26f69b39b42973baa4964f8ccb42bfd416e;hp=64650379e35a7d6450bdc51b42e3df06c7c364cb
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Aug 15 09:52:25 2021 +0100

    Revise tree234 comparison API.
    
    Comparison functions now take a third context parameter, in case they
    need to depend on something not accessible as a global variable. As
    yet this functionality is unused in Halibut: all context parameters so
    far used are NULL.
    
    This means that newtree234, find234 and split234, which always took a
    comparison function argument, now have to take a context pointer as
    well. That's particularly awkward for the find and split functions,
    which I think are likely to _often_ be called with NULL, NULL to use
    the tree's built-in version; so I've also revised the API of those
    functions to omit the comparison function, and made the versions that
    do take a special compare function be 'findcmp234' and friends.
    
    While I'm at it, the void * element pointers are now const void *,
    which is a long-overdue cleanup.

 bk_html.c  | 18 +++++++--------
 bk_paper.c | 26 ++++++++++-----------
 in_afm.c   |  6 ++---
 in_sfnt.c  |  6 ++---
 index.c    | 22 +++++++++---------
 input.c    |  6 ++---
 keywords.c |  8 +++----
 paper.h    |  6 ++---
 psdata.c   | 19 +++++++--------
 tree234.c  | 78 ++++++++++++++++++++++++++++++++++++++------------------------
 tree234.h  | 24 ++++++++++++-------
 winchm.c   | 30 +++++++++++++-----------
 winhelp.c  | 32 +++++++++++++-------------
 13 files changed, 155 insertions(+), 126 deletions(-)

commit 47fa6ab6cc0382269b770eebe5092f7e1b61a73e
web diff https://git.tartarus.org/?p=simon/halibut.git;a=commitdiff;h=47fa6ab6cc0382269b770eebe5092f7e1b61a73e;hp=d55aa26f69b39b42973baa4964f8ccb42bfd416e
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Aug 15 11:12:50 2021 +0100

    Refactor global variables into a 'psdata' struct.
    
    No functional change, but this restores an invariant that the Halibut
    code base originally had, which is that there are no mutable global
    variables - everything that modifies state is passed that state as a
    parameter, and ultimately, everything is either allocated on the heap
    or some function's stack.
    
    (There was never an especially good reason for this property. I had
    the vague idea at one time that it might be useful to have the Halibut
    code callable as sone kind of library, but never really came up with a
    good use for that in turn. However, now that the code _is_ mostly set
    up that way, I don't want to gratuitously lose it.)
    
    Ben's work on PS font management years ago broke that invariant,
    probably because I completely forgot to mention it to him. Now
    restored, by moving his cache of PS glyph names and global list of
    loaded fonts into a 'psdata' structure which is passed in to
    everything that needs to access it.
    
    It would be nice to be able to treat 'psdata' as a detail local to the
    paper backend cluster - have bk_paper put it in the 'document'
    structure, and bk_ps and bk_pdf read it out again. But it doesn't work
    that way, because PS fonts are loaded during the input phase, so the
    psdata has to already exist and be populated before bk_paper even
    runs. So psdata is a top-level thing that main() has to know about.

 bk_paper.c | 115 ++++++++++++++++++++++++++++++++++++-------------------------
 bk_pdf.c   |   2 +-
 bk_ps.c    |   4 +--
 halibut.h  |  15 ++++----
 in_afm.c   |  16 ++++-----
 in_pf.c    |  14 ++++----
 in_sfnt.c  |  32 ++++++++---------
 input.c    |   8 ++---
 main.c     |  13 ++++---
 paper.h    |  20 +++++++----
 psdata.c   |  75 ++++++++++++++++++++++++++++------------
 11 files changed, 190 insertions(+), 124 deletions(-)



More information about the tartarus-commits mailing list