--- rxvt-unicode/src/screen.C 2010/10/15 21:14:12 1.354 +++ rxvt-unicode/src/screen.C 2011/01/05 22:29:50 1.360 @@ -402,7 +402,7 @@ free (tabs); tabs = (char *)rxvt_malloc (ncol); - for (int col = ncol; --col; ) + for (int col = ncol; col--; ) tabs [col] = col % TABSIZE == 0; CLEAR_ALL_SELECTION (); @@ -919,7 +919,7 @@ } // nuke the character at this position, if required - // due to wonderful coincidents everywhere else in this loop + // due to wonderful coincidences everywhere else in this loop // we never have to check for overwriting a wide char itself, // only its tail. if (expect_false (line->t[screen.cur.col] == NOCHAR)) @@ -2629,7 +2629,7 @@ { int row, wrote; unsigned int width, towrite; - char r1[] = "\n"; + const char r1[] = "\n"; for (row = saveLines + top_row; row < saveLines + nrow - 1; row++) @@ -3000,7 +3000,7 @@ void rxvt_term::selection_make (Time tm) { - int i; + int size; wchar_t *new_selection_text; text_t *t; @@ -3026,8 +3026,8 @@ if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) return; - i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); - new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); + size = (selection.end.row - selection.beg.row + 1) * (ncol + 1); + new_selection_text = (wchar_t *)rxvt_malloc ((size + 4) * sizeof (wchar_t)); int ofs = 0; int extra = 0; @@ -3043,7 +3043,7 @@ if (selection.rect) { col = selection.beg.col; - end_col = ncol + 1; + end_col = selection.end.col; } else #endif @@ -3051,11 +3051,7 @@ col = max (col, 0); - if (row == selection.end.row -#if !ENABLE_MINIMAL - || selection.rect -#endif - ) + if (row == selection.end.row) min_it (end_col, selection.end.col); t = ROW(row).t + col; @@ -3073,9 +3069,9 @@ if (extra < 0) { - extra += i; - i += i; - new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t)); + extra += size; + size += size; + new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (size + 4) * sizeof (wchar_t)); } ofs += rxvt_composite.expand (*t++, new_selection_text + ofs); @@ -3097,7 +3093,8 @@ } else #endif - if (!ROW(row).is_longer () && row != selection.end.row) + if (!ROW(row).is_longer () && row != selection.end.row + && (row != selection.beg.row || selection.beg.col < ncol)) new_selection_text[ofs++] = C0_LF; }