From 7a2b1956e0c958ad53ef3385f862de17f8db777f Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Thu, 14 Jul 2005 14:31:09 +0000 Subject: increased matrix stack depth to 32 units and added error messages on under- and overflow error. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4417 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/fl_vertex.cxx | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 6465ed094..de3973e1b 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7 - Documentation fixes (STR #648, STR #692, STR #730, STR #744, STR #745) + - Increased matrix stack depth and added over/underfolw error + (STR #924) - Reverted Mac Carbon Clipping simplification that broke subwindow clipping (STR #908, SVN r4386) - Fixed bitmap scaling code diff --git a/src/fl_vertex.cxx b/src/fl_vertex.cxx index 9d9938f09..d9ee96c3a 100644 --- a/src/fl_vertex.cxx +++ b/src/fl_vertex.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -41,12 +42,22 @@ struct matrix {double a, b, c, d, x, y;}; static matrix m = {1, 0, 0, 1, 0, 0}; -static matrix stack[10]; +static matrix stack[32]; static int sptr = 0; -void fl_push_matrix() {stack[sptr++] = m;} +void fl_push_matrix() { + if (sptr==32) + Fl::error("fl_push_matrix(): matrix stack overflow."); + else + stack[sptr++] = m; +} -void fl_pop_matrix() {m = stack[--sptr];} +void fl_pop_matrix() { + if (sptr==0) + Fl::error("fl_pop_matrix(): matrix stack underflow."); + else + m = stack[--sptr]; +} void fl_mult_matrix(double a, double b, double c, double d, double x, double y) { matrix o; -- cgit v1.2.3