Skip to content

Commit

Permalink
Last commit was incomplete.
Browse files Browse the repository at this point in the history
  • Loading branch information
gautambt committed Jun 7, 2010
1 parent e43b377 commit d51ad66
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Makefile
@@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.5 2003/06/23 07:52:18 deraadt Exp $

PROG= grep
SRCS= binary.c file.c grep.c mmfile.c queue.c util.c
SRCS= binary.c file.c fgetln.c grep.c mmfile.c queue.c util.c
LINKS= ${BINDIR}/grep ${BINDIR}/egrep \
${BINDIR}/grep ${BINDIR}/fgrep \
${BINDIR}/grep ${BINDIR}/zgrep \
Expand All @@ -14,9 +14,10 @@ MLINKS= grep.1 egrep.1 \
grep.1 zegrep.1 \
grep.1 zfgrep.1

CPPFLAGS+= -DNOZ -D_POSIX_SOURCE -D_MINIX
CFLAGS+= -Wall

LDADD= -lz
DPADD= ${LIBZ}

.include <bsd.prog.mk>
.include <minix.prog.mk>
1 change: 0 additions & 1 deletion binary.c
Expand Up @@ -29,7 +29,6 @@
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <zlib.h>

#include "grep.h"

Expand Down
3 changes: 2 additions & 1 deletion file.c
Expand Up @@ -32,7 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <zlib.h>

#include "grep.h"

Expand All @@ -51,7 +50,9 @@ struct file {
int noseek;
FILE *f;
mmf_t *mmf;
#ifndef NOZ
gzFile *gzf;
#endif
};

#ifndef NOZ
Expand Down
9 changes: 7 additions & 2 deletions grep.c
Expand Up @@ -237,9 +237,12 @@ main(int argc, char *argv[])
struct patfile *patfile, *pf_next;
long l;
char *ep;
const char *progname;

SLIST_INIT(&patfilelh);
switch (__progname[0]) {
setprogname(argv[0]);
progname=getprogname();
switch (progname[0]) {
case 'e':
Eflag++;
break;
Expand All @@ -252,7 +255,7 @@ main(int argc, char *argv[])
#ifndef NOZ
case 'z':
Zflag++;
switch(__progname[1]) {
switch(progname[1]) {
case 'e':
Eflag++;
break;
Expand Down Expand Up @@ -468,8 +471,10 @@ main(int argc, char *argv[])
}
}

#ifndef __minix
if (lbflag)
setlinebuf(stdout);
#endif

if ((argc == 0 || argc == 1) && !oflag)
hflag = 1;
Expand Down
5 changes: 5 additions & 0 deletions grep.h
Expand Up @@ -31,7 +31,10 @@
#include <limits.h>
#include <regex.h>
#include <stdio.h>

#ifndef NOZ
#include <zlib.h>
#endif

#define VER_MAJ 0
#define VER_MIN 17
Expand Down Expand Up @@ -117,6 +120,8 @@ void grep_close(file_t *f);

/* binary.c */
int bin_file(FILE * f);
#ifndef NOZ
int gzbin_file(gzFile * f);
#endif
int mmbin_file(mmf_t *f);

6 changes: 4 additions & 2 deletions mmfile.c
Expand Up @@ -63,7 +63,9 @@ mmopen(char *fn, char *mode)
goto ouch2;
mmf->ptr = mmf->base;
mmf->end = mmf->base + mmf->len;
#ifdef MADV_SEQUENTIAL
madvise(mmf->base, mmf->len, MADV_SEQUENTIAL);
#endif
return mmf;

ouch2:
Expand All @@ -85,8 +87,8 @@ char *
mmfgetln(mmf_t *mmf, size_t *l)
{
static char *p;
char *start = mmf->ptr; // Remove speed bump
char *end = mmf->end; // Remove speed bump
char *start = mmf->ptr; /* Remove speed bump */
char *end = mmf->end; /* Remove speed bump */

if (start >= end)
return NULL;
Expand Down
5 changes: 4 additions & 1 deletion util.c
Expand Up @@ -38,7 +38,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <zlib.h>

#include "grep.h"

Expand Down Expand Up @@ -580,7 +579,11 @@ printline(str_t *line, int sep)
if (bflag) {
if (n)
putchar(sep);
#ifndef __minix
printf("%lld", (long long)line->off);
#else
printf("%ld", (long)line->off);
#endif
++n;
}
if (n)
Expand Down

0 comments on commit d51ad66

Please sign in to comment.