From patchwork Thu Feb 18 05:02:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 42098 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B904B386EC3A; Thu, 18 Feb 2021 05:02:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B904B386EC3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613624553; bh=E1yiQNB4nkZF8/upwiCwb9UtfenA5syn7tiGU2R34PM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Q0bkKcEfzxVXKrGvYIeUiR7kprRqOj3+Nfjfg14HEr8K/UicNMAWoszrSMxIszmJx FbrXD/iwPnuhBcmXZrWD2/liLv9YIXePtXhanix/GnRVUFN0W0DrvSOK+5StptS2ug ivOZTEffBjeP3qan4OamThvdf1XobWM1NS2Rl60M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 72702385800A for ; Thu, 18 Feb 2021 05:02:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 72702385800A Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-mQnmbidIPNSWnQG3yZ5hTw-1; Thu, 18 Feb 2021 00:02:28 -0500 X-MC-Unique: mQnmbidIPNSWnQG3yZ5hTw-1 Received: by mail-qk1-f197.google.com with SMTP id r15so558757qke.5 for ; Wed, 17 Feb 2021 21:02:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E1yiQNB4nkZF8/upwiCwb9UtfenA5syn7tiGU2R34PM=; b=UyTDVDrqOlUsNfl6WDMXTku7HZz+jEGJNwIBu/DSAkC9VF92ItSlqkaKTSg8ETVWrk 5TL1W/hjVbLo4a7XpI2Vt+pMNSwnzKHRFYTIbgV9GxXaYPrb0K0wLJtqiCQac+BNfCVu A0aEICNCrPHtO+uFqBDBkL6n2MEHBgNSBWxxkP6Hu2G5/JappQDwQ7BFTbVHUrzYeDIK Y4sHTJw4M5LyFZc3dP1P1EGim2Ebd1DSjd/m/LpIGd/bP0nHGplsu4v5wgxgOofo4b2Z S4G970RPKvkc1m2i0WqT6Sa1C9JQYjGU4vFu+tS9TlbgB38+uSIYQb4fmUI+zBYeU96J WpUg== X-Gm-Message-State: AOAM533NUUBqY8A0qHYU4/vioaTv6hBqxRCd8/n8mu6pOWpdinmlBedP wuNDCs/35rkV+wcFwi23t8spfdgo0X41JDv2kleuKHlTtX2d/BHw21O5YkGw+9n6abqC7fuUlFv 3+1BUgJp9cU7kL/7/dMzD7PI9gaaA6EEBuEQ/XaZ01ems2Wxb29cOrvbW4toftDgDDX5zfQ== X-Received: by 2002:a37:9c55:: with SMTP id f82mr2623014qke.234.1613624547213; Wed, 17 Feb 2021 21:02:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBfM8Bu7aOtCaXD61R53hWyJkjWZm/pouGyMUnBFKA608A/L6c3c+kqceI76mE7CHI30g7Dw== X-Received: by 2002:a37:9c55:: with SMTP id f82mr2622995qke.234.1613624546992; Wed, 17 Feb 2021 21:02:26 -0800 (PST) Received: from athas.redhat.com (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id d22sm2740173qtp.34.2021.02.17.21.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 21:02:26 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH] LC_COLLATE: Fix last character ellipsis handling (Bug 22668) Date: Thu, 18 Feb 2021 00:02:17 -0500 Message-Id: <20210218050217.2128682-1-carlos@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Carlos O'Donell via Libc-alpha From: Carlos O'Donell Reply-To: Carlos O'Donell Cc: Hanataka Shinya Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Hanataka Shinya During ellipsis processing the collation cursor was not correctly moved to the end of the ellipsis after processing. The code inserted the new entry after the cursor, but before the real end of the ellipsis: [cursor] ... element_t <-> element_t <-> element_t <-> element_t "" "" "" startp endp At the end of the function we have: [cursor] ... element_t <-> element_t <-> element_t "" "" endp The cursor should be pointing at endp, the last element in the doubly-linked list, otherwise when execution returns to the caller we will start inserting the next line after . Subsequent operations end up unlinking the ellipsis end entry or just leaving it in the list dangling from the end. This kind of dangling is immediately visible in C.UTF-8 with the following sorting from strcoll: With the cursor correctly adjusted the end entry is correctly given the right location and thus the right weight. No regressions on x86_64 and i686. Co-authored-by: Carlos O'Donell --- locale/programs/ld-collate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index 0af21e05e2..b6406b775d 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -1483,6 +1483,9 @@ order for `%.*s' already defined at %s:%Zu"), } } } + /* Move the cursor to the last entry in the ellipsis. + Subsequent operations need to start from the last entry. */ + collate->cursor = endp; }