summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2019-05-13 17:00:12 +0000
committerschwarze <schwarze@openbsd.org>2019-05-13 17:00:12 +0000
commit474067aa16f98acadbc6fc6ba12f0b8182ccc459 (patch)
tree52689ff60c5cc00ce70627005cbb462e280e2bac
parentadd idr_is_empty() (diff)
downloadwireguard-openbsd-474067aa16f98acadbc6fc6ba12f0b8182ccc459.tar.xz
wireguard-openbsd-474067aa16f98acadbc6fc6ba12f0b8182ccc459.zip
Delete tentacles of LC_NUMERIC support.
Our libc doesn't support that now and won't in the future. Minus ~90 lines of code, no functional change. OK tb@
-rw-r--r--usr.bin/sort/coll.c17
-rw-r--r--usr.bin/sort/coll.h10
-rw-r--r--usr.bin/sort/sort.129
-rw-r--r--usr.bin/sort/sort.c59
4 files changed, 9 insertions, 106 deletions
diff --git a/usr.bin/sort/coll.c b/usr.bin/sort/coll.c
index 78272d6acbb..9faf50b0f43 100644
--- a/usr.bin/sort/coll.c
+++ b/usr.bin/sort/coll.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: coll.c,v 1.11 2015/12/11 21:41:51 mmcc Exp $ */
+/* $OpenBSD: coll.c,v 1.12 2019/05/13 17:00:12 schwarze Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -46,12 +46,6 @@
struct key_specs *keys;
size_t keys_num = 0;
-wint_t symbol_decimal_point = L'.';
-/* there is no default thousands separator in collate rules: */
-wint_t symbol_thousands_sep = 0;
-wint_t symbol_negative_sign = L'-';
-wint_t symbol_positive_sign = L'+';
-
static int wstrcoll(struct key_value *kv1, struct key_value *kv2, size_t offset);
static int gnumcoll(struct key_value*, struct key_value *, size_t offset);
static int monthcoll(struct key_value*, struct key_value *, size_t offset);
@@ -701,7 +695,7 @@ read_number(struct bwstring *s0, int *sign, wchar_t *smain, size_t *main_len, wc
while (iswblank(bws_get_iter_value(s)))
s = bws_iterator_inc(s, 1);
- if (bws_get_iter_value(s) == (wchar_t)symbol_negative_sign) {
+ if (bws_get_iter_value(s) == L'-') {
*sign = -1;
s = bws_iterator_inc(s, 1);
}
@@ -716,16 +710,13 @@ read_number(struct bwstring *s0, int *sign, wchar_t *smain, size_t *main_len, wc
smain[*main_len] = bws_get_iter_value(s);
s = bws_iterator_inc(s, 1);
*main_len += 1;
- } else if (symbol_thousands_sep &&
- (bws_get_iter_value(s) == (wchar_t)symbol_thousands_sep))
- s = bws_iterator_inc(s, 1);
- else
+ } else
break;
}
smain[*main_len] = 0;
- if (bws_get_iter_value(s) == (wchar_t)symbol_decimal_point) {
+ if (bws_get_iter_value(s) == L'.') {
s = bws_iterator_inc(s, 1);
while (iswdigit(bws_get_iter_value(s)) &&
*frac_len < MAX_NUM_SIZE) {
diff --git a/usr.bin/sort/coll.h b/usr.bin/sort/coll.h
index 1b0a25f9b9b..a0ce49652a8 100644
--- a/usr.bin/sort/coll.h
+++ b/usr.bin/sort/coll.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: coll.h,v 1.1 2015/03/17 17:45:13 millert Exp $ */
+/* $OpenBSD: coll.h,v 1.2 2019/05/13 17:00:12 schwarze Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -123,14 +123,6 @@ typedef int (*listcoll_t)(struct sort_list_item **ss1, struct sort_list_item **s
extern struct key_specs *keys;
extern size_t keys_num;
-/*
- * Main localised symbols. These must be wint_t as they may hold WEOF.
- */
-extern wint_t symbol_decimal_point;
-extern wint_t symbol_thousands_sep;
-extern wint_t symbol_negative_sign;
-extern wint_t symbol_positive_sign;
-
/* funcs */
cmpcoll_t get_sort_func(struct sort_mods *sm);
diff --git a/usr.bin/sort/sort.1 b/usr.bin/sort/sort.1
index 45a2be02e00..2c66f99dbb9 100644
--- a/usr.bin/sort/sort.1
+++ b/usr.bin/sort/sort.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sort.1,v 1.58 2019/02/24 09:57:43 anton Exp $
+.\" $OpenBSD: sort.1,v 1.59 2019/05/13 17:00:12 schwarze Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)sort.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: February 24 2019 $
+.Dd $Mdocdate: May 13 2019 $
.Dt SORT 1
.Os
.Sh NAME
@@ -177,10 +177,6 @@ Unknown strings are considered smaller than valid month names.
.It Fl n , Fl Fl numeric-sort , Fl Fl sort Ns = Ns Cm numeric
An initial numeric string, consisting of optional blank space, optional
minus sign, and zero or more digits (including decimal point)
-.\" with
-.\" optional radix character and thousands
-.\" separator
-.\" (as defined in the current locale),
is sorted by arithmetic value.
Leading blank characters are ignored.
.It Fl R , Fl Fl random-sort , Fl Fl sort Ns = Ns Cm random
@@ -498,18 +494,6 @@ which has no
equivalent.
.Sh ENVIRONMENT
.Bl -tag -width Fl
-.It Ev GNUSORT_NUMERIC_COMPATIBILITY
-If defined
-.Fl t
-will not override the locale numeric symbols, that is, thousand
-separators and decimal separators.
-By default, if we specify
-.Fl t
-with the same symbol as the thousand separator or decimal point,
-the symbol will be treated as the field separator.
-Older behavior was less definite: the symbol was treated as both field
-separator and numeric separator, simultaneously.
-This environment variable enables the old behavior.
.It Ev LANG
Used as a last resort to determine different kinds of locale-specific
behavior if neither the respective environment variable nor
@@ -526,15 +510,6 @@ sorting records.
Locale settings to be used to case conversion and classification
of characters, that is, which characters are considered
whitespaces, etc.
-.It Ev LC_MESSAGES
-Locale settings that determine the language of output messages
-that
-.Nm
-prints out.
-.It Ev LC_NUMERIC
-Locale settings that determine the number format used in numeric sort.
-.It Ev LC_TIME
-Locale settings that determine the month format used in month sort.
.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 617a6c37dc4..8530122eee9 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.87 2017/01/04 15:30:58 millert Exp $ */
+/* $OpenBSD: sort.c,v 1.88 2019/05/13 17:00:12 schwarze Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -70,13 +70,9 @@ struct sort_opts sort_opts_vals;
bool debug_sort;
bool need_hint;
-static bool gnusort_numeric_compatibility;
-
static struct sort_mods default_sort_mods_object;
struct sort_mods * const default_sort_mods = &default_sort_mods_object;
-static bool print_symbols_on_debug;
-
/*
* Arguments from file (when file0-from option is used:
*/
@@ -239,45 +235,14 @@ set_hw_params(void)
}
/*
- * Convert "plain" symbol to wide symbol, with default value.
- */
-static void
-conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def)
-{
- int res;
-
- res = mbtowc(wc, c, MB_CUR_MAX);
- if (res < 1)
- *wc = def;
-}
-
-/*
* Set current locale symbols.
*/
static void
set_locale(void)
{
- struct lconv *lc;
const char *locale;
- setlocale(LC_ALL, "");
-
- /* Obtain LC_NUMERIC info */
- lc = localeconv();
-
- /* Convert to wide char form */
- conv_mbtowc(&symbol_decimal_point, lc->decimal_point,
- symbol_decimal_point);
- conv_mbtowc(&symbol_thousands_sep, lc->thousands_sep,
- symbol_thousands_sep);
- conv_mbtowc(&symbol_positive_sign, lc->positive_sign,
- symbol_positive_sign);
- conv_mbtowc(&symbol_negative_sign, lc->negative_sign,
- symbol_negative_sign);
-
- if (getenv("GNUSORT_NUMERIC_COMPATIBILITY"))
- gnusort_numeric_compatibility = true;
-
+ setlocale(LC_CTYPE, "");
locale = setlocale(LC_COLLATE, NULL);
if (locale != NULL) {
char *tmpl;
@@ -518,7 +483,6 @@ set_sort_modifier(struct sort_mods *sm, int c)
case 'n':
sm->nflag = true;
need_hint = true;
- print_symbols_on_debug = true;
break;
case 'r':
sm->rflag = true;
@@ -529,7 +493,6 @@ set_sort_modifier(struct sort_mods *sm, int c)
case 'h':
sm->hflag = true;
need_hint = true;
- print_symbols_on_debug = true;
break;
default:
return false;
@@ -963,16 +926,6 @@ main(int argc, char *argv[])
errno = EINVAL;
err(2, NULL);
}
- if (!gnusort_numeric_compatibility) {
- if (symbol_decimal_point == sort_opts_vals.field_sep)
- symbol_decimal_point = WEOF;
- if (symbol_thousands_sep == sort_opts_vals.field_sep)
- symbol_thousands_sep = WEOF;
- if (symbol_negative_sign == sort_opts_vals.field_sep)
- symbol_negative_sign = WEOF;
- if (symbol_positive_sign == sort_opts_vals.field_sep)
- symbol_positive_sign = WEOF;
- }
break;
case 'u':
sort_opts_vals.uflag = true;
@@ -1167,14 +1120,6 @@ main(int argc, char *argv[])
setlocale(LC_COLLATE, NULL));
if (byte_sort)
printf("Byte sort is used\n");
- if (print_symbols_on_debug) {
- printf("Decimal Point: <%lc>\n", symbol_decimal_point);
- if (symbol_thousands_sep)
- printf("Thousands separator: <%lc>\n",
- symbol_thousands_sep);
- printf("Positive sign: <%lc>\n", symbol_positive_sign);
- printf("Negative sign: <%lc>\n", symbol_negative_sign);
- }
}
if (sort_opts_vals.cflag)