瀏覽代碼

Remove non defined behaviour in selcopy

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

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

is non portable.
Roberto E. Vargas Caballero 11 年之前
父節點
當前提交
6521b5dc32
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      st.c

+ 5 - 4
st.c

@@ -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))