simon-git: spigot (master): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Thu Oct 12 20:46:27 BST 2017
TL;DR:
2c51ffa Wrap opener-making functions into a FileAccessContext class.
3dcb51e CLI spigot: add --safe, to forbid file/fd access.
7770e8e io: add an 'uncached' value in the file cache key type.
8961c0b Fix mishandling of EOF in continued-fraction file input.
d454c93 Python: make a spigot from a file object.
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-10-12 20:46:27
commit 2c51ffa30810ab38bd20d3244e453bb14d3a2653
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=2c51ffa30810ab38bd20d3244e453bb14d3a2653;hp=77561eff88fe4a793592e6b0d75d74c642d840cb
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Oct 12 07:11:57 2017 +0100
Wrap opener-making functions into a FileAccessContext class.
This allows me to swap it out for a different implementation, and also
to keep persistent state in it.
expr.cpp | 23 ++++++++++++++---------
expr.h | 5 ++++-
io.cpp | 29 +++++++++++++++++------------
io.h | 26 +++++++++++++++++---------
iocli.cpp | 20 ++++++++++++++++----
main.cpp | 4 +++-
python/pyspig.cpp | 27 ++++++++++++++-------------
7 files changed, 85 insertions(+), 49 deletions(-)
commit 3dcb51e7a808e5e916e626259b8ca332705b391d
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=3dcb51e7a808e5e916e626259b8ca332705b391d;hp=2c51ffa30810ab38bd20d3244e453bb14d3a2653
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Oct 12 07:23:53 2017 +0100
CLI spigot: add --safe, to forbid file/fd access.
This makes use of the new FileAccessContext class system by swapping
out the live CLIFileAccessContext (which can actually open things) for
a stub one that does nothing but throw errors, similar to the one in
the Python module but with the error messages' wording tweaked.
main.cpp | 41 +++++++++++++++++++++++++++++++++--------
manpage.but | 8 ++++++++
manual.but | 9 +++++++++
test.sh | 8 ++++++++
4 files changed, 58 insertions(+), 8 deletions(-)
commit 7770e8e9b8103a2b7b3f3efa28a149b089edf2ed
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=7770e8e9b8103a2b7b3f3efa28a149b089edf2ed;hp=3dcb51e7a808e5e916e626259b8ca332705b391d
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Oct 12 18:44:00 2017 +0100
io: add an 'uncached' value in the file cache key type.
This means that when I shortly start constructing spigots from unnamed
Python file objects which I can't relate to any other object anyway, I
won't have to invent spurious unique keys for them.
While I'm here, I've added a one-argument constructor for cache keys
(because now we have _two_ enum values which don't have an associated
string), and used it for the existing Stdin case.
io.cpp | 15 +++++++++++----
io.h | 4 +++-
iocli.cpp | 2 +-
3 files changed, 15 insertions(+), 6 deletions(-)
commit 8961c0b052c6f2a3247794164262b2a8c82637dc
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=8961c0b052c6f2a3247794164262b2a8c82637dc;hp=7770e8e9b8103a2b7b3f3efa28a149b089edf2ed
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Oct 12 20:37:53 2017 +0100
Fix mishandling of EOF in continued-fraction file input.
If we saw an EOF immediately after the digits of the last continued
fraction term in the file, we would forget to actually return that
term in our hurry to throw spigot_eof. I'd never noticed because all
my tests of exact-mode continued fraction file input worked by saying
things like 'echo "1;2;3" > file', which puts a newline in between the
last digit and the EOF, defusing the bug.
io.cpp | 12 ++++++------
test.sh | 2 ++
2 files changed, 8 insertions(+), 6 deletions(-)
commit d454c933fe3653063f03c860370e5bb719f3e057
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=d454c933fe3653063f03c860370e5bb719f3e057;hp=8961c0b052c6f2a3247794164262b2a8c82637dc
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Oct 12 18:46:02 2017 +0100
Python: make a spigot from a file object.
This is done by swapping in a hacky kind of FileAccessContext which
holds just one file object and always returns that one. I support the
same set of options as CLI spigot - configurable number base,
continued-fraction input, and the 'exact' flag that distinguishes
base10file from base10xfile - but the input source, in true Python
style, can be anything at all that quacks sufficiently like a
Python-language file object, in the sense of having a read() method
that returns either a raw byte string _or_ Unicode.
To deal with the case where exact=False, I've also had to introduce a
new Python exception, to be a translation of spigot_eof.
python/pyspig.cpp | 186 ++++++++++++++++++++++++++++++++++++++++++++++--
python/spig/__init__.py | 26 +++++--
python/testsuite.py | 69 ++++++++++++++++++
3 files changed, 271 insertions(+), 10 deletions(-)
More information about the tartarus-commits
mailing list