@@ -226,45 +226,43 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
226226 }
227227 unicode = vt_do_kdgkbmode (fg_console ) == K_UNICODE ;
228228
229- switch (v -> sel_mode )
230- {
231- case TIOCL_SELCHAR : /* character-by-character selection */
229+ switch (v -> sel_mode ) {
230+ case TIOCL_SELCHAR : /* character-by-character selection */
231+ new_sel_start = ps ;
232+ new_sel_end = pe ;
233+ break ;
234+ case TIOCL_SELWORD : /* word-by-word selection */
235+ spc = isspace (sel_pos (ps , unicode ));
236+ for (new_sel_start = ps ; ; ps -= 2 ) {
237+ if ((spc && !isspace (sel_pos (ps , unicode ))) ||
238+ (!spc && !inword (sel_pos (ps , unicode ))))
239+ break ;
232240 new_sel_start = ps ;
241+ if (!(ps % vc -> vc_size_row ))
242+ break ;
243+ }
244+
245+ spc = isspace (sel_pos (pe , unicode ));
246+ for (new_sel_end = pe ; ; pe += 2 ) {
247+ if ((spc && !isspace (sel_pos (pe , unicode ))) ||
248+ (!spc && !inword (sel_pos (pe , unicode ))))
249+ break ;
233250 new_sel_end = pe ;
234- break ;
235- case TIOCL_SELWORD : /* word-by-word selection */
236- spc = isspace (sel_pos (ps , unicode ));
237- for (new_sel_start = ps ; ; ps -= 2 )
238- {
239- if ((spc && !isspace (sel_pos (ps , unicode ))) ||
240- (!spc && !inword (sel_pos (ps , unicode ))))
241- break ;
242- new_sel_start = ps ;
243- if (!(ps % vc -> vc_size_row ))
244- break ;
245- }
246- spc = isspace (sel_pos (pe , unicode ));
247- for (new_sel_end = pe ; ; pe += 2 )
248- {
249- if ((spc && !isspace (sel_pos (pe , unicode ))) ||
250- (!spc && !inword (sel_pos (pe , unicode ))))
251- break ;
252- new_sel_end = pe ;
253- if (!((pe + 2 ) % vc -> vc_size_row ))
254- break ;
255- }
256- break ;
257- case TIOCL_SELLINE : /* line-by-line selection */
258- new_sel_start = ps - ps % vc -> vc_size_row ;
259- new_sel_end = pe + vc -> vc_size_row
260- - pe % vc -> vc_size_row - 2 ;
261- break ;
262- case TIOCL_SELPOINTER :
263- highlight_pointer (pe );
264- goto unlock ;
265- default :
266- ret = - EINVAL ;
267- goto unlock ;
251+ if (!((pe + 2 ) % vc -> vc_size_row ))
252+ break ;
253+ }
254+ break ;
255+ case TIOCL_SELLINE : /* line-by-line selection */
256+ new_sel_start = ps - ps % vc -> vc_size_row ;
257+ new_sel_end = pe + vc -> vc_size_row
258+ - pe % vc -> vc_size_row - 2 ;
259+ break ;
260+ case TIOCL_SELPOINTER :
261+ highlight_pointer (pe );
262+ goto unlock ;
263+ default :
264+ ret = - EINVAL ;
265+ goto unlock ;
268266 }
269267
270268 /* remove the pointer */
0 commit comments