[PATCH v2 1/2] comctl32/edit: Move common calls outside the blocks
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- v2: Move more stuff outside the blocks and use ~0 This supersedes 150050. dlls/comctl32/edit.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index 10ff5fb..3895dc5 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -3308,22 +3308,17 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key) else EDIT_WM_Clear(es); } else { - if (shift) { + EDIT_EM_SetSel(es, ~0, 0, FALSE); + if (shift) /* delete character left of caret */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveBackward(es, TRUE); - EDIT_WM_Clear(es); - } else if (control) { + else if (control) /* delete to end of line */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveEnd(es, TRUE, FALSE); - EDIT_WM_Clear(es); - } else { + else /* delete character right of caret */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveForward(es, TRUE); - EDIT_WM_Clear(es); - } + EDIT_WM_Clear(es); } } break; -- 1.9.1
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- v2: Move more stuff outside the blocks and use ~0 This supersedes 150051. dlls/user32/edit.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 96ecbec..0761938 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -3474,22 +3474,17 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key) else EDIT_WM_Clear(es); } else { - if (shift) { + EDIT_EM_SetSel(es, ~0, 0, FALSE); + if (shift) /* delete character left of caret */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveBackward(es, TRUE); - EDIT_WM_Clear(es); - } else if (control) { + else if (control) /* delete to end of line */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveEnd(es, TRUE, FALSE); - EDIT_WM_Clear(es); - } else { + else /* delete character right of caret */ - EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE); EDIT_MoveForward(es, TRUE); - EDIT_WM_Clear(es); - } + EDIT_WM_Clear(es); } } break; -- 1.9.1
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> I still think ~0u would be better, if only to match argument type.
On Thu, Aug 23, 2018 at 8:19 PM, Nikolay Sivov <nsivov(a)codeweavers.com> wrote:
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
I still think ~0u would be better, if only to match argument type.
The thing is that the argument type is a typedef (UINT). Here's an imagined scenario (one of my crazy thoughts). Say UINT on some other wacky platform, is typedef to long, and long is 64-bits there instead of 32-bits like int is. ~ is unary operator so it applies to 0u, and since int is 32-bits, this becomes silently zero-extended (since it's unsigned) to 0x00000000FFFFFFFF instead of sign-extended to 0xFFFFFFFFFFFFFFFF. Though yes, it doesn't really matter in practice and probably will never apply to UINT itself, just a (bad?) habit of mine. :)
participants (2)
-
Gabriel Ivăncescu -
Nikolay Sivov