[dev] [st][PATCH 4/4] Remove non defined behaviour in selcopy

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Sun, 2 Feb 2014 19:57:28 +0100

It is not defined when lateral effects of expressions are
calculated, so an expression as:

        --last >= gp && !(selected(last - gp, y)

is non portable.

Signed-off-by: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
---
 st.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/st.c b/st.c
index c59bf1d..6e7077a 100644
--- a/st.c
+++ b/st.c
_AT_@ -953,11 +953,12 @@ selcopy(void) {
 		/* append every set & selected glyph to the selection */
 		for(y = sel.nb.y; y < sel.ne.y + 1; y++) {
 			gp = &term.line[y][0];
-			last = gp + term.col;
+			last = &gp[term.col-1];
 
-			while(--last >= gp && !(selected(last - gp, y) && \
-						strcmp(last->c, " ") != 0))
-				/* nothing */;
+			while(last >= gp && !(selected(last - gp, y) &&
+			                      strcmp(last->c, " ") != 0)) {
+				--last;
+			}
 
 			for(x = 0; gp <= last; x++, ++gp) {
 				if(!selected(x, y) || (gp->mode & ATTR_WDUMMY))
-- 
1.8.5.3
Received on Sun Feb 02 2014 - 19:57:28 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 02 2014 - 20:00:16 CET