simon-git: spigot (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sun Feb 12 16:57:37 GMT 2017


TL;DR:
  974d472 Fix assertion failure on a class of parse error.
  854c9c4 Fix a typo about base10file: in the man page.
  0395c0e Rewrite io.cpp file caching.
  f3a3626 Support 'base10stdin' (and other bases) and 'cfracstdin'.
  e51b693 Stop using std::foo all over the place.
  7229b07 Replace FileReader's block list with a vector<unique_ptr>.

Repository:     https://git.tartarus.org/simon/spigot.git
On the web:     https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-02-12 16:57:37

commit 974d472c857bf048c2902c08afafb267b599f282
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=974d472c857bf048c2902c08afafb267b599f282;hp=34afe7316dd15ef80ff633860504d097d0a2dbfb
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 10:16:14 2017 +0000

    Fix assertion failure on a class of parse error.
    
    When spigot tries to parse an expression such as '1-' or '(1-)', in
    which a particular level of parentheses ends with a binary operator
    and no following atomic subexpression, it failed an assertion rather
    than reporting a sensible parse error.

 expr.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

commit 854c9c436db662cd4379a50df47c7e7ada42a8b9
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=854c9c436db662cd4379a50df47c7e7ada42a8b9;hp=974d472c857bf048c2902c08afafb267b599f282
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 13:53:10 2017 +0000

    Fix a typo about base10file: in the man page.
    
    I had written 'base10fd:filename' in an example, which should have
    been 'base10file:filename', of course.

 manpage.but | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 0395c0edf67bce28db780a90ae8844cac0f1a549
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=0395c0edf67bce28db780a90ae8844cac0f1a549;hp=854c9c436db662cd4379a50df47c7e7ada42a8b9
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 09:58:59 2017 +0000

    Rewrite io.cpp file caching.
    
    If the same external-input specification (baseNxfile, baseNfd, cfracfd
    etc) appears more than once in a spigot expression, then spigot has to
    arrange to only read the file once (because if it turns out to be a
    pipe or some other dynamic entity then it can't reopen or rewind it),
    and share the received input between all the actual Spigots that need
    to generate that number within its expression. So it has to have a
    cache of external data sources it's opened, and use existing entries
    in that cache rather than ever reopening the same thing again.
    
    This cache was only implemented for the Unix-specific 'fd:N' syntax
    and keyed by fd number, and was not applied at all for the
    cross-platform syntax 'file:NAME'. So if you had specified, say,
    'base10file:NAME' where NAME pointed to a named pipe, spigot would
    have done the wrong thing.
    
    Additionally, the cache was also maintained using manual memory
    management, contradicting my claim in commit 1d65ce372 that none of
    that was left in spigot! That's because I grepped for 'new', 'delete',
    'malloc' and 'free', which overlooked the cache in io.cpp because that
    is maintained using nothing but realloc :-)
    
    In response, I've rewritten the caching so that it uses a std::map,
    whose keys are general enough to specify a filename _or_ an fd (or
    something else again, should it become necessary in future), and moved
    the cache out of #ifdef HAVE_FDS so that it applies to all file
    reading. This should fix both problems.

 io.cpp | 299 ++++++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 212 insertions(+), 87 deletions(-)

commit f3a3626178c0050e311abe765c0178a7440ec298
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=f3a3626178c0050e311abe765c0178a7440ec298;hp=0395c0edf67bce28db780a90ae8844cac0f1a549
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 10:12:14 2017 +0000

    Support 'base10stdin' (and other bases) and 'cfracstdin'.
    
    Windows may not have numbered file descriptors or termios, but it at
    least has a standard input that you can pipe things into. So I now
    support an extra piece of syntax to mean 'read from stdin', even on
    platforms where general 'fd:N' syntax is not available.

 expr.cpp    | 55 ++++++++++++++++++++++++---------------
 funcs.h     |  2 ++
 io.cpp      | 45 +++++++++++++++++++++++++++++++-
 manpage.but |  4 ++-
 manual.but  | 85 +++++++++++++++++++++++++++++++++----------------------------
 5 files changed, 130 insertions(+), 61 deletions(-)

commit e51b69347e2bfe014164007e7bf444419113adb6
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=e51b69347e2bfe014164007e7bf444419113adb6;hp=f3a3626178c0050e311abe765c0178a7440ec298
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 14:16:49 2017 +0000

    Stop using std::foo all over the place.
    
    In my C++-using history I've wavered back and forth between qualifying
    everything from the standard library with std:: at the point of use,
    and on the other hand throwing up my hands and just saying 'using
    namespace std'. But the former is very verbose and the latter risks
    compile failures when some future C++ version stomps on a name I was
    using, so I've decided that perhaps the right thing is to import
    specific names from 'std' that I plan to use.
    
    This commit standardises on that policy across the whole spigot code
    base: everything from std:: that we use is now imported once via
    'using std::whatever', and referred to unqualified thereafter. That
    should make the code both readable and futureproof.

 algebraic.cpp     | 24 ++++++++++++++----------
 baseout.cpp       | 30 +++++++++++++++++-------------
 bi_internal.h     |  4 ++--
 cfracout.cpp      | 15 ++++++++-------
 exp.cpp           |  7 +++++--
 expr.cpp          | 41 +++++++++++++++++++++--------------------
 funcs.h           |  7 ++++---
 holefiller.h      |  5 ++++-
 io.cpp            |  5 +++--
 main.cpp          | 11 ++++++-----
 python/pyspig.cpp |  3 ++-
 spigot.h          |  9 ++++-----
 zeta.cpp          |  5 ++++-
 13 files changed, 94 insertions(+), 72 deletions(-)

commit 7229b071e6f96373478a8664f672efca4010b78c
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=7229b071e6f96373478a8664f672efca4010b78c;hp=e51b69347e2bfe014164007e7bf444419113adb6
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Feb 12 15:10:45 2017 +0000

    Replace FileReader's block list with a vector<unique_ptr>.
    
    I was seeing assertion failures happening at the point of rollover
    between one FileBlock and the next. I'm not exactly sure why; it
    doesn't help that if I tell gdb to print the value of a list::iterator
    then for some reason it prints the _contents_ of the pointed-to
    FileBlock rather than its address, so it was hard to identify which
    block was which during debugging. But my guess is that I had tripped
    over some fiddly semantics of when an existing list::iterator does or
    does not remain valid if you append to the list.
    
    Replacing my list<FileBlock> with a vector<unique_ptr<FileBlock>>
    solves the problem for me; resize operations on the vector look
    potentially painful in principle, but since it's a vector of pointers
    rather than actual blocks of data, it won't be _too_ bad. And doing it
    this way has the nice side effect that a FileReaderPos no longer needs
    to be initialised by its FileReader: since it contains an index into a
    vector rather than an iterator into a list, the starting index is
    always just 0 regardless of which vector it's destined for, so I can
    simply let FileReaderPos be initialised by its own default
    constructor.
    
    While I'm here, I've put a couple of helper methods into FileBlock to
    try to clarify the code that handles them.

 io.cpp | 62 +++++++++++++++++++++++---------------------------------------
 1 file changed, 23 insertions(+), 39 deletions(-)



More information about the tartarus-commits mailing list