openbsd-ports/japanese/jvim/patches/patch-ab
1998-07-29 01:31:02 +00:00

75 lines
1.9 KiB
Plaintext

--- ./src/jgrep.c.orig Mon Jul 3 23:52:28 1995
+++ ./src/jgrep.c Fri Sep 5 14:01:32 1997
@@ -38,17 +38,19 @@
static int o_nomat = FALSE; /* -v */
static int o_wsrch = FALSE; /* -w */
static int o_scode = FALSE; /* -C */
+static int o_sline = FALSE; /* -n */
static void
usage()
{
fprintf(stderr, "Jgrep/%s by ann@mrit.mei.co.jp\n", JpVersion);
- fprintf(stderr, "Usage: jgrep [ -cilsvwCNJESX., ] pattern [filename ...]\n");
+ fprintf(stderr, "Usage: jgrep [ -cilsvnwCNJESX., ] pattern [filename ...]\n");
fprintf(stderr, " -c Print only a count of the lines.\n");
fprintf(stderr, " -i Ignore case.\n");
fprintf(stderr, " -l Print only file name.\n");
fprintf(stderr, " -s Suppress error message.\n");
fprintf(stderr, " -v Print lines not match with the pattern.\n");
+ fprintf(stderr, " -n Print line number.\n");
fprintf(stderr, " -w Search \\<pattern\\>.\n");
fprintf(stderr, " -C Print kanji code.\n");
fprintf(stderr, " -N -J -E -S -X \n");
@@ -104,7 +106,7 @@
jread = jdisp = JP_NONE;
#endif
- if (argc > 1 && argv[0][0] == '-')
+ while (argc > 1 && argv[0][0] == '-')
{
char *cp;
for(cp = argv[0] + 1; *cp; cp++)
@@ -127,6 +129,10 @@
o_noerr = TRUE;
break;
+ case 'n':
+ o_sline = TRUE;
+ break;
+
case 'v':
o_nomat = TRUE;
break;
@@ -268,9 +274,11 @@
char *fname;
{
int count;
+ int nline;
reg_ic = o_icase;
count = 0;
+ nline = 0;
reset_jcount();
@@ -282,6 +290,9 @@
if (fgets(Line, IOSIZE, fp) == NULL)
break;
+ if (strchr(Line, '\n'))
+ nline++;
+
len = strlen(Line);
len = kanjiconvsfrom(Line, len, IObuff, IOSIZE * 2, NULL,
jread, NULL);
@@ -294,6 +305,8 @@
{
if (fname)
printf("%s:", fname);
+ if (o_sline)
+ printf("%d:", nline);
if (o_scode)
printf("(%c)", judge_jcode(jread));
if (o_nonly)