From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#60750: 29.0.60; encode-coding-char fails for utf-8-auto coding system Date: Thu, 12 Jan 2023 10:08:31 +0100 Message-ID: <87zgaof7cg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15585"; mail-complaints-to="usenet@ciao.gmane.io" To: 60750@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 12 10:10:11 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFtb9-0003bx-CE for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Jan 2023 10:10:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFta5-0007FU-EC; Thu, 12 Jan 2023 04:09:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFta3-0007F4-Rr for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:09:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFta3-00025A-5I for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:09:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFta2-0006NU-JI for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Jan 2023 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60750 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167351452724492 (code B ref -1); Thu, 12 Jan 2023 09:09:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jan 2023 09:08:47 +0000 Original-Received: from localhost ([127.0.0.1]:44646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFtZn-0006Mx-Dk for submit@debbugs.gnu.org; Thu, 12 Jan 2023 04:08:47 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:39182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFtZi-0006Mo-R5 for submit@debbugs.gnu.org; Thu, 12 Jan 2023 04:08:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtZd-0006t9-8L for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:08:37 -0500 Original-Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFtZb-00020T-Ln for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:08:36 -0500 Original-Received: by mail-wr1-x42c.google.com with SMTP id k8so2897830wrc.9 for ; Thu, 12 Jan 2023 01:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=tsAN6axpVH5j1iYEYe10YGsYWqOCNyFgLJRURg4MQFI=; b=qcyPPx2GAXc4rs07Az3+XYp7Ioes6H9m18f/fb3uppYVahFqqWjviRB3URg3ZpvAzK SZuUQbUCbmGyOC5uRESNS+R1CeFHyTKPsp0eInNkD7QFQ2v80+v106N16esIaKAI6sxA xBn7EmeqyP/V+kEU1BU1WLujxjX7IRy6FiRHaFjfWyyN0Zr8ekGjJjm5XQhJ1YAS7ci7 KqaZzh1mKS9T6mwAiFNe7oCjVIf/KuWnYEF4WC9nAzkz2Xlvzr2CSLs2WU3wjyAeLkTD hMdCBajAApHKWxwllYz1x3XqSbfJt0vraHj1hQPfDMIqm8Z/fwYTyGmCZrIXE29Mg+2J 4DUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tsAN6axpVH5j1iYEYe10YGsYWqOCNyFgLJRURg4MQFI=; b=pGyZ5r2fNWz0nu/1py/40NA0iNMuH+TDbvH3fxBHUj+QqQmcBKiIQaWt8JDEeZ0+Lc TvPUm6C6D6wLKHKSolftwWHXQgbP+lJILm4r5JsgFFbOrfVPDRiArdTz5lEOHJmRTHYx d5biyu54q2OidHYyo7v5vq+qaD/z4Qozer9zW+FsCmbmzjRWxRhvaLfMsC4dTMoFYjvn HxI86S0K0/fO/Pu+KPcVbt68xwOp+6O2P3wbBfULeP/ZCFWSqV86fIFuSMtJk2jyxXyz 9/cqCN8j/RD+flPb73+JMMqvnJguZ8gFDlZUT7K0RIXNHIt1ogrtirX9foGn5T6Jv4TA Q2ow== X-Gm-Message-State: AFqh2kqQXfTrRfWiLxTltCiND3HMujvyXp0lsUL4MRqXnoNVEKnXniNc tOQfdhEkptWobSKFgFSfsIekkuRkMqA= X-Google-Smtp-Source: AMrXdXtI0jjObjhSdTsOlHgKmL3tOgVzKh6cIFC01admh7joyj2lEW4a84D+WvKCL1/HSdCr2yFwfQ== X-Received: by 2002:a5d:4a4f:0:b0:2bb:f255:6bb4 with SMTP id v15-20020a5d4a4f000000b002bbf2556bb4mr10139064wrs.25.1673514513203; Thu, 12 Jan 2023 01:08:33 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id m13-20020adfe94d000000b002714b3d2348sm15889896wrn.25.2023.01.12.01.08.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 01:08:32 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=rpluim@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253189 Archived-At: src/emacs -Q M-x toggle-debug-on-error M-: (setq buffer-file-coding-system 'utf-8-auto) C-b C-u C-x =3D =3D> Debugger entered--Lisp error: (args-out-of-range "))" 3 1) encode-coding-char(41 utf-8-auto ascii) describe-char(189) what-cursor-position((4)) This is because utf-8-auto has a non-nil :bom property: (define-coding-system 'utf-8-auto "UTF-8 (auto-detect signature (BOM))" :coding-type 'utf-8 :mnemonic ?U :charset-list '(unicode) :bom '(utf-8-with-signature . utf-8)) and `encode-coding-char' does this: ;; We also need to exclude the leading 2 or 3 bytes if they ;; come from a BOM. (setq i0 (if bom-p (cond ((eq (coding-system-type coding-system) 'utf-8) 3) ((eq (coding-system-type coding-system) 'utf-16) 2) (t 0)) 0)) (substring enc2 i0 i2))))) I=CA=BCm not sure if this needs fixing, but it was surprising, and the docstring of `define-coding-system' didn=CA=BCt make it clear to me whether a BOM should have been produced here or not. (I=CA=BCm willing to be told that buffer-file-coding-system shouldn=CA=BCt be 'utf-8-auto, but I never set that explicitly as far as I know =F0=9F=98=80) Thanks Robert In GNU Emacs 29.0.60 (build 14, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2023-01-12 built on rltb Repository revision: f4f30ff4c44dcfdf780f1981aa541af713f2805f Repository branch: emacs-29 System Description: Debian GNU/Linux 11 (bullseye) Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB