From b08c7605748ff7a8d801b82f0eb6f6664b6d38ca Mon Sep 17 00:00:00 2001 From: dim Date: Sat, 16 Feb 2013 12:48:06 +0000 Subject: Fix two instances of undefined behaviour in contrib/nvi. Found by: clang ToT Obtained from: NetBSD Reviewed by: jh MFC after: 3 days --- contrib/nvi/ex/ex_txt.c | 4 ++-- contrib/nvi/vi/v_txt.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/nvi/ex/ex_txt.c b/contrib/nvi/ex/ex_txt.c index 2f62ff5..30bcf97 100644 --- a/contrib/nvi/ex/ex_txt.c +++ b/contrib/nvi/ex/ex_txt.c @@ -398,8 +398,8 @@ txt_dent(sp, tp) ++scno; /* Get the previous shiftwidth column. */ - cno = scno; - scno -= --scno % sw; + cno = scno--; + scno -= scno % sw; /* * Since we don't know what comes before the character(s) being diff --git a/contrib/nvi/vi/v_txt.c b/contrib/nvi/vi/v_txt.c index 4a3e80a..0cb1ff5 100644 --- a/contrib/nvi/vi/v_txt.c +++ b/contrib/nvi/vi/v_txt.c @@ -1956,8 +1956,10 @@ txt_dent(sp, tp, isindent) target = current; if (isindent) target += COL_OFF(target, sw); - else - target -= --target % sw; + else { + --target; + target -= target % sw; + } /* * The AI characters will be turned into overwrite characters if the -- cgit v1.1