[hackers] [st] fix segfault when selecting big buffers || pancake

From: <hg_AT_suckless.org>
Date: Tue, 31 Aug 2010 15:41:11 +0000 (UTC)

changeset: 124:36337e90e0df
tag: tip
user: pancake_AT_nopcode.org
date: Tue Aug 31 17:36:55 2010 +0200
files: config.mk st.c
description:
fix segfault when selecting big buffers
shift+insert paste clipboard
honor CFLAGS and LDFLAGS in config.mk

diff -r dde4d16ec379 -r 36337e90e0df config.mk
--- a/config.mk Tue Aug 31 16:56:27 2010 +0200
+++ b/config.mk Tue Aug 31 17:36:55 2010 +0200
@@ -16,8 +16,8 @@
 
 # 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 -r dde4d16ec379 -r 36337e90e0df st.c
--- a/st.c Tue Aug 31 16:56:27 2010 +0200
+++ b/st.c Tue Aug 31 17:36:55 2010 +0200
@@ -249,19 +249,15 @@
         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(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y)))
+ *ptr = term.line[y][x].c, ptr++;
                 }
- if (ls) {
- *ptr = '\n';
- ptr++;
- }
+ if (ls)
+ *ptr = '\n', ptr++;
         }
         *ptr = 0;
         return str;
@@ -283,12 +279,6 @@
         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 @@
                         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);
Received on Tue Aug 31 2010 - 17:41:11 CEST

This archive was generated by hypermail 2.2.0 : Tue Aug 31 2010 - 17:48:03 CEST