summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-12-04 16:50:23 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-12-04 16:50:23 +0100
commita73a14347db54693fa486e2ebf400d7ce26231e6 (patch)
tree5ebd4e33c5e726f77b4ff95028366f66eb01b34b /src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
parent75c97edb1e7af1afe317af796a3c73c35e19df23 (diff)
Fix compiler warnings
fluid/code.cxx: unused variable src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx: function may return address of local variable [-Wreturn-local-addr]
Diffstat (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
index 94d013b3f..8ba7fb908 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
@@ -452,21 +452,22 @@ int fl_correct_encoding(const char* name) {
static const char *find_best_font(const char *fname, int size) {
int cnt;
static char **list = NULL;
-// locate or create an Fl_Font_Descriptor for a given Fl_Fontdesc and size:
+ // note: namebuffer must be static: its address may be returned to caller
+ static char namebuffer[1024]; // holds scalable font name
+ // locate or create an Fl_Font_Descriptor for a given Fl_Fontdesc and size:
if (list) XFreeFontNames(list);
list = XListFonts(fl_display, fname, 100, &cnt);
if (!list) return "fixed";
// search for largest <= font size:
- char* name = list[0]; int ptsize = 0; // best one found so far
+ char* name = list[0]; int ptsize = 0; // best one found so far
int matchedlength = 32767;
- char namebuffer[1024]; // holds scalable font name
int found_encoding = 0;
int m = cnt; if (m<0) m = -m;
for (int n=0; n < m; n++) {
char* thisname = list[n];
if (fl_correct_encoding(thisname)) {
- if (!found_encoding) ptsize = 0; // force it to choose this
+ if (!found_encoding) ptsize = 0; // force it to choose this
found_encoding = 1;
} else {
if (found_encoding) continue;