> + while(--last >= gp && !(selected(last - gp, y) && \ > + strcmp(last->c, " ") != 0)) > /* nothing */;
I think you could write here only: while(--last >= gp && strcmp(last->c, " ")) /* nothing */ because it is not important if it is selected or not, you only want to remove the trailing white spaces, and the next loop will look if the character is selected or not: for(x = 0; gp <= last; x++, ++gp) { if(!selected(x, y)) continue; isselected = 1; size = utf8size(p); memcpy(ptr, p, size); ptr += size; }