From 93a4f5c4758f68717c4e8fa8cb346719b265319c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 21 Feb 2011 15:56:54 +0100 Subject: Fix status reporting for braille patterns _XimLocalMbLookupString can return a braille keysym even if _Xlcwctomb can't convert to the current MB charset. _XimLocalUtf8LookupString needs to set the braille keysym and status too. Signed-off-by: Samuel Thibault Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imLcLkup.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'nx-X11/lib/X11/imLcLkup.c') diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index fa65ed077..9449b9f43 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -67,12 +67,21 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, if(status) *status = XBufferOverflow; return(ret); } - if(keysym) { - *keysym = XK_braille_blank | pattern; - if(status) *status = XLookupBoth; - } else - if(status) *status = XLookupChars; - memcpy(buffer, mb, ret); + if(keysym) *keysym = XK_braille_blank | pattern; + if(ret > 0) { + if (keysym) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } + memcpy(buffer, mb, ret); + } else { + if(keysym) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } + } } else { /* Composed Event */ ret = strlen(&mb[b[ic->private.local.composed].mb]); if(ret > bytes) { @@ -213,6 +222,11 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f); buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6); buffer[2] = 0x80 | (pattern & 0x3f); + if(keysym) { + *keysym = XK_braille_blank | pattern; + if(status) *status = XLookupBoth; + } else + if(status) *status = XLookupChars; } else { /* Composed Event */ ret = strlen(&utf8[b[ic->private.local.composed].utf8]); if(ret > bytes) { -- cgit v1.2.3 From 81422098f57f568499de2fba55a606c74575aba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 31 Jan 2011 14:02:15 +0200 Subject: ximcp/imLckup: Handle negative return value from _Xlcwctomb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed by negative value to memcpy by checking for the negative return value of _Xlcwctomb and returning 0/XLookupNone in that case. a negative value was passed to memcpy Unfortunately the other return values for *status don't fit into the error (which appears to indicate some internal error or running out of memory). The other valid status codes are XBufferOverflow, XLookupNone, XLookupChars, XLookupKeySym, and XLookupBoth. Each of these has a specific meaning attached. Reviewed-by: Ander Conselvan de Oliveira Signed-off-by: Erkki Seppälä Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imLcLkup.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nx-X11/lib/X11/imLcLkup.c') diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index 9449b9f43..f2f96e280 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -63,6 +63,10 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, unsigned char pattern = ic->private.local.brl_committed; char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)]; ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern); + if(ret < 0) { + if(status) *status = XLookupNone; + return(0); + } if(ret > bytes) { if(status) *status = XBufferOverflow; return(ret); -- cgit v1.2.3 From 11d6dac92b6c3c3f62d49817809ce8c6a61c9293 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 22 Oct 2012 13:54:11 -0500 Subject: XIM: remove Private and Public macros Private is a struct member name in mingw-w64 , causing this useless define in a private header to break the build. Signed-off-by: Yaakov Selkowitz Reviewed-by: Jon TURNEY Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imLcLkup.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'nx-X11/lib/X11/imLcLkup.c') diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index f2f96e280..51c1f2ed8 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -43,7 +43,7 @@ PERFORMANCE OF THIS SOFTWARE. #include "XlcPubI.h" #include "Ximint.h" -Public int +int _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, KeySym *keysym, Status *status) { @@ -130,7 +130,7 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, return (ret); } -Public int +int _XimLocalWcLookupString(XIC xic, XKeyEvent *ev, wchar_t *buffer, int wlen, KeySym *keysym, Status *status) { @@ -202,7 +202,7 @@ _XimLocalWcLookupString(XIC xic, XKeyEvent *ev, wchar_t *buffer, int wlen, return (ret); } -Public int +int _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, KeySym *keysym, Status *status) { @@ -275,7 +275,7 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, return (ret); } -Private int +static int _XimLcctsconvert( XlcConv conv, char *from, @@ -341,7 +341,7 @@ _XimLcctsconvert( return to_cnvlen; } -Public int +int _XimLcctstombs(XIM xim, char *from, int from_len, char *to, int to_len, Status *state) { @@ -349,7 +349,7 @@ _XimLcctstombs(XIM xim, char *from, int from_len, from, from_len, to, to_len, state); } -Public int +int _XimLcctstowcs(XIM xim, char *from, int from_len, wchar_t *to, int to_len, Status *state) { @@ -412,7 +412,7 @@ _XimLcctstowcs(XIM xim, char *from, int from_len, return to_cnvlen; } -Public int +int _XimLcctstoutf8(XIM xim, char *from, int from_len, char *to, int to_len, Status *state) { -- cgit v1.2.3 From a2fded2e334eb2f68b5ee6b44463daf58bd8b32c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 7 Oct 2016 22:16:24 +0200 Subject: Revert incomplete "Fix status reporting for braille patterns" This reverts commit 8866f80d9f42e02093058cab027edbf127118105. That commit had been edited and was incomplete, by reverting and re-applying we get it right. --- nx-X11/lib/X11/imLcLkup.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'nx-X11/lib/X11/imLcLkup.c') diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index 51c1f2ed8..50e09d2e7 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -71,21 +71,12 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, if(status) *status = XBufferOverflow; return(ret); } - if(keysym) *keysym = XK_braille_blank | pattern; - if(ret > 0) { - if (keysym) { - if(status) *status = XLookupBoth; - } else { - if(status) *status = XLookupChars; - } - memcpy(buffer, mb, ret); - } else { - if(keysym) { - if(status) *status = XLookupKeySym; - } else { - if(status) *status = XLookupNone; - } - } + if(keysym) { + *keysym = XK_braille_blank | pattern; + if(status) *status = XLookupBoth; + } else + if(status) *status = XLookupChars; + memcpy(buffer, mb, ret); } else { /* Composed Event */ ret = strlen(&mb[b[ic->private.local.composed].mb]); if(ret > bytes) { @@ -226,11 +217,6 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f); buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6); buffer[2] = 0x80 | (pattern & 0x3f); - if(keysym) { - *keysym = XK_braille_blank | pattern; - if(status) *status = XLookupBoth; - } else - if(status) *status = XLookupChars; } else { /* Composed Event */ ret = strlen(&utf8[b[ic->private.local.composed].utf8]); if(ret > bytes) { -- cgit v1.2.3 From b00312f5d4e09ade3e91e5d6c5f7c847c474fb58 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 21 Feb 2011 15:56:54 +0100 Subject: Fix status reporting for braille patterns _XimLocalMbLookupString can return a braille keysym even if _Xlcwctomb can't convert to the current MB charset. _XimLocalUtf8LookupString needs to set the braille keysym and status too. Signed-off-by: Samuel Thibault Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imLcLkup.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'nx-X11/lib/X11/imLcLkup.c') diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index 50e09d2e7..878b8e350 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -63,20 +63,25 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, unsigned char pattern = ic->private.local.brl_committed; char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)]; ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern); - if(ret < 0) { - if(status) *status = XLookupNone; - return(0); - } if(ret > bytes) { if(status) *status = XBufferOverflow; return(ret); } - if(keysym) { - *keysym = XK_braille_blank | pattern; - if(status) *status = XLookupBoth; - } else - if(status) *status = XLookupChars; - memcpy(buffer, mb, ret); + if(keysym) *keysym = XK_braille_blank | pattern; + if(ret > 0) { + if (keysym) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } + memcpy(buffer, mb, ret); + } else { + if(keysym) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } + } } else { /* Composed Event */ ret = strlen(&mb[b[ic->private.local.composed].mb]); if(ret > bytes) { @@ -217,6 +222,11 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f); buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6); buffer[2] = 0x80 | (pattern & 0x3f); + if(keysym) { + *keysym = XK_braille_blank | pattern; + if(status) *status = XLookupBoth; + } else + if(status) *status = XLookupChars; } else { /* Composed Event */ ret = strlen(&utf8[b[ic->private.local.composed].utf8]); if(ret > bytes) { -- cgit v1.2.3