summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpancake@nopcode.org <unknown>2010-08-31 17:36:55 +0200
committerpancake@nopcode.org <unknown>2010-08-31 17:36:55 +0200
commit591d147af7d59f31a68513f613124d49f25f9859 (patch)
tree386af53d0c8ca8a4957b418861374956c65e005c
parent1132d9e2d65f469dedd9c5b6f356495c7a87b743 (diff)
fix segfault when selecting big buffers
shift+insert paste clipboard honor CFLAGS and LDFLAGS in config.mk
-rw-r--r--config.mk6
-rw-r--r--st.c22
2 files changed, 9 insertions, 19 deletions
diff --git a/config.mk b/config.mk
index 46efc0c..01a3779 100644
--- a/config.mk
+++ b/config.mk
@@ -16,8 +16,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil
# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
-CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
-LDFLAGS = -s ${LIBS}
+CFLAGS += -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
+LDFLAGS += -s ${LIBS}
# compiler and linker
-CC = cc
+CC ?= cc
diff --git a/st.c b/st.c
index 1474c53..c2f294a 100644
--- a/st.c
+++ b/st.c
@@ -249,19 +249,15 @@ static char *getseltext() {
int ls, x, y, sz;
if(sel.bx==-1)
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);
for(y = 0; y < term.row; y++) {
for(x = 0; x < term.col; x++) {
- if(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y))) {
- *ptr = term.line[y][x].c;
- ptr++;
- }
- }
- if (ls) {
- *ptr = '\n';
- ptr++;
+ if(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y)))
+ *ptr = term.line[y][x].c, ptr++;
}
+ if (ls)
+ *ptr = '\n', ptr++;
}
*ptr = 0;
return str;
@@ -283,12 +279,6 @@ static void brelease(XEvent *e) {
int b;
sel.mode = 0;
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) {
sel.bx = -1;
if(b==2)
@@ -1411,7 +1401,7 @@ kpress(XEvent *ev) {
break;
case XK_Insert:
if(shift)
- draw(1), puts("draw!")/* XXX: paste X clipboard */;
+ selpaste(), draw(1);
break;
default:
fprintf(stderr, "errkey: %d\n", (int)ksym);