Project

General

Profile

Feature #3546 ยป illumos-grep-o.patch

Andrew Stormont, 2013-02-10 02:11 PM

View differences:

grep.c Sat Feb 9 14:27:32 2013
95 95
static int	wflag;
96 96
static int	hflag;
97 97
static int	qflag;
98
static int	oflag;
98 99
static int	errflg;
99 100
static int	nfile;
100 101
static long long	tln;
......
123 124
#endif
124 125
	(void) textdomain(TEXT_DOMAIN);
125 126

  
126
	while ((c = getopt(argc, argv, "hqblcnRrsviyw")) != -1)
127
	while ((c = getopt(argc, argv, "hqblcnRrsviywo")) != -1)
127 128
		switch (c) {
128 129
		case 'h':
129 130
			hflag++;
......
162 163
		case 'w':
163 164
			wflag++;
164 165
			break;
166
		case 'o':
167
			oflag++;
168
			break;
165 169
		case '?':
166 170
			errflg++;
167 171
		}
168 172

  
169 173
	if (errflg || (optind >= argc)) {
170
		errmsg("Usage: grep [-c|-l|-q] [-r|-R] -hbnsviw "
174
		errmsg("Usage: grep [-c|-l|-q] [-r|-R] -hbnsviwo "
171 175
		    "pattern file . . .\n",
172 176
		    (char *)NULL);
173 177
		exit(2);
......
397 401
			lbuf = ptr;
398 402

  
399 403
		/* lflag only once */
400
		if ((step(lbuf, expbuf) ^ vflag) && succeed(file) == 1)
401
			break;
404
		if (step(lbuf, expbuf) ^ vflag) {
405
			if (oflag) {
406
				/*
407
				 * Only store the matching bits
408
				 */
409
				ptr = loc1;
410
				ptrend = loc2;
411
			}
412
			if (succeed(file) == 1)
413
				break;
414
		}
402 415

  
403 416
		if (!nlflag)
404 417
			break;
    (1-1/1)