summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/t1lint/cscheck.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/lcdf-typetools/t1lint/cscheck.hh')
-rw-r--r--Build/source/texk/lcdf-typetools/t1lint/cscheck.hh84
1 files changed, 83 insertions, 1 deletions
diff --git a/Build/source/texk/lcdf-typetools/t1lint/cscheck.hh b/Build/source/texk/lcdf-typetools/t1lint/cscheck.hh
index 9563e27fa62..9ba167b1588 100644
--- a/Build/source/texk/lcdf-typetools/t1lint/cscheck.hh
+++ b/Build/source/texk/lcdf-typetools/t1lint/cscheck.hh
@@ -3,7 +3,24 @@
#include <efont/t1interp.hh>
#include <lcdf/point.hh>
#include <lcdf/vector.hh>
-class ErrorHandler;
+#include <lcdf/error.hh>
+#include <lcdf/straccum.hh>
+#include <ctype.h>
+
+template <typename T>
+class CharstringCheckerErrorHandler : public ErrorVeneer { public:
+
+ CharstringCheckerErrorHandler(ErrorHandler *errh, T *checker)
+ : ErrorVeneer(errh), _checker(checker) {
+ }
+
+ String decorate(const String &str);
+
+ private:
+
+ T *_checker;
+
+};
class CharstringChecker : public Efont::CharstringInterp { public:
@@ -16,9 +33,18 @@ class CharstringChecker : public Efont::CharstringInterp { public:
bool check(const Efont::CharstringContext &, ErrorHandler *);
+ int ncommand() const {
+ return _ncommand;
+ }
+ int subrno() const {
+ return _subrno;
+ }
+
private:
ErrorHandler *_errh;
+ int _ncommand;
+ int _subrno;
Point _cp;
@@ -49,4 +75,60 @@ class CharstringChecker : public Efont::CharstringInterp { public:
};
+class CharstringSubrChecker : public Efont::CharstringInterp { public:
+
+ CharstringSubrChecker();
+ CharstringSubrChecker(const Vector<double> &weight_vec);
+
+ bool error(int, int);
+ bool type1_command(int);
+
+ bool check(const Efont::CharstringContext &, ErrorHandler *);
+
+ int ncommand() const {
+ return -1;
+ }
+ int subrno() const {
+ return -1;
+ }
+
+ private:
+
+ ErrorHandler *_errh;
+
+ bool _returned;
+
+};
+
+
+template <typename T> String
+CharstringCheckerErrorHandler<T>::decorate(const String &str)
+{
+ StringAccum sa;
+ const char *s = skip_anno(str.begin(), str.end());
+ while (s < str.end() && isspace((unsigned char) *s))
+ ++s;
+ sa.append(str.begin(), s);
+ if (_checker->subrno() >= 0)
+ sa << "called from ";
+ if (_checker->ncommand() >= 0)
+ sa << "command " << (_checker->ncommand() - 1) << ':';
+ if (sa)
+ sa << ' ';
+ if (s + 11 < str.end() && memcmp(s, "charstring ", 11) == 0) {
+ bool quote_parity = 0;
+ const char *last = s + 11;
+ for (const char *x = last; x != str.end(); ++x)
+ if (*x == '\'') {
+ sa.append(last, x);
+ sa << format(quote_parity ? "%>" : "%<");
+ quote_parity = !quote_parity;
+ last = x + 1;
+ }
+ sa.append(last, str.end());
+ } else
+ sa.append(s, str.end());
+ return ErrorVeneer::decorate(sa.take_string());
+}
+
#endif