git: f129398f6454 - main - localedef: off by one bug drops the highest code point from every collation table

From: Ryan Moeller <rmoeller_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 22:19:50 UTC
The branch main has been updated by rmoeller:

URL: https://cgit.FreeBSD.org/src/commit/?id=f129398f64547e1c604dc86f0a786f2d4db8b635

commit f129398f64547e1c604dc86f0a786f2d4db8b635
Author:     Greg Becker <becker.greg@att.net>
AuthorDate: 2026-11-26 22:14:10 +0000
Commit:     Ryan Moeller <rmoeller@FreeBSD.org>
CommitDate: 2026-11-26 22:16:00 +0000

    localedef: off by one bug drops the highest code point from every collation table
    
    localedef(1) writes one fewer entry than it has into the "large" (code point
    above UCHAR_MAX) collation table, and records a count one short.  The table is
    built in code point order, so the entry lost is always the character with the
    highest code point in the locale.  For that character wcsxfrm(3) returns 0 and
    wcscoll(3) gives it no weight: it sorts with the ignorables and compares equal
    to unrelated characters.
    
    Reviewed by:    rmoeller, kevans
    Approved by:    kevans (mentor)
    Differential Revision:  https://reviews.freebsd.org/D60057
---
 usr.bin/localedef/collate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c
index 181d8ecd4840..ec5dbf9d2a5c 100644
--- a/usr.bin/localedef/collate.c
+++ b/usr.bin/localedef/collate.c
@@ -1288,7 +1288,7 @@ dump_collate(void)
 		}
 		if (!undef) {
 			large[i].val = htote(cc->wc);
-			large_count = i++;
+			large_count = ++i;
 		}
 	}