aboutsummaryrefslogtreecommitdiffstats
path: root/japanese/jvim/files/patch-ab
blob: 42fd87d9cf6bfc7d941c206dc240b0e8126708a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--- ./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)