Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609755

Re: [PATCH 2/2] vt: make mouse selection of non-ASCII consistent

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] vt: make mouse selection of non-ASCII consistent
Date 2017-03-27 14:00 +0200
Message-ID <tpBtw-7vp-19@gated-at.bofh.it> (permalink)
References <tpAe6-6F9-13@gated-at.bofh.it> <tpAnL-6J9-7@gated-at.bofh.it> <tpAnL-6J9-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 03/27/2017, 12:37 PM, Adam Borowski wrote:
> For some reason a handful of ISO-8859-1 symbols are excluded from "word
> chars" while the vast majority of Unicode is hard-coded as included, even
> when inappropriate (we really would want to _not_ select line-drawing/etc).
> Those symbols are: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷
> 
> Thus, let's not special-case any non-ASCII anymore.  Attempts to set these
> via ioctl will be silently ignored.
> 
> As an extra bonus, we debloat the kernel by 128 bytes.
> 
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
>  drivers/tty/vt/selection.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
> index 2252e11d8347..c81c99165ea6 100644
> --- a/drivers/tty/vt/selection.c
> +++ b/drivers/tty/vt/selection.c
> @@ -80,21 +80,17 @@ void clear_selection(void)
>  
>  /*
>   * User settable table: what characters are to be considered alphabetic?
> - * 256 bits. Locked by the console lock.
> + * 128 bits. Locked by the console lock.
>   */
> -static u32 inwordLut[8]={
> +static u32 inwordLut[4]={

No need for the constant here. Let it autosize.

>    0x00000000, /* control chars     */
>    0x03FFE000, /* digits and "-./"  */
>    0x87FFFFFE, /* uppercase and '_' */
>    0x07FFFFFE, /* lowercase         */
> -  0x00000000,
> -  0x00000000,
> -  0xFF7FFFFF, /* latin-1 accented letters, not multiplication sign */
> -  0xFF7FFFFF  /* latin-1 accented letters, not division sign */
>  };
>  
>  static inline int inword(const u16 c) {
> -	return c > 0xff || (( inwordLut[c>>5] >> (c & 0x1F) ) & 1);
> +	return c > 0x7f || (( inwordLut[c>>5] >> (c & 0x1F) ) & 1);
>  }
>  
>  /**
> @@ -106,10 +102,10 @@ static inline int inword(const u16 c) {
>   */
>  int sel_loadlut(char __user *p)
>  {
> -	u32 tmplut[8];
> -	if (copy_from_user(tmplut, (u32 __user *)(p+4), 32))
> +	u32 tmplut[4];

ARRAY_SIZE(inwordLut) here.

> +	if (copy_from_user(tmplut, (u32 __user *)(p+4), 16))
>  		return -EFAULT;
> -	memcpy(inwordLut, tmplut, 32);
> +	memcpy(inwordLut, tmplut, 16);

sizeof(inwordLut) here and for copy_from_user too.

>  	return 0;
>  }

thanks,
-- 
js
suse labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] vt: mouse selection word boundaries Adam Borowski <kilobyte@angband.pl> - 2017-03-27 12:40 +0200
  [PATCH 2/2] vt: make mouse selection of non-ASCII consistent Adam Borowski <kilobyte@angband.pl> - 2017-03-27 12:50 +0200
    Re: [PATCH 2/2] vt: make mouse selection of non-ASCII consistent Jiri Slaby <jslaby@suse.cz> - 2017-03-27 14:00 +0200
      [PATCH v2 2/2] vt: make mouse selection of non-ASCII consistent Adam Borowski <kilobyte@angband.pl> - 2017-03-27 14:30 +0200
      [PATCH v2 1/2] vt: set mouse selection word-chars to gpm's default Adam Borowski <kilobyte@angband.pl> - 2017-03-27 14:30 +0200
  [PATCH 1/2] vt: set mouse selection word-chars to gpm's default Adam Borowski <kilobyte@angband.pl> - 2017-03-27 12:50 +0200

csiph-web