simon-git: spigot (master): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Wed Oct 11 21:41:37 BST 2017
TL;DR:
2672af0 io.cpp: rename FileReader to BufferingReader.
7192d04 io.cpp: make FileReaderRaw an abstract base class.
fa5137e io.cpp: replace FileReaderRaw::getch() with a bulk read.
4c044cb io.cpp: turn the FooOpeners into a virtual hierarchy.
406961c Split up io.cpp to stop Python spigot.eval opening files.
77561ef Remove a few ifdefs on HAVE_FDS.
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-11 21:41:37
commit 2672af0d327f0d0f30e3fbe0d9c563c360149fbe
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=2672af0d327f0d0f30e3fbe0d9c563c360149fbe;hp=f71b87ae1cc8262c286c1f671cf8b94d6675e317
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:33:47 2017 +0100
io.cpp: rename FileReader to BufferingReader.
I'm preparing to divide this module up differently, and since it
contains some confusingly similarly named classes, I thought I'd start
by giving better names to some of them. NFCI.
io.cpp | 123 ++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 64 insertions(+), 59 deletions(-)
commit 7192d0491ba0c6e622b644b4bdc16edb3a8b9a77
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=7192d0491ba0c6e622b644b4bdc16edb3a8b9a77;hp=2672af0d327f0d0f30e3fbe0d9c563c360149fbe
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:34:01 2017 +0100
io.cpp: make FileReaderRaw an abstract base class.
The functionality specific to FILE * is now all in a derived class
StdioStreamReaderRaw; as much top-level logic as possible is
centralised into the abstract class. Users should now be able to
derive entirely non-stdio kinds of FileReaderRaw by filling in just
the really necessary methods.
Since the FileOpener class is tied not to the underlying abstract
concept but to the stdio implementation specifically, I've also
renamed that to StdioFileOpener to make that clear.
NFCI.
io.cpp | 110 ++++++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 78 insertions(+), 32 deletions(-)
commit fa5137eaad19af55132970f66b70a9aeb24e4d31
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=fa5137eaad19af55132970f66b70a9aeb24e4d31;hp=7192d0491ba0c6e622b644b4bdc16edb3a8b9a77
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:34:54 2017 +0100
io.cpp: replace FileReaderRaw::getch() with a bulk read.
Now whenever BufferingReader needs more data it will at least _try_ to
get as much as will fit in the next buffer block, instead of insisting
on getting just one character at a time.
I don't expect this will improve the existing code's performance
noticeably, because all the readchars were going via stdio anyway and
that will have been doing the buffering. But this change breaks the
dependency on stdio, i.e. we're now free to switch to other data
sources which might _not_ already have efficient buffering.
io.cpp | 85 ++++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 52 insertions(+), 33 deletions(-)
commit 4c044cb35e4cdccea8ebae3e6e1cfdf189b6944b
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=4c044cb35e4cdccea8ebae3e6e1cfdf189b6944b;hp=fa5137eaad19af55132970f66b70a9aeb24e4d31
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:35:54 2017 +0100
io.cpp: turn the FooOpeners into a virtual hierarchy.
This gets rid of the nasty use of templates in make_buffering_reader,
and is also groundwork that will let me move what are now FileOpener
subclasses into other source files where make_buffering_reader won't
be able to see them at (what was previously) template instantiation
time.
io.cpp | 49 ++++++++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 21 deletions(-)
commit 406961c7fecbd05baefc6b130ed4be2132fc9fe6
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=406961c7fecbd05baefc6b130ed4be2132fc9fe6;hp=4c044cb35e4cdccea8ebae3e6e1cfdf189b6944b
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:37:16 2017 +0100
Split up io.cpp to stop Python spigot.eval opening files.
The core functionality that deals with storing the data coming from
input files, parsing it, and turning it into Spigot objects is still
in io.cpp. The abstract base classes FileReaderRaw and FileOpener are
now defined in io.h (and their centralised non-overridable methods are
still in io.cpp).
But the actual underlying _I/O_ - the use of stdio and/or Unix system
calls to open and read from files - is now in a separate source file
iocli.cpp. This allows me to exclude that one file from the Python
extension module, and replace it with three stub file-opener functions
in pyspig.cpp which all just throw an error that will terminate
expression parsing.
So now the Python spigot.eval won't be able to interpret any input
expression in a way that will make it open an arbitrary disk file, or
confuse the Python interpreter process it's been loaded into by
reading from an arbitrary file descriptor.
expr.cpp | 1 +
funcs.h | 10 ---
io.cpp | 240 +++++-----------------------------------------------
io.h | 60 +++++++++++++
iocli.cpp | 191 +++++++++++++++++++++++++++++++++++++++++
python/pyspig.cpp | 16 ++++
python/setup.py | 1 +
python/testsuite.py | 16 ++++
sources.mk | 10 ++-
9 files changed, 313 insertions(+), 232 deletions(-)
commit 77561eff88fe4a793592e6b0d75d74c642d840cb
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=77561eff88fe4a793592e6b0d75d74c642d840cb;hp=406961c7fecbd05baefc6b130ed4be2132fc9fe6
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Oct 11 21:36:02 2017 +0100
Remove a few ifdefs on HAVE_FDS.
Rather than conditioning out all the code in expr.cpp that parses
them, I realise it's now actually easier to let it run anyway, because
any keyword of that kind will have to end up in the new fd_opener()
function in iocli.cpp, so having _that_ throw the exception is easier
and also fits better with the stub opener functions in pyspig.cpp.
There are still ifdefs on HAVE_FDS in main.cpp (if nothing else
because any other way of adjusting the online help would be more
painful). It's just expr.cpp that's been simplified.
expr.cpp | 10 ----------
io.h | 2 --
iocli.cpp | 5 +++++
3 files changed, 5 insertions(+), 12 deletions(-)
More information about the tartarus-commits
mailing list