[Pcre-svn] [868] code/trunk: Set PCRE2GREP_RC to the pcre2gr…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [868] code/trunk: Set PCRE2GREP_RC to the pcre2grep exit status when running under VMS.
Revision: 868
          http://www.exim.org/viewvc/pcre2?view=rev&revision=868
Author:   ph10
Date:     2017-10-11 17:49:10 +0100 (Wed, 11 Oct 2017)
Log Message:
-----------
Set PCRE2GREP_RC to the pcre2grep exit status when running under VMS.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2grep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-09-26 17:01:23 UTC (rev 867)
+++ code/trunk/ChangeLog    2017-10-11 16:49:10 UTC (rev 868)
@@ -26,7 +26,11 @@


8. Added two casts to compile.c and one to match.c to avoid compiler warnings.

+9. Added code to pcre2grep when compiled under VMS to set the symbol
+PCRE2GREP_RC to the exit status, because VMS does not distinguish between
+exit(0) and exit(1).

+
Version 10.30 14-August-2017
----------------------------


Modified: code/trunk/src/pcre2grep.c
===================================================================
--- code/trunk/src/pcre2grep.c    2017-09-26 17:01:23 UTC (rev 867)
+++ code/trunk/src/pcre2grep.c    2017-10-11 16:49:10 UTC (rev 868)
@@ -520,6 +520,22 @@
 static void
 pcre2grep_exit(int rc)
 {
+/* VMS does exit codes differently: both exit(1) and exit(0) return with a
+status of 1, which is not helpful. To help with this problem, define a symbol
+(akin to an environment variable) called "PCRE2GREP_RC" and put the exit code
+therein. */
+
+#ifdef __VMS
+#include descrip
+#include lib$routines
+  char val_buf[4];
+  $DESCRIPTOR(sym_nam, "PCRE2GREP_RC");
+  $DESCRIPTOR(sym_val, val_buf);
+  sprintf(val_buf, "%d", rc);
+  sym_val.dsc$w_length = strlen(val_buf);
+  lib$set_symbol(&sym_nam, &sym_val);
+#endif
+
 if (resource_error)
   {
   fprintf(stderr, "pcre2grep: Error %d, %d, %d or %d means that a resource "