From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#58168: string-lessp glitches and inconsistencies Date: Thu, 29 Sep 2022 18:24:04 +0200 Message-ID: <7824372D-8002-4639-8AEE-E80A6D5FEFC6@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) 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="29629"; mail-complaints-to="usenet@ciao.gmane.io" To: 58168@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 29 18:52:28 2022 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 1odwlw-0007XB-9b for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Sep 2022 18:52:28 +0200 Original-Received: from localhost ([::1]:55984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odwlu-0002Q7-WA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Sep 2022 12:52:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odwLO-0004eb-J0 for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 12:25:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odwLO-0001aC-AH for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 12:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odwLN-0001iE-T5 for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 12:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Sep 2022 16:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58168 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.16644686566524 (code B ref -1); Thu, 29 Sep 2022 16:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Sep 2022 16:24:16 +0000 Original-Received: from localhost ([127.0.0.1]:39379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odwKd-0001hA-OG for submit@debbugs.gnu.org; Thu, 29 Sep 2022 12:24:16 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55208) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odwKc-0001h2-2t for submit@debbugs.gnu.org; Thu, 29 Sep 2022 12:24:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odwKb-0003Uw-SR for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 12:24:13 -0400 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:35564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odwKZ-0001Nk-Oy for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 12:24:13 -0400 Original-Received: by mail-lf1-x134.google.com with SMTP id z4so3024614lft.2 for ; Thu, 29 Sep 2022 09:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:sender:from:to:cc:subject:date; bh=fRrCIJ7KPJ5ORKcyMvwTiCXyDh5QYMh4lIr4K3mvLOM=; b=iHbGCmaY3B90zN6Zwx6xDtMVcmjK6aJVVRqRWpQScCBHx/EWMUSYcQzuu/04r+YSJT snGMvb5+0DXyIg/jOaivT2T0XSSbu+fRj8yUkbsms7tqg//shZ9ujDtN/j8xjFifTqDt KrBFm0zATBWB3qbLK5s6ynfJHY0Q59kyrLzox1cutestp5q12lC2p6VTqMi8wh7dv1L2 09EXEWpWEPWNlw9xnuLLJPDrOSQBBR5zrWrmdHi1/AfMLT2nj0iXbcDhu4kIyB4dUDJH jeLTe9EfkCUEzF5FljQMTGDZMYGpJsx3qOjcN5cHi4AByHcKuDo4nepAB3ocwal2186M U/vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:sender:x-gm-message-state:from:to:cc:subject:date; bh=fRrCIJ7KPJ5ORKcyMvwTiCXyDh5QYMh4lIr4K3mvLOM=; b=s371LFuAhdUIsrUk/HfAUU+mUvlAf3C3CpmihmZAbMeFJUhTZ+wimRyUmEa3yIkunv xbTngnPrf3SJ0bUWkxu5wnYXtd9Lenx0TIDxKSk6QpeeH5pBSPiY6s4F6UxZmfGFssmc DTGHwWirWd3fUafzs0KpwRBYjvWf8jrvPuszkzNX/nsqevoLyL98eU17Ew5FCZ3jZl9C iF9Wzix6CYHkxJvSiiOdpJezLluOwcnfOvdorsQaAcWK99MqWFmT35+v81RdYIuSivMP sG5yxOnoH9Y2m8k8XiPqSP4Gr7VIHDCzBD+5IyO7Qk8lGhGGsut1SY/RarKmX6AlU0Px iN3A== X-Gm-Message-State: ACrzQf36My4+jPAqiIr1AqLEX5yGqVrhq/eNkyeC0s7c83XccBgqSHvL VtdDsdQipxNMKfRAF3mtcDyvre1dLVYAPA== X-Google-Smtp-Source: AMsMyM6DtucQvTMmG7Yl4PEdnaSmuneadpd9FA1o5C18o7HqqOZ+x80NoU9fZVWPufQNSYWMpsKqKA== X-Received: by 2002:a05:6512:b1e:b0:4a1:ba8c:7ea7 with SMTP id w30-20020a0565120b1e00b004a1ba8c7ea7mr1718588lfu.608.1664468645276; Thu, 29 Sep 2022 09:24:05 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-171-209.bredband.tele2.se. [188.150.171.209]) by smtp.gmail.com with ESMTPSA id v27-20020ac258fb000000b0049f54c5f2a4sm823071lfo.229.2022.09.29.09.24.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2022 09:24:04 -0700 (PDT) X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x134.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" Xref: news.gmane.io gmane.emacs.bugs:243924 Archived-At: We really want string< to be consistent with string=3D and itself since = this is fundamental for string ordering in searching and sorting = applications. This means that for any pair of strings A and B, we should either have = A (nil nil nil) because string< considers the unibyte raw byte 0xFC and the multibyte = char U+00FC to be the same, but string=3D thinks they are different. We also distinguish raw bytes by multibyte-ness: (let* ((u "\x80") (m (string-to-multibyte u))) (list (string=3D u m) (string< u m) (string< m u))) =3D> (nil t nil) but this is a minor annoyance that we can live with: we strongly want = string=3D to remain consistent with `equal` for strings. So, what can be done? The current string< implementation uses the = character order ASCII < ub raw 80..FF =3D mb U+0080..U+00FF < U+0100..10FFFF < mb raw = 80..FF in conflict with string=3D which unifies unibyte and multibyte ASCII but = not raw bytes and Latin-1. It suggests the following alternative collation orders: A. ASCII < ub raw 80..FF < mb U+0080..10FFFF < mb raw 80..FF which puts all non-ASCII multibyte chars after unibyte. B. ASCII < ub raw 80..FF < mb raw 80..FF < mb U+0080..10FFFF which inserts multibyte raw bytes after the unibyte ones, permitting any = ub-ub and mb-mb comparisons to be made using memcmp, and a slow decoding = loop only required for unibyte against non-ASCII multibyte strings. C. ASCII < mb U+0080..10FFFF < mb raw 80..FF < ub raw 80..FF which instead moves unibyte raw bytes to after the multibyte raw range. = This has the same memcmp benefit as alternative B, but may be slightly = faster for ub-mb comparisons since only unibyte 80..FF need to be = remapped. Any particular preference? Otherwise, I'll go with B or C, depending on = what the resulting code looks like.