From: Bruno Haible Date: Sun, 2 Sep 2007 11:13:02 +0000 (+0000) Subject: Fix mis-recognition of 'mcs' on QNX 6. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56f199068c8fcb99ace44b286476dea3fe214fe0;p=pspp Fix mis-recognition of 'mcs' on QNX 6. --- diff --git a/ChangeLog b/ChangeLog index d3d1b67cde..c33fa0cc9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-02 Bruno Haible + + 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 at . + 2007-09-01 Bruno Haible Fix collision between uniwidth/* and linebreak modules. diff --git a/lib/csharpcomp.c b/lib/csharpcomp.c index 16646dc463..486ceeb90b 100644 --- a/lib/csharpcomp.c +++ b/lib/csharpcomp.c @@ -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; } diff --git a/m4/csharpcomp.m4 b/m4/csharpcomp.m4 index dab35a7852..8e66e01bf2 100644 --- a/m4/csharpcomp.m4 +++ b/m4/csharpcomp.m4 @@ -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