--- rxvt-unicode/src/rxvtfont.C 2011/05/30 18:39:03 1.180 +++ rxvt-unicode/src/rxvtfont.C 2012/01/26 13:08:51 1.188 @@ -24,7 +24,7 @@ #include "rxvtutil.h" #include "rxvtfont.h" -#include +#include #include @@ -134,7 +134,6 @@ # endif #endif - { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, //{ CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, // this gem of a font has actual dotted circles within the combining character glyphs. #if XFT { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" }, @@ -819,10 +818,10 @@ // this loop only iterates when the guessed font-size is too small for (;;) { - font_weight *best = fonts + count - 1; + font_weight *best = fonts; - for (font_weight *w = best; w-- > fonts; ) - if (w->diff <= best->diff) + for (font_weight *w = fonts + 1; w < fonts + count; w++) + if (w->diff < best->diff) best = w; if (!best->name @@ -927,7 +926,7 @@ width = 1; - for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; ) + for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) { if (FROM_UNICODE (cs, *t) == NOCHAR) continue; @@ -1249,7 +1248,7 @@ int glheight = height; - for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; ) + for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) { FcChar16 ch = *t; @@ -1502,7 +1501,7 @@ (*i)->unref (); for (pagemap **p = fmap.begin (); p != fmap.end (); p++) - delete *p; + delete [] *p; free (fontdesc); fontdesc = 0; @@ -1788,7 +1787,14 @@ if (!fmap[hi]) { - fmap[hi] = (pagemap *)new pagemap; + // we use [1] here because C++ has no separate new and new [] forms, + // and pagemap is char[256], so new incorrectly assumes we want to + // allocate an array of chars instead of a single pagemap. + // we can either cast the resulting pointer to (pagemap *) or + // allocate an array of pagemaps, returning a pointer to the first member + // this is no extra overhead, as new even allocates an array for + // "new pagemap" + fmap[hi] = new pagemap[1]; memset (fmap[hi], 0xff, sizeof (pagemap)); }