diff -Naur patch-2.7.1/build-aux/ar-lib patch-2.7.1-p/build-aux/ar-lib
--- patch-2.7.1/build-aux/ar-lib	2012-04-06 15:41:12 +0400
+++ patch-2.7.1-p/build-aux/ar-lib	2013-02-24 13:43:38 +0400
@@ -53,7 +53,7 @@
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN* | MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -65,7 +65,7 @@
 	mingw)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin)
+	cygwin | msys)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine)
--- patch-2.7.2/build-aux/compile.orig	2015-01-21 16:10:12.538600000 +0300
+++ patch-2.7.2/build-aux/compile	2015-01-21 16:10:30.821800000 +0300
@@ -53,7 +53,7 @@
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN*|MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -67,7 +67,7 @@
 	mingw/*)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin/*)
+	cygwin/*|msys/*)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine/*)
diff -Naur patch-2.7.1/build-aux/config.guess patch-2.7.1-p/build-aux/config.guess
--- patch-2.7.1/build-aux/config.guess	2012-09-28 14:47:37 +0400
+++ patch-2.7.1-p/build-aux/config.guess	2013-02-24 13:43:19 +0400
@@ -805,6 +805,9 @@
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
     *:MINGW64*:*)
 	echo ${UNAME_MACHINE}-pc-mingw64
 	exit ;;
@@ -851,6 +854,9 @@
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	echo x86_64-unknown-cygwin
 	exit ;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-unknown-msys
+	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
 	exit ;;
diff -Naur patch-2.7.1/lib/gnulib.mk patch-2.7.1-p/lib/gnulib.mk
--- patch-2.7.1/lib/gnulib.mk	2012-09-28 20:40:58 +0400
+++ patch-2.7.1-p/lib/gnulib.mk	2013-02-24 13:46:08 +0400
@@ -572,7 +572,7 @@
 	  case '$(host_os)' in \
 	    darwin[56]*) \
 	      need_charset_alias=true ;; \
-	    darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+	    darwin* | cygwin* | msys* | mingw* | pw32* | cegcc*) \
 	      need_charset_alias=false ;; \
 	    *) \
 	      need_charset_alias=true ;; \
diff -Naur patch-2.7.1/m4/double-slash-root.m4 patch-2.7.1-p/m4/double-slash-root.m4
--- patch-2.7.1/m4/double-slash-root.m4	2012-08-01 06:44:13 +0400
+++ patch-2.7.1-p/m4/double-slash-root.m4	2013-02-24 13:47:12 +0400
@@ -16,7 +16,7 @@
         # special semantics and is distinct from /, please report it to
         # <bug-gnulib@gnu.org>.
         case $host in
-          *-cygwin | i370-ibm-openedition)
+          *-cygwin | *-msys | i370-ibm-openedition)
             gl_cv_double_slash_root=yes ;;
           *)
             # Be optimistic and assume that / and // are the same when we
diff -Naur patch-2.7.1/m4/dup2.m4 patch-2.7.1-p/m4/dup2.m4
--- patch-2.7.1/m4/dup2.m4	2012-08-01 06:44:13 +0400
+++ patch-2.7.1-p/m4/dup2.m4	2013-02-24 13:47:28 +0400
@@ -46,7 +46,7 @@
         [case "$host_os" in
            mingw*) # on this platform, dup2 always returns 0 for success
              gl_cv_func_dup2_works="guessing no" ;;
-           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+           cygwin* | msys*) # on cygwin 1.5.x, dup2(1,1) returns 0
              gl_cv_func_dup2_works="guessing no" ;;
            linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
                    # closed fd may yield -EBADF instead of -1 / errno=EBADF.
diff -Naur patch-2.7.1/m4/malloc.m4 patch-2.7.1-p/m4/malloc.m4
--- patch-2.7.1/m4/malloc.m4	2012-08-01 06:44:13 +0400
+++ patch-2.7.1-p/m4/malloc.m4	2013-02-24 13:47:58 +0400
@@ -30,7 +30,7 @@
        [case "$host_os" in
           # Guess yes on platforms where we know the result.
           *-gnu* | gnu* | freebsd* | netbsd* | openbsd* \
-          | hpux* | solaris* | cygwin* | mingw*)
+          | hpux* | solaris* | cygwin* | msys* | mingw*)
             ac_cv_func_malloc_0_nonnull=yes ;;
           # If we don't know, assume the worst.
           *) ac_cv_func_malloc_0_nonnull=no ;;
diff -Naur patch-2.7.1/m4/printf.m4 patch-2.7.1-p/m4/printf.m4
--- patch-2.7.1/m4/printf.m4	2012-08-01 06:44:13 +0400
+++ patch-2.7.1-p/m4/printf.m4	2013-02-24 13:48:31 +0400
@@ -735,7 +735,7 @@
            openbsd*)       gl_cv_func_printf_directive_ls="guessing no";;
            irix*)          gl_cv_func_printf_directive_ls="guessing no";;
            solaris*)       gl_cv_func_printf_directive_ls="guessing no";;
-           cygwin*)        gl_cv_func_printf_directive_ls="guessing no";;
+           cygwin* | msys*)         gl_cv_func_printf_directive_ls="guessing no";;
            beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
                            # Guess yes on native Windows.
            mingw*)         gl_cv_func_printf_directive_ls="guessing yes";;
@@ -812,7 +812,7 @@
         [
 changequote(,)dnl
          case "$host_os" in
-           cygwin*)      gl_cv_func_printf_flag_grouping="guessing no";;
+           cygwin* | msys*)      gl_cv_func_printf_flag_grouping="guessing no";;
            netbsd*)      gl_cv_func_printf_flag_grouping="guessing no";;
            mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
            *)            gl_cv_func_printf_flag_grouping="guessing yes";;
@@ -1464,7 +1464,7 @@
            darwin[1-6].*)        gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
            darwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on Cygwin.
-           cygwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+           cygwin* | msys*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on Solaris >= 2.6.
            solaris2.[0-5] | solaris2.[0-5].*)
                                  gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
diff -Naur patch-2.7.1/m4/realloc.m4 patch-2.7.1-p/m4/realloc.m4
--- patch-2.7.1/m4/realloc.m4	2012-08-01 06:44:13 +0400
+++ patch-2.7.1-p/m4/realloc.m4	2013-02-24 13:48:54 +0400
@@ -30,7 +30,7 @@
        [case "$host_os" in
           # Guess yes on platforms where we know the result.
           *-gnu* | gnu* | freebsd* | netbsd* | openbsd* \
-          | hpux* | solaris* | cygwin* | mingw*)
+          | hpux* | solaris* | cygwin* | msys* | mingw*)
             ac_cv_func_realloc_0_nonnull=yes ;;
           # If we don't know, assume the worst.
           *) ac_cv_func_realloc_0_nonnull=no ;;
diff -Naur patch-2.7.1/src/inp.c patch-2.7.1-p/src/inp.c
--- patch-2.7.1/src/inp.c	2012-09-19 05:07:31 +0400
+++ patch-2.7.1-p/src/inp.c	2013-02-24 13:50:56 +0400
@@ -231,7 +231,11 @@
     {
       if (S_ISREG (instat.st_mode))
         {
+#ifdef __CYGWIN__
+	  int ifd = safe_open (filename, O_RDONLY | (binary_transput ?: O_TEXT), 0);
+#else
 	  int ifd = safe_open (filename, O_RDONLY|binary_transput, 0);
+#endif
 	  size_t buffered = 0, n;
 	  if (ifd < 0)
 	    pfatal ("can't open file %s", quotearg (filename));
diff -Naur patch-2.7.1/src/patch.c patch-2.7.1-p/src/patch.c
--- patch-2.7.1/src/patch.c	2012-09-28 14:43:12 +0400
+++ patch-2.7.1-p/src/patch.c	2013-02-24 13:51:50 +0400
@@ -798,7 +798,11 @@
 "",
 "  -d DIR  --directory=DIR  Change the working directory to DIR first.",
 "  --reject-format=FORMAT  Create 'context' or 'unified' rejects.",
+#ifdef __CYGWIN__
+"  --binary  Read data in binary mode.  Writing data is always binary.",
+#else
 "  --binary  Read and write data in binary mode.",
+#endif
 "  --read-only=BEHAVIOR  How to handle read-only input files: 'ignore' that they",
 "                        are read-only, 'warn' (default), or 'fail'.",
 "",
@@ -1526,9 +1530,15 @@
 static FILE *
 create_output_file (char const *name, int open_flags)
 {
+#ifdef __CYGWIN__
+  int fd = create_file (name, O_WRONLY | O_BINARY | open_flags,
+			instat.st_mode, true);
+  FILE *f = fdopen (fd, "wb");
+#else
   int fd = create_file (name, O_WRONLY | binary_transput | open_flags,
 			instat.st_mode, true);
   FILE *f = fdopen (fd, binary_transput ? "wb" : "w");
+#endif
   if (! f)
     pfatal ("Can't create file %s", quotearg (name));
   return f;
diff -Naur patch-2.7.1/src/pch.c patch-2.7.1-p/src/pch.c
--- patch-2.7.1/src/pch.c	2012-09-22 21:44:33 +0400
+++ patch-2.7.1-p/src/pch.c	2013-02-24 13:54:00 +0400
@@ -124,8 +124,10 @@
 #if HAVE_SETMODE_DOS
     if (binary_transput)
       {
+#ifndef __CYGWIN__
 	if (isatty (fileno (pfp)))
 	  fatal ("cannot read binary data from tty on this platform");
+#endif
 	setmode (fileno (pfp), O_BINARY);
       }
 #endif
@@ -2393,7 +2395,11 @@
 		 verbosity == VERBOSE ? "" : "- ",
 		 outname);
 	fflush (stdout);
+#ifdef __CYGWIN__
+       pipefp = popen(buf, "wb");
+#else
 	pipefp = popen(buf, binary_transput ? "wb" : "w");
+#endif
 	if (!pipefp)
 	  pfatal ("Can't open pipe to %s", quotearg (buf));
     }
