Date: Wed, 7 May 2008 16:18:48 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 141285 for review Message-ID: <200805071618.m47GImJ6035400@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=141285 Change 141285 by gabor@gabor_server on 2008/05/07 16:17:48 - Implement --null Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#4 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.h#5 edit .. //depot/projects/soc2008/gabor_textproc/grep/util.c#5 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#4 (text+ko) ==== @@ -89,6 +89,7 @@ int wflag; /* -w: pattern must start and end on word boundaries */ int xflag; /* -x: pattern must match entire line */ int lbflag; /* --line-buffered */ +int nullflag; /* --null */ int binbehave = BIN_FILE_BIN; @@ -96,7 +97,8 @@ BIN_OPT = CHAR_MAX + 1, HELP_OPT, MMAP_OPT, - LINEBUF_OPT + LINEBUF_OPT, + NULL_OPT }; /* Housekeeping */ @@ -131,9 +133,8 @@ {"line-buffered", no_argument, NULL, LINEBUF_OPT}, /* XXX: UNIMPLEMENTED {"label", required_argument, NULL, LABEL_OPT}, */ + {"null", no_argument, NULL, NULL_OPT}, /* XXX: UNIMPLEMENTED - {"null", no_argument, NULL, NULL_OPT}, */ -/* XXX: UNIMPLEMENTED {"color", optional_argument, NULL, COLOR_OPT}, {"colour", optional_argument, NULL, COLOR_OPT}, */ {"after-context", required_argument, NULL, 'A'}, @@ -429,6 +430,9 @@ case LINEBUF_OPT: lbflag = 1; break; + case NULL_OPT: + nullflag = 1; + break; case HELP_OPT: default: usage(); ==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#5 (text+ko) ==== @@ -63,7 +63,8 @@ extern int Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag, Pflag, Sflag, Rflag, Zflag, bflag, cflag, hflag, iflag, lflag, nflag, qflag, sflag, - vflag, wflag, xflag; + vflag, wflag, xflag, + nullflag; extern int binbehave; extern int first, matchall, patterns, tail; ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#5 (text+ko) ==== @@ -573,11 +573,13 @@ void printline(struct str *line, int sep) { - int n; + int n = 0; - n = 0; if (!hflag) { - fputs(line->file, stdout); + if (nullflag == 0) + fputs(line->file, stdout); + else + printf("%s", line->file); ++n; } if (nflag) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805071618.m47GImJ6035400>