vt: Move custom isspace() to its own namespace

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>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510144947.58270-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Andy Shevchenko 2021-05-10 17:49:47 +03:00 committed by Greg Kroah-Hartman
parent 1df92640ba
commit 7985723d21

View file

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