From 97a2dda5335e9fe9a74a6f03ae79e16facb8f500 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Fri, 19 Sep 2014 14:00:16 -0400 Subject: [PATCH] *finally fixed the memory leak and improved how the newlines are created inside objects (needs further testing) --- pd/src/g_rtext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c index 9f975aa26..270d6b5d1 100644 --- a/pd/src/g_rtext.c +++ b/pd/src/g_rtext.c @@ -297,10 +297,10 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp, nlines++; } // append new line in case we end our input with an \n - if (x_bufsize_c > 0 && x->x_buf[x_bufsize_c - 1] == '\n') + if (x_bufsize_c > 0 && (x->x_buf[x_bufsize_c - 1] == '\n' || x->x_buf[x_bufsize_c - 1] == '\v')) { - //nlines++; - //tempbuf[outchars_b++] = '\n'; + nlines++; + tempbuf[outchars_b++] = '\n'; //tempbuf[outchars_b] = '\0'; //outchars_b++; } @@ -691,10 +691,11 @@ be printable in whatever 8-bit character set we find ourselves. */ // allow us to go visually above where we used // to be in multiline situations (e.g. comments) int right = 0; - //printf("start: selstart=%d\n", x->x_selstart); + //printf("start: selstart=%d x->x_bufsize=%d\n", x->x_selstart, x->x_bufsize); if (x->x_selstart > 0 && - (x->x_buf[x->x_selstart] == '\n' || - x->x_buf[x->x_selstart] == '\v')) + (x->x_selstart == x->x_bufsize || + x->x_buf[x->x_selstart] == '\n' || + x->x_buf[x->x_selstart] == '\v')) { //printf("found break\n"); u8_dec(x->x_buf, &x->x_selstart); -- GitLab