Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 2020 22:59:03 +0000 (UTC)
From:      Yuri Pankov <yuripv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r362515 - head/contrib/nvi/common
Message-ID:  <202006222259.05MMx3eA003694@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yuripv
Date: Mon Jun 22 22:59:03 2020
New Revision: 362515
URL: https://svnweb.freebsd.org/changeset/base/362515

Log:
  Revert r362148.
  
  Breaks UTF-8 input for new or having only 7bit characters present files.
  
  Reported by:	glebius

Modified:
  head/contrib/nvi/common/exf.c

Modified: head/contrib/nvi/common/exf.c
==============================================================================
--- head/contrib/nvi/common/exf.c	Mon Jun 22 22:43:09 2020	(r362514)
+++ head/contrib/nvi/common/exf.c	Mon Jun 22 22:59:03 2020	(r362515)
@@ -1237,10 +1237,7 @@ file_encinit(SCR *sp)
 	}
 
 	/*
-	 * 1. Check for valid UTF-8.
-	 * 2. Check if fallback fileencoding is set and is NOT UTF-8.
-	 * 3. Check if user locale's encoding is NOT UTF-8.
-	 * 4. Use ISO8859-1 as last resort.
+	 * Detect UTF-8 and fallback to the locale/preset encoding.
 	 *
 	 * XXX
 	 * A manually set O_FILEENCODING indicates the "fallback
@@ -1249,13 +1246,9 @@ file_encinit(SCR *sp)
 	 */
 	if (looks_utf8(buf, blen) > 1)
 		o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0);
-	else if (O_ISSET(sp, O_FILEENCODING) &&
-	    strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8") != 0)
-		/* Use fileencoding as is */ ;
-	else if (strcasecmp(codeset(), "utf-8") != 0)
+	else if (!O_ISSET(sp, O_FILEENCODING) ||
+	    !strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8"))
 		o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0);
-	else
-		o_set(sp, O_FILEENCODING, OS_STRDUP, "iso8859-1", 0);
 
 	conv_enc(sp, O_FILEENCODING, 0);
 #endif



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