diff options
author | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-08-30 22:48:30 +0000 |
---|---|---|
committer | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-08-30 22:48:30 +0000 |
commit | 06cbe800bf3e2586b015dc271c78aa00651833f5 (patch) | |
tree | 4d501029fc977403c58b7f8ee2d33a509023f63e /draw.c | |
parent | 6e76e603b126b39c13e3741f74b2df7112773238 (diff) | |
download | dzen-06cbe800bf3e2586b015dc271c78aa00651833f5.tar.gz dzen-06cbe800bf3e2586b015dc271c78aa00651833f5.zip |
prevent int overflow in ^ro()
prevent stairs effect in ^ro() when dzen.line_height - recth is not a multiple of 2
thanks Sebastien Gross
README fix
git-svn-id: http://dzen.googlecode.com/svn/trunk@164 f2baff5b-bf2c-0410-a398-912abdc3d8b2
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -364,9 +364,13 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { case recto: get_rect_vals(tval, &rectw, &recth); + if (!rectw) break; + rectw = rectw+px > dzen.w ? dzen.w-px : rectw; recth = recth > dzen.line_height ? dzen.line_height-2 : recth-1; recty = (dzen.line_height - recth)/2; + /* prevent from stairs effect when rounding recty */ + if (!((dzen.line_height - recth) % 2)) recty--; setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); XDrawRectangle(dzen.dpy, pm, dzen.tgc, px, (int)recty, rectw-1, recth); px += rectw; @@ -501,9 +505,13 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { case recto: get_rect_vals(tval, &rectw, &recth); + if (!rectw) break; + rectw = rectw+px > dzen.w ? dzen.w-px : rectw; recth = recth > dzen.line_height ? dzen.line_height-2 : recth-1; recty = (dzen.line_height - recth)/2; + /* prevent from stairs effect when rounding recty */ + if (!((dzen.line_height - recth) % 2)) recty--; setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); XDrawRectangle(dzen.dpy, pm, dzen.tgc, px, (int)recty, rectw-1, recth); px += rectw; |