fix segfault when selecting big buffers

shift+insert paste clipboard
honor CFLAGS and LDFLAGS in config.mk
This commit is contained in:
pancake@nopcode.org 2010-08-31 17:36:55 +02:00
parent 4449abbddb
commit 87d1f98637
2 changed files with 9 additions and 19 deletions

View File

@ -16,8 +16,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil
# flags # flags
CPPFLAGS = -DVERSION=\"${VERSION}\" CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} CFLAGS += -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
LDFLAGS = -s ${LIBS} LDFLAGS += -s ${LIBS}
# compiler and linker # compiler and linker
CC = cc CC ?= cc

22
st.c
View File

@ -249,19 +249,15 @@ static char *getseltext() {
int ls, x, y, sz; int ls, x, y, sz;
if(sel.bx==-1) if(sel.bx==-1)
return NULL; return NULL;
sz = ((xw.w/xw.ch) * (sel.e[1]-sel.b[1]+2)); sz = ((term.col+1) * (sel.e[1]-sel.b[1]+1));
ptr = str = malloc (sz); ptr = str = malloc (sz);
for(y = 0; y < term.row; y++) { for(y = 0; y < term.row; y++) {
for(x = 0; x < term.col; x++) { for(x = 0; x < term.col; x++) {
if(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y))) { if(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y)))
*ptr = term.line[y][x].c; *ptr = term.line[y][x].c, ptr++;
ptr++;
}
}
if (ls) {
*ptr = '\n';
ptr++;
} }
if (ls)
*ptr = '\n', ptr++;
} }
*ptr = 0; *ptr = 0;
return str; return str;
@ -283,12 +279,6 @@ static void brelease(XEvent *e) {
int b; int b;
sel.mode = 0; sel.mode = 0;
getbuttoninfo(e, &b, &sel.ex, &sel.ey); getbuttoninfo(e, &b, &sel.ex, &sel.ey);
if(b==4)
tscrollup(1);
else
if(b==5)
tscrolldown(1);
else
if(sel.bx==sel.ex && sel.by==sel.ey) { if(sel.bx==sel.ex && sel.by==sel.ey) {
sel.bx = -1; sel.bx = -1;
if(b==2) if(b==2)
@ -1411,7 +1401,7 @@ kpress(XEvent *ev) {
break; break;
case XK_Insert: case XK_Insert:
if(shift) if(shift)
draw(1), puts("draw!")/* XXX: paste X clipboard */; selpaste(), draw(1);
break; break;
default: default:
fprintf(stderr, "errkey: %d\n", (int)ksym); fprintf(stderr, "errkey: %d\n", (int)ksym);