git: ed990a7a2ff8 - main - sort: remove NLS support

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 12 Oct 2022 14:25:07 UTC
The branch main has been updated by bapt:

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

commit ed990a7a2ff8899314f512dda045b90f1027b9aa
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-12 14:18:59 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-12 14:24:29 +0000

    sort: remove NLS support
    
    NLS support for sort(1) is:
    1/ incomplete: many error string are not using nls
    2/ only covers hu_HU.ISO8859-2
---
 ObsoleteFiles.inc                        |  3 +++
 tools/build/mk/OptionalObsoleteFiles.inc |  1 -
 usr.bin/sort/Makefile                    | 12 ------------
 usr.bin/sort/nls/C.msg                   | 16 ----------------
 usr.bin/sort/nls/hu_HU.ISO8859-2.msg     | 16 ----------------
 usr.bin/sort/sort.1.in                   |  2 --
 usr.bin/sort/sort.c                      | 17 +----------------
 usr.bin/sort/sort.h                      |  8 --------
 8 files changed, 4 insertions(+), 71 deletions(-)

diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 6cccea90c74f..d5c8744d9c4c 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -52,6 +52,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20221012: remove nls support from sort
+OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/sort.cat
+
 # 20221003: ip6protosw.h removed
 OLD_FILES+=usr/include/netinet6/ip6protosw.h
 
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index f0ddd90b784c..979225d24b99 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -6361,7 +6361,6 @@ OLD_DIRS+=usr/share/nls/hu_HU.ISO8859-2
 OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/ee.cat
 OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/grep.cat
 OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/libc.cat
-OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/sort.cat
 OLD_DIRS+=usr/share/nls/hr_HR.UTF-8
 OLD_DIRS+=usr/share/nls/hu_HU.UTF-8
 OLD_DIRS+=usr/share/nls/hy_AM.ARMSCII-8
diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile
index 40cd99086b95..1192b26b3252 100644
--- a/usr.bin/sort/Makefile
+++ b/usr.bin/sort/Makefile
@@ -21,18 +21,6 @@ LIBADD=	md
 MAN_SUB+= -e 's|%%THREADS%%|\.\\"|g'
 .endif
 
-.if ${MK_NLS} != "no"
-NLS+=	hu_HU.ISO8859-2
-NLSSRCFILES= ${NLS:S@$@.msg@}
-MAN_SUB+= -e 's|%%NLS%%||g'
-.for lang in ${NLS}
-NLSSRCDIR_${lang}= ${.CURDIR}/nls
-.endfor
-.else
-CFLAGS+= -DWITHOUT_NLS
-MAN_SUB+= -e 's|%%NLS%%|\.\\"|g'
-.endif
-
 HAS_TESTS=
 SUBDIR.${MK_TESTS}+= tests
 
diff --git a/usr.bin/sort/nls/C.msg b/usr.bin/sort/nls/C.msg
deleted file mode 100644
index 541d1d889647..000000000000
--- a/usr.bin/sort/nls/C.msg
+++ /dev/null
@@ -1,16 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "mutually exclusive flags"
-2 "extra argument not allowed with -c"
-3 "Unknown feature"
-4 "Wrong memory buffer specification"
-5 "0 field in key specs"
-6 "0 column in key specs"
-7 "Wrong file mode"
-8 "Cannot open file for reading"
-9 "Radix sort cannot be used with these sort options"
-10 "The chosen sort method cannot be used with stable and/or unique sort"
-11 "Invalid key position"
-12 "Usage: %s [-bcCdfigMmnrsuz] [-kPOS1[,POS2] ... ] [+POS1 [-POS2]] [-S memsize] [-T tmpdir] [-t separator] [-o outfile] [--batch-size size] [--files0-from file] [--heapsort] [--mergesort] [--radixsort] [--qsort] [--nthreads thread_no] [--human-numeric-sort] [--version-sort] [--random-sort [--random-source file]] [--compress-program program] [file ...]\n"
diff --git a/usr.bin/sort/nls/hu_HU.ISO8859-2.msg b/usr.bin/sort/nls/hu_HU.ISO8859-2.msg
deleted file mode 100644
index 054acc6ad612..000000000000
--- a/usr.bin/sort/nls/hu_HU.ISO8859-2.msg
+++ /dev/null
@@ -1,16 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "egymást kizáró opciók"
-2 "extra argumentum a -%c opcióval"
-3 "Ismeretlen funkció\n"
-4 "Rossz memória puffer érték"
-5 "0 mező a kulcsspecifikációban\n"
-6 "0 oszlop a kulcsspecifikációban\n"
-7 "Helytelen fájl mód"
-8 "A fájl nem nyitható meg olvasásra"
-9 "A radix rendezés nem használható a megadott rendezési opciókkal"
-10 "A választott rendezési mód nem használható a --stable és --unique opciókkal"
-11 "Érvénytelen kulcs pozíció"
-12 "Használat: %s [-bcCdfigMmnrsuz] [-kPOS1[,POS2] ... ] [+POS1 [-POS2]] [-S memóriaméret] [-T ideiglenes_könyvtár] [-t elválasztó] [-o kimeneti_fájl] [--batch-size méret] [--files0-from fájl] [--heapsort] [--mergesort] [--radixsort] [--qsort] [--nthreads szálak_száma] [--human-numeric-sort] [--version-sort] [--random-sort [--random-source fájl]] [--compress-program program] [fájl ...]\n"
diff --git a/usr.bin/sort/sort.1.in b/usr.bin/sort/sort.1.in
index a6ef4378d778..6aabdd6965d9 100644
--- a/usr.bin/sort/sort.1.in
+++ b/usr.bin/sort/sort.1.in
@@ -527,8 +527,6 @@ Used as a last resort to determine different kinds of locale-specific
 behavior if neither the respective environment variable, nor
 .Ev LC_ALL
 are set.
-%%NLS%%.It Ev NLSPATH
-%%NLS%%Path to NLS catalogs.
 .It Ev TMPDIR
 Path to the directory in which temporary files will be stored.
 Note that
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index b7c8107cc22d..25d7e0c624ae 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -55,11 +55,6 @@ __FBSDID("$FreeBSD$");
 #include "file.h"
 #include "sort.h"
 
-#ifndef WITHOUT_NLS
-#include <nl_types.h>
-nl_catd catalog = (nl_catd)-1;
-#endif
-
 #define	OPTIONS	"bcCdfghik:Mmno:RrsS:t:T:uVz"
 
 static bool need_random;
@@ -67,8 +62,7 @@ static bool need_random;
 MD5_CTX md5_ctx;
 
 /*
- * Default messages to use when NLS is disabled or no catalogue
- * is found.
+ * Default messages to use
  */
 const char *nlsstr[] = { "",
 /* 1*/"mutually exclusive flags",
@@ -1011,10 +1005,6 @@ main(int argc, char **argv)
 	set_tmpdir();
 	set_sort_opts();
 
-#ifndef WITHOUT_NLS
-	catalog = catopen("sort", NL_CAT_LOCALE);
-#endif
-
 	fix_obsolete_keys(&argc, argv);
 
 	while (((c = getopt_long(argc, argv, OPTIONS, long_options, NULL))
@@ -1339,10 +1329,5 @@ main(int argc, char **argv)
 
 	sort_free(outfile);
 
-#ifndef WITHOUT_NLS
-	if (catalog != (nl_catd)-1)
-		catclose(catalog);
-#endif
-
 	return (result);
 }
diff --git a/usr.bin/sort/sort.h b/usr.bin/sort/sort.h
index 47ce6ea29ab3..634a9d90c22e 100644
--- a/usr.bin/sort/sort.h
+++ b/usr.bin/sort/sort.h
@@ -43,15 +43,7 @@
 
 #define	VERSION	"2.3-FreeBSD"
 
-#ifdef WITHOUT_NLS
 #define	getstr(n)	 nlsstr[n]
-#else
-#include <nl_types.h>
-
-extern nl_catd catalog;
-#define	getstr(n)	\
-	(catalog == (nl_catd)-1 ? nlsstr[n] : catgets(catalog, 1, n, nlsstr[n]))
-#endif
 
 extern const char *nlsstr[];