Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vt: move glyph determination to a separate function

No logical changes. Make it easier for enhancements to come.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Link: https://lore.kernel.org/r/20250507141535.40655-4-nico@fluxnic.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Nicolas Pitre and committed by
Greg Kroah-Hartman
bb9a1516 68e7a421

+38 -33
+38 -33
drivers/tty/vt/vt.c
··· 2925 2925 2926 2926 #define UCS_ZWS 0x200b /* Zero Width Space */ 2927 2927 #define UCS_VS16 0xfe0f /* Variation Selector 16 */ 2928 + #define UCS_REPLACEMENT 0xfffd /* Replacement Character */ 2928 2929 2929 2930 static int vc_process_ucs(struct vc_data *vc, int *c, int *tc) 2930 2931 { ··· 2985 2984 return 0; 2986 2985 } 2987 2986 2987 + static int vc_get_glyph(struct vc_data *vc, int tc) 2988 + { 2989 + int glyph = conv_uni_to_pc(vc, tc); 2990 + u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; 2991 + 2992 + if (!(glyph & ~charmask)) 2993 + return glyph; 2994 + 2995 + if (glyph == -1) 2996 + return -1; /* nothing to display */ 2997 + 2998 + /* Glyph not found */ 2999 + if ((!vc->vc_utf || vc->vc_disp_ctrl || tc < 128) && !(tc & ~charmask)) { 3000 + /* 3001 + * In legacy mode use the glyph we get by a 1:1 mapping. 3002 + * This would make absolutely no sense with Unicode in mind, but do this for 3003 + * ASCII characters since a font may lack Unicode mapping info and we don't 3004 + * want to end up with having question marks only. 3005 + */ 3006 + return tc; 3007 + } 3008 + 3009 + /* Display U+FFFD (Unicode Replacement Character). */ 3010 + return conv_uni_to_pc(vc, UCS_REPLACEMENT); 3011 + } 3012 + 2988 3013 static int vc_con_write_normal(struct vc_data *vc, int tc, int c, 2989 3014 struct vc_draw_region *draw) 2990 3015 { 2991 3016 int next_c; 2992 3017 unsigned char vc_attr = vc->vc_attr; 2993 - u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; 3018 + u16 himask = vc->vc_hi_font_mask; 2994 3019 u8 width = 1; 2995 3020 bool inverse = false; 2996 3021 ··· 3027 3000 } 3028 3001 3029 3002 /* Now try to find out how to display it */ 3030 - tc = conv_uni_to_pc(vc, tc); 3031 - if (tc & ~charmask) { 3032 - if (tc == -1) 3033 - return -1; /* nothing to display */ 3003 + tc = vc_get_glyph(vc, tc); 3004 + if (tc == -1) 3005 + return -1; /* nothing to display */ 3006 + if (tc < 0) { 3007 + inverse = true; 3008 + tc = conv_uni_to_pc(vc, '?'); 3009 + if (tc < 0) 3010 + tc = '?'; 3034 3011 3035 - /* Glyph not found */ 3036 - if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && 3037 - !(c & ~charmask)) { 3038 - /* 3039 - * In legacy mode use the glyph we get by a 1:1 3040 - * mapping. 3041 - * This would make absolutely no sense with Unicode in 3042 - * mind, but do this for ASCII characters since a font 3043 - * may lack Unicode mapping info and we don't want to 3044 - * end up with having question marks only. 3045 - */ 3046 - tc = c; 3047 - } else { 3048 - /* 3049 - * Display U+FFFD. If it's not found, display an inverse 3050 - * question mark. 3051 - */ 3052 - tc = conv_uni_to_pc(vc, 0xfffd); 3053 - if (tc < 0) { 3054 - inverse = true; 3055 - tc = conv_uni_to_pc(vc, '?'); 3056 - if (tc < 0) 3057 - tc = '?'; 3058 - 3059 - vc_attr = vc_invert_attr(vc); 3060 - con_flush(vc, draw); 3061 - } 3062 - } 3012 + vc_attr = vc_invert_attr(vc); 3013 + con_flush(vc, draw); 3063 3014 } 3064 3015 3065 3016 next_c = c;