⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 336to337.dif

📁 Mehldau和Myer的Agrep3版本
💻 DIF
字号:
--- agrep.c.orig	Wed Sep  9 17:09:30 1998
+++ agrep.c	Wed Sep  9 17:42:20 1998
@@ -97,9 +97,10 @@
 extern unsigned char LUT[256];
 
 #define PRINT(s)
-
+#ifndef __BORLANDC__
 extern char **environ;
 extern int errno;
+#endif
 int pattern_index;		/* index in argv where the pattern is */
 
 int glimpse_isserver=0;		/* so that there is no user interaction */
@@ -2068,6 +2069,7 @@
 	int	quitwhile;
 	int	NOOUTTAIL=OFF;
 	char	metatxt[]=" metasymbol; not searchable";
+	int 	grep_stdin = 0;
 
 	initial_value();
 
@@ -2920,6 +2922,16 @@
 /*		execfd = 0;	*/
 
 		/* [chg] TG 02.03.97 */
+	/* <aaron> fix plumbing problems */
+		if (!isatty(0)) // pipe
+			{
+			grep_stdin = 1;
+			if (Textfiles = (CHAR **) malloc(sizeof(CHAR *)))
+				{
+				strcpy(Textfiles[Numfiles++], "-");
+				goto WHILEARGC;
+				}
+			}
 
 		fprintf(stderr,"%s: no target files found.\n",Progname);
 		if (!EXITONERROR) {
@@ -2942,6 +2954,7 @@
 		
 		copied_from_argv = 1;	/* should I free Textfiles next time? */
 		
+WHILEARGC:
 		while (argc--)
 		{	/* one or more filenames on command line -- put the valid filenames in a array of strings */
 
@@ -3410,7 +3423,14 @@
 			if (!tuncompressible_filename(file_list[i], strlen(file_list[i]))) TCOMPRESSED = OFF;
 			NEW_FILE = ON;
 			
-			if ((fd = open(file_list[i], O_RDONLY)) < /*=*/ 0) {
+			if (strcmp(file_list[i], "-") == 0 ) {
+				fd = 0;
+				}
+			else {
+				fd = open(file_list[i], O_RDONLY);
+				}
+
+			if (fd < /*=*/ 0) {
 				fprintf(stderr, "%s: can't open file for reading: %s\n",Progname, file_list[i]);
 			} 
 			else { 
--- agrep.h.orig	Sun Jan  4 18:31:38 1998
+++ agrep.h	Wed Sep  9 17:12:46 1998
@@ -61,7 +61,7 @@
 #define Maxresult 10000
 #define MaxCan 2500
 
-#if ( ! (defined(__EMX__) && defined(ISO_CHAR_SET)))
+#if ( ! ((defined(WIN32) || defined(__EMX__)) && defined(ISO_CHAR_SET)))
 
 #define MAXSYM 256 /* ASCII */
 #define WORDB     133    /* -w option */
--- agrephlp.c.orig	Sat Jan 31 15:28:58 1998
+++ agrephlp.c	Wed Sep  9 17:14:12 1998
@@ -111,7 +111,13 @@
 fprintf(stderr,"\nAGREP %s for %s compiled with EMX 0.9c. Manber/Wu/Gries et al.(%s)\n",AGREP_VERSION,AGREP_OS,AGREP_DATE);
 #else
 #ifdef _WIN32
-fprintf(stderr,"\nAGREP %s for %s compiled with MS VC 5.0 (%s)\n",AGREP_VERSION,AGREP_OS,AGREP_DATE);
+fprintf(stderr,"\nAGREP %s for %s compiled with "
+#ifdef __BORLANDC__
+		"Borland C"
+#else
+		"MS VC 5.0"
+#endif
+		" (%s)\n",AGREP_VERSION,AGREP_OS,AGREP_DATE);
 #endif
 #endif 
 fprintf(stderr,"\n           Approximate Pattern Matching GREP -- Get Regular Expression\n");
--- asearch.c.orig	Tue Dec 30 10:54:46 1997
+++ asearch.c	Wed Sep  9 17:14:52 1998
@@ -7,7 +7,9 @@
 extern int I, num_of_matched, prev_num_of_matched, TRUNCATE;
 
 extern int CurrentByteOffset;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 extern CHAR *agrep_inbuffer;
 extern int  agrep_inlen;
 extern int  agrep_initialfd;
--- bitap.c.orig	Tue Dec 30 10:59:38 1997
+++ bitap.c	Wed Sep  9 17:15:38 1998
@@ -56,7 +56,9 @@
 extern int agrep_outlen;
 extern int agrep_outpointer;
 extern FILE *agrep_finalfp;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 
 extern int NEW_FILE, POST_FILTER;
 
--- checkfil.c.orig	Wed Sep  9 17:09:32 1998
+++ checkfil.c	Wed Sep  9 17:43:30 1998
@@ -29,8 +29,10 @@
 #define MAXLINE 512
 
 extern char Progname[];
+#ifndef __BORLANDC__
 extern int errno;
-
+#endif
+#include <string.h>
 unsigned char ibuf[MAXLINE];
 
 /**************************************************************************
@@ -49,7 +51,7 @@
 {
 	struct stat buf;
 
-	if (stat(fname, &buf) != 0) {
+	if (strcmp(fname, "-") && stat(fname, &buf) != 0) {
 		if (errno == ENOENT)
 			return NOSUCHFILE;
 		else
--- checksg.c.orig	Mon Apr  7 23:50:02 1997
+++ checksg.c	Wed Sep  9 17:16:52 1998
@@ -3,7 +3,9 @@
 #include "agrep.h"
 #include "checkfil.h"
 
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 extern CHAR Progname[MAXNAME]; 
 extern int SGREP, PAT_FILE, PAT_BUFFER, EXITONERROR, SIMPLEPATTERN,
 	CONSTANT, D, NOUPPER, JUMP, I, LINENUM, INVERSE, WORDBOUND, WHOLELINE,
--- codepage.c.orig	Sun Jan  4 18:36:10 1998
+++ codepage.c	Wed Sep  9 17:18:10 1998
@@ -102,7 +102,18 @@
 }	/* end of get_current_codepage() */
 
 #else			/* using a non-EMX compiler */
+#if defined(__BORLANDC__) && defined(_WIN32)
+{
+extern int __stdcall GetACP();
+	if (GetACP() == 1252)
+		return 850;
+	else
+		return -1;
+}
+
+#else
 { return(-1); }
+#endif
 #endif
  
 
--- compat.c.orig	Mon Apr  7 23:50:02 1997
+++ compat.c	Wed Sep  9 17:18:34 1998
@@ -15,7 +15,9 @@
 extern char Progname[32];
 extern int agrep_initialfd;
 extern int EXITONERROR;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 
 int
 compat()
--- maskgen.c.orig	Sat Jan 31 15:11:58 1998
+++ maskgen.c	Wed Sep  9 17:20:36 1998
@@ -18,7 +18,9 @@
 extern unsigned char Progname[];
 extern int agrep_initialfd;
 extern int EXITONERROR;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 
 int
 maskgen(Pattern, D)
@@ -47,7 +49,7 @@
 	/* the metasymbols are not transposed in that table */
 	
 	if(NOUPPER) {
-#if (defined(__EMX__) && defined(ISO_CHAR_SET)) || (defined(_WIN32) && defined(ISO_CHAR_SET))
+#if ((defined(__EMX__) || defined(_WIN32)) && defined(ISO_CHAR_SET))
 		for(i=0; i<M; i++) Pattern[i] = LUT[Pattern[i]];
 #else
 		for(i=0; i<M; i++) if(isalpha((int)Pattern[i])) 
@@ -255,8 +257,7 @@
 
 	if(NOUPPER) for(i=0; i<MAXSYM; i++)
 
-#if (defined(__EMX__) && defined(ISO_CHAR_SET)) || (defined(_WIN32) && defined(ISO_CHAR_SET))
-
+#if ((defined(__EMX__) || defined(_WIN32)) && defined(ISO_CHAR_SET))
 		Mask[i] = Mask[LUT[i]];
 #else
 		if (isupper(i)) Mask[i] = Mask[tolower(i)];
--- newmgrep.c.orig	Sat Jan 31 15:12:30 1998
+++ newmgrep.c	Wed Sep  9 17:21:50 1998
@@ -76,7 +76,9 @@
 extern int agrep_outpointer;
 extern int agrep_outlen;
 extern CHAR * agrep_outbuffer;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 extern int NEW_FILE, POST_FILTER;
 
 extern int tuncompressible();
@@ -292,7 +294,7 @@
 	if(NOUPPER) {
                 for (i=0; i<MAXSYM; i++)
 
-#if (defined(__EMX__) && defined(ISO_CHAR_SET)) || (defined(_WIN32) && defined(ISO_CHAR_SET))
+#if ((defined(__EMX__) || defined(_WIN32)) && defined(ISO_CHAR_SET))
 			tr[i] = tr[LUT[i]];
 #else
                         if (isupper(i)) tr[i] = tr[tolower(i)];
--- preproce.c.orig	Tue Dec 30 11:09:46 1997
+++ preproce.c	Wed Sep  9 17:22:12 1998
@@ -29,7 +29,9 @@
 extern int table[WORD][WORD];
 extern int agrep_initialfd;
 extern int EXITONERROR;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 
 extern int  multifd;
 extern char *multibuf;
--- re.h.orig	Mon Apr  7 23:50:02 1997
+++ re.h	Wed Sep  9 17:36:56 1998
@@ -72,8 +72,6 @@
 
 #define new_node(type, l, x)	\
 {\
-	extern void *malloc();\
-\
 	(l) = (type) malloc(sizeof(*(x)));\
 	if ((l) == NULL) {\
 		fprintf(stderr, "malloc failure in new_node\n");\
--- recursiv.c.orig	Sun Jan  4 18:33:08 1998
+++ recursiv.c	Wed Sep  9 17:25:48 1998
@@ -30,7 +30,7 @@
 
 #if HAVE_DIRENT_H
 
-#ifndef _WIN32
+#if defined(__BORLANDC__) || !defined(_WIN32)
 # include <dirent.h>
 #else
 # include "ntdirent.h"
@@ -146,7 +146,9 @@
 {
 	struct stat stbuf;
 	int i;
+#ifndef __BORLANDC__
 	extern void *malloc();
+#endif
 
 #ifdef REC_DIAG
 	printf(" In treewalk. name= %s\n",name);
--- sgrep.c.orig	Sat Jan 31 15:11:32 1998
+++ sgrep.c	Wed Sep  9 17:27:16 1998
@@ -110,7 +110,9 @@
 extern int NEW_FILE, POST_FILTER;
 
 extern int EXITONERROR;
+#ifndef __BORLANDC__
 extern int errno;
+#endif
 extern int TCOMPRESSED;
 extern int EASYSEARCH;
 extern char FREQ_FILE[MAX_LINE_LEN], HASH_FILE[MAX_LINE_LEN], STRING_FILE[MAX_LINE_LEN];
@@ -219,8 +221,7 @@
 
 		for(i=0; i<MAXSYM; i++)
 
-#if (defined(__EMX__) && defined(ISO_CHAR_SET)) || (defined(_WIN32) && defined(ISO_CHAR_SET))
-
+#if ((defined(__EMX__) || defined(_WIN32)) && defined(ISO_CHAR_SET))
 			TR[i] = TR[LUT[i]];
 #else
 			if (isupper(i)) TR[i] = TR[tolower(i)];
@@ -1506,8 +1507,7 @@
 
 	/* if(NOUPPER) */ for(i=0; i<MAXSYM; i++) {
 
-#if (defined(__EMX__) && defined(ISO_CHAR_SET)) || (defined(_WIN32) && defined(ISO_CHAR_SET))
-
+#if ((defined(__EMX__) || defined(_WIN32)) && defined(ISO_CHAR_SET))
 		SHIFT[i] = SHIFT[LUT[i]];
 #else
 		if (isupper(i)) SHIFT[i] = SHIFT[tolower(i)];
--- version.h.orig	Sat Jan 31 15:38:20 1998
+++ version.h	Thu Sep 10 08:35:34 1998
@@ -1,4 +1,7 @@
 /*
+[fix]	3.37	RA 10.09.98		Windows: add BorlandC makefile.w32, make code BC ok,
+				Added Win32 GetACP() call to figure out codepage (codepage.c)
+				Fixed pipe, so e.g. 'cat agrep.c | agrep something ' now works.
 [fix]	3.36	DM 31.01.98     Windows: fix keyboard handling in agrephlp;
                                          fix case sensitive searching in sgrep.c,
                                              maskgen.c, newgrep.c
@@ -42,7 +45,7 @@
 
 */
 
-#define AGREP_VERSION	"3.36"
+#define AGREP_VERSION	"3.37"
 
 #ifdef __DOS
 #define AGREP_OS	"DOS"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -