Author: dim
Date: Sat Feb 16 12:48:06 2013
New Revision: 246874
URL: http://svnweb.freebsd.org/changeset/base/246874

Log:
  Fix two instances of undefined behaviour in contrib/nvi.
  
  Found by:     clang ToT
  Obtained from:        NetBSD
  Reviewed by:  jh
  MFC after:    3 days

Modified:
  head/contrib/nvi/ex/ex_txt.c
  head/contrib/nvi/vi/v_txt.c

Modified: head/contrib/nvi/ex/ex_txt.c
==============================================================================
--- head/contrib/nvi/ex/ex_txt.c        Sat Feb 16 12:45:57 2013        
(r246873)
+++ head/contrib/nvi/ex/ex_txt.c        Sat Feb 16 12:48:06 2013        
(r246874)
@@ -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

Modified: head/contrib/nvi/vi/v_txt.c
==============================================================================
--- head/contrib/nvi/vi/v_txt.c Sat Feb 16 12:45:57 2013        (r246873)
+++ head/contrib/nvi/vi/v_txt.c Sat Feb 16 12:48:06 2013        (r246874)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to