From e0550db4d156d9a76a5d78a5bdde6ef470cd3eca Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 18 Sep 2015 17:53:58 +0800 Subject: [PATCH] $line returns a full copy of the current line instead of truncated at NSTRING. --- line.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/line.c b/line.c index 6aeecf8..587a74d 100644 --- a/line.c +++ b/line.c @@ -619,14 +619,24 @@ char *getctext(void) int size; /* length of line to return */ char *sp; /* string pointer into line */ char *dp; /* string pointer into returned line */ - static char rline[NSTRING]; /* line to return */ + static int rsize = 0 ; + static char *rline ; /* line to return */ /* find the contents of the current line and its length */ lp = curwp->w_dotp; sp = lp->l_text; size = lp->l_used; - if (size >= NSTRING) - size = NSTRING - 1; + if( size >= rsize) { + if( rsize) + free( rline) ; + + rsize = size + 1 ; + rline = malloc( rsize) ; + if( rline == NULL) { + rsize = 0 ; + return "" ; + } + } /* copy it across */ dp = rline;