diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-11-14 13:06:25 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-11-14 13:06:25 +0100 |
| commit | d96c980d29c3caecadca49af62def57e86d7eed9 (patch) | |
| tree | 65b4e9604b51b625a658f55bebe13ca6daba964c | |
| parent | 654e20ff8b8ee8d8679acad5e448d0e16c9afb42 (diff) | |
Fix "failed to build with pango libarary" (issue #291)
The error was reported for "centos 6 with devtoolset-6 installed
which contains gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)".
The fix includes the missing header files *and* makes sure that the
correct conversions (to size_t) take place as in
src/drivers/PostScript/Fl_PostScript_image.cxx.
| -rw-r--r-- | src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 881d2cbaf..f6db07cda 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -26,6 +26,8 @@ #include <cairo/cairo.h> #include <pango/pangocairo.h> #include <math.h> +#include <stdlib.h> // abs(int) +#include <string.h> // memcpy() // duplicated from Fl_PostScript.cxx struct callback_data { @@ -52,10 +54,11 @@ static void draw_image_cb(void *data, int x, int y, int w, uchar *buf) { cb_data = (struct callback_data*)data; int last = x+w; + const size_t aD = abs(cb_data->D); curdata = cb_data->data + x*cb_data->D + y*cb_data->LD; for (; x<last; x++) { - memcpy(buf, curdata, abs(cb_data->D)); - buf += abs(cb_data->D); + memcpy(buf, curdata, aD); + buf += aD; curdata += cb_data->D; } } @@ -535,8 +538,9 @@ void Fl_Cairo_Graphics_Driver::draw_image(Fl_Draw_Image_Cb call, void *data, int void Fl_Cairo_Graphics_Driver::draw_image_mono(const uchar *data, int ix, int iy, int iw, int ih, int D, int LD) { struct callback_data cb_data; - if (!LD) LD = iw*abs(D); - if (D<0) data += iw*abs(D); + const size_t aD = abs(D); + if (!LD) LD = iw * aD; + if (D<0) data += iw * aD; cb_data.data = data; cb_data.D = D; cb_data.LD = LD; |
