Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2015 07:49:27 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287098 - head/sys/teken
Message-ID:  <201508240749.t7O7nRZL084483@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Mon Aug 24 07:49:27 2015
New Revision: 287098
URL: https://svnweb.freebsd.org/changeset/base/287098

Log:
  Sync HPA and VPA implementations with CUP.
  
  After fixing the 16-bits integer arithmetic overflow in 286981, we
  should also make sure to fix the VPA sequence. Bring HPA and VPA in sync
  with how we now implement CUP.
  
  PR:		202612
  Reported by:	kcwu csie org
  MFC after:	1 month

Modified:
  head/sys/teken/teken_subr.h

Modified: head/sys/teken/teken_subr.h
==============================================================================
--- head/sys/teken/teken_subr.h	Mon Aug 24 05:38:05 2015	(r287097)
+++ head/sys/teken/teken_subr.h	Mon Aug 24 07:49:27 2015	(r287098)
@@ -583,9 +583,9 @@ static void
 teken_subr_horizontal_position_absolute(teken_t *t, unsigned int col)
 {
 
-	t->t_cursor.tp_col = col - 1;
-	if (t->t_cursor.tp_col >= t->t_winsize.tp_col)
-		t->t_cursor.tp_col = t->t_winsize.tp_col - 1;
+	col--;
+	t->t_cursor.tp_col = col < t->t_winsize.tp_col ?
+	    col : t->t_winsize.tp_col - 1;
 
 	t->t_stateflags &= ~TS_WRAPPED;
 	teken_funcs_cursor(t);
@@ -1297,9 +1297,9 @@ static void
 teken_subr_vertical_position_absolute(teken_t *t, unsigned int row)
 {
 
-	t->t_cursor.tp_row = t->t_originreg.ts_begin + row - 1;
-	if (t->t_cursor.tp_row >= t->t_originreg.ts_end)
-		t->t_cursor.tp_row = t->t_originreg.ts_end - 1;
+	row = row - 1 + t->t_originreg.ts_begin;
+	t->t_cursor.tp_row = row < t->t_originreg.ts_end ?
+	    row : t->t_originreg.ts_end - 1;
 
 	t->t_stateflags &= ~TS_WRAPPED;
 	teken_funcs_cursor(t);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508240749.t7O7nRZL084483>