From owner-svn-src-head@freebsd.org Mon Jun 22 22:11:52 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CF17133E298; Mon, 22 Jun 2020 22:11:52 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 49rNtJ2spyz4Vb0; Mon, 22 Jun 2020 22:11:51 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id 05MMBiAh032106 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 22 Jun 2020 15:11:44 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id 05MMBiw1032105; Mon, 22 Jun 2020 15:11:44 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Mon, 22 Jun 2020 15:11:44 -0700 From: Gleb Smirnoff To: Yuri Pankov , Zhihao Yuan Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r362148 - head/contrib/nvi/common Message-ID: <20200622221144.GA31842@FreeBSD.org> References: <202006131411.05DEB2mP097868@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202006131411.05DEB2mP097868@repo.freebsd.org> X-Rspamd-Queue-Id: 49rNtJ2spyz4Vb0 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; ASN(0.00)[asn:27348, ipnet:162.251.186.0/24, country:US]; local_wl_from(0.00)[freebsd.org] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2020 22:11:52 -0000 Yuri, Zhihao, this commit totally broke Russian input for me in nvi. After exiting edit mode, nvi immediately converts all text to ???????. I don't have any special settings in my environment. All I have is "russian" class for my user which yields in these environment variables: declare -x LANG="ru_RU.UTF-8" declare -x MM_CHARSET="UTF-8" declare -x XTERM_LOCALE="ru_RU.UTF-8" I'm already digging into that problem, but may be you have a clue immediately. On Sat, Jun 13, 2020 at 02:11:02PM +0000, Yuri Pankov wrote: Y> Author: yuripv Y> Date: Sat Jun 13 14:11:02 2020 Y> New Revision: 362148 Y> URL: https://svnweb.freebsd.org/changeset/base/362148 Y> Y> Log: Y> nvi: fallback to ISO8859-1 as last resort Y> Y> Current logic of using user's locale encoding that is UTF-8 doesn't make Y> much sense if we already failed the looks_utf8() check and skipped Y> encoding set using "fileencoding" as being UTF-8 as well; fallback to Y> ISO8859-1 in that case. Y> Y> Reviewed by: Zhihao Yuan Y> Differential Revision: https://reviews.freebsd.org/D24919 Y> Y> Modified: Y> head/contrib/nvi/common/exf.c Y> Y> Modified: head/contrib/nvi/common/exf.c Y> ============================================================================== Y> --- head/contrib/nvi/common/exf.c Sat Jun 13 09:16:07 2020 (r362147) Y> +++ head/contrib/nvi/common/exf.c Sat Jun 13 14:11:02 2020 (r362148) Y> @@ -1237,7 +1237,10 @@ file_encinit(SCR *sp) Y> } Y> Y> /* Y> - * Detect UTF-8 and fallback to the locale/preset encoding. Y> + * 1. Check for valid UTF-8. Y> + * 2. Check if fallback fileencoding is set and is NOT UTF-8. Y> + * 3. Check if user locale's encoding is NOT UTF-8. Y> + * 4. Use ISO8859-1 as last resort. Y> * Y> * XXX Y> * A manually set O_FILEENCODING indicates the "fallback Y> @@ -1246,9 +1249,13 @@ file_encinit(SCR *sp) Y> */ Y> if (looks_utf8(buf, blen) > 1) Y> o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0); Y> - else if (!O_ISSET(sp, O_FILEENCODING) || Y> - !strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8")) Y> + else if (O_ISSET(sp, O_FILEENCODING) && Y> + strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8") != 0) Y> + /* Use fileencoding as is */ ; Y> + else if (strcasecmp(codeset(), "utf-8") != 0) Y> o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0); Y> + else Y> + o_set(sp, O_FILEENCODING, OS_STRDUP, "iso8859-1", 0); Y> Y> conv_enc(sp, O_FILEENCODING, 0); Y> #endif Y> _______________________________________________ Y> svn-src-all@freebsd.org mailing list Y> https://lists.freebsd.org/mailman/listinfo/svn-src-all Y> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" -- Gleb Smirnoff