linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] vt: Move custom isspace() to its own namespace
@ 2021-05-10 14:49 Andy Shevchenko
  2021-05-13  7:43 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2021-05-10 14:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Greg Kroah-Hartman, Jiri Slaby, kernel test robot

If by some reason any of the headers will include ctype.h
we will have a name collision. Avoid this by moving isspace()
to the dedicate namespace.

First appearance of the code is in the commit 24a1c2a769cf
("Import 1.1.92").

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/vt/selection.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index f245a5acf7e9..bcb6bc5731cc 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -33,7 +33,7 @@
 #include <linux/sched/signal.h>
 
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
-#define isspace(c)	((c) == ' ')
+#define is_space_on_vt(c)	((c) == ' ')
 
 /* FIXME: all this needs locking */
 static struct vc_selection {
@@ -209,7 +209,7 @@ static int vc_selection_store_chars(struct vc_data *vc, bool unicode)
 			bp += store_utf8(c, bp);
 		else
 			*bp++ = c;
-		if (!isspace(c))
+		if (!is_space_on_vt(c))
 			obp = bp;
 		if (!((i + 2) % vc->vc_size_row)) {
 			/* strip trailing blanks from line and add newline,
@@ -238,9 +238,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
 		new_sel_end = pe;
 		break;
 	case TIOCL_SELWORD:	/* word-by-word selection */
-		spc = isspace(sel_pos(ps, unicode));
+		spc = is_space_on_vt(sel_pos(ps, unicode));
 		for (new_sel_start = ps; ; ps -= 2) {
-			if ((spc && !isspace(sel_pos(ps, unicode))) ||
+			if ((spc && !is_space_on_vt(sel_pos(ps, unicode))) ||
 			    (!spc && !inword(sel_pos(ps, unicode))))
 				break;
 			new_sel_start = ps;
@@ -248,9 +248,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
 				break;
 		}
 
-		spc = isspace(sel_pos(pe, unicode));
+		spc = is_space_on_vt(sel_pos(pe, unicode));
 		for (new_sel_end = pe; ; pe += 2) {
-			if ((spc && !isspace(sel_pos(pe, unicode))) ||
+			if ((spc && !is_space_on_vt(sel_pos(pe, unicode))) ||
 			    (!spc && !inword(sel_pos(pe, unicode))))
 				break;
 			new_sel_end = pe;
@@ -276,12 +276,12 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
 	/* select to end of line if on trailing space */
 	if (new_sel_end > new_sel_start &&
 		!atedge(new_sel_end, vc->vc_size_row) &&
-		isspace(sel_pos(new_sel_end, unicode))) {
+		is_space_on_vt(sel_pos(new_sel_end, unicode))) {
 		for (pe = new_sel_end + 2; ; pe += 2)
-			if (!isspace(sel_pos(pe, unicode)) ||
+			if (!is_space_on_vt(sel_pos(pe, unicode)) ||
 			    atedge(pe, vc->vc_size_row))
 				break;
-		if (isspace(sel_pos(pe, unicode)))
+		if (is_space_on_vt(sel_pos(pe, unicode)))
 			new_sel_end = pe;
 	}
 	if (vc_sel.start == -1)	/* no current selection */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] vt: Move custom isspace() to its own namespace
  2021-05-10 14:49 [PATCH v1 1/1] vt: Move custom isspace() to its own namespace Andy Shevchenko
@ 2021-05-13  7:43 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2021-05-13  7:43 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Greg Kroah-Hartman, kernel test robot

On 10. 05. 21, 16:49, Andy Shevchenko wrote:
> If by some reason any of the headers will include ctype.h
> we will have a name collision. Avoid this by moving isspace()
> to the dedicate namespace.
> 
> First appearance of the code is in the commit 24a1c2a769cf
> ("Import 1.1.92").
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   drivers/tty/vt/selection.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
> index f245a5acf7e9..bcb6bc5731cc 100644
> --- a/drivers/tty/vt/selection.c
> +++ b/drivers/tty/vt/selection.c
> @@ -33,7 +33,7 @@
>   #include <linux/sched/signal.h>
>   
>   /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
> -#define isspace(c)	((c) == ' ')
> +#define is_space_on_vt(c)	((c) == ' ')
>   
>   /* FIXME: all this needs locking */
>   static struct vc_selection {
> @@ -209,7 +209,7 @@ static int vc_selection_store_chars(struct vc_data *vc, bool unicode)
>   			bp += store_utf8(c, bp);
>   		else
>   			*bp++ = c;
> -		if (!isspace(c))
> +		if (!is_space_on_vt(c))
>   			obp = bp;
>   		if (!((i + 2) % vc->vc_size_row)) {
>   			/* strip trailing blanks from line and add newline,
> @@ -238,9 +238,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
>   		new_sel_end = pe;
>   		break;
>   	case TIOCL_SELWORD:	/* word-by-word selection */
> -		spc = isspace(sel_pos(ps, unicode));
> +		spc = is_space_on_vt(sel_pos(ps, unicode));
>   		for (new_sel_start = ps; ; ps -= 2) {
> -			if ((spc && !isspace(sel_pos(ps, unicode))) ||
> +			if ((spc && !is_space_on_vt(sel_pos(ps, unicode))) ||
>   			    (!spc && !inword(sel_pos(ps, unicode))))
>   				break;
>   			new_sel_start = ps;
> @@ -248,9 +248,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
>   				break;
>   		}
>   
> -		spc = isspace(sel_pos(pe, unicode));
> +		spc = is_space_on_vt(sel_pos(pe, unicode));
>   		for (new_sel_end = pe; ; pe += 2) {
> -			if ((spc && !isspace(sel_pos(pe, unicode))) ||
> +			if ((spc && !is_space_on_vt(sel_pos(pe, unicode))) ||
>   			    (!spc && !inword(sel_pos(pe, unicode))))
>   				break;
>   			new_sel_end = pe;
> @@ -276,12 +276,12 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
>   	/* select to end of line if on trailing space */
>   	if (new_sel_end > new_sel_start &&
>   		!atedge(new_sel_end, vc->vc_size_row) &&
> -		isspace(sel_pos(new_sel_end, unicode))) {
> +		is_space_on_vt(sel_pos(new_sel_end, unicode))) {
>   		for (pe = new_sel_end + 2; ; pe += 2)
> -			if (!isspace(sel_pos(pe, unicode)) ||
> +			if (!is_space_on_vt(sel_pos(pe, unicode)) ||
>   			    atedge(pe, vc->vc_size_row))
>   				break;
> -		if (isspace(sel_pos(pe, unicode)))
> +		if (is_space_on_vt(sel_pos(pe, unicode)))
>   			new_sel_end = pe;
>   	}
>   	if (vc_sel.start == -1)	/* no current selection */
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-13  7:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 14:49 [PATCH v1 1/1] vt: Move custom isspace() to its own namespace Andy Shevchenko
2021-05-13  7:43 ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).