diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-07-08 06:44:39 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-07-08 06:44:39 +0000 |
commit | eadda9e7616e95abf27cb9c9c208db41371a6cf5 (patch) | |
tree | 909828105d8a9c05d6af749aefbe39f117bbfa7d /Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh | |
parent | 0b34c5e54c8d047aa6a34af8ced91b29c5e7ad46 (diff) |
lcdf-typetools 2.104
git-svn-id: svn://tug.org/texlive/trunk@34550 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh')
-rw-r--r-- | Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh new file mode 100644 index 00000000000..2e400d3c3f2 --- /dev/null +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/include/lcdf/slurper.hh @@ -0,0 +1,63 @@ +// -*- related-file-name: "../../liblcdf/slurper.cc" -*- +#ifndef LCDF_SLURPER_HH +#define LCDF_SLURPER_HH +#include <lcdf/landmark.hh> +#include <lcdf/filename.hh> +#include <stdio.h> + +class Slurper { public: + + Slurper(const Filename &, FILE * = 0); + ~Slurper(); + + bool ok() const { return _f != 0; } + + Landmark landmark() const { return Landmark(_filename.name(), _lineno); } + operator Landmark() const { return landmark(); } + unsigned lineno() const { return _lineno; } + + const Filename &filename() const { return _filename; } + char *peek_line(); + char *next_line(); + char *append_next_line(); + void save_line() { _saved_line = true; } + + char *cur_line() const { return (char *)_line; } + unsigned cur_line_length() const { return _line_len; } + void shorten_line(unsigned); + + private: + + FILE *_f; + Filename _filename; + unsigned _lineno; + bool _own_f; + + unsigned char *_data; + unsigned _cap; + unsigned _pos; + unsigned _len; + + unsigned char *_line; + unsigned _line_len; + + bool _saved_line; + bool _at_eof; + + void grow_buffer(); + inline int more_data(); + char *get_line_at(unsigned); + +}; + + +inline void +Slurper::shorten_line(unsigned pos) +{ + if (pos < _line_len) { + _line_len = pos; + _line[_line_len] = 0; + } +} + +#endif |