summaryrefslogtreecommitdiff
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2018-06-06 23:12:35 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2018-06-06 23:12:35 +0000
commit30dc95029e879a2ca9be652999284f7728d99f70 (patch)
treeffce1ea46b62e303bd0a08d7d83e2826b730bf22 /usr.bin/grep
parent9316908f481c5d3e6474d31e013f238b931c2972 (diff)
downloadsrc-test-30dc95029e879a2ca9be652999284f7728d99f70.tar.gz
src-test-30dc95029e879a2ca9be652999284f7728d99f70.zip
Remove NLS support from BSD grep
GNU grep as in actually in base does not have any translations support compiled in, so no functionnality loss. We do support 193 locales in base, we will never catch up on that number of translation with bsd grep. Removing NLS support make bsd grep consistent with the other binaries in base which are not translated, and also reduce a little bit the code. Reviewed by: kevans Approved by: kevans Discussed with: kevans @BSDCan Differential Revision: https://reviews.freebsd.org/D15682
Notes
Notes: svn path=/head/; revision=334744
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/Makefile6
-rw-r--r--usr.bin/grep/grep.c37
-rw-r--r--usr.bin/grep/grep.h9
-rw-r--r--usr.bin/grep/nls/C.msg13
-rw-r--r--usr.bin/grep/nls/Makefile.inc18
-rw-r--r--usr.bin/grep/nls/es_ES.ISO8859-1.msg13
-rw-r--r--usr.bin/grep/nls/gl_ES.ISO8859-1.msg13
-rw-r--r--usr.bin/grep/nls/hu_HU.ISO8859-2.msg13
-rw-r--r--usr.bin/grep/nls/ja_JP.SJIS.msg13
-rw-r--r--usr.bin/grep/nls/ja_JP.UTF-8.msg13
-rw-r--r--usr.bin/grep/nls/ja_JP.eucJP.msg13
-rw-r--r--usr.bin/grep/nls/pt_BR.ISO8859-1.msg13
-rw-r--r--usr.bin/grep/nls/ru_RU.KOI8-R.msg13
-rw-r--r--usr.bin/grep/nls/uk_UA.UTF-8.msg12
-rw-r--r--usr.bin/grep/nls/zh_CN.UTF-8.msg13
-rw-r--r--usr.bin/grep/util.c4
16 files changed, 12 insertions, 204 deletions
diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile
index 9eec5877e348b..cc698d54d197a 100644
--- a/usr.bin/grep/Makefile
+++ b/usr.bin/grep/Makefile
@@ -65,12 +65,6 @@ CFLAGS+= -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DWITH_GNU
LIBADD+= gnuregex
.endif
-.if ${MK_NLS} != "no"
-.include "${.CURDIR}/nls/Makefile.inc"
-.else
-CFLAGS+= -DWITHOUT_NLS
-.endif
-
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 3d22b3fb12593..e891ccc7592a4 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -53,15 +53,6 @@ __FBSDID("$FreeBSD$");
#include "grep.h"
-#ifndef WITHOUT_NLS
-#include <nl_types.h>
-nl_catd catalog;
-#endif
-
-/*
- * Default messags to use when NLS is disabled or no catalogue
- * is found.
- */
const char *errstr[] = {
"",
/* 1*/ "(standard input)",
@@ -162,10 +153,10 @@ bool file_err; /* file reading error */
static void
usage(void)
{
- fprintf(stderr, getstr(3), getprogname());
- fprintf(stderr, "%s", getstr(4));
- fprintf(stderr, "%s", getstr(5));
- fprintf(stderr, "%s", getstr(6));
+ fprintf(stderr, errstr[3], getprogname());
+ fprintf(stderr, "%s", errstr[4]);
+ fprintf(stderr, "%s", errstr[5]);
+ fprintf(stderr, "%s", errstr[6]);
exit(2);
}
@@ -351,10 +342,6 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
-#ifndef WITHOUT_NLS
- catalog = catopen("grep", NL_CAT_LOCALE);
-#endif
-
/* Check what is the program name of the binary. In this
way we can have all the funcionalities in one binary
without the need of scripting and using ugly hacks. */
@@ -470,7 +457,7 @@ main(int argc, char *argv[])
else if (strcasecmp(optarg, "read") == 0)
devbehave = DEV_READ;
else
- errx(2, getstr(2), "--devices");
+ errx(2, errstr[2], "--devices");
break;
case 'd':
if (strcasecmp("recurse", optarg) == 0) {
@@ -481,7 +468,7 @@ main(int argc, char *argv[])
else if (strcasecmp("read", optarg) == 0)
dirbehave = DIR_READ;
else
- errx(2, getstr(2), "--directories");
+ errx(2, errstr[2], "--directories");
break;
case 'E':
grepbehave = GREP_EXTENDED;
@@ -577,9 +564,9 @@ main(int argc, char *argv[])
break;
case 'V':
#ifdef WITH_GNU
- printf(getstr(9), getprogname(), VERSION);
+ printf(errstr[9], getprogname(), VERSION);
#else
- printf(getstr(8), getprogname(), VERSION);
+ printf(errstr[8], getprogname(), VERSION);
#endif
exit(0);
case 'v':
@@ -604,7 +591,7 @@ main(int argc, char *argv[])
else if (strcasecmp("text", optarg) == 0)
binbehave = BINFILE_TEXT;
else
- errx(2, getstr(2), "--binary-files");
+ errx(2, errstr[2], "--binary-files");
break;
case COLOR_OPT:
color = NULL;
@@ -624,7 +611,7 @@ main(int argc, char *argv[])
} else if (strcasecmp("never", optarg) != 0 &&
strcasecmp("none", optarg) != 0 &&
strcasecmp("no", optarg) != 0)
- errx(2, getstr(2), "--color");
+ errx(2, errstr[2], "--color");
cflags &= ~REG_NOSUB;
break;
case LABEL_OPT:
@@ -746,10 +733,6 @@ main(int argc, char *argv[])
c+= procfile(*aargv);
}
-#ifndef WITHOUT_NLS
- catclose(catalog);
-#endif
-
/* Find out the correct return value according to the
results and the command line option. */
exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h
index 41a8a812309fe..fde711820985f 100644
--- a/usr.bin/grep/grep.h
+++ b/usr.bin/grep/grep.h
@@ -38,15 +38,6 @@
#include <stdio.h>
#include <zlib.h>
-#ifdef WITHOUT_NLS
-#define getstr(n) errstr[n]
-#else
-#include <nl_types.h>
-
-extern nl_catd catalog;
-#define getstr(n) catgets(catalog, 1, n, errstr[n])
-#endif
-
extern const char *errstr[];
#define VERSION "2.6.0-FreeBSD"
diff --git a/usr.bin/grep/nls/C.msg b/usr.bin/grep/nls/C.msg
deleted file mode 100644
index 81573b587a84d..0000000000000
--- a/usr.bin/grep/nls/C.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(standard input)"
-2 "unknown %s option"
-3 "usage: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C[num]]\n"
-4 "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n"
-5 "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n"
-6 "\t[--null] [pattern] [file ...]\n"
-7 "Binary file %s matches\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/Makefile.inc b/usr.bin/grep/nls/Makefile.inc
deleted file mode 100644
index 0433f67f31f05..0000000000000
--- a/usr.bin/grep/nls/Makefile.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-NLSNAME= grep
-
-NLS= es_ES.ISO8859-1
-NLS+= gl_ES.ISO8859-1
-NLS+= hu_HU.ISO8859-2
-NLS+= ja_JP.eucJP
-NLS+= ja_JP.SJIS
-NLS+= ja_JP.UTF-8
-NLS+= pt_BR.ISO8859-1
-NLS+= ru_RU.KOI8-R
-NLS+= uk_UA.UTF-8
-NLS+= zh_CN.UTF-8
-
-NLSSRCDIR= ${.CURDIR}/nls
-.for lang in ${NLS}
-NLSSRCFILES_${lang}=${lang}.msg
-.endfor
diff --git a/usr.bin/grep/nls/es_ES.ISO8859-1.msg b/usr.bin/grep/nls/es_ES.ISO8859-1.msg
deleted file mode 100644
index 77df985f22d08..0000000000000
--- a/usr.bin/grep/nls/es_ES.ISO8859-1.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(entrada estndar)"
-2 "opcin desconocida de %s"
-3 "uso: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A no] [-B no] [-C[no]]\n"
-4 "\t[-e pauta] [-f fichero] [--binary-files=valor] [--color=cuando]\n"
-5 "\t[--context[=no]] [--directories=accin] [--label] [--line-buffered]\n"
-6 "\t[--null] [pauta] [fichero ...]\n"
-7 "fichero binario %s se ajusta\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/gl_ES.ISO8859-1.msg b/usr.bin/grep/nls/gl_ES.ISO8859-1.msg
deleted file mode 100644
index 4cce8eb4d767b..0000000000000
--- a/usr.bin/grep/nls/gl_ES.ISO8859-1.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(entrada estndar)"
-2 "opcin descoecida de %s"
-3 "uso: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A no] [-B no] [-C[no]]\n"
-4 "\t[-e pauta] [-f ficheiro] [--binary-files=valor] [--color=cando]\n"
-5 "\t[--context[=no]] [--directories=accin] [--label] [--line-buffered]\n"
-6 "\t[--null] [pauta] [ficheiro ...]\n"
-7 "ficheiro binario %s conforma\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/hu_HU.ISO8859-2.msg b/usr.bin/grep/nls/hu_HU.ISO8859-2.msg
deleted file mode 100644
index a0ca08f4ef5d5..0000000000000
--- a/usr.bin/grep/nls/hu_HU.ISO8859-2.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(szabvnyos bemenet)"
-2 "ismeretlen %s opci"
-3 "hasznlat: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A szm] [-B szm] [-C[szm]]\n"
-4 "\t[-e minta] [-f fjl] [--binary-files=rtk] [--color=mikor]\n"
-5 "\t[--context[=szm]] [--directories=mvelet] [--label] [--line-buffered]\n"
-6 "\t[--null] [minta] [fjl ...]\n"
-7 "%s binris fjl illeszkedik\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/ja_JP.SJIS.msg b/usr.bin/grep/nls/ja_JP.SJIS.msg
deleted file mode 100644
index 654a1f2045fb4..0000000000000
--- a/usr.bin/grep/nls/ja_JP.SJIS.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(W)"
-2 "%s IvV̎wlɌ肪܂"
-3 "g: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A ] [-B ] [-C[]]\n"
-4 "\t[-e p^[] [-f t@C] [--binary-files=l] [--color=l]\n"
-5 "\t[--context[=]] [--directories=] [--label] [--line-buffered]\n"
-6 "\t[--null] [p^[] [t@C ...]\n"
-7 "oCit@C %s Ƀ}b`܂\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/ja_JP.UTF-8.msg b/usr.bin/grep/nls/ja_JP.UTF-8.msg
deleted file mode 100644
index 77c2ca698c519..0000000000000
--- a/usr.bin/grep/nls/ja_JP.UTF-8.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(標準入力)"
-2 "%s オプションの指定値に誤りがあります"
-3 "使い方: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A 数字] [-B 数字] [-C[数字]]\n"
-4 "\t[-e パターン] [-f ファイル名] [--binary-files=値] [--color=値]\n"
-5 "\t[--context[=数字]] [--directories=動作] [--label] [--line-buffered]\n"
-6 "\t[--null] [パターン] [ファイル名 ...]\n"
-7 "バイナリファイル %s にマッチしました\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/ja_JP.eucJP.msg b/usr.bin/grep/nls/ja_JP.eucJP.msg
deleted file mode 100644
index 5e5184034421c..0000000000000
--- a/usr.bin/grep/nls/ja_JP.eucJP.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(ɸ)"
-2 "%s ץλͤ˸꤬ޤ"
-3 "Ȥ: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A ] [-B ] [-C[]]\n"
-4 "\t[-e ѥ] [-f ե̾] [--binary-files=] [--color=]\n"
-5 "\t[--context[=]] [--directories=ư] [--label] [--line-buffered]\n"
-6 "\t[--null] [ѥ] [ե̾ ...]\n"
-7 "Хʥե %s ˥ޥåޤ\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/pt_BR.ISO8859-1.msg b/usr.bin/grep/nls/pt_BR.ISO8859-1.msg
deleted file mode 100644
index 7655dbcc44733..0000000000000
--- a/usr.bin/grep/nls/pt_BR.ISO8859-1.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(entrada padro)"
-2 "opco no conhecida de %s"
-3 "uso: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C[num]]\n"
-4 "\t[-e padro] [-f arquivo] [--binary-files=valor] [--color=quando]\n"
-5 "\t[--context[=num]] [--directories=ao] [--label] [--line-buffered]\n"
-6 "\t[--null] [padro] [arquivo ...]\n"
-7 "arquivo binrio %s casa com o padro\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/ru_RU.KOI8-R.msg b/usr.bin/grep/nls/ru_RU.KOI8-R.msg
deleted file mode 100644
index 7740414fc3384..0000000000000
--- a/usr.bin/grep/nls/ru_RU.KOI8-R.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "( )"
-2 " %s"
-3 ": %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A ] [-B ] [-C[]]\n"
-4 "\t[-e ] [-f ] [--binary-files=] [--color=]\n"
-5 "\t[--context[=]] [--directories=] [--label] [--line-buffered]\n"
-6 "\t[--null] [] [ ...]\n"
-7 " %s \n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/uk_UA.UTF-8.msg b/usr.bin/grep/nls/uk_UA.UTF-8.msg
deleted file mode 100644
index 0f4650e24682f..0000000000000
--- a/usr.bin/grep/nls/uk_UA.UTF-8.msg
+++ /dev/null
@@ -1,12 +0,0 @@
-$ $FreeBSD$
-$set 1
-$quote "
-1 "(стандартний ввід)"
-2 "невiдома опція %s"
-3 "використання: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A чис] [-B чис] [-C[чис]]\n"
-4 "\t[-e шаблон] [-f файл] [--binary-files=значення] [--color=коли]\n"
-5 "\t[--context[=чис] [--directories=дія] [--label] [--line-buffered]\n"
-6 "\t[--null] [шаблон] [файл ...]\n"
-7 "двійковий файл %s співпадає\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/nls/zh_CN.UTF-8.msg b/usr.bin/grep/nls/zh_CN.UTF-8.msg
deleted file mode 100644
index 69ae1531b7c1c..0000000000000
--- a/usr.bin/grep/nls/zh_CN.UTF-8.msg
+++ /dev/null
@@ -1,13 +0,0 @@
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "(标准输入)"
-2 "选项 %s 无法识别"
-3 "用法: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A 行数] [-B 行数] [-C[行数]]\n"
-4 "\t[-e 模式] [-f 文件] [--binary-files=值] [--color=何时]\n"
-5 "\t[--context[=行数]] [--directories=动作] [--label] [--line-buffered]\n"
-6 "\t[--null] [模式] [文件名 ...]\n"
-7 "二进制文件 %s 包含模式\n"
-8 "%s (BSD grep) %s\n"
-9 "%s (BSD grep, GNU compatible) %s\n"
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index e53558e5e0bac..b354a7836f85d 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -299,7 +299,7 @@ procfile(const char *fn)
int c, t;
if (strcmp(fn, "-") == 0) {
- fn = label != NULL ? label : getstr(1);
+ fn = label != NULL ? label : errstr[1];
f = grep_open(NULL);
} else {
if (stat(fn, &sb) == 0) {
@@ -386,7 +386,7 @@ procfile(const char *fn)
printf("%s%c", fn, nullflag ? 0 : '\n');
if (c && !cflag && !lflag && !Lflag &&
binbehave == BINFILE_BIN && f->binary && !qflag)
- printf(getstr(7), fn);
+ printf(errstr[7], fn);
free(pc.ln.file);
free(f);