From: Ben Gras Date: Sun, 20 Jun 2010 11:55:19 +0000 (+0000) Subject: fixes for minix grep X-Git-Tag: v3.1.8~427 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.png?a=commitdiff_plain;h=28663f45d6d48e560f3a655f448832adb278c2aa;p=minix.git fixes for minix grep --- diff --git a/commands/Makefile b/commands/Makefile index 65d4abbd5..42f26b6b7 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -12,7 +12,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \ dhrystone diff dirname dis88 du dumpcore easypack \ ed eject elle elvis env expand factor file \ find finger fingerd fix fold format fortune fsck \ - fsck1 ftp101 ftpd200 getty gomoku head host \ + fsck1 ftp101 ftpd200 getty grep gomoku head host \ hostaddr id ifconfig ifdef indent install \ intr ipcrm ipcs irdpd isoread join kill last leave \ lex life loadkeys loadramdisk logger login look lp \ diff --git a/commands/grep/Makefile b/commands/grep/Makefile index 5c066d25d..692540d25 100644 --- a/commands/grep/Makefile +++ b/commands/grep/Makefile @@ -17,11 +17,12 @@ MLINKS= grep.1 egrep.1 \ CFLAGS+= -Wall +LDADD= -lz +DPADD= ${LIBZ} + .if ${OPSYS} == "Minix" -CPPFLAGS+= -DNOZ -D_POSIX_SOURCE -D_MINIX +CPPFLAGS+= -D_POSIX_SOURCE -D_MINIX .include .else -LDADD= -lz -DPADD= ${LIBZ} .include .endif diff --git a/commands/grep/file.c b/commands/grep/file.c index 1787ac090..9a6ae8ebc 100644 --- a/commands/grep/file.c +++ b/commands/grep/file.c @@ -42,7 +42,9 @@ static size_t lnbuflen; #endif #define FILE_STDIO 0 +#ifndef __minix #define FILE_MMAP 1 +#endif #define FILE_GZIP 2 struct file { @@ -142,11 +144,13 @@ grep_open(char *path, char *mode) } else #endif { +#ifdef FILE_MMAP /* try mmap first; if it fails, try stdio */ if ((f->mmf = mmopen(fname, mode)) != NULL) { f->type = FILE_MMAP; return f; } +#endif f->type = FILE_STDIO; if ((f->f = fopen(path, mode)) != NULL) return f; @@ -165,8 +169,10 @@ grep_bin_file(file_t *f) switch (f->type) { case FILE_STDIO: return bin_file(f->f); +#ifdef FILE_MMAP case FILE_MMAP: return mmbin_file(f->mmf); +#endif #ifndef NOZ case FILE_GZIP: return gzbin_file(f->gzf); @@ -183,8 +189,10 @@ grep_fgetln(file_t *f, size_t *l) switch (f->type) { case FILE_STDIO: return fgetln(f->f, l); +#ifdef FILE_MMAP case FILE_MMAP: return mmfgetln(f->mmf, l); +#endif #ifndef NOZ case FILE_GZIP: return gzfgetln(f->gzf, l); @@ -202,9 +210,11 @@ grep_close(file_t *f) case FILE_STDIO: fclose(f->f); break; +#ifdef FILE_MMAP case FILE_MMAP: mmclose(f->mmf); break; +#endif #ifndef NOZ case FILE_GZIP: gzclose(f->gzf); diff --git a/commands/grep/grep.c b/commands/grep/grep.c index b316981ae..310abba75 100755 --- a/commands/grep/grep.c +++ b/commands/grep/grep.c @@ -102,8 +102,6 @@ struct patfile { }; SLIST_HEAD(, patfile) patfilelh; -extern char *__progname; - static void usage(void) { @@ -114,7 +112,7 @@ usage(void) "usage: %s [-abcEFGHhIiLlnoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n" #endif "\t[-e pattern] [-f file] [--binary-files=value] [--context[=num]]\n" - "\t[--line-buffered] [pattern] [file ...]\n", __progname); + "\t[--line-buffered] [pattern] [file ...]\n", getprogname()); exit(2); } @@ -240,11 +238,7 @@ main(int argc, char *argv[]) SLIST_INIT(&patfilelh); -#ifdef __minix - setprogname(argv[0]); -#endif - - switch (__progname[0]) { + switch (getprogname()[0]) { case 'e': Eflag++; break; @@ -257,7 +251,7 @@ main(int argc, char *argv[]) #ifndef NOZ case 'z': Zflag++; - switch(__progname[1]) { + switch(getprogname()[1]) { case 'e': Eflag++; break; diff --git a/commands/grep/mmfile.c b/commands/grep/mmfile.c index aa1a28ac0..8cdfefe21 100644 --- a/commands/grep/mmfile.c +++ b/commands/grep/mmfile.c @@ -1,3 +1,4 @@ +#ifndef __minix /* $OpenBSD: mmfile.c,v 1.11 2006/09/19 05:52:23 otto Exp $ */ /*- @@ -100,3 +101,4 @@ mmfgetln(mmf_t *mmf, size_t *l) ++mmf->ptr; return p; } +#endif