Re: FreeBSD awk behavior change proposal

Jamie Landeg-Jones <[email protected]>
Newsgroups gmane.os.freebsd.architechture
Organization Dyslexic Fish
Message-ID <[email protected]>
Warner Losh <[email protected]> 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) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.