The branch stable/15 has been updated by bapt:

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

commit a51ec1cc5a82d770a37f3c5cfef9ee48cc7eab47
Author:     Baptiste Daroussin <[email protected]>
AuthorDate: 2026-02-14 05:54:08 +0000
Commit:     Baptiste Daroussin <[email protected]>
CommitDate: 2026-02-19 09:13:19 +0000

    tr: fix class handling in unicode world
    
    toupper/tolower logic was only handled for CCLASS_TOUPPER and
    CCLASS_TOLOWER, add support for CCLASS ([:alpha:])
    
    PR:             219900
    MFC After:      1 week
    
    (cherry picked from commit 625dc44832cd760be3d7242d8e21a530c7e32bfc)
---
 usr.bin/tr/tr.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c
index d31a51a73542..75b7cd8be7c0 100644
--- a/usr.bin/tr/tr.c
+++ b/usr.bin/tr/tr.c
@@ -242,6 +242,40 @@ main(int argc, char **argv)
                                        break;
                        } while (s2.state == CCLASS_LOWER && s2.cnt > 1);
                        goto again;
+               } else if (s1.state == CCLASS &&
+                          s2.state == CCLASS_UPPER &&
+                          s1.cnt == 1 && s2.cnt == 1) {
+                       do {
+                               ch = towupper(s1.lastch);
+                               cmap_add(map, s1.lastch, ch);
+                               if (sflag && iswupper(ch))
+                                       cset_add(squeeze, ch);
+                               if (!next(&s1))
+                                       goto endloop;
+                       } while (s1.state == CCLASS && s1.cnt > 1);
+                       /* skip upper set */
+                       do {
+                               if (!next(&s2))
+                                       break;
+                       } while (s2.state == CCLASS_UPPER && s2.cnt > 1);
+                       goto again;
+               } else if (s1.state == CCLASS &&
+                          s2.state == CCLASS_LOWER &&
+                          s1.cnt == 1 && s2.cnt == 1) {
+                       do {
+                               ch = towlower(s1.lastch);
+                               cmap_add(map, s1.lastch, ch);
+                               if (sflag && iswlower(ch))
+                                       cset_add(squeeze, ch);
+                               if (!next(&s1))
+                                       goto endloop;
+                       } while (s1.state == CCLASS && s1.cnt > 1);
+                       /* skip lower set */
+                       do {
+                               if (!next(&s2))
+                                       break;
+                       } while (s2.state == CCLASS_LOWER && s2.cnt > 1);
+                       goto again;
                } else {
                        cmap_add(map, s1.lastch, s2.lastch);
                        if (sflag)

Reply via email to