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
This commit is contained in:
Baptiste Daroussin 2018-06-06 23:12:35 +00:00
parent 9316908f48
commit 30dc95029e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334744
18 changed files with 23 additions and 214 deletions

View File

@ -38,6 +38,17 @@
# xargs -n1 | sort | uniq -d;
# done
# 20180607: remove nls support from grep
OLD_FILES+=usr/share/nls/pt_BR.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/hu_HU.ISO8859-2/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.SJIS/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.eucJP/grep.cat
OLD_FILES+=usr/share/nls/gl_ES.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/zh_CN.UTF-8/grep.cat
OLD_FILES+=usr/share/nls/es_ES.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/ru_RU.KOI8-R/grep.cat
OLD_FILES+=usr/share/nls/uk_UA.UTF-8/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.UTF-8/grep.cat
# 20180517: retire vxge
OLD_FILES+=usr/share/man/man4/if_vxge.4.gz
OLD_FILES+=usr/share/man/man4/vxge.4.gz

View File

@ -6277,7 +6277,6 @@ OLD_FILES+=usr/share/nls/el_GR.ISO8859-7/tcsh.cat
OLD_FILES+=usr/share/nls/el_GR.UTF-8/tcsh.cat
OLD_FILES+=usr/share/nls/en_US.ISO8859-1/ee.cat
OLD_FILES+=usr/share/nls/en_US.ISO8859-15/ee.cat
OLD_FILES+=usr/share/nls/es_ES.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/es_ES.ISO8859-1/libc.cat
OLD_FILES+=usr/share/nls/es_ES.ISO8859-1/tcsh.cat
OLD_FILES+=usr/share/nls/es_ES.ISO8859-15/tcsh.cat
@ -6309,10 +6308,8 @@ OLD_FILES+=usr/share/nls/fr_FR.ISO8859-1/tcsh.cat
OLD_FILES+=usr/share/nls/fr_FR.ISO8859-15/ee.cat
OLD_FILES+=usr/share/nls/fr_FR.ISO8859-15/tcsh.cat
OLD_FILES+=usr/share/nls/fr_FR.UTF-8/tcsh.cat
OLD_FILES+=usr/share/nls/gl_ES.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/gl_ES.ISO8859-1/libc.cat
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_FILES+=usr/share/nls/it_CH.ISO8859-1/tcsh.cat
@ -6322,12 +6319,9 @@ OLD_FILES+=usr/share/nls/it_IT.ISO8859-1/tcsh.cat
OLD_FILES+=usr/share/nls/it_IT.ISO8859-15/libc.cat
OLD_FILES+=usr/share/nls/it_IT.ISO8859-15/tcsh.cat
OLD_FILES+=usr/share/nls/it_IT.UTF-8/tcsh.cat
OLD_FILES+=usr/share/nls/ja_JP.SJIS/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.SJIS/tcsh.cat
OLD_FILES+=usr/share/nls/ja_JP.UTF-8/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.UTF-8/libc.cat
OLD_FILES+=usr/share/nls/ja_JP.UTF-8/tcsh.cat
OLD_FILES+=usr/share/nls/ja_JP.eucJP/grep.cat
OLD_FILES+=usr/share/nls/ja_JP.eucJP/libc.cat
OLD_FILES+=usr/share/nls/ja_JP.eucJP/tcsh.cat
OLD_FILES+=usr/share/nls/ko_KR.UTF-8/libc.cat
@ -6338,14 +6332,12 @@ OLD_FILES+=usr/share/nls/no_NO.ISO8859-1/libc.cat
OLD_FILES+=usr/share/nls/pl_PL.ISO8859-2/ee.cat
OLD_FILES+=usr/share/nls/pl_PL.ISO8859-2/libc.cat
OLD_FILES+=usr/share/nls/pt_BR.ISO8859-1/ee.cat
OLD_FILES+=usr/share/nls/pt_BR.ISO8859-1/grep.cat
OLD_FILES+=usr/share/nls/pt_BR.ISO8859-1/libc.cat
OLD_FILES+=usr/share/nls/pt_PT.ISO8859-1/ee.cat
OLD_FILES+=usr/share/nls/ru_RU.CP1251/tcsh.cat
OLD_FILES+=usr/share/nls/ru_RU.CP866/tcsh.cat
OLD_FILES+=usr/share/nls/ru_RU.ISO8859-5/tcsh.cat
OLD_FILES+=usr/share/nls/ru_RU.KOI8-R/ee.cat
OLD_FILES+=usr/share/nls/ru_RU.KOI8-R/grep.cat
OLD_FILES+=usr/share/nls/ru_RU.KOI8-R/libc.cat
OLD_FILES+=usr/share/nls/ru_RU.KOI8-R/tcsh.cat
OLD_FILES+=usr/share/nls/ru_RU.UTF-8/tcsh.cat
@ -6354,12 +6346,10 @@ OLD_FILES+=usr/share/nls/sv_SE.ISO8859-1/libc.cat
OLD_FILES+=usr/share/nls/uk_UA.ISO8859-5/tcsh.cat
OLD_FILES+=usr/share/nls/uk_UA.KOI8-U/ee.cat
OLD_FILES+=usr/share/nls/uk_UA.KOI8-U/tcsh.cat
OLD_FILES+=usr/share/nls/uk_UA.UTF-8/grep.cat
OLD_FILES+=usr/share/nls/uk_UA.UTF-8/libc.cat
OLD_FILES+=usr/share/nls/uk_UA.UTF-8/tcsh.cat
OLD_FILES+=usr/share/nls/zh_CN.GB18030/libc.cat
OLD_FILES+=usr/share/nls/zh_CN.GB2312/libc.cat
OLD_FILES+=usr/share/nls/zh_CN.UTF-8/grep.cat
OLD_FILES+=usr/share/nls/zh_CN.UTF-8/libc.cat
OLD_FILES+=usr/tests/bin/sh/builtins/locale1.0
.endif

View File

@ -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

View File

@ -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));

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -1,13 +0,0 @@
$ $FreeBSD$
$
$set 1
$quote "
1 "(entrada estándar)"
2 "opción 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=acción] [--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"

View File

@ -1,13 +0,0 @@
$ $FreeBSD$
$
$set 1
$quote "
1 "(entrada estándar)"
2 "opción descoñecida 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=acción] [--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"

View File

@ -1,13 +0,0 @@
$ $FreeBSD$
$
$set 1
$quote "
1 "(szabványos bemenet)"
2 "ismeretlen %s opció"
3 "használat: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A szám] [-B szám] [-C[szám]]\n"
4 "\t[-e minta] [-f fájl] [--binary-files=érték] [--color=mikor]\n"
5 "\t[--context[=szám]] [--directories=művelet] [--label] [--line-buffered]\n"
6 "\t[--null] [minta] [fájl ...]\n"
7 "%s bináris fájl illeszkedik\n"
8 "%s (BSD grep) %s\n"
9 "%s (BSD grep, GNU compatible) %s\n"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -1,13 +0,0 @@
$ $FreeBSD$
$
$set 1
$quote "
1 "(entrada padrão)"
2 "opcão não conhecida de %s"
3 "uso: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C[num]]\n"
4 "\t[-e padrão] [-f arquivo] [--binary-files=valor] [--color=quando]\n"
5 "\t[--context[=num]] [--directories=ação] [--label] [--line-buffered]\n"
6 "\t[--null] [padrão] [arquivo ...]\n"
7 "arquivo binário %s casa com o padrão\n"
8 "%s (BSD grep) %s\n"
9 "%s (BSD grep, GNU compatible) %s\n"

View File

@ -1,13 +0,0 @@
$ $FreeBSD$
$
$set 1
$quote "
1 "(釉廖牧以钨<E4BBA5> 鬃夏)"
2 "闻哨着釉钨<E98789> 颂擂 %s"
3 "捎邢特谙琢紊<E790A2>: %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"

View File

@ -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"

View File

@ -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"

View File

@ -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);