--- src/roff/groff/pipeline.c~	2018-10-11 00:44:56.000000000 +0300
+++ src/roff/groff/pipeline.c	2018-12-27 08:19:21.756598900 +0200
@@ -304,11 +304,13 @@ int run_pipeline(int ncommands, char ***
  	}
       }
     }
-    if ((pid = spawnvp(_P_NOWAIT, commands[i][0], commands[i])) < 0) {
+    if ((pid = spawnvp(no_pipe ? _P_WAIT : _P_NOWAIT,
+		       commands[i][0], commands[i])) < 0) {
       error("couldn't exec %1: %2",
 	    commands[i][0], strerror(errno), (char *)0);
       fflush(stderr);			/* just in case error() doesn't */
-      _exit(EXEC_FAILED_EXIT_STATUS);
+      if (!no_pipe)
+	_exit(EXEC_FAILED_EXIT_STATUS);
     }
     pids[i] = pid;
   }
@@ -326,17 +328,19 @@ int run_pipeline(int ncommands, char ***
     }
   }
 
-  for (i = 0; i < ncommands; i++) {
-    int status;
-    PID_T pid;
-
-    pid = pids[i];
-    if ((pid = WAIT(&status, pid, _WAIT_CHILD)) < 0) {
-      sprintf(err_str, "%s: wait", commands[i][0]);
-      sys_fatal(err_str);
+  if (!no_pipe) {
+    for (i = 0; i < ncommands; i++) {
+      int status;
+      PID_T pid;
+
+      pid = pids[i];
+      if ((pid = WAIT(&status, pid, _WAIT_CHILD)) < 0) {
+	sprintf(err_str, "%s: wait", commands[i][0]);
+	sys_fatal(err_str);
+      }
+      else if (status != 0)
+	ret |= 1;
     }
-    else if (status != 0)
-      ret |= 1;
   }
   return ret;
 }
--- src/roff/groff/groff.cpp~	2018-12-23 16:27:47.000000000 +0200
+++ src/roff/groff/groff.cpp	2018-12-27 08:25:44.691363700 +0200
@@ -228,6 +228,10 @@ int main(int argc, char **argv)
 	"named COPYING.\n");
       printf("\ncalled subprograms:\n\n");
       fflush(stdout);
+      // Pass -v to all possible subprograms
+      commands[PRECONV_INDEX].append_arg(buf);
+      commands[CHEM_INDEX].append_arg(buf);
+      commands[IDEAL_INDEX].append_arg(buf);
       commands[POST_INDEX].append_arg(buf);
       // fall through
     case 'C':
--- src/preproc/preconv/preconv.cpp~0	2018-10-11 00:44:56.000000000 +0300
+++ src/preproc/preconv/preconv.cpp	2018-12-30 09:56:40.782422500 +0200
@@ -1080,6 +1080,7 @@ do_file(const char *filename)
 {
   FILE *fp;
   string BOM, data;
+  char *tmpfn = NULL;
   if (strcmp(filename, "-")) {
     if (debug_flag)
       fprintf(stderr, "file '%s':\n", filename);
@@ -1094,6 +1095,35 @@ do_file(const char *filename)
       fprintf(stderr, "standard input:\n");
     SET_BINARY(fileno(stdin));
     fp = stdin;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    /* Functions that detect encoding seek to and fro into the file,
+       which is not portable with stdin redirected from a pipe, and
+       doesn't work on MS-Windows.  We need to copy input to a
+       temporary file and read from there instead.  */
+    tmpfn = tmpnam (NULL);
+    FILE *tmpfp = fopen(tmpfn, FOPEN_WB);
+    if (!tmpfp) {
+      error("can't open temporary file '%1': %2", tmpfn, strerror(errno));
+      return 0;
+    }
+    unsigned char buf[16 * 1024];
+    size_t bytes_read;
+    while ((bytes_read = fread(buf, 1, sizeof buf, fp)) > 0)
+      fwrite (buf, 1, bytes_read, tmpfp);
+    if (ferror(fp)) {
+      fclose(tmpfp);
+      unlink(tmpfn);
+      error("fread: %s\n", strerror(errno));
+      return 0;
+    }
+    fclose(tmpfp);
+    fp = fopen(tmpfn, FOPEN_RB);
+    if (!fp) {
+      error("can't open '%1' for reading: %2", tmpfn, strerror(errno));
+      unlink(tmpfn);
+      return 0;
+    }
+#endif
   }
   const char *BOM_encoding = get_BOM(fp, BOM, data);
   // Determine the encoding.
@@ -1145,6 +1175,8 @@ do_file(const char *filename)
   if (encoding[0] == '\0') {
     error("encoding '%1' not supported, not a portable encoding",
 	  encoding_string);
+    if (tmpfn)
+      unlink(tmpfn);
     return 0;
   }
   if (debug_flag)
@@ -1173,6 +1205,8 @@ do_file(const char *filename)
   }
   if (fp != stdin)
     fclose(fp);
+  if (tmpfn)
+    unlink(tmpfn);
   return success;
 }
 
@@ -1273,6 +1307,11 @@ main(int argc, char **argv)
       assert(0);
     }
   int nbad = 0;
+  /* We are reading input in BINARY mode, except from console device,
+     so need to switch stdout to BINARY mode also, otherwise we will
+     generate extra CR character at end of each line.  */
+  if (!isatty(fileno(stdin)))
+    SET_BINARY(fileno(stdout));
   if (debug_flag)
     fprintf(stderr, "default encoding: '%s'\n", default_encoding);
   if (optind >= argc)
--- src/libs/libgroff/maxfilename.cpp~0	2018-10-11 00:44:56.000000000 +0300
+++ src/libs/libgroff/maxfilename.cpp	2019-01-12 09:02:01.119500000 +0200
@@ -36,6 +36,11 @@
 
 #else /* not _POSIX_VERSION */
 
+#include <stdio.h>
+#ifdef FILENAME_MAX
+# define NAME_MAX FILENAME_MAX
+#endif
+
 #ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #else /* not HAVE_DIRENT_H */
--- src/libs/libgroff/tmpfile.cpp~0	2019-01-11 21:35:55.790577200 +0200
+++ src/libs/libgroff/tmpfile.cpp	2019-01-12 09:45:02.760125000 +0200
@@ -53,6 +53,16 @@
 size_t tmpfile_prefix_len;
 int use_short_postfix = 0;
 
+#ifdef __MINGW32__
+// MinGW runtime 5.2 has a broken mkstemp.
+extern int gen_tempname(char *, int);
+int mkstemp(char *tmpl)
+{
+  return gen_tempname(tmpl, 0);
+}
+
+#endif
+
 struct temp_init {
   temp_init();
   ~temp_init();
