Only in grep: build
diff -ur G:\FGCVS\grep\lib\closeout.c grep\lib\closeout.c
--- G:\FGCVS\grep\lib\closeout.c	Thu Jun 28 21:10:44 2007
+++ grep\lib\closeout.c	Thu May 29 14:11:51 2008
@@ -117,5 +117,8 @@
 void
 close_stdout (void)
 {
+#ifdef ADD_GREP_STATS
+  show_results();
+#endif /* #ifdef ADD_GREP_STATS */
   close_stdout_status (default_exit_status);
 }
diff -ur G:\FGCVS\grep\lib\quotearg.c grep\lib\quotearg.c
--- G:\FGCVS\grep\lib\quotearg.c	Thu Jun 28 21:10:45 2007
+++ grep\lib\quotearg.c	Wed May 28 16:00:20 2008
@@ -74,7 +74,9 @@
 # define MB_CUR_MAX 1
 # define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
 # define mbsinit(ps) 1
+#ifndef iswprint
 # define iswprint(wc) ISPRINT ((unsigned char) (wc))
+#endif /* #ifndef iswprint */
 #endif
 
 #ifndef iswprint
diff -ur G:\FGCVS\grep\lib\regex.c grep\lib\regex.c
--- G:\FGCVS\grep\lib\regex.c	Thu Jun 28 21:10:45 2007
+++ grep\lib\regex.c	Fri May 30 12:37:57 2008
@@ -2176,11 +2176,22 @@
 #  define CHAR_CLASS_MAX_LENGTH 256
 # endif
 
+#ifdef _MSC_VER
+/* UGH - later runtime libraries no longer have wctype function */
+#define IS_CHAR_CLASS(string)						\
+   (STREQ (string, "alpha") || STREQ (string, "upper")			\
+    || STREQ (string, "lower") || STREQ (string, "digit")		\
+    || STREQ (string, "alnum") || STREQ (string, "xdigit")		\
+    || STREQ (string, "space") || STREQ (string, "print")		\
+    || STREQ (string, "punct") || STREQ (string, "graph")		\
+    || STREQ (string, "cntrl") || STREQ (string, "blank"))
+#else /* !#ifdef _MSC_VER */
 # ifdef _LIBC
 #  define IS_CHAR_CLASS(string) __wctype (string)
 # else
 #  define IS_CHAR_CLASS(string) wctype (string)
 # endif
+#endif /* #ifdef _MSC_VER y/n */
 #else
 # define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */
 
@@ -7826,8 +7837,8 @@
    from either regcomp or regexec.   We don't use PREG here.  */
 
 size_t
-regerror (errcode, preg, errbuf, errbuf_size)
-    int errcode;
+regerror (errcod, preg, errbuf, errbuf_size)
+    int errcod;
     const regex_t *preg;
     char *errbuf;
     size_t errbuf_size;
@@ -7835,8 +7846,8 @@
   const char *msg;
   size_t msg_size;
 
-  if (errcode < 0
-      || errcode >= (int) (sizeof (re_error_msgid_idx)
+  if (errcod < 0
+      || errcod >= (int) (sizeof (re_error_msgid_idx)
 			   / sizeof (re_error_msgid_idx[0])))
     /* Only error codes returned by the rest of the code should be passed
        to this routine.  If we are given anything else, or if other regex
@@ -7844,7 +7855,7 @@
        Dump core so we can fix it.  */
     abort ();
 
-  msg = gettext (re_error_msgid + re_error_msgid_idx[errcode]);
+  msg = gettext (re_error_msgid + re_error_msgid_idx[errcod]);
 
   msg_size = strlen (msg) + 1; /* Includes the null.  */
 
diff -ur G:\FGCVS\grep\lib\savedir.c grep\lib\savedir.c
--- G:\FGCVS\grep\lib\savedir.c	Thu Jun 28 21:10:45 2007
+++ grep\lib\savedir.c	Wed May 28 13:06:36 2008
@@ -102,8 +102,13 @@
 savedir (const char *dir, off_t name_size, struct exclude *included_patterns,
 	 struct exclude *excluded_patterns, struct exclude *excluded_directory_patterns )
 {
+#ifdef _MSC_VER
+  PDIR dirp;
+  PDE    dp;
+#else /* !#ifdef _MSC_VER */
   DIR *dirp;
   struct dirent *dp;
+#endif /* #ifdef _MSC_VER y/n */
   char *name_space;
   char *namep;
 
diff -ur G:\FGCVS\grep\src\dosbuf.c grep\src\dosbuf.c
--- G:\FGCVS\grep\src\dosbuf.c	Thu Jan 20 05:43:03 2000
+++ grep\src\dosbuf.c	Thu May 29 18:12:58 2008
@@ -70,6 +70,9 @@
       dos_pos_map_used = 0;
       dos_stripped_crs = 0;
       dos_file_type = dos_use_file_type;
+#ifdef EXTRA_DEBUG2
+      show_buffer( buf, buflen, "Input" );
+#endif /* #ifdef EXTRA_DEBUG2 */
     }
 
   /* Guess if this file is binary, unless we already know that.  */
diff -ur G:\FGCVS\grep\src\getpagesize.h grep\src\getpagesize.h
--- G:\FGCVS\grep\src\getpagesize.h	Thu Feb 08 16:56:55 2001
+++ grep\src\getpagesize.h	Wed May 28 13:14:51 2008
@@ -25,6 +25,10 @@
 # endif
 #endif
 
+#if !defined getpagesize && defined _MSC_VER
+#  define getpagesize() 4096
+#endif
+
 #ifndef getpagesize
 # include <sys/param.h>
 # ifdef EXEC_PAGESIZE
diff -ur G:\FGCVS\grep\src\grep.c grep\src\grep.c
--- G:\FGCVS\grep\src\grep.c	Thu Feb 14 05:03:39 2008
+++ grep\src\grep.c	Thu May 29 18:23:41 2008
@@ -47,6 +47,11 @@
 #include "error.h"
 #include "exclude.h"
 #include "closeout.h"
+#ifdef _MSC_VER
+#include "fnmatch.h"
+#else /* !_MSC_VER */
+#define  set_exit_status()
+#endif /* _MSC_VER y/n */
 
 #undef MAX
 #define MAX(A,B) ((A) > (B) ? (A) : (B))
@@ -1217,6 +1222,95 @@
   int count;
   int status;
 
+#ifdef _MSC_VER
+   if( file && has_wild( file ) )
+   {
+      /* ***************************************************
+      // WINDOWS COMMAND PROMPT DOES NOT EXPAND '*' TO FILES
+      // so entering 'grep *', is more like entering 'grep \*'
+      // in unix!!!
+      // ===================================================
+      // So, must read directory, and process EACH file in it,
+      // and match to file mask given, like * or *.* would be ALL,
+      // *.h* would be all headers ...
+      // and if -r (directories == RECURSE_DIRECTORIES)
+      // process each directory
+      // fill in grep_filesfound, grep_filessearched,
+      // grep_dirsfound, grep_dirssearched,
+      // and most important grep_finds
+      // **************************************************** */
+
+      PSPLITTING psp = (PSPLITTING)xmalloc(sizeof(SPLITTING));
+      PDIR pdir;
+      PDE   dp;
+      status = 0;
+      _splitpath(file, psp->drive, psp->dir, psp->fname, psp->ext);
+      strcpy( psp->path, psp->drive );
+      strcat( psp->path, psp->dir );
+      if( psp->path[0] == 0 )
+         strcpy( psp->path, "." );
+      pdir = opendir( psp->path );
+      if( pdir )
+      {
+         while(( dp = readdir(pdir) ) != 0 )
+         {
+            /* Skip "." and ".." (some NFS filesystems' directories lack them). */
+            if ((dp->d_name[0] != '.') ||
+               ((dp->d_name[1] != '\0') &&
+               ((dp->d_name[1] != '.') || (dp->d_name[2] != '\0'))))
+            {
+               strcpy( psp->path, psp->drive );
+               strcat( psp->path, psp->dir );
+               strcat( psp->path, dp->d_name );
+               if ( dp->d_type == DT_DIR )
+               {
+                  grep_dirsfound++;
+                  if ( directories == RECURSE_DIRECTORIES )
+                  {
+                     if ( excluded_directory_patterns &&
+                        excluded_filename (excluded_directory_patterns, dp->d_name, 0) )
+                     {
+                        // skip this directory
+                     }
+                     else
+                     {
+                        grep_dirssearched++;
+                        strcat( psp->path, "\\" );
+                        strcat( psp->path, psp->fname );
+                        strcat( psp->path, psp->ext );
+                        status |= grepfile (psp->path, stats);
+                     }
+                  }
+               }
+               else
+               {
+                  grep_filesfound++;
+                  if (included_patterns && !excluded_filename (included_patterns, dp->d_name, 0))
+                  {
+                     // continue;
+                  }
+                  else if (excluded_patterns && excluded_filename (excluded_patterns, dp->d_name, 0))
+                  {
+                     // continue;
+                  }
+                  else
+                  {
+                     if ( fnmatch( file, psp->path, FNM_CASEFOLD | FNM_NOESCAPE ) != FNM_NOMATCH )
+                     {
+                        status |= grepfile( psp->path, stats );
+                     }
+                  }
+               }
+            }
+         }
+         closedir(pdir);
+      } else {
+         status = 2;
+      }
+      free(psp);
+      return status;
+   }
+#endif /* _MSC_VER */
   if (! file)
     {
       desc = 0;
@@ -1277,6 +1371,9 @@
 	  return 1;
 	}
 
+#ifdef _MSC_VER
+      grep_filessearched++;  /* accumulate files searched count */
+#endif /* ifdef _MSC_VER */
       filename = file;
     }
 
@@ -1292,6 +1389,9 @@
     status = count + 2;
   else
     {
+#ifdef _MSC_VER
+      grep_finds += count;  /* accumulate finds count */
+#endif /* ifdef _MSC_VER */
       if (count_matches)
 	{
 	  if (out_file)
@@ -1508,6 +1608,7 @@
 if any error occurs and -q was not given, the exit status is 2.\n"));
       printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
     }
+  set_exit_status(status);
   exit (status);
 }
 
@@ -1827,7 +1928,14 @@
   extern int optind;
 
   initialize_main (&argc, &argv);
+#ifdef _MSC_VER
+  program_name = get_title_only(argv[0]);
+  /* in some MSVC initialize_main gets defined away! despite #ifndef ???
+     and anyway, need address of some items, for exist diags */
+  initialize_win32 (&argc, &argv, &errseen, &status);
+#else /* !#ifdef _MSC_VER */
   program_name = argv[0];
+#endif /* #ifdef _MSC_VER y/n */
 
   keys = NULL;
   keycc = 0;
@@ -2188,6 +2296,7 @@
 There is NO WARRANTY, to the extent permitted by law.\n"),
         "2008");
       printf ("\n");
+      set_exit_status(0);
       exit (0);
     }
 
@@ -2232,6 +2341,10 @@
     mb_icase_keys (&keys, &keycc);
 #endif /* MBS_SUPPORT */
 
+#ifdef EXTRA_DEBUG2
+  show_buffer(keys, keycc, "Keys");
+#endif /* #ifdef EXTRA_DEBUG2 */
+
   compile(keys, keycc);
 
   if ((argc - optind > 1 && !no_filenames) || with_filenames)
@@ -2244,8 +2357,10 @@
     SET_BINARY (1);
 #endif
 
-  if (max_count == 0)
+  if (max_count == 0) {
+    set_exit_status(1);
     exit (1);
+  }
 
   if (optind < argc)
     {
@@ -2272,6 +2387,7 @@
     status = grepfile ((char *) NULL, &stats_base);
 
   /* We register via atexit() to test stdout.  */
+  set_exit_status( errseen ? 2 : status );
   exit (errseen ? 2 : status);
 }
 /* vim:set shiftwidth=2: */
diff -ur G:\FGCVS\grep\src\system.h grep\src\system.h
--- G:\FGCVS\grep\src\system.h	Thu Jun 28 21:10:46 2007
+++ grep\src\system.h	Thu May 29 13:52:03 2008
@@ -32,8 +32,11 @@
 #endif
 
 #ifdef HAVE_UNISTD_H
-# include <fcntl.h>
 # include <unistd.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
 #else
 # define O_RDONLY 0
 # define SEEK_SET 0
