From 9164b93ea7fafcff12e3cbbfc815f059cb74fad6 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sun, 31 Dec 2017 06:39:31 +0100
Subject: [PATCH] WIP

---
 usr.bin/sort/Makefile                |  6 ++++++
 usr.bin/sort/nls/C.msg               | 16 ++++++++++++++++
 usr.bin/sort/nls/hu_HU.ISO8859-2.msg | 16 ++++++++++++++++
 usr.bin/sort/sort.1                  |  4 ++--
 usr.bin/sort/sort.c                  | 12 +++++-------
 5 files changed, 45 insertions(+), 9 deletions(-)
 create mode 100644 usr.bin/sort/nls/C.msg
 create mode 100644 usr.bin/sort/nls/hu_HU.ISO8859-2.msg

diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile
index 3299ed92ef..42c80e8842 100644
--- a/usr.bin/sort/Makefile
+++ b/usr.bin/sort/Makefile
@@ -24,4 +24,10 @@ CFLAGS+= -DSORT_THREADS
 CFLAGS+= -I${_SHLIBDIRPREFIX}/usr/include/priv
 .endif
 
+NLS+=	hu_HU.ISO8859-2
+NLSSRCFILES= ${NLS:S@$@.msg@}
+.for lang in ${NLS}
+NLSSRCDIR_${lang}= ${.CURDIR}/nls
+.endfor
+
 .include <bsd.prog.mk>
diff --git a/usr.bin/sort/nls/C.msg b/usr.bin/sort/nls/C.msg
new file mode 100644
index 0000000000..81300ba41a
--- /dev/null
+++ b/usr.bin/sort/nls/C.msg
@@ -0,0 +1,16 @@
+$ $FreeBSD: head/usr.bin/sort/nls/C.msg 235434 2012-05-14 09:55:23Z gabor $
+$
+$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
new file mode 100644
index 0000000000..c45862b656
--- /dev/null
+++ b/usr.bin/sort/nls/hu_HU.ISO8859-2.msg
@@ -0,0 +1,16 @@
+$ $FreeBSD: head/usr.bin/sort/nls/hu_HU.ISO8859-2.msg 235434 2012-05-14 09:55:23Z gabor $
+$
+$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 b/usr.bin/sort/sort.1
index 7c95ed7ad2..b032dd8ff6 100644
--- a/usr.bin/sort/sort.1
+++ b/usr.bin/sort/sort.1
@@ -527,8 +527,8 @@ 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 NLSPATH
+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 9b0cf68cd9..4644ffb466 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -228,11 +228,9 @@ sort_modifier_empty(struct sort_mods *sm)
 static void
 usage(bool opt_err)
 {
-//	struct option *o;
 	FILE *out;
 
 	out = stdout;
-//	o = &(long_options[0]);
 
 	if (opt_err)
 		out = stderr;
@@ -1195,6 +1193,11 @@ main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
+	if (argv_from_file0) {
+		argc = argc_from_file0;
+		argv = argv_from_file0;
+	}
+
 #ifndef WITHOUT_NLS
 	catalog = catopen("sort", NL_CAT_LOCALE);
 #endif
@@ -1232,11 +1235,6 @@ main(int argc, char **argv)
 		ks->sm.func = get_sort_func(&(ks->sm));
 	}
 
-	if (argv_from_file0) {
-		argc = argc_from_file0;
-		argv = argv_from_file0;
-	}
-
 	if (debug_sort) {
 		printf("Memory to be used for sorting: %llu\n",available_free_memory);
 #if defined(SORT_THREADS)
-- 
2.15.0

