Fix mis-recognition of 'mcs' on QNX 6.
authorBruno Haible <bruno@clisp.org>
Sun, 2 Sep 2007 11:13:02 +0000 (11:13 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Sep 2007 11:13:02 +0000 (11:13 +0000)
ChangeLog
lib/csharpcomp.c
m4/csharpcomp.m4

index d3d1b67cde0ed4bd912d330f99a6e6226c4f89d8..c33fa0cc9a72ef7556642775f376f2621f30bf4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-02  Bruno Haible  <bruno@clisp.org>
+
+       Fix mis-recognition of 'mcs' on QNX 6.
+       * m4/csharpcomp.m4 (gt_CSHARPCOMP): Test whether the "mcs --version"
+       output contains the string "Mono".
+       * lib/csharpcomp.c (compile_csharp_using_mono): Likewise.
+       Reported by <kraai@ftbfs.org> at <https://savannah.gnu.org/bugs/?18337>.
+
 2007-09-01  Bruno Haible  <bruno@clisp.org>
 
        Fix collision between uniwidth/* and linebreak modules.
index 16646dc4638460d2506c61e72b509bc02b8d7ded..486ceeb90b5c1fe833b7f3ddf4202632c76a7054 100644 (file)
@@ -182,16 +182,48 @@ compile_csharp_using_mono (const char * const *sources,
   if (!mcs_tested)
     {
       /* Test for presence of mcs:
-        "mcs --version >/dev/null 2>/dev/null"  */
+        "mcs --version >/dev/null 2>/dev/null"
+        and (to exclude an unrelated 'mcs' program on QNX 6)
+        "mcs --version 2>/dev/null | grep Mono >/dev/null"  */
       char *argv[3];
+      pid_t child;
+      int fd[1];
       int exitstatus;
 
       argv[0] = "mcs";
       argv[1] = "--version";
       argv[2] = NULL;
-      exitstatus = execute ("mcs", "mcs", argv, false, false, true, true, true,
-                           false);
-      mcs_present = (exitstatus == 0);
+      child = create_pipe_in ("mcs", "mcs", argv, DEV_NULL, true, true, false,
+                             fd);
+      mcs_present = false;
+      if (child != -1)
+       {
+         /* Read the subprocess output, and test whether it contains the
+            string "Mono".  */
+         char c[4];
+         size_t count = 0;
+
+         while (safe_read (fd[0], &c[count], 1) > 0)
+           {
+             count++;
+             if (count == 4)
+               {
+                 if (memcmp (c, "Mono", 4) == 0)
+                   mcs_present = true;
+                 c[0] = c[1]; c[1] = c[2]; c[2] = c[3];
+                 count--;
+               }
+           }
+
+         close (fd[0]);
+
+         /* Remove zombie process from process list, and retrieve exit
+            status.  */
+         exitstatus =
+           wait_subprocess (child, "mcs", false, true, true, false);
+         if (exitstatus != 0)
+           mcs_present = false;
+       }
       mcs_tested = true;
     }
 
index dab35a7852d0bcbd0cf3e21f1db36b0fd76b6433..8e66e01bf2b92c000ada7403df80a47b773230e7 100644 (file)
@@ -1,5 +1,5 @@
-# csharpcomp.m4 serial 6 (gettext-0.15)
-dnl Copyright (C) 2003-2005 Free Software Foundation, Inc.
+# csharpcomp.m4 serial 7 (gettext-0.16.2)
+dnl Copyright (C) 2003-2005, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -43,7 +43,8 @@ AC_DEFUN([gt_CSHARPCOMP],
         ;;
       mono)
         if test -n "$HAVE_MCS_IN_PATH" \
-           && mcs --version >/dev/null 2>/dev/null; then
+           && mcs --version >/dev/null 2>/dev/null \
+           && mcs --version 2>/dev/null | grep Mono >/dev/null; then
           HAVE_MCS=1
           ac_result="mcs"
           break