X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=cad61bf6796907a1606c4a0aefe232277bff6650;hb=cdb3b1892af40110660da8c3f6fc06b1b054fd12;hp=6e7077af3963f93d96c12aa731754106f778fe3c;hpb=6521b5dc32d9bdc4d8826324cb7b2877910cc633;p=st.git diff --git a/st.c b/st.c index 6e7077a..cad61bf 100644 --- a/st.c +++ b/st.c @@ -441,6 +441,7 @@ static int isfullutf8(char *, int); static ssize_t xwrite(int, char *, size_t); static void *xmalloc(size_t); static void *xrealloc(void *, size_t); +static char *xstrdup(char *s); static void (*handler[LASTEvent])(XEvent *) = { [KeyPress] = kpress, @@ -529,6 +530,16 @@ xrealloc(void *p, size_t len) { return p; } +char * +xstrdup(char *s) { + char *p = strdup(s); + + if (!p) + die("Out of memory\n"); + + return p; +} + int utf8decode(char *s, long *u) { uchar c; @@ -3298,8 +3309,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { XftDrawRect(xw.draw, fg, winx, winy + font->ascent + 1, width, 1); } - XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, winx, winy, width, - CEIL((font->ascent + font->descent) * chscale), winx, winy); /* Reset clip to none. */ XftDrawSetClip(xw.draw, 0); @@ -3398,6 +3407,8 @@ redraw(int timeout) { void draw(void) { drawregion(0, 0, term.col, term.row); + XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, + xw.h, 0, 0); XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg].pixel); @@ -3789,7 +3800,7 @@ main(int argc, char *argv[]) { if(argc > 1) { opt_cmd = &argv[1]; if(argv[1] != NULL && opt_title == NULL) { - titles = strdup(argv[1]); + titles = xstrdup(argv[1]); opt_title = basename(titles); } }