Re: FreeBSD awk behavior change proposal
- In reply to: Warner Losh : "FreeBSD awk behavior change proposal"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Jul 2021 11:44:35 UTC
Warner Losh <imp@bsdimp.com> wrote: > In 2005, FreeBSD changed one-true-awk to honor the locale's collating order. > https://svnweb.freebsd.org/base/head/usr.bin/awk/b.c.diff?annotate=146322&pathrev=201988 > This was billed as a temporary patch. It was also compatible with > the then-current behavior of gawk. That temporary patch has lasted 16 > years now. [ ... ] ` > To restore compatibility with other implementaitons of awk, revert this > patch. FreeBSD is the odd-system out. It also has the nice side effect > of eliminating the last of our differences with upstream one-true-awk. Yes! Definitely! For a few years, I've already been building locally with the following patch, so official parity would be useful! Cheers, Jamie --- contrib/one-true-awk/main.c.orig 2014-09-19 19:24:02.083097000 +0100 +++ contrib/one-true-awk/main.c 2018-05-24 14:53:38.539477000 +0100 @@ -62,7 +62,13 @@ const char *fs = NULL; setlocale(LC_CTYPE, ""); - setlocale(LC_COLLATE, ""); + /* As per more recent POSIX, collation for anything other than the 'C' */ + /* locale is undefined. As it messes up with expected results with */ + /* exotic locales, we force it to 'C' here to restore expected */ + /* behaviour + /* setlocale(LC_COLLATE, ""); */ + setlocale(LC_COLLATE, "C"); + setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */ cmdname = argv[0]; if (argc == 1) {