From c52238d69bc63f52f14815dc804b846c10265685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Thu, 19 Oct 2006 19:25:08 +0200 Subject: [PATCH] wineconsole: Remove spaces from the ends of lines while copying to the clipboard. --- programs/wineconsole/user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index e1efda2e26f..557ccfc07f1 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -689,8 +689,15 @@ static void WCUSER_CopySelectionToClipboard(const struct inner_data* data) for (y = 0; y < h; y++, c.Y++) { - ReadConsoleOutputCharacter(data->hConOut, &p[y * w], w - 1, c, NULL); - p[y * w + w - 1] = (y < h - 1) ? '\n' : '\0'; + LPWSTR end; + ReadConsoleOutputCharacter(data->hConOut, p, w - 1, c, NULL); + + /* strip spaces from the end of the line */ + end = p + w - 1; + while (end > p && *(end - 1) == ' ') + end--; + *end = (y < h - 1) ? '\n' : '\0'; + p = end + 1; } GlobalUnlock(hMem); SetClipboardData(CF_UNICODETEXT, hMem);