Add support for --null-data. Change -Z to behave like GNU grep's -Z.
This commit is contained in:
parent
9605db34e0
commit
34bdd27889
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: file.c,v 1.6 2011/04/18 03:27:40 joerg Exp $ */
|
||||
/* $NetBSD: file.c,v 1.7 2011/04/18 22:46:48 joerg Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/grep/file.c 211496 2010-08-19 09:28:59Z des $ */
|
||||
/* $OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $ */
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: file.c,v 1.6 2011/04/18 03:27:40 joerg Exp $");
|
||||
__RCSID("$NetBSD: file.c,v 1.7 2011/04/18 22:46:48 joerg Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -147,7 +147,7 @@ grep_fgetln(struct file *f, size_t *lenp)
|
|||
}
|
||||
|
||||
/* Look for a newline in the remaining part of the buffer */
|
||||
if ((p = memchr(bufpos, '\n', bufrem)) != NULL) {
|
||||
if ((p = memchr(bufpos, line_sep, bufrem)) != NULL) {
|
||||
++p; /* advance over newline */
|
||||
ret = (char *)bufpos;
|
||||
len = p - bufpos;
|
||||
|
@ -169,7 +169,7 @@ grep_fgetln(struct file *f, size_t *lenp)
|
|||
if (bufrem == 0)
|
||||
/* EOF: return partial line */
|
||||
break;
|
||||
if ((p = memchr(bufpos, '\n', bufrem)) == NULL)
|
||||
if ((p = memchr(bufpos, line_sep, bufrem)) == NULL)
|
||||
continue;
|
||||
/* got it: finish up the line (like code above) */
|
||||
++p;
|
||||
|
@ -207,7 +207,8 @@ grep_file_init(struct file *f)
|
|||
goto error;
|
||||
|
||||
/* Check for binary stuff, if necessary */
|
||||
if (binbehave != BINFILE_TEXT && memchr(bufpos, '\0', bufrem) != NULL)
|
||||
if (!nulldataflag && binbehave != BINFILE_TEXT &&
|
||||
memchr(bufpos, '\0', bufrem) != NULL)
|
||||
f->binary = true;
|
||||
|
||||
return (f);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: grep.1,v 1.2 2011/02/16 01:31:33 joerg Exp $
|
||||
.\" $NetBSD: grep.1,v 1.3 2011/04/18 22:46:48 joerg Exp $
|
||||
.\" $FreeBSD: head/usr.bin/grep/grep.1 210652 2010-07-30 14:05:20Z joel $
|
||||
.\" $OpenBSD: grep.1,v 1.38 2010/04/05 06:30:59 jmc Exp $
|
||||
.\" Copyright (c) 1980, 1990, 1993
|
||||
|
@ -30,7 +30,7 @@
|
|||
.\"
|
||||
.\" @(#)grep.1 8.3 (Berkeley) 4/18/94
|
||||
.\"
|
||||
.Dd July 28, 2010
|
||||
.Dd April 19, 2011
|
||||
.Dt GREP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -40,7 +40,7 @@
|
|||
.Sh SYNOPSIS
|
||||
.Nm grep
|
||||
.Bk -words
|
||||
.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZ
|
||||
.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZz
|
||||
.Op Fl A Ar num
|
||||
.Op Fl B Ar num
|
||||
.Op Fl C Ns Op Ar num
|
||||
|
@ -50,9 +50,9 @@
|
|||
.Op Fl Fl color Ns Op = Ns Ar when
|
||||
.Op Fl Fl colour Ns Op = Ns Ar when
|
||||
.Op Fl Fl context Ns Op = Ns Ar num
|
||||
.Op Fl Fl decompress
|
||||
.Op Fl Fl label
|
||||
.Op Fl Fl line-buffered
|
||||
.Op Fl Fl null
|
||||
.Op Ar pattern
|
||||
.Op Ar
|
||||
.Ek
|
||||
|
@ -318,8 +318,6 @@ or
|
|||
.Fl q
|
||||
is
|
||||
specified.
|
||||
.It Fl Fl null
|
||||
Prints a zero-byte after the file name.
|
||||
.It Fl O
|
||||
If
|
||||
.Fl R
|
||||
|
@ -372,11 +370,10 @@ expression are considered to be matching lines.
|
|||
Equivalent to
|
||||
.Fl i .
|
||||
Obsoleted.
|
||||
.It Fl Z , Fl z , Fl Fl decompress
|
||||
Force
|
||||
.Nm grep
|
||||
to behave as
|
||||
.Nm zgrep .
|
||||
.It Fl Z , Fl Fl null
|
||||
Prints a zero-byte after the file name.
|
||||
.It Fl z , Fl Fl null-data
|
||||
Use the zero byte (ASCII NUL) as line separator.
|
||||
.It Fl Fl binary-files Ns = Ns Ar value
|
||||
Controls searching and printing of binary files.
|
||||
Options are
|
||||
|
@ -387,13 +384,16 @@ do not search binary files;
|
|||
and
|
||||
.Ar text :
|
||||
treat all files as text.
|
||||
.Sm off
|
||||
.It Fl Fl context Op = Ar num
|
||||
.Sm on
|
||||
Print
|
||||
.Ar num
|
||||
lines of leading and trailing context.
|
||||
The default is 2.
|
||||
.It Fl Fl decompress
|
||||
Detect input files compressed with
|
||||
.Xr bzip2 1
|
||||
or
|
||||
.Xr gzip 1
|
||||
and decompress them dynamically.
|
||||
This makes
|
||||
.Nm grep
|
||||
behave like
|
||||
.Nm zgrep .
|
||||
.It Fl Fl line-buffered
|
||||
Force output to be line buffered.
|
||||
By default, output is line buffered when standard output is a terminal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: grep.c,v 1.7 2011/04/18 17:18:03 joerg Exp $ */
|
||||
/* $NetBSD: grep.c,v 1.8 2011/04/18 22:46:48 joerg Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/grep/grep.c 211519 2010-08-19 22:55:17Z delphij $ */
|
||||
/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: grep.c,v 1.7 2011/04/18 17:18:03 joerg Exp $");
|
||||
__RCSID("$NetBSD: grep.c,v 1.8 2011/04/18 22:46:48 joerg Exp $");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -68,10 +68,10 @@ const char *errstr[] = {
|
|||
/* 1*/ "(standard input)",
|
||||
/* 2*/ "cannot read bzip2 compressed file",
|
||||
/* 3*/ "unknown %s option",
|
||||
/* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n",
|
||||
/* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n",
|
||||
/* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n",
|
||||
/* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n",
|
||||
/* 7*/ "\t[--null] [pattern] [file ...]\n",
|
||||
/* 7*/ "\t[pattern] [file ...]\n",
|
||||
/* 8*/ "Binary file %s matches\n",
|
||||
/* 9*/ "%s (BSD grep) %s\n",
|
||||
};
|
||||
|
@ -118,6 +118,8 @@ bool wflag; /* -w: pattern must start and end on word boundaries */
|
|||
bool xflag; /* -x: pattern must match entire line */
|
||||
bool lbflag; /* --line-buffered */
|
||||
bool nullflag; /* --null */
|
||||
bool nulldataflag; /* --null-data */
|
||||
unsigned char line_sep = '\n'; /* 0 for --null-data */
|
||||
char *label; /* --label */
|
||||
const char *color; /* --color */
|
||||
int grepbehave = GREP_BASIC; /* -EFGP: type of the regex */
|
||||
|
@ -133,11 +135,11 @@ bool fexclude, finclude; /* --exclude and --include */
|
|||
enum {
|
||||
BIN_OPT = CHAR_MAX + 1,
|
||||
COLOR_OPT,
|
||||
DECOMPRESS_OPT,
|
||||
HELP_OPT,
|
||||
MMAP_OPT,
|
||||
LINEBUF_OPT,
|
||||
LABEL_OPT,
|
||||
NULL_OPT,
|
||||
R_EXCLUDE_OPT,
|
||||
R_INCLUDE_OPT,
|
||||
R_DEXCLUDE_OPT,
|
||||
|
@ -166,16 +168,17 @@ usage(void)
|
|||
exit(2);
|
||||
}
|
||||
|
||||
static const char *optstr = "0123456789A:B:C:D:EFGHIJLOPSRUVZabcd:e:f:hilm:nopqrsuvwxy";
|
||||
static const char optstr[] =
|
||||
"0123456789A:B:C:D:EFGHIJLOPSRUVZabcd:e:f:hilm:nopqrsuvwxyz";
|
||||
|
||||
struct option long_options[] =
|
||||
{
|
||||
{"binary-files", required_argument, NULL, BIN_OPT},
|
||||
{"decompress", no_argument, NULL, DECOMPRESS_OPT},
|
||||
{"help", no_argument, NULL, HELP_OPT},
|
||||
{"mmap", no_argument, NULL, MMAP_OPT},
|
||||
{"line-buffered", no_argument, NULL, LINEBUF_OPT},
|
||||
{"label", required_argument, NULL, LABEL_OPT},
|
||||
{"null", no_argument, NULL, NULL_OPT},
|
||||
{"color", optional_argument, NULL, COLOR_OPT},
|
||||
{"colour", optional_argument, NULL, COLOR_OPT},
|
||||
{"exclude", required_argument, NULL, R_EXCLUDE_OPT},
|
||||
|
@ -214,7 +217,8 @@ struct option long_options[] =
|
|||
{"version", no_argument, NULL, 'V'},
|
||||
{"word-regexp", no_argument, NULL, 'w'},
|
||||
{"line-regexp", no_argument, NULL, 'x'},
|
||||
{"decompress", no_argument, NULL, 'Z'},
|
||||
{"null", no_argument, NULL, 'Z'},
|
||||
{"null-data", no_argument, NULL, 'z'},
|
||||
{NULL, no_argument, NULL, 0}
|
||||
};
|
||||
|
||||
|
@ -563,7 +567,11 @@ main(int argc, char *argv[])
|
|||
xflag = true;
|
||||
break;
|
||||
case 'Z':
|
||||
filebehave = FILE_GZIP;
|
||||
nullflag = true;
|
||||
break;
|
||||
case 'z':
|
||||
nulldataflag = true;
|
||||
line_sep = '\0';
|
||||
break;
|
||||
case BIN_OPT:
|
||||
if (strcasecmp("binary", optarg) == 0)
|
||||
|
@ -595,15 +603,15 @@ main(int argc, char *argv[])
|
|||
strcasecmp("no", optarg) != 0)
|
||||
errx(2, getstr(3), "--color");
|
||||
break;
|
||||
case DECOMPRESS_OPT:
|
||||
filebehave = FILE_GZIP;
|
||||
break;
|
||||
case LABEL_OPT:
|
||||
label = optarg;
|
||||
break;
|
||||
case LINEBUF_OPT:
|
||||
lbflag = true;
|
||||
break;
|
||||
case NULL_OPT:
|
||||
nullflag = true;
|
||||
break;
|
||||
case R_INCLUDE_OPT:
|
||||
finclude = true;
|
||||
add_fpattern(optarg, INCL_PAT);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: grep.h,v 1.6 2011/04/18 17:18:04 joerg Exp $ */
|
||||
/* $NetBSD: grep.h,v 1.7 2011/04/18 22:46:48 joerg Exp $ */
|
||||
/* $OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/grep/grep.h 211496 2010-08-19 09:28:59Z des $ */
|
||||
|
||||
|
@ -113,7 +113,8 @@ extern int cflags, eflags;
|
|||
extern bool Eflag, Fflag, Gflag, Hflag, Lflag,
|
||||
bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag,
|
||||
qflag, sflag, vflag, wflag, xflag;
|
||||
extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag;
|
||||
extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag, nulldataflag;
|
||||
extern unsigned char line_sep;
|
||||
extern unsigned long long Aflag, Bflag, mcount;
|
||||
extern char *label;
|
||||
extern const char *color;
|
||||
|
|
|
@ -5,9 +5,9 @@ $quote "
|
|||
1 "(standard input)"
|
||||
2 "cannot read bzip2 compressed file"
|
||||
3 "unknown %s option"
|
||||
4 "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n"
|
||||
4 "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n"
|
||||
5 "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n"
|
||||
6 "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [pattern] [file ...]\n"
|
||||
7 "\t[pattern] [file ...]\n"
|
||||
8 "Binary file %s matches\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: es_ES.ISO8859-1.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/es_ES.ISO8859-1.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(entrada estándar)"
|
||||
2 "no se puede leer el fichero comprimido bzip2"
|
||||
3 "opción desconocida de %s"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A no] [-B no] [-C[no]]\n"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A no] [-B no] [-C[no]]\n"
|
||||
5 "\t[-e pauta] [-f fichero] [--binary-files=valor] [--color=cuando]\n"
|
||||
6 "\t[--context[=no]] [--directories=acción] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [pauta] [fichero ...]\n"
|
||||
7 "\t[pauta] [fichero ...]\n"
|
||||
8 "fichero binario %s se ajusta\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: gl_ES.ISO8859-1.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/gl_ES.ISO8859-1.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(entrada estándar)"
|
||||
2 "non se pode ler o ficheiro comprimido bzip2"
|
||||
3 "opción descoñecida de %s"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A no] [-B no] [-C[no]]\n"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A no] [-B no] [-C[no]]\n"
|
||||
5 "\t[-e pauta] [-f ficheiro] [--binary-files=valor] [--color=cando]\n"
|
||||
6 "\t[--context[=no]] [--directories=acción] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [pauta] [ficheiro ...]\n"
|
||||
7 "\t[pauta] [ficheiro ...]\n"
|
||||
8 "ficheiro binario %s conforma\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: hu_HU.ISO8859-2.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/hu_HU.ISO8859-2.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(szabványos bemenet)"
|
||||
2 "bzip2 tömörített fájl nem olvasható"
|
||||
3 "ismeretlen %s opció"
|
||||
4 "használat: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A szám] [-B szám] [-C[szám]]\n"
|
||||
4 "használat: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A szám] [-B szám] [-C[szám]]\n"
|
||||
5 "\t[-e minta] [-f fájl] [--binary-files=érték] [--color=mikor]\n"
|
||||
6 "\t[--context[=szám]] [--directories=művelet] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [minta] [fájl ...]\n"
|
||||
7 "\t[minta] [fájl ...]\n"
|
||||
8 "%s bináris fájl illeszkedik\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: ja_JP.SJIS.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/ja_JP.SJIS.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(標準入力)"
|
||||
2 "bzip2 圧縮ファイルを読み込むことができません"
|
||||
3 "%s オプションの指定値に誤りがあります"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
5 "\t[-e パターン] [-f ファイル名] [--binary-files=値] [--color=値]\n"
|
||||
6 "\t[--context[=数字]] [--directories=動作] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [パターン] [ファイル名 ...]\n"
|
||||
7 "\t[パターン] [ファイル名 ...]\n"
|
||||
8 "バイナリファイル %s にマッチしました\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: ja_JP.UTF-8.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/ja_JP.UTF-8.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(標準入力)"
|
||||
2 "bzip2 圧縮ファイルを読み込むことができません"
|
||||
3 "%s オプションの指定値に誤りがあります"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
5 "\t[-e パターン] [-f ファイル名] [--binary-files=値] [--color=値]\n"
|
||||
6 "\t[--context[=数字]] [--directories=動作] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [パターン] [ファイル名 ...]\n"
|
||||
7 "\t[パターン] [ファイル名 ...]\n"
|
||||
8 "バイナリファイル %s にマッチしました\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: ja_JP.eucJP.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/ja_JP.eucJP.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(標準入力)"
|
||||
2 "bzip2 圧縮ファイルを読み込むことができません"
|
||||
3 "%s オプションの指定値に誤りがあります"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
4 "使い方: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A 数字] [-B 数字] [-C[数字]]\n"
|
||||
5 "\t[-e パターン] [-f ファイル名] [--binary-files=値] [--color=値]\n"
|
||||
6 "\t[--context[=数字]] [--directories=動作] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [パターン] [ファイル名 ...]\n"
|
||||
7 "\t[パターン] [ファイル名 ...]\n"
|
||||
8 "バイナリファイル %s にマッチしました\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: pt_BR.ISO8859-1.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/pt_BR.ISO8859-1.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(entrada padrão)"
|
||||
2 "não se posso ler o fichero comprimido bzip2"
|
||||
3 "opcão não conhecida de %s"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n"
|
||||
4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n"
|
||||
5 "\t[-e padrão] [-f arquivo] [--binary-files=valor] [--color=quando]\n"
|
||||
6 "\t[--context[=num]] [--directories=ação] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [padrão] [arquivo ...]\n"
|
||||
7 "\t[padrão] [arquivo ...]\n"
|
||||
8 "arquivo binário %s casa com o padrão\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: ru_RU.KOI8-R.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/ru_RU.KOI8-R.msg 210622 2010-07-29 18:02:57Z gabor $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(стандартный ввод)"
|
||||
2 "не могу прочитать сжатый в bzip2 файл"
|
||||
3 "неизвестный ключ %s"
|
||||
4 "использование: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A чис] [-B чис] [-C[чис]]\n"
|
||||
4 "использование: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A чис] [-B чис] [-C[чис]]\n"
|
||||
5 "\t[-e шаблон] [-f файл] [--binary-files=значение] [--color=когда]\n"
|
||||
6 "\t[--context[=чис]] [--directories=действие] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [шаблон] [файл ...]\n"
|
||||
7 "\t[шаблон] [файл ...]\n"
|
||||
8 "двоичный файл %s совпадает\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
$ $NetBSD: uk_UA.UTF-8.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/uk_UA.UTF-8.msg 210927 2010-08-06 10:34:48Z gabor $
|
||||
$set 1
|
||||
$quote "
|
||||
1 "(стандартний ввід)"
|
||||
2 "не можу прочитати стиснутий bzip2 файл"
|
||||
3 "невiдома опція %s"
|
||||
4 "використання: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A чис] [-B чис] [-C[чис]]\n"
|
||||
4 "використання: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A чис] [-B чис] [-C[чис]]\n"
|
||||
5 "\t[-e шаблон] [-f файл] [--binary-files=значення] [--color=коли]\n"
|
||||
6 "\t[--context[=чис] [--directories=дія] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [шаблон] [файл ...]\n"
|
||||
7 "\t[шаблон] [файл ...]\n"
|
||||
8 "двійковий файл %s співпадає\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$ $NetBSD: zh_CN.UTF-8.msg,v 1.2 2011/04/18 22:46:48 joerg Exp $
|
||||
$ $FreeBSD: head/usr.bin/grep/nls/zh_CN.UTF-8.msg 212927 2010-09-20 19:42:52Z delphij $
|
||||
$
|
||||
$set 1
|
||||
|
@ -5,9 +6,9 @@ $quote "
|
|||
1 "(标准输入)"
|
||||
2 "读取 bzip2 压缩文件时出错"
|
||||
3 "选项 %s 无法识别"
|
||||
4 "用法: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A 行数] [-B 行数] [-C[行数]]\n"
|
||||
4 "用法: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A 行数] [-B 行数] [-C[行数]]\n"
|
||||
5 "\t[-e 模式] [-f 文件] [--binary-files=值] [--color=何时]\n"
|
||||
6 "\t[--context[=行数]] [--directories=动作] [--label] [--line-buffered]\n"
|
||||
7 "\t[--null] [模式] [文件名 ...]\n"
|
||||
7 "\t[模式] [文件名 ...]\n"
|
||||
8 "二进制文件 %s 包含模式\n"
|
||||
9 "%s (BSD grep) %s\n"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.11 2011/04/18 17:18:04 joerg Exp $ */
|
||||
/* $NetBSD: util.c,v 1.12 2011/04/18 22:46:48 joerg Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/grep/util.c 211496 2010-08-19 09:28:59Z des $ */
|
||||
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: util.c,v 1.11 2011/04/18 17:18:04 joerg Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.12 2011/04/18 22:46:48 joerg Exp $");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -231,7 +231,7 @@ procfile(const char *fn)
|
|||
else
|
||||
break;
|
||||
}
|
||||
if (ln.len > 0 && ln.dat[ln.len - 1] == '\n')
|
||||
if (ln.len > 0 && ln.dat[ln.len - 1] == line_sep)
|
||||
--ln.len;
|
||||
ln.line_no++;
|
||||
|
||||
|
@ -260,12 +260,12 @@ procfile(const char *fn)
|
|||
if (cflag) {
|
||||
if (!hflag)
|
||||
printf("%s:", ln.file);
|
||||
printf("%u\n", c);
|
||||
printf("%u%c", c, line_sep);
|
||||
}
|
||||
if (lflag && !qflag && c != 0)
|
||||
printf("%s\n", fn);
|
||||
printf("%s%c", fn, line_sep);
|
||||
if (Lflag && !qflag && c == 0)
|
||||
printf("%s\n", fn);
|
||||
printf("%s%c", fn, line_sep);
|
||||
if (c && !cflag && !lflag && !Lflag &&
|
||||
binbehave == BINFILE_BIN && f->binary && !qflag)
|
||||
printf(getstr(8), fn);
|
||||
|
@ -498,10 +498,10 @@ printline(struct str *line, int sep, regmatch_t *matches, int m)
|
|||
if (!oflag) {
|
||||
if (line->len - a > 0)
|
||||
fwrite(line->dat + a, line->len - a, 1, stdout);
|
||||
putchar('\n');
|
||||
putchar(line_sep);
|
||||
}
|
||||
} else {
|
||||
fwrite(line->dat, line->len, 1, stdout);
|
||||
putchar('\n');
|
||||
putchar(line_sep);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue