gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, new-vms, created. gawk-4.1.0-128-g072966


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, new-vms, created. gawk-4.1.0-128-g0729669
Date: Thu, 12 Dec 2013 19:00:24 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, new-vms has been created
        at  07296693d0b748f6e6040f988099177d877f1229 (commit)

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=07296693d0b748f6e6040f988099177d877f1229

commit 07296693d0b748f6e6040f988099177d877f1229
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Dec 12 21:00:00 2013 +0200

    Further changes.

diff --git a/ChangeLog b/ChangeLog
index 9df0284..7ab202a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,6 @@
 
        * io.c (redirect): Add additional VMS error codes.
        (nextfile): Retry open after closing some files.
-       * main.c : VMS needs to fix up argv[0] and timezone.
 
 2013-12-10         Scott Deifik          <address@hidden>
 
diff --git a/main.c b/main.c
index a47b025..4f77510 100644
--- a/main.c
+++ b/main.c
@@ -194,11 +194,6 @@ static const struct option optab[] = {
        { NULL, 0, NULL, '\0' }
 };
 
-/* VMS needs some special fix-ups for the program name */
-#ifdef __VMS
-#include "vms_gawk_main_wrapper.c"
-#endif
-
 /* main --- process args, parse program, run it, clean up */
 
 int
diff --git a/vms/vms_gawk_main_wrapper.c b/vms/vms_gawk_main_wrapper.c
deleted file mode 100644
index 367f0cc..0000000
--- a/vms/vms_gawk_main_wrapper.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/* File: vms_gawk_main_wrapper.c
- *
- * This module provides a wrapper around the main() function of a ported
- * program for two functions:
- *
- * 1. Make sure that the argv[0] string is set as close as possible to
- *    what the original command was given.
- *
- * 2. Make sure that the posix exit is called.
- *
- * 3. Fixup the timezone information.
- *
- * Copyright 2012, John Malmberg
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-#include <descrip.h>
-#include <dvidef.h>
-#include <efndef.h>
-#include <fscndef.h>
-#include <stsdef.h>
-#include <time.h>
-#include <lnmdef.h>
-
-
-#pragma member_alignment save
-#pragma nomember_alignment longword
-struct item_list_3 {
-       unsigned short len;
-       unsigned short code;
-       void * bufadr;
-       unsigned short * retlen;
-};
-
-struct filescan_itmlst_2 {
-    unsigned short length;
-    unsigned short itmcode;
-    char * component;
-};
-
-#pragma member_alignment
-
-int SYS$GETDVIW
-       (unsigned long efn,
-       unsigned short chan,
-       const struct dsc$descriptor_s * devnam,
-       const struct item_list_3 * itmlst,
-       void * iosb,
-       void (* astadr)(unsigned long),
-       unsigned long astprm,
-       void * nullarg);
-
-int SYS$FILESCAN
-   (const struct dsc$descriptor_s * srcstr,
-    struct filescan_itmlst_2 * valuelist,
-    unsigned long * fldflags,
-    struct dsc$descriptor_s *auxout,
-    unsigned short * retlen);
-
-int   SYS$TRNLNM(
-       const unsigned long * attr,
-       const struct dsc$descriptor_s * table_dsc,
-       struct dsc$descriptor_s * name_dsc,
-       const unsigned char * acmode,
-       const struct item_list_3 * item_list);
-
-/* Take all the fun out of simply looking up a logical name */
-static int sys_trnlnm
-   (const char * logname,
-    char * value,
-    int value_len)
-{
-    const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
-    const unsigned long attr = LNM$M_CASE_BLIND;
-    struct dsc$descriptor_s name_dsc;
-    int status;
-    unsigned short result;
-    struct item_list_3 itlst[2];
-
-    itlst[0].len = value_len;
-    itlst[0].code = LNM$_STRING;
-    itlst[0].bufadr = value;
-    itlst[0].retlen = &result;
-
-    itlst[1].len = 0;
-    itlst[1].code = 0;
-
-    name_dsc.dsc$w_length = strlen(logname);
-    name_dsc.dsc$a_pointer = (char *)logname;
-    name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-    name_dsc.dsc$b_class = DSC$K_CLASS_S;
-
-    status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);
-
-    if ($VMS_STATUS_SUCCESS(status)) {
-
-        /* Null terminate and return the string */
-       /*--------------------------------------*/
-       value[result] = '\0';
-    }
-
-    return status;
-}
-
-int original_main(int argc, char ** argv, char **env);
-
-int main(int argc, char ** argv, char **env) {
-int status;
-int result;
-char arg_nam[256];
-char **new_argv;
-char *tz_rule;
-
-#ifdef TEST_MAIN
-    printf("original argv[0] = %s\n", argv[0]);
-#endif
-
-    new_argv = argv;
-    result = 0;
-
-    /* If the path name starts with a /, then it is an absolute path        */
-    /* that may have been generated by the CRTL instead of the command name  */
-    /* If it is the device name between the slashes, then this was likely    */
-    /* from the run command and needs to be fixed up.                       */
-    /* If the DECC$POSIX_COMPLIANT_PATHNAMES is set to 2, then it is the     */
-    /* DISK$VOLUME that will be present, and it will still need to be fixed. */
-    if (argv[0][0] == '/') {
-       char * nextslash;
-       int length;
-       struct item_list_3 itemlist[3];
-       unsigned short dvi_iosb[4];
-       char alldevnam[64];
-       unsigned short alldevnam_len;
-       struct dsc$descriptor_s devname_dsc;
-       char diskvolnam[256];
-       unsigned short diskvolnam_len;
-
-         /* Get some information about the disk */
-       /*--------------------------------------*/
-       itemlist[0].len = (sizeof alldevnam) - 1;
-       itemlist[0].code = DVI$_ALLDEVNAM;
-       itemlist[0].bufadr = alldevnam;
-       itemlist[0].retlen = &alldevnam_len;
-       itemlist[1].len = (sizeof diskvolnam) - 1 - 5;
-       itemlist[1].code = DVI$_VOLNAM;
-       itemlist[1].bufadr = &diskvolnam[5];
-       itemlist[1].retlen = &diskvolnam_len;
-       itemlist[2].len = 0;
-       itemlist[2].code = 0;
-
-       /* Add the prefix for the volume name. */
-       /* SYS$GETDVI will append the volume name to this */
-       strcpy(diskvolnam,"DISK$");
-
-       nextslash = strchr(&argv[0][1], '/');
-       if (nextslash != NULL) {
-           length = nextslash - argv[0] - 1;
-
-           /* Cast needed for HP C compiler diagnostic */
-           devname_dsc.dsc$a_pointer = (char *)&argv[0][1];
-           devname_dsc.dsc$w_length = length;
-           devname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-           devname_dsc.dsc$b_class = DSC$K_CLASS_S;
-
-           status = SYS$GETDVIW
-              (EFN$C_ENF,
-               0,
-               &devname_dsc,
-               itemlist,
-               dvi_iosb,
-               NULL, 0, 0);
-           if (!$VMS_STATUS_SUCCESS(status)) {
-               /* If the sys$getdviw fails, then this path was passed by */
-               /* An exec() program and not from DCL, so do nothing */
-               /* An example is "/tmp/program" where tmp: does not exist */
-#ifdef TEST_MAIN
-               printf("sys$getdviw failed with status %d\n", status);
-#endif
-               result = 0;
-           } else if (!$VMS_STATUS_SUCCESS(dvi_iosb[0])) {
-#ifdef TEST_MAIN
-               printf("sys$getdviw failed with iosb %d\n", dvi_iosb[0]);
-#endif
-               result = 0;
-           } else {
-               char * devnam;
-               int devnam_len;
-               char argv_dev[64];
-
-               /* Null terminate the returned alldevnam */
-               alldevnam[alldevnam_len] = 0;
-               devnam = alldevnam;
-               devnam_len = alldevnam_len;
-
-               /* Need to skip past any leading underscore */
-               if (devnam[0] == '_') {
-                   devnam++;
-                   devnam_len--;
-               }
-
-               /* And remove the trailing colon */
-               if (devnam[devnam_len - 1] == ':') {
-                   devnam_len--;
-                   devnam[devnam_len] = 0;
-               }
-
-               /* Null terminate the returned volnam */
-               diskvolnam_len += 5;
-               diskvolnam[diskvolnam_len] = 0;
-
-               /* Check first for normal CRTL behavior */
-               if (devnam_len == length) {
-                   strncpy(arg_nam, &argv[0][1], length);
-                   arg_nam[length] = 0;
-                   result = (strcasecmp(devnam, arg_nam) == 0);
-               }
-
-               /* If we have not got a match check for POSIX Compliant */
-               /* behavior.  To be more accurate, we could also check */
-               /* to see if that feature is active. */
-               if ((result == 0) && (diskvolnam_len == length)) {
-                   strncpy(arg_nam, &argv[0][1], length);
-                   arg_nam[length] = 0;
-                   result = (strcasecmp(diskvolnam, arg_nam) == 0);
-               }
-           }
-       }
-    } else {
-       /* The path did not start with a slash, so it could be VMS format */
-       /* If it is vms format, it has a volume/device in it as it must   */
-       /* be an absolute path */
-       struct dsc$descriptor_s path_desc;
-       int status;
-       unsigned long field_flags;
-       struct filescan_itmlst_2 item_list[5];
-       char * volume;
-       char * name;
-       int name_len;
-       char * ext;
-
-       path_desc.dsc$a_pointer = (char *)argv[0]; /* cast ok */
-       path_desc.dsc$w_length = strlen(argv[0]);
-       path_desc.dsc$b_dtype = DSC$K_DTYPE_T;
-       path_desc.dsc$b_class = DSC$K_CLASS_S;
-
-       /* Don't actually need to initialize anything buf itmcode */
-       /* I just do not like uninitialized input values */
-
-       /* Sanity check, this must be the same length as input */
-       item_list[0].itmcode = FSCN$_FILESPEC;
-       item_list[0].length = 0;
-       item_list[0].component = NULL;
-
-       /* If the device is present, then it if a VMS spec */
-       item_list[1].itmcode = FSCN$_DEVICE;
-       item_list[1].length = 0;
-       item_list[1].component = NULL;
-
-       /* we need the program name and type */
-       item_list[2].itmcode = FSCN$_NAME;
-       item_list[2].length = 0;
-       item_list[2].component = NULL;
-
-       item_list[3].itmcode = FSCN$_TYPE;
-       item_list[3].length = 0;
-       item_list[3].component = NULL;
-
-       /* End the list */
-       item_list[4].itmcode = 0;
-       item_list[4].length = 0;
-       item_list[4].component = NULL;
-
-       status = SYS$FILESCAN(
-               (const struct dsc$descriptor_s *)&path_desc,
-               item_list, &field_flags, NULL, NULL);
-
-       if ($VMS_STATUS_SUCCESS(status) &&
-          (item_list[0].length == path_desc.dsc$w_length) &&
-          (item_list[1].length != 0)) {
-
-           char * dollar;
-           int keep_ext;
-           int i;
-
-           /* We need the filescan to be successful, */
-           /* same length as input, and a volume to be present */
-
-           /* Need a new argv array */
-           new_argv = malloc((argc + 1) * (sizeof(char *)));
-           new_argv[0] = arg_nam;
-           i = 1;
-           while (i < argc) {
-               new_argv[i] = argv[i];
-               i++;
-           }
-
-           /* We will assume that we only get to this path on a version */
-           /* of VMS that does not support the EFS character set */
-
-           /* There may be a xxx$ prefix on the image name.  Linux */
-           /* programs do not handle that well, so strip the prefix */
-           name = item_list[2].component;
-           name_len = item_list[2].length;
-           dollar = strrchr(name, '$');
-           if (dollar != NULL) {
-               dollar++;
-               name_len = name_len - (dollar - name);
-               name = dollar;
-           }
-
-           strncpy(arg_nam, name, name_len);
-           arg_nam[name_len] = 0;
-
-           /* We only keep the extension if it is not ".exe" */
-           keep_ext = 0;
-           ext = item_list[3].component;
-
-           if (item_list[3].length != 1) {
-               if (item_list[3].length != 4) {
-                   keep_ext = 1;
-               } else {
-                   int x;
-                   x = strncmp(ext, ".exe", 4);
-                   if (x != 0) {
-                       keep_ext = 1;
-                   }
-               }
-           }
-
-           if (keep_ext == 1) {
-               strncpy(&arg_nam[name_len], ext, item_list[3].length);
-           }
-       }
-    }
-
-    if (result) {
-       char * lastslash;
-       char * dollar;
-       char * dotexe;
-       char * lastdot;
-       char * extension;
-
-       /* This means it is probably the name from a DCL command */
-       /* Find the last slash which separates the file from the */
-       /* path. */
-       lastslash = strrchr(argv[0], '/');
-
-       if (lastslash != NULL) {
-           int i;
-
-           lastslash++;
-
-           /* There may be a xxx$ prefix on the image name.  Linux */
-           /* programs do not handle that well, so strip the prefix */
-           dollar = strrchr(lastslash, '$');
-
-           if (dollar != NULL) {
-               dollar++;
-               lastslash = dollar;
-           }
-
-           strcpy(arg_nam, lastslash);
-
-           /* In UNIX mode + EFS character set, there should not be a */
-           /* version present, as it is not possible when parsing to  */
-           /* tell if it is a version or part of the UNIX filename as */
-           /* UNIX programs use numeric extensions for many reasons.  */
-
-           lastdot = strrchr(arg_nam, '.');
-           if (lastdot != NULL) {
-               int i;
-
-               i = 1;
-               while (isdigit(lastdot[i])) {
-                   i++;
-               }
-               if (lastdot[i] == 0) {
-                   *lastdot = 0;
-               }
-           }
-
-           /* Find the .exe on the name (case insenstive) and toss it */
-           dotexe = strrchr(arg_nam, '.');
-           if (dotexe != NULL) {
-               if ((dotexe[1] == 'e' || dotexe[1] == 'E') &&
-                   (dotexe[2] == 'x' || dotexe[2] == 'X') &&
-                   (dotexe[3] == 'e' || dotexe[3] == 'E') &&
-                   (dotexe[4] == 0)) {
-
-                   *dotexe = 0;
-               } else {
-                   /* Also need to handle a null extension because of a */
-                   /* CRTL bug. */
-                   if (dotexe[1] == 0) {
-                       *dotexe = 0;
-                   }
-               }
-           }
-
-           /* Need a new argv array */
-           new_argv = malloc((argc + 1) * (sizeof(char *)));
-           new_argv[0] = arg_nam;
-           i = 1;
-           while (i < argc) {
-               new_argv[i] = argv[i];
-               i++;
-           }
-           new_argv[i] = 0;
-
-       } else {
-           /* There is no way that the code should ever get here */
-           /* As we already verified that the '/' was present */
-           fprintf(stderr, "Sanity failure somewhere we lost a '/'\n");
-       }
-
-    }
-
-    /*
-     * The vms_main_wrapper fixes up the name, but for the DCL shell
-     * may leave it in upper case, which messes up the self tests.
-     * force it to lower case here.
-     */
-    char * shell;
-    int lcname = 0;
-    shell = getenv("SHELL");
-    if (shell != NULL) {
-        if (strcmp(shell, "DCL") == 0) {
-            lcname = 1;
-        }
-    } else {
-        lcname = 1;
-    }
-    if (lcname == 1) {
-        int i = 0;
-        while (new_argv[0][i] != 0) {
-               new_argv[0][i] = tolower(new_argv[0][i]);
-            i++;
-        }
-    }
-
-    /* Fix up the time zone */
-    tz_rule = malloc(1024);
-    status = sys_trnlnm("TZ", tz_rule, 1024);
-    if ($VMS_STATUS_SUCCESS(status)) {
-        setenv("TZ", tz_rule, 1);
-    } else {
-        status = sys_trnlnm("SYS$TIMEZONE_RULE", tz_rule, 1024);
-        if ($VMS_STATUS_SUCCESS(status)) {
-            setenv("TZ", tz_rule, 1);
-        }
-    }
-    free(tz_rule);
-
-    exit(original_main(argc, new_argv, env));
-    return 1; /* Needed to silence compiler diagnostic */
-}
-
-#define main original_main
-
-#ifdef TEST_MAIN
-
-int main(int argc, char ** argv, char **env) {
-
-    printf("modified argv[0] = %s\n", argv[0]);
-
-    return 0;
-}
-
-#endif

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=25e276741ea0a8fb6503a4c060610827dac55825

commit 25e276741ea0a8fb6503a4c060610827dac55825
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Dec 12 20:54:30 2013 +0200

    Next set of changes.

diff --git a/vms/ChangeLog b/vms/ChangeLog
index afcdf89..b941fbe 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-10         John E. Malmberg    <address@hidden>
+
+       * gawkmisc.mvs: Add lots of includes.
+       (sys_trnlnm): New function.
+       (gawk_name): Improved.
+       (os_arg_fixup): Fix up time zone.
+
 2013-12-08        John E. Malmberg     <address@hidden>
 
        * descrip.mms: Add IEEE float for non-vax.
diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms
index bee0b96..046c516 100644
--- a/vms/gawkmisc.vms
+++ b/vms/gawkmisc.vms
@@ -23,30 +23,446 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA
  */
 
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <descrip.h>
+#include <dvidef.h>
+#include <efndef.h>
+#include <fscndef.h>
+#include <stsdef.h>
+#include <time.h>
+#include <lnmdef.h>
+
+
+#pragma member_alignment save
+#pragma nomember_alignment longword
+struct item_list_3 {
+       unsigned short len;
+       unsigned short code;
+       void * bufadr;
+       unsigned short * retlen;
+};
+
+struct filescan_itmlst_2 {
+    unsigned short length;
+    unsigned short itmcode;
+    char * component;
+};
+
+#pragma member_alignment
+
+int SYS$GETDVIW(
+        unsigned long efn,
+        unsigned short chan,
+        const struct dsc$descriptor_s * devnam,
+        const struct item_list_3 * itmlst,
+        void * iosb,
+        void (* astadr)(unsigned long),
+        unsigned long astprm,
+        void * nullarg);
+
+int SYS$FILESCAN(
+        const struct dsc$descriptor_s * srcstr,
+        struct filescan_itmlst_2 * valuelist,
+        unsigned long * fldflags,
+        struct dsc$descriptor_s *auxout,
+        unsigned short * retlen);
+
+int   SYS$TRNLNM(
+        const unsigned long * attr,
+        const struct dsc$descriptor_s * table_dsc,
+        struct dsc$descriptor_s * name_dsc,
+        const unsigned char * acmode,
+        const struct item_list_3 * item_list);
+
 char quote = '\'';
 char *defpath = DEFPATH;
 char *deflibpath = DEFLIBPATH;
 char envsep  = ',';
+#define VMS_NAME_LEN 1
+static char vms_name[VMS_NAME_LEN+1];
+
+/* Take all the fun out of simply looking up a logical name */
+static int sys_trnlnm
+   (const char * logname,
+    char * value,
+    int value_len)
+{
+       const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
+       const unsigned long attr = LNM$M_CASE_BLIND;
+       struct dsc$descriptor_s name_dsc;
+       int status;
+       unsigned short result;
+       struct item_list_3 itlst[2];
+
+       itlst[0].len = value_len;
+       itlst[0].code = LNM$_STRING;
+       itlst[0].bufadr = value;
+       itlst[0].retlen = &result;
+
+       itlst[1].len = 0;
+       itlst[1].code = 0;
+
+       name_dsc.dsc$w_length = strlen(logname);
+       name_dsc.dsc$a_pointer = (char *)logname;
+       name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+       name_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+       status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);
+
+       if ($VMS_STATUS_SUCCESS(status)) {
+
+               /* Null terminate and return the string */
+               value[result] = '\0';
+       }
+
+       return status;
+}
+
 
 /* gawk_name --- pull out the "gawk" part from how the OS called us */
 
+/* You would not think that this should be a such a problem, but
+ * VMS extended file specifications are tricky to parse, and we have
+ * to tell the difference between a CRTL generated argv[0] and a
+ * passed exec() argv[0] and handle both cases.
+ */
+
 char *
 gawk_name(filespec)
 const char *filespec;
 {
-       char *p, *q;
+       int status;
+       int result;
+       char * shell;
+       int lcname = 0;
+
+       /* If the path name starts with a /, then it is an absolute path
+        * that may have been generated by the CRTL instead of the command
+        * name.  If it is the device name between the slashes, then this
+        * was likely from the run command and needs to be fixed up.
+        * If the DECC$POSIX_COMPLIANT_PATHNAMES is set to 2, then it is
+        * the DISK$VOLUME that will be present, and it will still need to
+        * be fixed.
+        */
 
-       /* "device:[root.][directory.subdir]GAWK.EXE;n" -> "GAWK" */
-       p = strrchr(filespec, ']');  /* directory punctuation */
-       q = strrchr(filespec, '>');  /* alternate <international> punct */
+       if (filespec[0] == '/') {
+               char * nextslash;
+               int length;
+               struct item_list_3 itemlist[3];
+               unsigned short dvi_iosb[4];
+               char alldevnam[64];
+               unsigned short alldevnam_len;
+               struct dsc$descriptor_s devname_dsc;
+               char diskvolnam[256];
+               unsigned short diskvolnam_len;
+
+                /* Get some information about the disk */
+               /*--------------------------------------*/
+               itemlist[0].len = (sizeof alldevnam) - 1;
+               itemlist[0].code = DVI$_ALLDEVNAM;
+               itemlist[0].bufadr = alldevnam;
+               itemlist[0].retlen = &alldevnam_len;
+               itemlist[1].len = (sizeof diskvolnam) - 1 - 5;
+               itemlist[1].code = DVI$_VOLNAM;
+               itemlist[1].bufadr = &diskvolnam[5];
+               itemlist[1].retlen = &diskvolnam_len;
+               itemlist[2].len = 0;
+               itemlist[2].code = 0;
+
+               /* Add the prefix for the volume name. */
+               /* SYS$GETDVI will append the volume name to this */
+               strcpy(diskvolnam,"DISK$");
+
+               nextslash = strchr(&filespec[1], '/');
+               if (nextslash != NULL) {
+                       length = nextslash - filespec - 1;
+
+                       /* DECC requires a cast here */
+                       devname_dsc.dsc$a_pointer = (char *)&filespec[1];
+                       devname_dsc.dsc$w_length = length;
+                       devname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+                       devname_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+                       status = SYS$GETDVIW(
+                               EFN$C_ENF,
+                               0,
+                               &devname_dsc,
+                               itemlist,
+                               dvi_iosb,
+                               NULL, 0, 0);
+                       if (!$VMS_STATUS_SUCCESS(status)) {
+                               /* If the sys$getdviw fails, then this path
+                                * was passed by an exec() program and not
+                                * from DCL, so do nothing.
+                                * An example is "/tmp/program" where tmp:
+                                * does not exist
+                                */
+                               result = 0;
+                       } else if (!$VMS_STATUS_SUCCESS(dvi_iosb[0])) {
+                               result = 0;
+                       } else {
+                               char * devnam;
+                               int devnam_len;
+                               char argv_dev[64];
+
+                               /* Null terminate the returned alldevnam */
+                               alldevnam[alldevnam_len] = 0;
+                               devnam = alldevnam;
+                               devnam_len = alldevnam_len;
+
+                               /* Need to skip past any leading underscore */
+                               if (devnam[0] == '_') {
+                                       devnam++;
+                                       devnam_len--;
+                               }
+
+                               /* And remove the trailing colon */
+                               if (devnam[devnam_len - 1] == ':') {
+                                       devnam_len--;
+                                       devnam[devnam_len] = 0;
+                               }
+
+                               /* Null terminate the returned volnam */
+                               diskvolnam_len += 5;
+                               diskvolnam[diskvolnam_len] = 0;
+
+                               /* Check first for normal CRTL behavior */
+                               if (devnam_len == length) {
+                                       strncpy(vms_name, &filespec[1], length);
+                               vms_name[length] = 0;
+                               result = (strcasecmp(devnam, vms_name) == 0);
+                               }
+
+                               /* If we have not got a match check for
+                                * POSIX Compliant behavior.  To be more
+                                * accurate, we could also check to see
+                                * if that feature is active.
+                                */
+                               if ((result == 0) &&
+                                   (diskvolnam_len == length)) {
+                                       int cmp;
+                                       strncpy(vms_name, &filespec[1], length);
+                                       vms_name[length] = 0;
+                                       cmp = strcasecmp(diskvolnam, vms_name);
+                                       result = (cmp == 0);
+                               }
+                       }
+               }
+       } else {
+               /* The path did not start with a slash, so it could be VMS
+                * format.  If it is vms format, it has a volume/device in
+                * it as it must be an absolute path
+                */
+               struct dsc$descriptor_s path_desc;
+               int status;
+               unsigned long field_flags;
+               struct filescan_itmlst_2 item_list[5];
+               char * volume;
+               char * name;
+               int name_len;
+               char * ext;
+
+               /* DECC requires a cast here */
+               path_desc.dsc$a_pointer = (char *)filespec;
+               path_desc.dsc$w_length = strlen(filespec);
+               path_desc.dsc$b_dtype = DSC$K_DTYPE_T;
+               path_desc.dsc$b_class = DSC$K_CLASS_S;
+
+               /* Don't actually need to initialize anything buf itmcode */
+               /* I just do not like uninitialized input values */
+
+               /* Sanity check, this must be the same length as input */
+               item_list[0].itmcode = FSCN$_FILESPEC;
+               item_list[0].length = 0;
+               item_list[0].component = NULL;
+
+               /* If the device is present, then it if a VMS spec */
+               item_list[1].itmcode = FSCN$_DEVICE;
+               item_list[1].length = 0;
+               item_list[1].component = NULL;
+
+               /* we need the program name and type */
+               item_list[2].itmcode = FSCN$_NAME;
+               item_list[2].length = 0;
+               item_list[2].component = NULL;
+
+               item_list[3].itmcode = FSCN$_TYPE;
+               item_list[3].length = 0;
+               item_list[3].component = NULL;
+
+               /* End the list */
+               item_list[4].itmcode = 0;
+               item_list[4].length = 0;
+               item_list[4].component = NULL;
+
+               status = SYS$FILESCAN(
+                   (const struct dsc$descriptor_s *)&path_desc,
+                    item_list, &field_flags, NULL, NULL);
+
+               if ($VMS_STATUS_SUCCESS(status) &&
+                  (item_list[0].length == path_desc.dsc$w_length) &&
+                  (item_list[1].length != 0)) {
+
+                       char * dollar;
+                       int keep_ext;
+                       int i;
+
+                       /* We need the filescan to be successful,
+                        * same length as input, and a volume to be present.
+                        *
+                        * We will assume that we only get to this path on
+                        * a version of VMS that does not support the EFS
+                        * character set.
+                        *
+                        * There may be a xxx$ prefix on the image name.
+                        * Linux  programs do not handle that well, so
+                        * strip the prefix.
+                        */
+                       name = item_list[2].component;
+                       name_len = item_list[2].length;
+                       dollar = strrchr(name, '$');
+                       if (dollar != NULL) {
+                               dollar++;
+                               name_len = name_len - (dollar - name);
+                               name = dollar;
+                       }
+
+                       strncpy(vms_name, name, name_len);
+                       vms_name[name_len] = 0;
+
+                       /* We only keep the extension if it is not ".exe" */
+                       keep_ext = 0;
+                       ext = item_list[3].component;
+
+                       if (item_list[3].length != 1) {
+                               if (item_list[3].length != 4) {
+                                       keep_ext = 1;
+                               } else {
+                                       int x;
+                                       x = strncmp(ext, ".exe", 4);
+                                       if (x != 0) {
+                                               keep_ext = 1;
+                                       }
+                               }
+                       }
+
+                       if (keep_ext == 1) {
+                               strncpy(&vms_name[name_len],
+                                       ext, item_list[3].length);
+                       }
+               }
+       }
+
+       if (result) {
+               char * lastslash;
+               char * dollar;
+               char * dotexe;
+               char * lastdot;
+               char * extension;
+
+               /* This means it is probably the name from a DCL command
+                * Find the last slash which separates the file from the
+                * path.
+                */
+               lastslash = strrchr(filespec, '/');
+
+               if (lastslash != NULL) {
+                       int i;
+
+                       lastslash++;
+
+                       /* There may be a xxx$ prefix on the image name. */
+                       /* Linux programs do not handle that well, so    */
+                       /* strip the prefix */
+                       dollar = strrchr(lastslash, '$');
+
+                       if (dollar != NULL) {
+                               dollar++;
+                               lastslash = dollar;
+                       }
+
+                       strcpy(vms_name, lastslash);
+
+                       /* In UNIX mode + EFS character set, there should
+                        * not be a version present, as it is not possible
+                        * when parsing to tell if it is a version or part
+                        * of the UNIX filename as UNIX programs use numeric
+                        * extensions for many reasons.
+                        */
+
+                       lastdot = strrchr(vms_name, '.');
+                       if (lastdot != NULL) {
+                               int i;
+
+                               i = 1;
+                               while (isdigit(lastdot[i])) {
+                                       i++;
+                               }
+                               if (lastdot[i] == 0) {
+                                       *lastdot = 0;
+                               }
+                       }
+
+                       /* Find the .exe on the name (case insenstive)
+                        * and toss it
+                        */
+                       dotexe = strrchr(vms_name, '.');
+                       if (dotexe != NULL) {
+                               if ((dotexe[1] == 'e' || dotexe[1] == 'E') &&
+                                   (dotexe[2] == 'x' || dotexe[2] == 'X') &&
+                                   (dotexe[3] == 'e' || dotexe[3] == 'E') &&
+                                   (dotexe[4] == 0)) {
+
+                                       *dotexe = 0;
+                               } else {
+                                       /* Also need to handle a null
+                                        * extension because of a CRTL bug.
+                                        */
+                                       if (dotexe[1] == 0) {
+                                               *dotexe = 0;
+                                       }
+                               }
+                       }
+
+               } else {
+                       /* There is no way that the code should ever get here
+                        * As we already verified that the '/' was present
+                        */
+                       fprintf(stderr,
+                               "Sanity failure somewhere we lost a '/'\n");
+               }
+       } else {
+               /* No changes needed */
+               strncpy(vms_name, filespec, VMS_NAME_LEN);
+               vms_name[VMS_NAME_LEN] = 0;
+       }
 
-       if (p == NULL || q > p)
-               p = q;
-       p = strdup(p == NULL ? filespec : (p + 1));
-       if ((q = strrchr(p, '.')) != NULL)
-               *q = '\0';  /* strip .typ;vers */
 
-       return p;
+       /*
+        * The above fixes up the name, but for the DCL shell
+        * may leave it in upper case, which messes up the self tests.
+        * force it to lower case here.
+        */
+       shell = getenv("SHELL");
+       if (shell != NULL) {
+               if (strcmp(shell, "DCL") == 0) {
+                       lcname = 1;
+               }
+       } else {
+               lcname = 1;
+       }
+       if (lcname == 1) {
+               int i = 0;
+               while (vms_name[i] != 0) {
+                       vms_name[i] = tolower(vms_name[i]);
+                       i++;
+               }
+       }
+       return vms_name;
 }
 
 /* os_arg_fixup --- fixup the command line */
@@ -56,7 +472,24 @@ os_arg_fixup(argcp, argvp)
 int *argcp;
 char ***argvp;
 {
+       char *tz_rule;
+       int status;
+
        (void) vms_arg_fixup(argcp, argvp);
+
+       /* Fix up the time zone */
+       /* For some reason it gets trashed */
+       tz_rule = malloc(1024);
+       status = sys_trnlnm("TZ", tz_rule, 1024);
+       if ($VMS_STATUS_SUCCESS(status)) {
+               setenv("TZ", tz_rule, 1);
+       } else {
+               status = sys_trnlnm("SYS$TIMEZONE_RULE", tz_rule, 1024);
+               if ($VMS_STATUS_SUCCESS(status)) {
+                       setenv("TZ", tz_rule, 1);
+               }
+       }
+       free(tz_rule);
 }
 
 /* os_devopen --- open special per-OS devices */

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=9953f4cee02f2781ee5da2e42bcb837c1a849cb0

commit 9953f4cee02f2781ee5da2e42bcb837c1a849cb0
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Dec 12 20:45:59 2013 +0200

    First round of VMS changes.

diff --git a/ChangeLog b/ChangeLog
index 88bf4c2..9df0284 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-12         John E. Malmberg      <address@hidden>
+
+       * io.c (redirect): Add additional VMS error codes.
+       (nextfile): Retry open after closing some files.
+       * main.c : VMS needs to fix up argv[0] and timezone.
+
 2013-12-10         Scott Deifik          <address@hidden>
 
        * io.c (closemaybesocket): Add definition for DJGPP.
diff --git a/README_d/ChangeLog b/README_d/ChangeLog
index 49c30f1..5068111 100644
--- a/README_d/ChangeLog
+++ b/README_d/ChangeLog
@@ -1,3 +1,6 @@
+2013-12-05        John E. Malmberg     <address@hidden>
+       * readme.vms: updated with current build information.
+
 2013-07-02         Arnold D. Robbins     <address@hidden>
 
        * README.pc: Update that |& also now works on MinGW.
diff --git a/README_d/README.VMS b/README_d/README.VMS
index b47cb0f..84bfe2f 100644
--- a/README_d/README.VMS
+++ b/README_d/README.VMS
@@ -6,21 +6,36 @@ CC and LINK commands, and there's also a Makefile for use 
with the MMS
 utility.  From the source directory, use either
  |$ @[.VMS]VMSBUILD.COM
 or
- |$ MMS/DECRIPTION=[.VMS]DECSRIP.MMS GAWK
+ |$ MMS/DESCRIPTION=[.VMS]DESCRIP.MMS gawk
+or
+ |$ MMK/DESCRIPTION=[.VMS]DESCRIP.MMS gawk
+
+Note that on IA64 and Alpha the case of the target may be important.
 
 DEC C  -- use either vmsbuild.com or descrip.mms as is.
+       DEC C is also known as Compaq C and HP C.
+
 VAX C  -- use address@hidden VAXC' or `MMS/MACRO=("VAXC")'.  On a system
         with both VAX C and DEC C installed where DEC C is the default,
         use `MMS/MACRO=("VAXC","CC=CC/VAXC")' for the MMS variant; for
         the vmsbuild.com variant, any need for `/VAXC' will be detected
         automatically.
+        * IMPORTANT NOTE * VAX C should not be used on VAX/VMS 5.5-2 and
+        later.  Use DEC C instead.
+
 GNU C  -- use address@hidden GNUC' or `MMS/MACRO=("GNUC")'.  On a system
         where the GCC command is not already defined, use either
         address@hidden GNUC DO_GNUC_SETUP' or
         `MMS/MACRO=("GNUC","DO_GNUC_SETUP")'.
 
-     Tested under Alpha/VMS V7.1 using DEC C V6.4.  GAWK should work
-without modifications for VMS V4.6 and up.
+Most recent builds are using:
+    OpenVMS VAX 7.3 using DEC C 6.4
+    OpenVMS Alpha 8.3 using HP C V 7.3
+    OpenVMS Alpha 8.4 using HP C V 7.3
+    OpenVMS IA64 8.4 using HP C V 7.3
+
+GAWK was originally ported for VMS V4.6 and up.  It has not been tested
+with a release that old for some time.
 
 
 Installing GAWK on VMS:
@@ -79,9 +94,3 @@ separated list of directory specifications.  When defining 
it, the
 value should be quoted so that it retains a single translation, not a
 multi-translation RMS searchlist.
 
-------------------------------
-Thu Jun 18 05:22:10 IDT 2009
-============================
-
-On OpenVMS V7.3 (Alpha) the "manyfiles" test is known to fail. The reason
-is not (yet) known.
diff --git a/io.c b/io.c
index 4f24453..ac1855b 100644
--- a/io.c
+++ b/io.c
@@ -121,6 +121,11 @@
 #endif
 
 #if defined(VMS)
+#include <ssdef.h>
+#ifndef SS$_EXBYTLM
+#define SS$_EXBYTLM 0x2a14  /* VMS 8.4 seen */
+#endif
+#include <rmsdef.h>
 #define closemaybesocket(fd)   close(fd)
 #endif
 
@@ -462,6 +467,11 @@ nextfile(IOBUF **curfile, bool skipping)
                        /* IOBUF management: */
                        errno = 0;
                        fd = devopen(fname, binmode("r"));
+                       if (fd == INVALID_HANDLE && errno == EMFILE) {
+                               close_one();
+                               close_one();
+                               fd = devopen(fname, binmode("r"));
+                       }
                        errcode = errno;
                        if (! do_traditional)
                                update_ERRNO_int(errno);
@@ -948,13 +958,13 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
                        if (errno == EMFILE || errno == ENFILE)
                                close_one();
 #ifdef VMS
-                       /* Alpha/VMS V7.1's C RTL is returning this instead
+                       /* Alpha/VMS V7.1+ C RTL is returning these instead
                           of EMFILE (haven't tried other post-V6.2 systems) */
-#define SS$_EXQUOTA 0x001C
-#define SS$_EXBYTLM 0x2a14  /* VMS 8.4 seen */
-                       else if (errno == EIO && 
+                       else if ((errno == EIO || errno == EVMSERR) && 
                                  (vaxc$errno == SS$_EXQUOTA ||
-                                  vaxc$errno == SS$_EXBYTLM))
+                                  vaxc$errno == SS$_EXBYTLM ||
+                                  vaxc$errno == RMS$_ACC ||
+                                 vaxc$errno == RMS$_SYN))
                                close_one();
 #endif
                        else {
diff --git a/main.c b/main.c
index e0bc195..a47b025 100644
--- a/main.c
+++ b/main.c
@@ -194,6 +194,10 @@ static const struct option optab[] = {
        { NULL, 0, NULL, '\0' }
 };
 
+/* VMS needs some special fix-ups for the program name */
+#ifdef __VMS
+#include "vms_gawk_main_wrapper.c"
+#endif
 
 /* main --- process args, parse program, run it, clean up */
 
diff --git a/vms/ChangeLog b/vms/ChangeLog
index f834465..afcdf89 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,3 +1,36 @@
+2013-12-08        John E. Malmberg     <address@hidden>
+
+       * descrip.mms: Add IEEE float for non-vax.
+         Add vms_crtl_init.c.
+         Remove code to generate version.c
+       * generate_config_vms_h_gawk.com (__attribute__): Removed
+         definition from here.
+       * version_c.com: removed no longer used.
+       * vmsbuild.com: Add IEEE float for non-vax.
+         Add vms_crtl_init.c
+         Remove code to generate version.c
+         Changes that should have been in the previous commit.
+       * vms_misc.c (vms_open): VMS CRTL for 8.3 Alpha is setting
+         errno to ENOENT instead of EISDIR for ".".
+
+2013-12-05        John E. Malmberg     <address@hidden>
+
+       * New config_h.com to generate config.h
+       * New gawk_ident.com generates ident line for link option file.
+       * Add version_c.com to create version.c from version.in.
+       * Remove fcntl.h covering up real fcntl.h.  If an older version
+         of VMS needs this file, the build procedure should be updated
+         to generate it from a template.
+       * descrip.mms: Use command files to generate files based
+         on same input files as a Linux build.
+       * gawkmisc.vms (files_are_same): support _USE_STD_STAT for VMS 8.x.
+       * generate_config_vms_h_gawk.com: Generates a helper file
+         config_vms.h to cover issues config_h.com can not handle.
+       * vmsbuild.com: Use command files to generate files based
+         on the same input files as a Linux build.
+       * vms_misc.c (vms_open): VMS CRTL setting errno to ENOENT where
+         it should be set to EMFILE.
+
 2013-12-06         Arnold D. Robbins     <address@hidden>
 
        * vms-conf.h (__attribute__): Removed definition from here; fixed
diff --git a/vms/config_h.com b/vms/config_h.com
new file mode 100644
index 0000000..406e126
--- /dev/null
+++ b/vms/config_h.com
@@ -0,0 +1,1652 @@
+$! File: config_h.com
+$!
+$! $Id: config_h.com,v 1.1.1.1 2012/12/02 19:25:21 wb8tyw Exp $
+$!
+$! This procedure attempts to figure out how to build a config.h file
+$! for the current project.
+$!
+$! The P1 parameter of "NOBUILTINS" inhibits the default #include <builtins.h>
+$! that is normally added.  This include can cause side effects if
+$! special VMS compiler settings are used.
+$!
+$! The CONFIGURE shell script will be examined for hints and a few symbols
+$! but most of the tests will not produce valid results on OpenVMS.  Some
+$! will produce false positives and some will produce false negatives.
+$!
+$! It is easier to just read the config.h_in file and make up tests based
+$! on what is in it!
+$!
+$! This file will create an empty config_vms.h file if one does not exist.
+$! The config_vms.h is intended for manual edits to handle things that
+$! this procedure can not.
+$!
+$! The config_vms.h will be invoked by the resulting config.h file.
+$!
+$! This procedure knows about the DEC C RTL on the system it is on.
+$! Future versions may be handle the GNV, the OpenVMS porting library,
+$! and others.
+$!
+$! This procedure may not guess the options correctly for all architectures,
+$! and is a work in progress.
+$!
+$! Copyright 2011, John Malmberg
+$!
+$! Permission to use, copy, modify, and/or distribute this software for any
+$! purpose with or without fee is hereby granted, provided that the above
+$! copyright notice and this permission notice appear in all copies.
+$!
+$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+$!
+$! 15-Jan-2001 J. Malmberg     Original
+$! 29-Apr-2001 J. Malmberg     Also look for config.*in* in a [.include]
+$!                             subdirectory
+$! 30-Apr-2001 J. Malmberg     Update for SAMBA checks
+$! 09-Apr-2005 J. Malmberg     Update for RSYNC and large file.
+$! 29-Sep-2011 J. Malmberg     Update for Bash 4.2
+$! 01-Mar-2012 J. Malmberg     Warn about getcwd(0,0)
+$! 21-Dec-2012 J. Malmberg     Update for gawk
+$!============================================================================
+$!
+$ss_normal = 1
+$ss_abort = 44
+$ss_control_y = 1556
+$status = ss_normal
+$on control_y then goto control_y
+$on warning then goto general_error
+$!
+$! Some information for writing timestamps to created files
+$!----------------------------------------------------------
+$my_proc = f$environment("PROCEDURE")
+$my_proc_file = f$parse(my_proc,,,"NAME") + f$parse(my_proc,,,"TYPE")
+$tab[0,8] = 9
+$datetime = f$element(0,".",f$cvtime(,"ABSOLUTE","DATETIME"))
+$username = f$edit(f$getjpi("","USERNAME"),"TRIM")
+$!
+$pid = f$getjpi("","PID")
+$tfile1 = "SYS$SCRATCH:config_h_temp1_''pid'.TEMP"
+$dchfile = "SYS$SCRATCH:config_h_decc_''pid'.TEMP"
+$configure_script = "SYS$SCRATCH:configure_script_''pid'.TEMP"
+$!
+$!  Get the system type
+$!----------------------
+$arch_type = f$getsyi("arch_type")
+$!
+$! Does config_vms.h exist?
+$!-------------------------
+$update_config_vms = 0
+$file = f$search("sys$disk:[]config_vms.h")
+$if file .nes. ""
+$then
+$   write sys$output "Found existing custom file ''file'."
+$else
+$   update_config_vms = 1
+$   write sys$output "Creating new sys$disk:[]config_vms.h for you."
+$   gosub write_config_vms
+$endif
+$!
+$!
+$! On some platforms, DCL search has problems with searching a file
+$! on a NFS mounted volume.  So copy it to sys$scratch:
+$!
+$if f$search(configure_script) .nes. "" then delete 'configure_script';*
+$copy PRJ_ROOT:configure 'configure_script'
+$!
+$!
+$! Write out the header
+$!----------------------
+$gosub write_config_h_header
+$!
+$!
+$!
+$! config.h.in could have at least five different names depending
+$! on how it was transferred to OpenVMS
+$!------------------------------------------------------------------
+$cfile = f$search("sys$disk:[]config.h.in")
+$if cfile .eqs. ""
+$then
+$   cfile = f$search("sys$disk:[]config.h_in")
+$   if cfile .eqs. ""
+$   then
+$      cfile = f$search("sys$disk:[]configh.in")
+$      if cfile .eqs. ""
+$      then
+$          cfile = f$search("sys$disk:[]config__2eh.in")
+$          if cfile .eqs. ""
+$          then
+$              cfile = f$search("sys$disk:[]config.h__2ein")
+$          endif
+$      endif
+$   endif
+$endif
+$if f$trnlnm("PRJ_INCLUDE") .nes. ""
+$then
+$   cfile = f$search("PRJ_INCLUDE:config.h.in")
+$   if cfile .eqs. ""
+$   then
+$      cfile = f$search("PRJ_INCLUDE:config.h_in")
+$      if cfile .eqs. ""
+$      then
+$          cfile = f$search("PRJ_INCLUDE:config__2eh.in")
+$          if cfile .eqs. ""
+$          then
+$              cfile = f$search("PRJ_INCLUDE:config__2eh.in")
+$              if cfile .eqs. ""
+$              then
+$                  cfile = f$search("PRJ_INCLUDE:config.h__2ein")
+$              endif
+$          endif
+$      endif
+$    endif
+$endif
+$if cfile .eqs. ""
+$then
+$   write sys$output "Can not find sys$disk:config.h.in"
+$   line_out = "Looked for config.h.in, config.h_in, configh.in, "
+$   line_out = line_out + "config__2eh.in, "config.h__2ein"
+$   write/symbol sys$output line_out
+$   if f$trnlnm("PRJ_INCLUDE") .nes. ""
+$   then
+$      write sys$output "Also looked in PRJ_INCLUDE: for these files."
+$   endif
+$!
+$   write tf ""
+$   write tf -
+       "   /* Could not find sys$disk:config.h.in                           */"
+$   write tf -
+       "  /*  Looked also for config.h_in, configh.in, config__2eh.in,     */"
+$   write tf -
+       " /*   config.h__2ein                                              */"
+$   if f$trnlnm("PRJ_INCLUDE") .nes. ""
+$   then
+$      write tf -
+       " /* Also looked in PRJ_INCLUDE: for these files.                 */"
+$   endif
+$   write tf -
+       "/*--------------------------------------------------------------*/
+$   write tf ""
+$   goto write_tail
+$endif
+$!
+$!
+$! Locate the DECC libraries in use
+$!-----------------------------------
+$decc_rtldef = f$parse("decc$rtldef","sys$library:.tlb;0")
+$decc_shr = f$parse("decc$shr","sys$share:.exe;0")
+$!
+$! Dump the DECC header names into a file
+$!----------------------------------------
+$if f$search(dchfile) .nes. "" then delete 'dchfile';*
+$if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$define/user sys$output 'tfile1'
+$library/list 'decc_rtldef'
+$open/read/error=rtldef_loop1_end tf1 'tfile1'
+$open/write/error=rtldef_loop1_end tf2 'dchfile'
+$rtldef_loop1:
+$   read/end=rtldef_loop1_end tf1 line_in
+$   line_in = f$edit(line_in,"TRIM,COMPRESS")
+$   key1 = f$element(0," ",line_in)
+$   key2 = f$element(1," ",line_in)
+$   if key1 .eqs. " " .or. key1 .eqs. "" then goto rtldef_loop1
+$   if key2 .nes. " " .and. key2 .nes. "" then goto rtldef_loop1
+$   write tf2 "|",key1,"|"
+$   goto rtldef_loop1
+$rtldef_loop1_end:
+$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
+$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
+$if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$!
+$!
+$! Now calculate what should be in the file from reading
+$! config.h.in and CONFIGURE.
+$!---------------------------------------------------------------
+$open/read inf 'cfile'
+$do_comment = 0
+$if_block = 0
+$cfgh_in_loop1:
+$!set nover
+$   read/end=cfgh_in_loop1_end inf line_in
+$   xline = f$edit(line_in,"TRIM,COMPRESS")
+$!
+$!  Blank line handling
+$!---------------------
+$   if xline .eqs. ""
+$   then
+$      write tf ""
+$      goto cfgh_in_loop1
+$   endif
+$   xlen = f$length(xline)
+$   key = f$extract(0,2,xline)
+$!
+$!  deal with comments by copying exactly
+$!-----------------------------------------
+$   if (do_comment .eq. 1) .or. (key .eqs. "/*")
+$   then
+$      do_comment = 1
+$      write tf line_in
+$      key = f$extract(xlen - 2, 2, xline)
+$      if key .eqs. "*/" then do_comment = 0
+$      goto cfgh_in_loop1
+$   endif
+$!
+$!  Some quick parsing
+$!----------------------
+$   keyif = f$extract(0,3,xline)
+$   key1 = f$element(0," ",xline)
+$   key2 = f$element(1," ",xline)
+$   key2a = f$element(0,"_",key2)
+$   key2b = f$element(1,"_",key2)
+$   key2_len = f$length(key2)
+$   key2_h = f$extract(key2_len - 2, 2, key2)
+$   key2_t = f$extract(key2_len - 5, 5, key2)
+$   if key2_t .eqs. "_TYPE" then key2_h = "_T"
+$   key64 = 0
+$   if f$locate("64", xline) .lt. xlen then key64 = 1
+$!
+$!write sys$output "xline = ''xline'"
+$!
+$!  Comment out this section of the ifblock
+$!-----------------------------------------
+$   if if_block .ge. 3
+$   then
+$      write tf "/* ", xline, " */"
+$      if keyif .eqs. "#en" then if_block = 0
+$      goto cfgh_in_loop1
+$   endif
+$!
+$!  Handle the end of an ifblock
+$!-------------------------------
+$   if keyif .eqs. "#en"
+$   then
+$      write tf xline
+$      if_block = 0
+$      goto cfgh_in_loop1
+$   endif
+$!
+$   if key1 .eqs. "#ifndef"
+$   then
+$!     Manual check for _ALL_SOURCE on AIX error
+$!-----------------------------------------------
+$      if key2 .eqs. "_ALL_SOURCE"
+$      then
+$         write tf "/* ", xline, " */"
+$!
+$!        Ignore the rest of the block
+$!--------------------------------------
+$         if_block = 3
+$         goto cfgh_in_loop1
+$      endif
+$   endif
+$!
+$!
+$!  Default action for an #if/#else/#endif
+$!------------------------------------------
+$   if keyif .eqs. "#if" .or. keyif .eqs. "#el"
+$   then
+$      if_block = 1
+$      write tf xline
+$      goto cfgh_in_loop1
+$   endif
+$!
+$!
+$!  Process "normal?" stuff
+$!---------------------------
+$   if key1 .eqs. "#undef"
+$   then
+$      key2c = f$element(2, "_", key2)
+$      if (key2c .eqs. "_") .or. (key2c .eqs. "H") then key2c = ""
+$      key2d = f$element(3, "_", key2)
+$      if (key2d .eqs. "_") .or. (key2d .eqs. "H") then key2d = ""
+$      key2e = f$element(4, "_", key2)
+$      if (key2e .eqs. "_") .or. (key2e .eqs. "H") then key2e = ""
+$      if key2d .eqs. "T"
+$      then
+$          if key2e .eqs. "TYPE"
+$          then
+$              key2_h = "_T"
+$              key2d = ""
+$          endif
+$      endif
+$!
+$      double_under = 0
+$!
+$      if key2 .eqs. "bits16_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' short"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "u_bits16_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' unsigned short"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "bits32_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' int"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "u_bits32_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' unsigned int"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "intmax_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#ifdef __VAX"
+$          write tf "#define ''key2' long"
+$          write tf "#else"
+$          write tf "#define ''key2' long long"
+$          write tf "#endif"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "uintmax_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#ifdef __VAX"
+$          write tf "#define ''key2' unsigned long"
+$          write tf "#else"
+$          write tf "#define ''key2' unsigned long long"
+$          write tf "#endif"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "socklen_t"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' int"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "GETGROUPS_T"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' gid_t"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_SYS_SIGLIST"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 0"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_SYS_ERRLIST"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_STRUCT_DIRENT_D_INO"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     ! The header files have this information, however
+$!      ! The ioctl() call only works on sockets.
+$!     if key2 .eqs. "FIONREAD_IN_SYS_IOCTL"
+$!     then
+$!         write tf "#ifndef ''key2'"
+$!         write tf "#define ''key2' 1"
+$!         write tf "#endif"
+$!         goto cfgh_in_loop1
+$!     endif
+$!
+$!     ! The header files have this information, however
+$!      ! The ioctl() call only works on sockets.
+$!     if key2 .eqs. "GWINSZ_IN_SYS_IOCTL"
+$!     then
+$!         write tf "#ifndef ''key2'"
+$!         write tf "#define ''key2' 1"
+$!         write tf "#endif"
+$!         goto cfgh_in_loop1
+$!     endif
+$!
+$!     ! The header files have this information, however
+$!      ! The ioctl() call only works on sockets.
+$!     if key2 .eqs. "STRUCT_WINSIZE_IN_SYS_IOCTL"
+$!     then
+$!         write tf "#ifndef ''key2'"
+$!         write tf "#define ''key2' 0"
+$!         write tf "#endif"
+$!         goto cfgh_in_loop1
+$!     endif
+$!
+$      if key2 .eqs. "HAVE_STRUCT_TM_TM_ZONE"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_TM_ZONE"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_TIMEVAL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_TZNAME"
+$      then
+$          write tf "#if __CRTL_VER >= 70000000"
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "WEXITSTATUS_OFFSET"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 2"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_GETPW_DECLS"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_CONFSTR"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_PRINTF"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_SBRK"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRSIGNAL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 0"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2a .eqs. "HAVE_DECL_STRTOLD"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 0"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOIMAX"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 0"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOLL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOUL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOULL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_STRTOUMAX"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 0"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "GETPGRP_VOID"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "NAMED_PIPES_MISSING"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "OPENDIR_NOT_ROBUST"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "PGRP_PIPE"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "CAN_REDEFINE_GETENV"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_PRINTF_A_FORMAT"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "CTYPE_NON_ASCII"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_LANGINFO_CODESET"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_LC_MESSAGES"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!      This wants execve() to do this automagically to pass.
+$!     if key2 .eqs. "HAVE_HASH_BANG_EXEC"
+$!     then
+$!         write tf "#ifndef ''key2'"
+$!         write tf "#define ''key2' 1"
+$!         write tf "#endif"
+$!         goto cfgh_in_loop1
+$!     endif
+$!
+$      if key2 .eqs. "ICONV_CONST"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2'"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "VOID_SIGHANDLER"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_POSIX_SIGNALS"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "UNUSABLE_RT_SIGNALS"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2a .eqs. "HAVE_DECL_FPURGE"
+$      then
+$          write tf "#ifndef ''key2a'"
+$          write tf "#define ''key2a' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_DECL_SETREGID"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_POSIX_SIGSETJMP"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "HAVE_LIBDL"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "STRCOLL_BROKEN"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2 .eqs. "DUP_BROKEN"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     This is for a test that getcwd(0,0) works.
+$!     It does not on VMS.
+$!--------------------------
+$      if key2 .eqs. "GETCWD_BROKEN"
+$      then
+$          write sys$output ""
+$          write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being tested for!"
+$                 write sys$output -
+ "-CONFIG_H-I-GETCWD, GETCWD(0,0) does not work on VMS."
+$                 write sys$output -
+ "-CONFIG_H-I-GETCWD2, Work around hack probably required."
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$                  if update_config_vms
+$                  then
+$                      open/append tfcv sys$disk:[]config_vms.h
+$                      write tfcv ""
+$                      write tfcv -
+               "/* Check config.h for use of ''key2' settings */"
+$                      write tfcv ""
+$                      close tfcv
+$                  endif
+$
+$          goto cfgh_in_loop1
+$      endif
+$!
+$      if key2a .eqs. "HAVE" .or. key2a .eqs. "STAT"
+$      then
+$!
+$!         Process extra underscores
+$!------------------------------------
+$          if f$locate("HAVE___", key2) .lt. key2_len
+$          then
+$              key2b = "__" + key2d
+$              key2d = ""
+$              double_under = 1
+$          else
+$              if f$locate("HAVE__", key2) .lt. key2_len
+$              then
+$                  key2b = "_" + key2c
+$                  key2c = ""
+$                  double_under = 1
+$              endif
+$          endif
+$!
+$          if key2_h .eqs. "_H"
+$          then
+$!
+$!             Looking for a header file
+$!---------------------------------------
+$              headf = key2b
+$              if key2c .nes. "" then headf = headf + "_" + key2c
+$              if key2d .nes. "" then headf = headf + "_" + key2d
+$!
+$!                (key2b .eqs. "READLINE")
+$!
+$!             Some special parsing
+$!------------------------------------------
+$              if (key2b .eqs. "SYS") .or. (key2b .eqs. "ARPA") .or. -
+                  (key2b .eqs. "NET") .or. (key2b .eqs. "NETINET")
+$              then
+$                  if key2c .nes. ""
+$                  then
+$                      headf = key2c
+$                      if key2d .nes. "" then headf = key2c + "_" + key2d
+$                  endif
+$              endif
+$!
+$!             And of course what's life with out some special cases
+$!--------------------------------------------------------------------
+$              if key2b .eqs. "FILE"
+$              then
+$                 write sys$output ""
+$                 write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
+$                 write sys$output -
+ "-CONFIG_H-I-FILE_OLD, file.h will not be configured as is obsolete!"
+$                 write sys$output -
+ "-CONFIG_H_I-FCNTL_NEW, "Expecting fcntl.h to be configured instead!"
+$                 write sys$output -
+ "-CONFIG_H_I-FCNTL_CHK, "Unable to verify at this time!"
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$!
+$                  if update_config_vms
+$                  then
+$                      open/append tfcv sys$disk:[]config_vms.h
+$                      write tfcv ""
+$                      write tfcv -
+               "/* Check config.h for use of fcntl.h instead of file.h */"
+$                      write tfcv ""
+$                      close tfcv
+$                  endif
+$              endif
+$!
+$!             Now look it up in the DEC C RTL
+$!---------------------------------------------
+$              define/user sys$output nl:
+$              define/user sys$error nl:
+$              search/output=nl: 'dchfile' |'headf'|/exact
+$              if '$severity' .eq. 1
+$              then
+$                  if key64 then write tf "#ifndef __VAX"
+$                  write tf "#ifndef ''key2'"
+$                  write tf "#define ''key2' 1"
+$if p2 .nes. "" then write sys$output "''dchfile' - #define ''key2' 1"
+$                  write tf "#endif"
+$                  if key64 then write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$          else
+$!
+$!             Looking for a routine or a symbol
+$!------------------------------------------------
+$              if key2c .eqs. "MACRO"
+$              then
+$                  if (key2b .eqs. "FILE") .or. (key2b .eqs. "DATE") -
+                       .or. (key2b .eqs. "LINE") .or. (key2b .eqs. "TIME")
+$                  then
+$                      write tf "#ifndef HAVE_''key2b'"
+$                      write tf "#define HAVE_''key2b' 1"
+$                      write tf "#endif"
+$                  endif
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!             Special false tests
+$!-------------------------------------
+$              if double_under
+$              then
+$                  if key2b .eqs. "_FCNTL" .or. key2b .eqs. "__FCNTL"
+$                  then
+$                      write tf "/* #undef HAVE_''key2b' */"
+$                      goto cfgh_in_loop1
+$                  endif
+$!
+$                  if key2b .eqs. "_STAT" .or. key2b .eqs. "__STAT"
+$                  then
+$                      write tf "/* #undef HAVE_''key2b' */"
+$                      goto cfgh_in_loop1
+$                  endif
+$!
+$                  if key2b .eqs. "_READ" .or. key2b .eqs. "__READ"
+$                  then
+$                      write tf "/* #undef HAVE_''key2b' */"
+$                      goto cfgh_in_loop1
+$                  endif
+$              endif
+$!
+$              keysym = key2b
+$              if key2c .nes. "" then keysym = keysym + "_" + key2c
+$              if key2d .nes. "" then keysym = keysym + "_" + key2d
+$              if key2e .nes. "" then keysym = keysym + "_" + key2e
+$!
+$!
+$!             Stat structure members
+$!-------------------------------------
+$              if key2b .eqs. "STRUCT"
+$              then
+$                  if key2c .eqs. "STAT" .and (key2d .nes. "")
+$                  then
+$                      key2b = key2b + "_" + key2c + "_" + key2d
+$                      key2c = key2e
+$                      key2d = ""
+$                      key2e = ""
+$                  endif
+$              endif
+$              if (key2b .eqs. "ST") .or. (key2b .eqs. "STRUCT_STAT_ST")
+$              then
+$                  keysym = "ST" + "_" + key2c
+$                  keysym = f$edit(keysym,"LOWERCASE")
+$              endif
+$              if key2a .eqs. "STAT"
+$              then
+$                  if (f$locate("STATVFS", key2b) .eq. 0) .and. key2c .eqs. ""
+$                  then
+$                      keysym = f$edit(key2b, "LOWERCASE")
+$                  endif
+$!$                if (key2b .eqs. "STATVFS" .or. key2b .eqs. "STATFS2" -
+$!                     .or. key2b .eqs. "STATFS3") .and. key2c .nes. ""
+$!
+$                  if (key2b .eqs. "STATVFS") .and. key2c .nes. ""
+$                  then
+$!                     Should really verify that the structure
+$!                     named by key2b actually exists first.
+$!------------------------------------------------------------
+$!
+$!                     Statvfs structure members
+$!-------------------------------------------------
+$                      keysym = "f_" + f$edit(key2c,"LOWERCASE")
+$                  endif
+$              endif
+$!
+$!             UTMPX structure members
+$!--------------------------------------
+$              if key2b .eqs. "UT" .and. key2c .eqs. "UT"
+$              then
+$                  keysym = "ut_" + f$edit(key2d,"LOWERCASE")
+$              endif
+$!
+$              if f$locate("MMAP",key2) .lt. key2_len
+$              then
+$                 write sys$output ""
+$                 write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
+$                 write sys$output -
+ "-CONFIG_H-I-MMAP, MMAP operations only work on STREAM and BINARY files!"
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$                  if update_config_vms
+$                  then
+$                      open/append tfcv sys$disk:[]config_vms.h
+$                      write tfcv ""
+$                      write tfcv -
+               "/* Check config.h for use of ''key2' settings */"
+$                      write tfcv ""
+$                      close tfcv
+$                  endif
+$              endif
+$!
+$!
+$              if keysym .eqs. "CRYPT"
+$              then
+$                 write sys$output ""
+$                 write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
+$                 write sys$output -
+ "-CONFIG_H-I-CRYPT, CRYPT operations on the VMS SYSUAF may not work!"
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$                  if update_config_vms
+$                  then
+$                      open/append tfcv sys$disk:[]config_vms.h
+$                      write tfcv ""
+$                      write tfcv -
+               "/* Check config.h for use of ''keysym' */"
+$                      write tfcv ""
+$                      close tfcv
+$                  endif
+$              endif
+$!
+$!
+$              if keysym .eqs. "EXECL"
+$              then
+$                 write sys$output ""
+$                 write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
+$                 write sys$output -
+ "-CONFIG_H-I-EXCEL, EXECL configured, Will probably not work."
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$                  if update_config_vms
+$                  then
+$                      open/append tfcv sys$disk:[]config_vms.h
+$                      write tfcv ""
+$                      write tfcv -
+               "/* Check config.h for use of ''keysym' */"
+$                      write tfcv ""
+$                      close tfcv
+$                  endif
+$              endif
+$!
+$!
+$!             Process if cpp supports ANSI-C stringizing '#' operator
+$!-----------------------------------------------------------------------
+$              if keysym .eqs. "STRINGIZE"
+$              then
+$                  write tf "#ifndef HAVE_STRINGIZE"
+$                  write tf "#define HAVE_STRINGSIZE 1"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$              if keysym .eqs. "VOLATILE"
+$              then
+$                  write tf "#ifndef HAVE_VOLATILE"
+$                  write tf "#define HAVE_VOLATILE 1"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$              if keysym .eqs. "ALLOCA"
+$              then
+$                  write tf "#ifndef HAVE_ALLOCA"
+$                  write tf "#define HAVE_ALLOCA 1"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$              if keysym .eqs. "ERRNO_DECL"
+$              then
+$                  write tf "#ifndef HAVE_ERRNO_DECL"
+$                  write tf "#define HAVE_ERRNO_DECL 1"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$              if keysym .eqs. "LONGLONG"
+$              then
+$                  write tf "#ifndef __VAX"
+$                  write tf "#pragma message disable longlongtype"
+$                  write tf "#ifndef HAVE_LONGLONG"
+$                  write tf "#define HAVE_LONGLONG 1"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!             May need to test compiler version
+$!-----------------------------------------------
+$              if (keysym .eqs. "LONG_LONG") .or. -
+                   (keysym .eqs. "LONG_LONG_INT")
+$              then
+$                  write tf "#ifndef __VAX"
+$                  write tf "#pragma message disable longlongtype"
+$                  write tf "#ifndef HAVE_''keysym'"
+$                  write tf "#define HAVE_''keysym' 1"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!             May need to test compiler version
+$!-----------------------------------------------
+$              if keysym .eqs. "UNSIGNED_LONG_LONG"
+$              then
+$                  write tf "#ifndef __VAX"
+$                  write tf "#pragma message disable longlongtype"
+$                  write tf "#ifndef HAVE_UNSIGNED_LONG_LONG"
+$                  write tf "#define HAVE_UNSIGNED_LONG_LONG 1"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!             May need to test compiler version
+$!-----------------------------------------------
+$              if keysym .eqs. "UNSIGNED_LONG_LONG_INT"
+$              then
+$                  write tf "#ifndef __VAX"
+$                  write tf "#pragma message disable longlongtype"
+$                  write tf "#ifndef HAVE_UNSIGNED_LONG_LONG_INT"
+$                  write tf "#define HAVE_UNSIGNED_LONG_LONG_INT 1"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!             May need to test compiler version
+$!-----------------------------------------------
+$              if keysym .eqs. "LONG_DOUBLE"
+$              then
+$                  write tf "#ifndef __VAX"
+$                  write tf "#pragma message disable longlongtype"
+$                  write tf "#ifndef HAVE_LONG_DOUBLE"
+$                  write tf "#define HAVE_LONG_DOUBLE 1"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$              if keysym .eqs. "FCNTL_LOCK"
+$              then
+$                  write sys$output -
+  "%CONFIG_H-I-NONPORT, ''key2' being asked for!
+$                 write sys$output -
+ "-CONFIG_H-I-REVIEW, Manual Code review required!"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!
+$!             These libraries are provided by the DEC C RTL
+$!-------------------------------------------------------------
+$              if keysym .eqs. "LIBINET" .or. keysym .eqs. "LIBSOCKET"
+$              then
+$                  write tf "#ifndef HAVE_''keysym'"
+$                  write tf "#define HAVE_''keysym' 1"
+$if p2 .nes. "" then write sys$output "''decc_shr' #define ''keysym' 1"
+$                  write tf "#endif
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$!
+$              if keysym .eqs. "HERRNO" then keysym = "h_errno"
+$              if keysym .eqs. "UTIMBUF" then keysym = "utimbuf"
+$              if key2c .eqs. "STRUCT"
+$              then
+$                  keysym = f$edit(key2d,"LOWERCASE")
+$              else
+$                  if key2_h .eqs. "_T"
+$                  then
+$                      if key2_t .eqs. "_TYPE"
+$                      then
+$                          keysym = f$extract(0, key2_len - 5, key2) - "HAVE_"
+$                      endif
+$                      keysym = f$edit(keysym,"LOWERCASE")
+$                  endif
+$              endif
+$!
+$!             Check the DEC C RTL shared image first
+$!------------------------------------------------------
+$              if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$              define/user sys$output nl:
+$              define/user sys$error nl:
+$              search/format=nonull/out='tfile1' 'decc_shr' 'keysym'
+$              if '$severity' .eq. 1
+$              then
+$!
+$!                 Not documented, but from observation
+$!------------------------------------------------------
+$                  define/user sys$output nl:
+$                  define/user sys$error nl:
+$                  if arch_type .eq. 3
+$                  then
+$                      keyterm = "''keysym'<SOH>"
+$                  else
+$                      if arch_type .eq. 2
+$                      then
+$                          keyterm = "''keysym'<BS>"
+$                      else
+$                          keyterm = "''keysym'<STX>"
+$                      endif
+$                  endif
+$                  search/out=nl: 'tfile1' -
+   "$''keyterm'","$g''keyterm'","$__utc_''keyterm'",-
+   "$__utctz_''keyterm'","$__bsd44_''keyterm'","$bsd_''keyterm'",-
+   "$''keysym'decc$","$G''keysym'decc$","$GX''keyterm'"
+$                  severity = '$severity'
+$!
+$!
+$!                 Of course the 64 bit stuff is different
+$!---------------------------------------------------------
+$                  if severity .ne. 1 .and. key64
+$                  then
+$                      define/user sys$output nl:
+$                      define/user sys$error nl:
+$                      search/out=nl: 'tfile1' "$_''keyterm'"
+$!                     search/out 'tfile1' "$_''keyterm'"
+$                      severity = '$severity'
+$                  endif
+$!
+$!                 UNIX compatability routines
+$!---------------------------------------------
+$                  if severity .ne. 1
+$                  then
+$                      define/user sys$output nl:
+$                      define/user sys$error nl:
+$                      search/out=nl: 'tfile1' -
+    "$__unix_''keyterm'","$__vms_''keyterm'","$_posix_''keyterm'"
+$                      severity = '$severity'
+$                  endif
+$!
+$!                 VAX special handling routines
+$!---------------------------------------------
+$                  if (severity .ne. 1) .and. (arch_type .eq. 1)
+$                  then
+$                      define/user sys$output nl:
+$                      define/user sys$error nl:
+$                      search/out=nl: 'tfile1' "DECC$''keysym'<SOH>"
+$                      severity = '$severity'
+$                  endif
+$!
+$!                 Show the result of the search
+$!------------------------------------------------
+$                  if 'severity' .eq. 1
+$                  then
+$                      if key64 then write tf "#ifndef __VAX"
+$                      write tf "#ifndef ''key2'"
+$                      write tf "#define ''key2' 1"
+$if p2 .nes. "" then write sys$output "''decc_shr' #define ''key2' 1"
+$                      write tf "#endif"
+$                      if key64 then write tf "#endif"
+$                      goto cfgh_in_loop1
+$                  endif
+$              endif
+$              if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$!
+$!             Check the DECC Header files next
+$!----------------------------------------------
+$              define/user sys$output nl:
+$              define/user sys$error nl:
+$              search/out=nl: 'decc_rtldef' -
+                   "''keysym';", "''keysym'[", "struct ''keysym'"/exact
+$              severity = '$severity'
+$              if severity .eq. 1
+$              then
+$                  if key64 then write tf "#ifndef __VAX"
+$                  write tf "#ifndef ''key2'"
+$                  write tf "#define ''key2' 1"
+$if p2 .nes. "" then write sys$output "''decc_rtldef' #define ''key2' 1"
+$                  write tf "#endif"
+$                  if key64 then write tf "#endif"
+$                  goto cfgh_in_loop1
+$              endif
+$!
+$          endif
+$          write tf "/* ", xline, " */"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!
+$!     Process SIZEOF directives found in SAMBA
+$!------------------------------------------------
+$      if key2a .eqs. "SIZEOF"
+$      then
+$          if key2b .eqs. "INO" .and. key2_h .eqs. "_T"
+$          then
+$              write tf "#ifndef SIZEOF_INO_T"
+$              write tf "#define SIZEOF_INO_T (6)"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "INTMAX" .and. key2_h .eqs. "_T"
+$          then
+$              write tf "#ifndef SIZEOF_INTMAX_T"
+$              write tf "#ifdef __VAX"
+$              write tf "#define SIZEOF_INTMAX_T (4)"
+$              write tf "#else"
+$              write tf "#define SIZEOF_INTMAX_T (8)"
+$              write tf "#endif"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "OFF" .and. key2_h .eqs. "_T"
+$          then
+$              write tf "#ifndef SIZEOF_OFF_T"
+$              write tf "#ifdef __VAX"
+$              write tf "#define SIZEOF_OFF_T (4)"
+$              write tf "#else"
+$              write tf "#define SIZEOF_OFF_T (8)"
+$              write tf "#endif"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "CHAR" .and. key2_h .eqs. "_P"
+$          then
+$              write tf "#ifndef SIZEOF_CHAR_P"
+$              write tf "#define SIZEOF_CHAR_P (4)"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if (key2b .eqs. "INT")
+$          then
+$              write tf "#ifndef SIZEOF_''key2b'"
+$              write tf "#define SIZEOF_''key2b' (4)"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "UNSIGNED"
+$          then
+$               if key2c .eqs. "INT" .or. key2c .eqs. "LONG"
+$               then
+$                  write tf "#ifndef SIZEOF_''key2b'_''key2c'"
+$                  write tf "#define SIZEOF_''key2b'_''key2c' (4)"
+$                  write tf "#endif"
+$                  goto cfgh_in_loop1
+$               endif
+$          endif
+$          if key2b .eqs. "DOUBLE"
+$          then
+$              write tf "#ifndef SIZEOF_DOUBLE"
+$              write tf "#define SIZEOF_DOUBLE (8)"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "LONG"
+$          then
+$              if key2c .eqs. ""
+$              then
+$                  write tf "#ifndef SIZEOF_LONG"
+$                  write tf "#define SIZEOF_LONG (4)"
+$                  write tf "#endif"
+$              else
+$                  write tf "#ifndef SIZEOF_LONG_LONG"
+$                  write tf "#ifndef __VAX"
+$                  write tf "#define SIZEOF_LONG_LONG (8)"
+$                  write tf "#endif"
+$                  write tf "#endif"
+$              endif
+$              goto cfgh_in_loop1
+$          endif
+$          if key2b .eqs. "SHORT"
+$          then
+$              write tf "#ifndef SIZEOF_SHORT"
+$              write tf "#define SIZEOF_SHORT (2)"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          write tf "/* ", xline, " */"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Process NEED directives
+$!-------------------------------
+$      if key2a .eqs. "NEED"
+$      then
+$          if key2b .eqs. "STRINGS" .and. key2_h .eqs. "_H"
+$          then
+$              write tf "#ifndef NEED_STRINGS_H"
+$              write tf "#define NEED_STRINGS_H 1"
+$              write tf "#endif"
+$              goto cfgh_in_loop1
+$          endif
+$          write tf "/* ", xline, " */"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!
+$!     Process STATFS directives
+$!-------------------------------
+$!     if key2a .eqs. "STATFS"
+$!     then
+$!         write tf "/* ", xline, " */"
+$!         goto cfgh_in_loop1
+$!     endif
+$!
+$!     Process inline directive
+$!------------------------------
+$      if key2 .eqs. "inline"
+$      then
+$          write tf "#ifndef inline"
+$          write tf "#define inline __inline"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Process restrict directive
+$!--------------------------------
+$      if key2 .eqs. "restrict"
+$      then
+$          write tf "#ifndef restrict"
+$          write tf "#define restrict __restrict"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Process RETSIGTYPE directive
+$!----------------------------------
+$      if key2 .eqs. "RETSIGTYPE"
+$      then
+$          write tf "#ifndef RETSIGTYPE"
+$          write tf "#define RETSIGTYPE void"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Process STDC_HEADERS (SAMBA!)
+$!---------------------------
+$      if key2 .eqs. "STDC_HEADERS"
+$      then
+$          write tf "#ifndef STDC_HEADERS"
+$          write tf "#define STDC_HEADERS 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Process PROTOTYPES directive
+$!-------------------------------------
+$      if key2 .eqs. "PROTOTYPES"
+$      then
+$          write tf "#ifndef PROTOTYPES"
+$          write tf "#define PROTOTYPES 1"
+$          write tf "#endif"
+$          goto cfgh_in_loop1
+$      endif
+$!
+$!     Special for SEEKDIR_RETURNS_VOID
+$!---------------------------------------
+$      if key2 .eqs. "SEEKDIR_RETURNS_VOID"
+$      then
+$          write tf "#ifndef SEEKDIR_RETURNS_VOID"
+$          write tf "#define SEEKDIR_RETURNS_VOID 1"
+$          write tf "#endif"
+$      endif
+$!
+$!      TIME_WITH_SYS_TIME note:  On VMS time.h and sys/time.h are same module.
+$!
+$!      TIME_T_IN_SYS_TYPES_H
+$!------------------------------
+$      if key2 .eqs. "TIME_T_IN_TYPES_H"
+$      then
+$          write tf "#ifndef ''key2'"
+$          write tf "#define ''key2' 1"
+$          write tf "#endif"
+$      endif
+$!
+$!     Unknown - See if CONFIGURE can give a clue for this
+$!----------------------------------------------------------
+$      pflag = 0
+$      set_flag = 0
+$!     gproj_name = proj_name - "_VMS" - "-VMS"
+$      if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$      define/user sys$output nl:
+$      define/user sys$error nl:
+$!     if f$locate("FILE", key2) .lt. key2_len then pflag = 1
+$!     if f$locate("DIR", key2) .eq. key2_len - 3 then pflag = 1
+$!     if f$locate("PATH", key2) .eq. key2_len - 4 then pflag = 1
+$!
+$      search/out='tfile1' 'configure_script' "''key2'="/exact
+$      search_sev = '$severity'
+$      if 'search_sev' .eq. 1
+$      then
+$          open/read/err=unknown_cf_rd_error sf 'tfile1'
+$search_file_rd_loop:
+$          read/end=unknown_cf_rd_err sf line_in
+$          line_in = f$edit(line_in, "TRIM")
+$          skey1 = f$element(0,"=",line_in)
+$          if skey1 .eqs. key2
+$          then
+$              skey2 = f$element(1,"=",line_in)
+$              skey2a = f$extract(0,2,skey2)
+$!
+$!             Keep these two cases separate to make it easier to add
+$!             more future intelligence to this routine
+$!----------------------------------------------------------------------
+$              if skey2a .eqs. """`"
+$              then
+$!                 if pflag .eq. 1
+$!                 then
+$!                     write tf "#ifndef ''key2'"
+$!                     write tf "#define ",key2," """,gproj_name,"_",key2,""""
+$!                     write tf "#endif"
+$!                 else
+$!                     Ignore this for now
+$!------------------------------------------
+$                      write tf "/* ", xline, " */"
+$!                 endif
+$                  set_flag = 1
+$                  goto found_in_configure
+$              endif
+$              if skey2a .eqs. """$"
+$              then
+$!                 if pflag .eq. 1
+$!                 then
+$!                     write tf "#ifndef ''key2'"
+$!                     write tf "#define ",key2," """,gproj_name,"_",key2,""""
+$!                     write tf "#endif"
+$!                 else
+$!                     Ignore this for now
+$!-------------------------------------------
+$                      write tf "/* ", xline, " */"
+$!                 endif
+$                  set_flag = 1
+$                  goto found_in_configure
+$              endif
+$              if f$extract(0, 1, skey2) .eqs. "'"
+$              then
+$                  skey2 = skey2 - "'" - "'"
+$              endif
+$              write tf "#ifndef ''key2'"
+$              write tf "#define ",key2," """,skey2,""""
+$              write tf "#endif"
+$              set_flag = 1
+$          else
+$              goto search_file_rd_loop
+$!             if pflag .eq. 1
+$!             then
+$!                 write tf "#ifndef ''key2'"
+$!                 write tf "#define ",key2," """,gproj_name,"_",key2,""""
+$!                 write tf "#endif"
+$!                 set_flag = 1
+$!             endif
+$          endif
+$found_in_configure:
+$unknown_cf_rd_err:
+$          if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. ""
+$          then
+$              close sf
+$          endif
+$          if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$          if set_flag .eq. 1 then goto cfgh_in_loop1
+$      endif
+$   endif
+$!
+$!
+$!
+$!  If it falls through everything else, comment it out
+$!-----------------------------------------------------
+$   write tf "/* ", xline, " */"
+$   goto cfgh_in_loop1
+$cfgh_in_loop1_end:
+$close inf
+$!
+$!
+$! Write out the tail
+$!--------------------
+$write_tail:
+$gosub write_config_h_tail
+$!
+$! Exit and clean up
+$!--------------------
+$general_error:
+$status = '$status'
+$all_exit:
+$set noon
+$if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. "" then close sf
+$if f$trnlnm("tf","lnm$process",,"SUPERVISOR") .nes. "" then close tf
+$if f$trnlnm("inf","lnm$process",,"SUPERVISOR") .nes. "" then close inf
+$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
+$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
+$if f$trnlnm("tfcv","lnm$process",,"SUPERVISOR") .nes. "" then close tfcv
+$if f$type(tfile1) .eqs. "STRING"
+$then
+$   if f$search(tfile1) .nes. "" then delete 'tfile1';*
+$endif
+$if f$type(dchfile) .eqs. "STRING"
+$then
+$   if f$search(dchfile) .nes. "" then delete 'dchfile';*
+$endif
+$if f$type(configure_script) .eqs. "STRING"
+$then
+$   if f$search(configure_script) .nes. "" then delete 'configure_script';*
+$endif
+$exit 'status'
+$!
+$!
+$control_y:
+$   status = ss_control_y
+$   goto all_exit
+$!
+$!
+$!
+$! Gosub to write a new config_vms.h
+$!-----------------------------------
+$write_config_vms:
+$outfile = "sys$disk:[]config_vms.h"
+$create 'outfile'
+$open/append tf 'outfile'
+$write tf "/* File: config_vms.h"
+$write tf "**"
+$write tf "** This file contains the manual edits needed for porting"
+$!write tf "** the ''proj_name' package to OpenVMS.
+$write tf "**"
+$write tf "** Edit this file as needed.  The procedure that automatically"
+$write tf "** generated this header stub will not overwrite or make any"
+$write tf "** changes to this file."
+$write tf "**"
+$write tf -
+ "** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
+$write tf "**"
+$write tf -
+ "**========================================================================*/"
+$write tf ""
+$close tf
+$return
+$!
+$! gosub to write out a documentation header for config.h
+$!----------------------------------------------------------------
+$write_config_h_header:
+$outfile = "sys$disk:[]config.h"
+$create 'outfile'
+$open/append tf 'outfile'
+$write tf "#ifndef CONFIG_H"
+$write tf "#define CONFIG_H"
+$write tf "/* File: config.h"
+$write tf "**"
+$write tf -
+  "** This file contains the options needed for porting "
+$write tf "** the project on a VMS system."
+$write tf "**"
+$write tf "** Try not to make any edits to this file, as it is"
+$write tf "** automagically generated."
+$write tf "**"
+$write tf "** Manual edits should be made to the config_vms.h file."
+$write tf "**"
+$write tf -
+ "** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
+$write tf "**"
+$write tf -
+ "**========================================================================*/"
+$write tf ""
+$write tf "#if (__CRTL_VER >= 70200000) && !defined (__VAX)"
+$write tf "#define _LARGEFILE 1"
+$write tf "#endif"
+$write tf ""
+$write tf "#ifndef __VAX"
+$write tf "#ifdef __CRTL_VER"
+$write tf "#if __CRTL_VER >= 80200000"
+$write tf "#define _USE_STD_STAT 1"
+$write tf "#endif"
+$write tf "#endif"
+$write tf "#endif"
+$write tf ""
+$!
+$if P1 .nes. "NOBUILTINS"
+$then
+$   write tf " /* Allow compiler builtins */"
+$   write tf "/*-------------------------*/"
+$   write tf "#ifdef __DECC_VER"
+$   write tf "#include <non_existant_dir:builtins.h>"
+$   write tf "#endif"
+$endif
+$!
+$write tf ""
+$return
+$!
+$! gosub to write out the tail for config.h and close it
+$!---------------------------------------------------------
+$write_config_h_tail:
+$write tf ""
+$write tf " /* Include the hand customized settings */"
+$write tf "/*--------------------------------------*/"
+$write tf "#include ""sys$disk:config_vms.h"""
+$write tf ""
+$write tf "#endif /* CONFIG_H */"
+$close tf
+$return
+$!
diff --git a/vms/descrip.mms b/vms/descrip.mms
index 77dad90..5bf1b9e 100644
--- a/vms/descrip.mms
+++ b/vms/descrip.mms
@@ -47,6 +47,7 @@ MAKEFILE = $(VMSDIR)Descrip.MMS
 #CCFLAGS = /noOpt/Debug
 
 # a comma separated list of macros to define
+# Do not specify _POSIX_EXIT here, other tricks are used for this.
 CDEFS  = "GAWK","HAVE_CONFIG_H"
 
 .ifdef GNUC
@@ -67,8 +68,13 @@ CFLAGS       = /Incl=[]/Obj=[]/Opt=noInline/Def=($(CDEFS)) 
$(CCFLAGS)
 LIBS   = sys$share:vaxcrtl.exe/Shareable
 .else  !!VAXC
 # neither GNUC nor VAXC, assume DECC (same for either VAX or Alpha)
-CC     = cc/DECC/Prefix=All
-CFLAGS = /Incl=[]/Obj=[]/Def=($(CDEFS)) $(CCFLAGS)
+.ifdef __VAX__
+CFLOAT  =
+.else
+CFLOAT = /float=ieee/ieee_mode=denorm_results
+.endif
+CC     = cc/DECC/Prefix=All/NESTED_INCLUDE=NONE$(CFLOAT)
+CFLAGS = /Incl=([],[.vms])/Obj=[]/Def=($(CDEFS)) $(CCFLAGS)
 LIBS   =       # DECC$SHR instead of VAXCRTL, no special link option needed
 .endif !VAXC
 .endif !GNUC
@@ -106,7 +112,7 @@ AWKOBJS = $(AWKOBJ1),$(AWKOBJ2)
 # VMSOBJS
 #      VMS specific stuff
 VMSCODE = vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj,\
-       vms_gawk.obj,vms_cli.obj
+       vms_gawk.obj,vms_cli.obj,vms_crtl_init.obj
 VMSCMD = gawk_cmd.obj                  # built from .cld file
 VMSOBJS = $(VMSCODE),$(VMSCMD)
 
@@ -128,8 +134,8 @@ gawk : gawk.exe
 gawk.exe : $(GAWKOBJ) $(AWKOBJS) $(VMSOBJS) gawk.opt
        $(LINK) $(LINKFLAGS) gawk.opt/options
 
-gawk.opt : $(MAKEFILE)                 # create linker options file
-      @        open/write opt sys$disk:[]gawk.opt              ! ~ 'cat 
<<close >gawk.opt'
+gawk.opt : $(MAKEFILE) config.h         # create linker options file
+      @        open/write opt sys$disk:[]gawk.opt      ! ~ 'cat <<close 
>gawk.opt'
       @        write opt "! GAWK -- GNU awk"
       @ write opt "$(GAWKOBJ)"
       @ write opt "$(AWKOBJ1)"
@@ -139,17 +145,19 @@ gawk.opt : $(MAKEFILE)                    # create linker 
options file
       @ write opt "stack=48    !preallocate more pages (default is 20)"
       @ write opt "iosegment=128       !ditto (default is 32)"
       @        write opt "$(LIBS)"
-      @        write opt "identification=""V$(REL).$(PATCHLVL)"""
-      @        close opt
+      @ close opt
+      $ @$(VMSDIR)gawk_ident.com
 
 $(VMSCODE)     : awk.h config.h $(VMSDIR)redirect.h $(VMSDIR)vms.h
-$(AWKOBJS)     : awk.h gettext.h mbsupport.h regex.h dfa.h config.h 
$(VMSDIR)redirect.h
+$(AWKOBJS)     : awk.h gettext.h mbsupport.h regex.h dfa.h config.h \
+                 $(VMSDIR)redirect.h
 $(GAWKOBJ)     : awk.h config.h $(VMSDIR)redirect.h
 
 #-----------------------------------------------------------------------------
 # Older versions of MMS have problems handling lower case file names typically
 # found on ODS-5 disks. Fix this by adding explicit dependencies.
 #_____________________________________________________________________________
+
 array.obj      : array.c
 awkgram.obj    : awkgram.c awk.h
 builtin.obj    : builtin.c floatmagic.h random.h
@@ -174,7 +182,8 @@ node.obj    : node.c
 profile.obj    : profile.c
 random.obj     : random.c random.h
 re.obj         : re.c
-regex.obj      : regex.c regcomp.c regex_internal.c regexec.c regex.h 
regex_internal.h
+regex.obj      : regex.c regcomp.c regex_internal.c regexec.c regex.h \
+                 regex_internal.h
 str_array.obj  : str_array.c
 symbol.obj     : symbol.c
 version.obj    : version.c
@@ -184,12 +193,14 @@ vms_fwrite.obj    : $(VMSDIR)vms_fwrite.c
 vms_args.obj   : $(VMSDIR)vms_args.c
 vms_gawk.obj   : $(VMSDIR)vms_gawk.c
 vms_cli.obj    : $(VMSDIR)vms_cli.c
+vms_crtl_init.obj : $(VMSDIR)vms_crtl_init.c
 replace.obj    : replace.c $(MISSNGD)system.c $(MISSNGD)memcmp.c \
                  $(MISSNGD)memcpy.c $(MISSNGD)memset.c $(MISSNGD)memmove.c \
                  $(MISSNGD)strncasecmp.c $(MISSNGD)strerror.c \
                  $(MISSNGD)strftime.c $(MISSNGD)strchr.c $(MISSNGD)strtod.c \
                  $(MISSNGD)strtoul.c $(MISSNGD)tzset.c $(MISSNGD)mktime.c \
-                 $(MISSNGD)snprintf.c $(MISSNGD)getaddrinfo.c 
$(MISSNGD)usleep.c \
+                 $(MISSNGD)snprintf.c $(MISSNGD)getaddrinfo.c \
+                 $(MISSNGD)usleep.c \
                  $(MISSNGD)setenv.c $(MISSNGD)strcoll.c $(MISSNGD)wcmisc.c
 
 # bison or yacc required
@@ -201,7 +212,8 @@ awkgram.c   : awkgram.y     # foo.y :: yacc => y[_]tab.c, 
bison => foo_tab.c
        $(PARSER) $(YFLAGS) $<
      @- if f$search("ytab.c")  .nes."" then  rename/new_vers ytab.c  $@
      @- if f$search("y_tab.c") .nes."" then  rename/new_vers y_tab.c $@
-     @- if f$search("awkgram_tab.c").nes."" then  rename/new_vers 
awkgram_tab.c $@
+     @- if f$search("awkgram_tab.c").nes."" then \
+            rename/new_vers awkgram_tab.c $@
 
 command.c      : command.y
      @- if f$search("ytab.c")  .nes."" then  delete ytab.c;*
@@ -211,10 +223,14 @@ command.c : command.y
        $(PARSER) $(YFLAGS) $<
      @- if f$search("ytab.c")  .nes."" then  rename/new_vers ytab.c  $@
      @- if f$search("y_tab.c") .nes."" then  rename/new_vers y_tab.c $@
-     @- if f$search("command_tab.c").nes."" then  rename/new_vers 
command_tab.c $@
+     @- if f$search("command_tab.c").nes."" then \
+            rename/new_vers command_tab.c $@
+
+config_vms.h : $(VMSDIR)generate_config_vms_h_gawk.com
+     $ @$(VMSDIR)generate_config_vms_h_gawk.com
 
-config.h       : $(VMSDIR)vms-conf.h
-       copy $< sys$disk:[]$@
+config.h       : configh.in config_vms.h $(VMSDIR)config_h.com
+     $ @$(VMSDIR)config_h.com
 
 $(VMSCMD)      : $(VMSDIR)gawk.cld
        set command $(CLDFLAGS)/object=$@ $<
@@ -230,13 +246,16 @@ tidy :
 
 clean :
       - if f$search ("*.obj")    .nes. "" then delete *.obj;*
+      - if f$search ("*.lis")    .nes. "" then delete *.lis;*
       - if f$search ("gawk.opt") .nes. "" then delete gawk.opt;*
 
 spotless : clean tidy
-      - if f$search("config.h").nes."" then  rename config.h config.h-old/New
+      - if f$search("config.h").nes."" then delete config.h;*
+      - if f$search("config_vms.h").nes."" then delete config_vms.h;*
       - if f$search("gawk.exe").nes."" then  delete gawk.exe;*
       - if f$search("gawk.dvi").nes."" then  delete gawk.dvi;*
-      - if f$search("[.doc]texindex.exe").nes."" then  delete 
[.doc]texindex.exe;*
+      - if f$search("[.doc]texindex.exe").nes."" then \
+            delete [.doc]texindex.exe;*
 
 #
 # Note: this only works if you kept a copy of [.support]texindex.c
@@ -258,7 +277,8 @@ gawk.dvi : [.doc]texindex.exe [.doc]gawk.texi
       @ write sys$output " Third (final) pass"
        TeX gawk.texi
      -@ purge
-     -@ delete 
gawk.lis;,.aux;,gawk.%%;,.cps;,.fns;,.kys;,.pgs;,.toc;,.tps;,.vrs;
+     -@ delete \
+         gawk.lis;,.aux;,gawk.%%;,.cps;,.fns;,.kys;,.pgs;,.toc;,.tps;,.vrs;
       @ rename/new_vers gawk.dvi [-]*.*
       @ set default [-]
 
diff --git a/vms/fcntl.h b/vms/fcntl.h
deleted file mode 100644
index d975db7..0000000
--- a/vms/fcntl.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* "fcntl.h" -- constants for BSD-style I/O routines (ala VAX C's <file.h>) */
-#define O_RDONLY       0
-#define O_WRONLY       1
-#define O_RDWR         2
-#define O_NDELAY       4
-#define O_NOWAIT       4
-#define O_APPEND       8
-#define O_CREAT                0x0200
-#define O_TRUNC                0x0400
-#define O_EXCL         0x0800
diff --git a/vms/gawk_ident.com b/vms/gawk_ident.com
new file mode 100644
index 0000000..5b3966f
--- /dev/null
+++ b/vms/gawk_ident.com
@@ -0,0 +1,21 @@
+$! gawk_ident.com - Append ident with version to gawk.
+$!
+$!
+$ open/read cfgh config.h
+$cfgh_loop:
+$ read/end=cfgh_loop_end cfgh line_in
+$ key1 = f$element(0, " ", line_in)
+$ if key1 .nes. "#define" then goto cfgh_loop
+$ key2 = f$element(1, " ", line_in)
+$ if key2 .nes. "VERSION" then goto cfgh_loop
+$ version_string = f$element(2, " ", line_in) - """" - """"
+$ ver_major = f$element(0, ".", version_string)
+$ ver_minor = f$element(1, ".", version_string)
+$ REL = ver_major + "." + ver_minor
+$ PATCHLVL = f$element(2, ".", version_string)
+$cfgh_loop_end:
+$ close cfgh
+$!
+$ open/append Fopt gawk.opt
+$ write Fopt "identification=""V''REL'.''PATCHLVL'"""
+$ close Fopt
diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms
index cbc59cd..bee0b96 100644
--- a/vms/gawkmisc.vms
+++ b/vms/gawkmisc.vms
@@ -208,11 +208,17 @@ files_are_same(char *newfile, SRCFILE *oldfile)
 
        f2 = &oldfile->sbuf;
                /* compare device string */
+#ifdef _USE_STD_STAT
+       return (f1->st_dev == f2->st_dev
+               /* and 48-bit file id cookie */
+               && f1->st_ino == f2->st_ino);
+ #else
        return (strcmp(f1->st_dev, f2->st_dev) == 0
                /* and 48-bit file id cookie stored in 3 short ints */
                && f1->st_ino[0] == f2->st_ino[0]
                && f1->st_ino[1] == f2->st_ino[1]
                && f1->st_ino[2] == f2->st_ino[2]);
+#endif
 }
 
 int
diff --git a/vms/generate_config_vms_h_gawk.com 
b/vms/generate_config_vms_h_gawk.com
new file mode 100644
index 0000000..11493e5
--- /dev/null
+++ b/vms/generate_config_vms_h_gawk.com
@@ -0,0 +1,290 @@
+$! File: GENERATE_CONFIG_H_VMS_GAWK.COM
+$!
+$! Gawk like most open source products uses a variant of a config.h file.
+$! Depending on the curl version, this could be config.h or curl_config.h.
+$!
+$! For GNV based builds, the configure script is run and that produces
+$! a [curl_]config.h file.  Configure scripts on VMS generally do not
+$! know how to do everything, so there is also a [-.lib]config-vms.h file
+$! that has VMS specific code that compensates for bugs in some of the
+$! VMS shared images.
+$!
+$! This generates a []config.h file and also a config_vms.h file,
+$! which is used to supplement that file.
+$!
+$!
+$! Copyright 2013, John Malmberg
+$!
+$! Permission to use, copy, modify, and/or distribute this software for any
+$! purpose with or without fee is hereby granted, provided that the above
+$! copyright notice and this permission notice appear in all copies.
+$!
+$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+$!
+$!
+$! 28-Nov-2013 J. Malmberg
+$!
+$!=========================================================================
+$!
+$! Allow arguments to be grouped together with comma or separated by spaces
+$! Do no know if we will need more than 8.
+$ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
+$ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
+$!
+$! Provide lower case version to simplify parsing.
+$ args_lower = f$edit(args, "LOWERCASE")
+$!
+$ args_len = f$length(args)
+$!
+$ if (f$getsyi("HW_MODEL") .lt. 1024)
+$ then
+$   arch_name = "VAX"
+$ else
+$   arch_name = ""
+$   arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
+$   if (arch_name .eqs. "") then arch_name = "UNK"
+$ endif
+$!
+$!
+$! Start the configuration file.
+$! Need to do a create and then an append to make the file have the
+$! typical file attributes of a VMS text file.
+$ create sys$disk:[]config_vms.h
+$ open/append cvh sys$disk:[]config_vms.h
+$!
+$! Write the defines to prevent multiple includes.
+$! These are probably not needed in this case,
+$! but are best practice to put on all header files.
+$ write cvh "#ifndef __CONFIG_VMS_H__"
+$ write cvh "#define __CONFIG_VMS_H__"
+$ write cvh ""
+$!
+$ write cvh "#if __CRTL_VER >= 70000000"
+$ write cvh "#define VMS_V7"
+$ write cvh "#else"
+$ write cvh "#define HAVE_TZNAME 1 /* (faked in vms/vms_misc.c) */
+$ write cvh "#define HAVE_TZSET 1 /* (faked in vms/vms_misc.c) */
+$ write cvh "#endif"
+$ write cvh "#if __CRTL_VER >= 70200000"
+$ write cvh "#define DYNAMIC 1"
+$ write cvh "#endif"
+$ write cvh ""
+$ write cvh "#define PRINTF_HAS_F_FORMAT 1"
+$ write cvh ""
+$ write cvh "/* The _Noreturn keyword of C11.  */"
+$ write cvh "#ifndef _Noreturn"
+$ write cvh "# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \"
+$ write cvh "      || 0x5110 <= __SUNPRO_C)"
+$ write cvh "#  define _Noreturn __attribute__ ((__noreturn__))"
+$ write cvh "# elif defined _MSC_VER && 1200 <= _MSC_VER"
+$ write cvh "#  define _Noreturn __declspec (noreturn)"
+$ write cvh "# else"
+$ write cvh "#  define _Noreturn"
+$ write cvh "# endif"
+$ write cvh "#endif"
+$ write cvh ""
+$ write cvh "/*"
+$ write cvh " * VAXCRTL is pre-ANSI and does some variations of numeric"
+$ write cvh " * formatting differently than gawk expects."
+$ write cvh " */"
+$ write cvh "#if defined(VAX) && !defined(__DECC)"
+$ write cvh -
+ "/* '0' format modifier for %e,%f,%g gives wrong results in many cases */"
+$ write cvh "#define VAXCRTL"
+$ write cvh "/* %g format chooses %e format when should use %f */"
+$ write cvh "#define GFMT_WORKAROUND   1"
+$ write cvh "#endif"
+$ write cvh ""
+$ write cvh "/*"
+$ write cvh " * VAX C"
+$ write cvh " *"
+$ write cvh -
+ " * As of V3.2, VAX C is not yet ANSI-compliant.  But it's close enough"
+$ write cvh -
+ " * for GAWK's purposes.  Comment this out for VAX C V2.4 and earlier."
+$ write cvh -
+ " * YYDEBUG definition is needed for combination of VAX C V2.x and Bison."
+$ write cvh " */"
+$ write cvh "#if defined(VAXC) && !defined(__STDC__)"
+$ write cvh "#define __STDC__  0"
+$ write cvh "#define NO_TOKEN_PASTING"
+$ write cvh "#define signed  /*empty*/"
+$ write cvh "#define inline    /*empty*/"
+$ write cvh "#ifndef __DECC    /* DEC C does not support #pragma builtins */"
+$ write cvh "#define VAXC_BUILTINS"
+$ write cvh "#endif"
+$ write cvh "/* #define YYDEBUG 0 */"
+$ write cvh -
+  "#define NO_MBSUPPORT  /* VAX C's preprocessor can't handle mbsupport.h */"
+$ write cvh "#endif"
+$ write cvh ""
+$ write cvh ""
+$ write cvh "#if __DECC_VER >= 60400000 && !defined(DEBUG)"
+$ write cvh "/* disable ""new feature in C99"" diagnostics (for regex code); "
+$ write cvh "   NEWC99 ought to suffice but doesn't (at least in V6.4) */"
+$ write cvh "#pragma message disable (NEWC99,DESIGNATORUSE)"
+$ write cvh "#ifdef __VAX
+$ write cvh "#endif
+$ write cvh "#pragma message disable (LONGDOUBLENYI)"
+$ write cvh "#endif"
+$!
+$! This stuff seems needed for VMS 7.3 and earlier, but not VMS 8.2+
+$ write cvh "#if __VMS_VER <= 80200000"
+$ write cvh "#ifdef HAVE_MKSTEMP"
+$ write cvh "#undef HAVE_MKSTEMP"
+$ write cvh "#endif"
+$ write cvh "#endif"
+$ write cvh ""
+$!
+$! VMS not legal for ANSI compiler to pre-define
+$ write cvh "#ifndef VMS"
+$ write cvh "#define VMS 1"
+$ write cvh "#endif"
+$ write cvh ""
+$!
+$! Need to temp hide stuff that gawk is replacing or redefining before
+$! including the header.
+$ write cvh "/* Need to hide some stuff */"
+$ write cvh "#define getopt hide_getopt"
+$ write cvh "#define optopt hide_optopt"
+$ write cvh "#define optind hide_optind"
+$ write cvh "#define optarg hide_optarg"
+$ write cvh "#define opterr hide_opterr"
+$ write cvh "#define getpgrp hide_getpgrp"
+$ write cvh "#define unsetenv hide_unsetenv"
+$ write cvh "#define read hide_read"
+$ write cvh "#define delete hide_delete"
+$ write cvh "#define getcwd hide_getcwd"
+$ write cvh "#define getgid hide_getgid"
+$ write cvh "#define getegid hide_getegid"
+$ write cvh "#define setgid hide_setgid"
+$ write cvh "#define exit hide_exit"
+$ write cvh "#define _exit hide__exit"
+$ write cvh "#include <unistd.h>"
+$ write cvh "#include <stdlib.h>"
+$ write cvh "#include <stdio.h>"
+$ write cvh "#include <time.h>"
+$ write cvh "#include <stsdef.h>"
+$ write cvh "#include <string.h>"
+$ write cvh "#undef getopt"
+$ write cvh "#undef optopt"
+$ write cvh "#undef optind"
+$ write cvh "#undef optarg"
+$ write cvh "#undef opterr"
+$ write cvh "#undef getpgrp"
+$ write cvh "#undef getcwd"
+$ write cvh "#undef unsetenv"
+$ write cvh "#undef read"
+$ write cvh "#undef delete"
+$ write cvh "#undef getgid"
+$ write cvh "#undef getegid"
+$ write cvh "#undef setgid"
+$ write cvh "#undef exit"
+$ write cvh "#undef _exit"
+$!
+$write cvh "#ifdef HAVE_STRNCASECMP"
+$write cvh "#undef HAVE_STRNCASECMP"
+$write cvh "#endif"
+$!
+$ write cvh "#define IN_CONFIG_H"
+$ write cvh "#include ""redirect.h"""
+$ write cvh "#undef IN_CONFIG_H"
+$ write cvh "#define getpgrp gawk_vms_getpgrp"
+$ write cvh "#ifdef HAVE_SETENV"
+$ write cvh "#undef HAVE_SETENV"
+$ write cvh "#endif"
+$ write cvh "#ifdef HAVE_UNSETENV"
+$ write cvh "#undef HAVE_UNSETENV"
+$ write cvh "#endif"
+$ write cvh "#ifdef HAVE_STRFTIME"
+$ write cvh "#undef HAVE_STRFTIME"
+$ write cvh "#define USE_INCLUDED_STRFTIME"
+$ write cvh "#endif /* HAVE_STRFTIME */"
+$ write cvh ""
+$ write cvh "#include <bitypes.h>"
+$ write cvh "#define INT32_MAX __INT32_MAX"
+$ write cvh "#define INT32_MIN __INT32_MIN"
+$ write cvh ""
+$ write cvh "/*"
+$ write cvh " * DEFPATH"
+$ write cvh " *        VMS: ""/AWK_LIBRARY"" => ""AWK_LIBRARY:"""
+$ write cvh " * The default search path for the -f option of gawk.  It is"
+$ write cvh " * used if the AWKPATH environment variable is undefined."
+$ write cvh " *"
+$ write cvh " * Note: OK even if no AWK_LIBRARY logical name has been defined."
+$ write cvh " */"
+$ write cvh ""
+$ write cvh "#define DEFPATH   "".,/AWK_LIBRARY"""
+$ write cvh "#define DEFLIBPATH "".,/AWK_LIBRARY"""
+$ write cvh "#define ENVSEP    ','"
+$ write cvh ""
+$ write cvh "/*"
+$ write cvh " * Extended source file access."
+$ write cvh " */"
+$ write cvh "#define DEFAULT_FILETYPE "".awk"""
+$ write cvh ""
+$ write cvh "/*"
+$ write cvh " * fork/Pipe handling."
+$ write cvh " */"
+$ write cvh "#define PIPES_SIMULATED   1"
+$ write cvh ""
+$ write cvh "/* Extension for shared libraries */"
+$ write cvh "#define SHLIBEXT  ""exe"""
+$ write cvh ""
+$! GAWK does not want to use ALLOCA
+$ write cvh "#define NO_ALLOCA"
+$ write cvh "#define STACK_DIRECTION (-1)"
+$ write cvh ""
+$ write cvh "void decc$exit(int status);"
+$ write cvh "void __posix_exit(int status);"
+$ write cvh "#define _exit(foo) vms_exit(foo)"
+$ write cvh "#define exit(foo) vms_exit(foo)"
+$ write cvh ""
+$ write cvh "#define EXIT_FATAL (STS$M_INHIB_MSG | STS$K_SEVERE)"
+$ write cvh ""
+$ write cvh "#ifndef C_FACILITY_NO"
+$ write cvh "#define C_FACILITY_NO 0x350000"
+$ write cvh "#endif"
+$ write cvh ""
+$ write cvh "/* Use old exit codes for DCL, correct for other cases */
+$ write cvh "static void vms_exit(int status) {"
+$ write cvh "    char * shell;"
+$ write cvh "    int vms_status;"
+$ write cvh "    int use_old_exit = 0;"
+$ write cvh "    shell = getenv(""SHELL"");"
+$ write cvh "    if (shell != NULL) {"
+$ write cvh "        if (strcmp(shell, ""DCL"") == 0) {"
+$ write cvh "            use_old_exit = 1;"
+$ write cvh "        }"
+$ write cvh "    } else {"
+$ write cvh "        use_old_exit = 1;"
+$ write cvh "    }"
+$ write cvh "    if (use_old_exit == 1) {"
+$ write cvh "        decc$exit(status);"
+$ write cvh "    }"
+$ write cvh "    /* Fake the __posix_exit with severity added */"
+$ write cvh "    /* Undocumented correct way to do the above unless */"
+$ write cvh "    /* backwards compatibilty is needed */"
+$ write cvh "    vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;"
+$ write cvh "    if (status == EXIT_FAILURE) {"
+$ write cvh "        vms_status |= (1 << 3) | STS$K_ERROR;"
+$ write cvh "    } else if (status == EXIT_FATAL) {"
+$ write cvh "        vms_status |= (2 << 3) | STS$K_SEVERE;"
+$ write cvh "    }"
+$ write cvh "    decc$exit(vms_status);"
+$ write cvh "}"
+$!
+$! Close out the file
+$!
+$ write cvh ""
+$ write cvh "#endif /* __CONFIG_VMS_H__ */"
+$ close cvh
+$!
+$all_exit:
+$ exit
diff --git a/vms/vms-conf.h b/vms/vms-conf.h
deleted file mode 100644
index 575b5de..0000000
--- a/vms/vms-conf.h
+++ /dev/null
@@ -1,678 +0,0 @@
-#ifndef CONFIG_H
-#define CONFIG_H
-/*
- * config.h -- configuration definitions for gawk.
- *
- * For VMS (assumes V4.6 or later; tested on V7.3-1, V8.3.
- */
-
-/* 
- * Copyright (C) 1991-1992, 1995-1996, 1999, 2001-2003, 2005, 2009, 2010, 2011,
- * 2012, the Free Software Foundation, Inc.
- * 
- * This file is part of GAWK, the GNU implementation of the
- * AWK Programming Language.
- * 
- * GAWK is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- * 
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA
- */
-
-#if 0          /* no longer used */
-/* Define to 1 if using alloca.c.  */
-#define C_ALLOCA 1
-#else
-#define NO_ALLOCA      /* vms/vms_fwrite.c needs this */
-/* If using the C implementation of alloca, define if you know the
-   direction of stack growth for your system; otherwise it will be
-   automatically deduced at run-time.
-       STACK_DIRECTION > 0 => grows toward higher addresses
-       STACK_DIRECTION < 0 => grows toward lower addresses
-       STACK_DIRECTION = 0 => direction of growth unknown */
-#define STACK_DIRECTION (-1)
-#endif /*0*/
-
-#include <bitypes.h>
-#define INT32_MAX __INT32_MAX
-#define INT32_MIN __INT32_MIN
-
-/* dynamic loading is possible */
-#undef DYNAMIC
-
-/* Define to 1 if translation of program messages to the user's native
-   language is requested. */
-#undef ENABLE_NLS
-
-/* Define to the type of elements in the array set by `getgroups'. Usually
-   this is either `int' or `gid_t'. */
-#define GETGROUPS_T int
-
-/* Define to 1 if the `getpgrp' function requires zero arguments. */
-#define GETPGRP_VOID   1
-
-/* Define to 1 if you have the `alarm' function. */
-#define HAVE_ALARM 1
-
-/* Define to 1 if you have the <arpa/inet.h> header file. */
-#undef HAVE_ARPA_INET_H
-
-/* Define to 1 if you have the `atexit' function. */
-#define HAVE_ATEXIT 1
-
-/* Define to 1 if you have the `btowc' function. */
-#undef HAVE_BTOWC
-
-/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
-   CoreFoundation framework. */
-#undef HAVE_CFLOCALECOPYCURRENT
-
-/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
-   the CoreFoundation framework. */
-#undef HAVE_CFPREFERENCESCOPYAPPVALUE
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
-   */
-#undef HAVE_DCGETTEXT
-
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
-   */
-#undef HAVE_DECL_TZNAME
-
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-#undef HAVE_DOPRNT
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define to 1 if you have the `fmod' function. */
-#define HAVE_FMOD 1
-
-/* have getaddrinfo */
-#undef HAVE_GETADDRINFO
-
-/* Define to 1 if you have the `getgrent' function. */
-#undef HAVE_GETGRENT
-
-/* Define to 1 if you have the `getgroups' function. */
-#undef HAVE_GETGROUPS
-
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#undef HAVE_GETTEXT
-
-/* Define to 1 if you have the `grantpt' function. */
-#undef HAVE_GRANTPT
-
-/* Define if you have the iconv() function. */
-#undef HAVE_ICONV
-
-/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
-#undef HAVE_INTMAX_T
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
-   declares uintmax_t. */
-#undef HAVE_INTTYPES_H_WITH_UINTMAX
-
-/* Define to 1 if you have the `isascii' function. */
-#define HAVE_ISASCII 1
-
-/* Define to 1 if you have the `iswctype' function. */
-#define HAVE_ISWCTYPE 1
-
-/* Define to 1 if you have the `iswlower' function. */
-#define HAVE_ISWLOWER 1
-
-/* Define to 1 if you have the `iswupper' function. */
-#define HAVE_ISWUPPER 1
-
-/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
-#undef HAVE_LANGINFO_CODESET
-
-/* Define if your <locale.h> file defines LC_MESSAGES. */
-#undef HAVE_LC_MESSAGES
-
-/* Define to 1 if you have the <libintl.h> header file. */
-#undef HAVE_LIBINTL_H
-
-/* Define if you have the libsigsegv library. */
-#undef HAVE_LIBSIGSEGV
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* Define to 1 if you have a fully functional readline library. */
-#undef HAVE_LIBREADLINE
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define to 1 if you have the <locale.h> header file. */
-#undef HAVE_LOCALE_H
-
-/* Define if you have the 'long long' type. */
-#undef HAVE_LONG_LONG
-
-/* Define to 1 if the system has the type `long long int'. */
-#undef HAVE_LONG_LONG_INT
-
-/* Define to 1 if you have the `mbrlen' function. */
-#define HAVE_MBRLEN 1
-
-/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
-#define HAVE_MBRTOWC 1
-
-/* Define to 1 if you have the <mcheck.h> header file. */
-#undef HAVE_MCHECK_H
-
-/* Define to 1 if you have the `memcmp' function. */
-#define HAVE_MEMCMP 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the `memcpy_ulong' function. */
-#undef HAVE_MEMCPY_ULONG
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `memset' function. */
-#define HAVE_MEMSET 1
-
-/* Define to 1 if you have the `memset_ulong' function. */
-#undef HAVE_MEMSET_ULONG
-
-/* Define to 1 if you have the `mkstemp' function. */
-#undef HAVE_MKSTEMP
-
-/* we have the mktime function */
-#define HAVE_MKTIME 1
-
-/* Define to 1 if you have the <netdb.h> header file. */
-#undef HAVE_NETDB_H
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* we'll use the one in [.missing_d] */
-#undef HAVE_SETENV
-
-/* Define to 1 if you have the `setlocale' function. */
-#undef HAVE_SETLOCALE
-
-/* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
-
-/* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
-
-/* newer systems define this type here */
-#undef HAVE_SOCKADDR_STORAGE
-
-/* we have sockets on this system */
-#undef HAVE_SOCKETS
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
-   uintmax_t. */
-#undef HAVE_STDINT_H_WITH_UINTMAX
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strchr' function. */
-#define HAVE_STRCHR 1
-
-/* Define to 1 if you have the `strcoll' function. */
-#define HAVE_STRCOLL 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the `strftime' function. */
-#undef HAVE_STRFTIME           /* use the missing_d/strfime.c version */
-
-/* Define to 1 if cpp supports the ANSI # stringizing operator. */
-#ifdef VAXC
-#undef HAVE_STRINGIZE
-#else
-#define HAVE_STRINGIZE 1
-#endif
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the <stropts.h> header file. */
-#undef HAVE_STROPTS_H
-
-/* Define to 1 if you have the `strtod' function. */
-#define HAVE_STRTOD 1
-
-/* Define to 1 if you have the `strtoul' function. */
-#define HAVE_STRTOUL 1
-
-/* Define to 1 if `st_blksize' is a member of `struct stat'. */
-#undef HAVE_STRUCT_STAT_ST_BLKSIZE
-
-/* Define to 1 if `tm_zone' is a member of `struct tm'. */
-#undef HAVE_STRUCT_TM_TM_ZONE
-
-/* Define to 1 if you have the `system' function. */
-#define HAVE_SYSTEM 1
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#undef HAVE_SYS_SOCKET_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <termios.h> header file. */
-#undef HAVE_TERMIOS_H
-
-/* Define to 1 if you have the `tmpfile' function. */
-#define HAVE_TMPFILE 1
-/* Force snprintf.c to use tmpfile() instead of mkstemp(). */
-#ifdef HAVE_MKSTEMP
-#undef HAVE_MKSTEMP
-#endif
-
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
-   `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#undef HAVE_TM_ZONE
-
-/* Define to 1 if you have the `towlower' function. */
-#define HAVE_TOWLOWER 1
-
-/* Define to 1 if you have the `towupper' function. */
-#define HAVE_TOWUPPER 1
-
-/* Define to 1 if you don't have `tm_zone' but do have the external array
-   `tzname'. */
-#define HAVE_TZNAME 1          /* (faked in vms/vms_misc.c) */
-
-/* Define to 1 if you have the `tzset' function. */
-#define HAVE_TZSET 1           /* (faked in vms/vms_misc.c) */
-
-/* Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>. */
-#undef HAVE_UINTMAX_T
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#ifdef __DECC
-#define HAVE_UNISTD_H 1
-#else
-#undef HAVE_UNISTD_H
-#endif
-
-/* Define if you have the 'unsigned long long' type. */
-#undef HAVE_UNSIGNED_LONG_LONG
-
-/* Define to 1 if the system has the type `unsigned long long int'. */
-#undef HAVE_UNSIGNED_LONG_LONG_INT
-
-/* Define to 1 if you have the `usleep' function. */
-#define HAVE_USLEEP 1
-
-/* Define to 1 if you have the `vprintf' function. */
-#define HAVE_VPRINTF 1
-
-/* Define to 1 if you have the <wchar.h> header file. */
-#define HAVE_WCHAR_H 1
-
-/* Define to 1 if you have the `wcrtomb' function. */
-#define HAVE_WCRTOMB 1
-
-/* Define to 1 if you have the `wcscoll' function. */
-#define HAVE_WCSCOLL 1
-
-/* Define to 1 if you have the `wctype' function. */
-#define HAVE_WCTYPE 1
-
-/* Define to 1 if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_H 1
-
-/* systems should define this type here */
-#define HAVE_WCTYPE_T 1
-
-/* systems should define this type here */
-#undef HAVE_WINT_T
-
-/* disable fatal errors on directories */
-#undef NO_DIRECTORY_FATAL
-
-/* disable lint checks */
-#undef NO_LINT
-
-/* Name of package */
-#define PACKAGE "gawk"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "address@hidden"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "GNU Awk"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "GNU Awk 4.1.0"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "gawk"
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.1.0"
-
-/* Define to 1 if *printf supports %F format */
-#undef PRINTF_HAS_F_FORMAT
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* The size of a `unsigned int', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_INT 4
-
-/* The size of a `unsigned long', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_LONG 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* some systems define this type here */
-#undef TIME_T_IN_SYS_TYPES_H
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-#undef TM_IN_SYS_TIME
-
-/* force use of our version of strftime */
-#define USE_INCLUDED_STRFTIME 1
-
-/* Version number of package */
-#define VERSION "4.1.0"
-
-/* Define to 1 if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
-/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif
-
-/* Define for large files, on AIX-style hosts. */
-#undef _LARGE_FILES
-
-/* Define to 1 if on MINIX. */
-#undef _MINIX
-
-/* The _Noreturn keyword of C11.  */
-#ifndef _Noreturn
-# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
-      || 0x5110 <= __SUNPRO_C)
-#  define _Noreturn __attribute__ ((__noreturn__))
-# elif defined _MSC_VER && 1200 <= _MSC_VER
-#  define _Noreturn __declspec (noreturn)
-# else
-#  define _Noreturn
-# endif
-#endif
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
-   this defined. */
-#undef _POSIX_1_SOURCE
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-#undef _POSIX_SOURCE
-
-/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
-#ifndef __CHAR_UNSIGNED__
-# undef __CHAR_UNSIGNED__
-#endif
-
-/* Enable extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef gid_t
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-#undef inline
-#endif
-
-/* Define to widest signed type if <inttypes.h> doesn't define. */
-#define intmax_t long int
-
-/* Define to `int' if <sys/types.h> doesn't define.  */
-#undef pid_t
-
-/* Define to the equivalent of the C99 'restrict' keyword, or to
-   nothing if this is not supported.  Do not define if restrict is
-   supported directly.  */
-#define restrict
-#if defined(__DECC) && (__DECC_VER >= 60400000)
-#undef restrict
-#endif
-
-/* Define to `unsigned' if <sys/types.h> doesn't define.  */
-#undef size_t
-
-/* type to use in place of socklen_t if not defined */
-#undef socklen_t
-
-/* Define to `int' if <sys/types.h> does not define. */
-#define ssize_t int
-
-/* Define to `int' if <sys/types.h> doesn't define.  */
-#undef uid_t
-
-/* Define to unsigned long or unsigned long long if <stdint.h> and
-   <inttypes.h> don't define. */
-#define uintmax_t unsigned long
-
-#if 0
-#include "custom.h"    /* overrides for stuff autoconf can't deal with */
-#else
-
-/* Whether `time_t' is an unsigned type. */
-#define TIME_T_UNSIGNED 1
-
-/* Extension for shared libraries */
-#define SHLIBEXT       "exe"
-
-
-/*******************************/
-/* Gawk configuration options. */
-/*******************************/
-
-/*
- * DEFPATH
- *     VMS: "/AWK_LIBRARY" => "AWK_LIBRARY:"
- * The default search path for the -f option of gawk.  It is used
- * if the AWKPATH environment variable is undefined.
- *
- * Note: OK even if no AWK_LIBRARY logical name has been defined.
- */
-
-#define DEFPATH        ".,/AWK_LIBRARY"
-#define DEFLIBPATH ".,/AWK_LIBRARY"
-#define ENVSEP ','
-
-/*
- * Extended source file access.
- */
-#define DEFAULT_FILETYPE ".awk"
-
-/*
- * Pipe handling.
- */
-#define PIPES_SIMULATED        1
-
-/*
- * VAXCRTL is pre-ANSI and does some variations of numeric formatting
- * differently than gawk expects.
- */
-#if defined(VAX) && !defined(__DECC)
-/* '0' format modifier for %e,%f,%g gives wrong results in many cases */
-#define VAXCRTL
-/* %g format chooses %e format when should use %f */
-#define GFMT_WORKAROUND        1
-#endif
-
-/*
- * VAX C
- *
- * As of V3.2, VAX C is not yet ANSI-compliant.  But it's close enough
- * for GAWK's purposes.  Comment this out for VAX C V2.4 and earlier.
- * YYDEBUG definition is needed for combination of VAX C V2.x and Bison.
- */
-#if defined(VAXC) && !defined(__STDC__)
-#define __STDC__       0
-#define NO_TOKEN_PASTING
-#define signed  /*empty*/
-#define inline /*empty*/
-#ifndef __DECC /* DEC C does not support #pragma builtins even in VAXC mode */
-#define VAXC_BUILTINS
-#endif
-/* #define YYDEBUG 0 */
-#define NO_MBSUPPORT  /* VAX C's preprocessor can't handle mbsupport.h */
-#endif
-
-/*
- * DEC C
- *
- * Digital's ANSI complier.
- */
-#ifdef __DECC
- /* DEC C implies DECC$SHR, which doesn't have the %g problem of VAXCRTL */
-#undef GFMT_WORKAROUND
- /* DEC C V5.x introduces incompatibilities with prior porting efforts */
-#define _DECC_V4_SOURCE
-#define __SOCKET_TYPEDEFS
-#if __VMS_VER >= 60200000
-# undef __VMS_VER
-# define __VMS_VER 60100000
-#endif
-#if __CRTL_VER >= 60200000
-# if __CRTL_VER >= 70320000
-#  define CRTL_VER_V732
-#  define HAVE_SNPRINTF 1
-# endif
-# if __CRTL_VER >= 70301000
-#  define CRTL_VER_V731
-# endif
-# undef __CRTL_VER
-# define __CRTL_VER 60100000
-#endif
-#if __DECC_VER >= 60400000 && !defined(DEBUG)
-/* disable "new feature in C99" diagnostics (for regex code);
-   NEWC99 ought to suffice but doesn't (at least in V6.4) */
-#pragma message disable (NEWC99,DESIGNATORUSE)
-#endif
-#endif /* __DECC */
-
-/*
- * GNU C
- *
- * Versions of GCC (actually GAS) earlier than 1.38 don't produce the
- * right code for ``extern const'' constructs, and other usages of
- * const might not be right either.  The old set of include files from
- * the gcc-vms distribution did not contain prototypes, and this could
- * provoke some const-related compiler warnings.  If you've got an old
- * version of gcc for VMS, define 'const' out of existance, and by all
- * means obtain the most recent version!
- *
- * Note: old versions of GCC should also avoid defining STDC_HEADERS,
- *       because most of the ANSI-C required header files are missing.
- */
-#ifdef __GNUC__
-/* #define const */
-/* #undef STDC_HEADERS */
-/* #undef HAVE_STDDEF_H */
-#ifndef STDC_HEADERS
-#define alloca __builtin_alloca
-#define environ $$PsectAttributes_NOSHR$$environ       /* awful GAS kludge */
-#endif
-#undef  REGEX_MALLOC   /* use true alloca() in regex.c */
-#endif
-
-/* EXIT_SUCCESS and EXIT_FAILURE normally come from <stdlib.h> */
-#ifndef HAVE_STDLIB_H
-# define EXIT_SUCCESS  1               /* SYS$_NORMAL */
-# define EXIT_FAILURE  0x10000002      /* STS$M_INHIB_MSG|STS$K_ERROR */
-#endif
-/* EXIT_FATAL is specific to gawk, not part of Standard C */
-#define EXIT_FATAL     0x10000004      /* STS$M_INHIB_MSG|STS$K_SEVERE */
-
-#define IN_CONFIG_H
-#include "vms/redirect.h"
-#undef  IN_CONFIG_H
-
-#endif /*"custom.h"*/
-
-#endif /*CONFIG_H*/
diff --git a/vms/vms_crtl_init.c b/vms/vms_crtl_init.c
new file mode 100644
index 0000000..081ae2c
--- /dev/null
+++ b/vms/vms_crtl_init.c
@@ -0,0 +1,470 @@
+/* File: VMS_CRTL_INIT.C
+
+ This file is common to a lot of projects.
+
+ $Id: vms_crtl_init.c,v 1.1.1.1 2012/12/02 19:25:22 wb8tyw Exp $
+
+ Module that provides a LIB$INITIALIZE routine for the GNV toolset that
+ will turn on some CRTL features that are not enabled by default.
+
+ The CRTL features can also be turned on via logical names, but that
+ impacts all programs and some aren't ready, willing, or able to handle
+ the settings that GNV needs.
+
+ The original module was found linked with GPL V2 modules, and thus must
+ be able to be distributed under the GPL V2 provisions.
+
+ As this module or similar is needed for virtually all programs built to run
+ under GNV or UNIX, it can be distributed with other licenses.
+
+ Edit History
+
+ 1-001 John Reagan     Initial version using the old style interface
+                       but with the new version commented out.
+
+ 1-002 John Reagan     Switch to new API for setting features
+
+ 1-003 Steve Pitcher   Add DECC$RENAME_NO_INHERIT.
+
+ 1-004 Steve Pitcher   Quiet these, if the DECC feature doesn't exist.
+
+ 2-001 J. Malmberg     New GNV requirements:
+                           Three variations of object modules:
+                               1. For use with shells, sets the logical
+                                  name GNV$UNIX_SHELL.
+
+                               2. For utilities, if the logical name
+                                  GNV$UNIX_SHELL is set, it means that the
+                                  settings should assume that they are
+                                  running under a UNIX like shell.
+
+                               3. A third setting is for utilities that
+                                  always should behave as if they are
+                                  running under a UNIX shell.
+
+                           If GNV$GNU is defined, then locally define
+                           SYS$POSIX_ROOT to it.  GNV$GNU can be set in
+                           the SYSTEM table by the GNV setup.
+                           SYS$POSIX_ROOT can not.
+
+                           The logical name BIN also needs to be defined
+                           here, otherwise the CRTL replaces it with
+                           SYS$SYSTEM:
+
+                           Never set the POSIX UID here, it will break
+                           every reference to a GID/UID on systems that
+                           do not have every VMS account mapped to a UID/GID
+                           by TCPIP services.
+
+                           Reformat text to fit 80 columns.
+
+                           Remove all VAX C specific code.
+
+                           Linker is probably using exact case, so public
+                           symbols for LIB$* and SYS$* must be in upper case.
+
+ 2-002 J. Malmberg     Support for VAX builds.  OpenVMS/VAX does not have the
+       17-Jun-2010     DECC$FEATURE routines.  At this time I will not
+                       be concerned if a feature setting exists on VAX,
+                       as all we are doing is setting a logical name.
+
+ 2-003 J. Malmberg     Add DECC$FILENAME_UNIX_NOVERSION as version numbers
+                       will usually mess up ported programs.
+
+*/
+
+#include <stdio.h>
+#include <descrip.h>
+#include <lnmdef.h>
+#include <stsdef.h>
+#include <string.h>
+
+#pragma message disable pragma
+#pragma message disable dollarid
+#pragma message disable valuepres
+
+#pragma member_alignment save
+#pragma nomember_alignment longword
+#pragma message save
+#pragma message disable misalgndmem
+struct itmlst_3 {
+  unsigned short int buflen;
+  unsigned short int itmcode;
+  void *bufadr;
+  unsigned short int *retlen;
+};
+#pragma message restore
+#pragma member_alignment restore
+
+#ifdef __VAX
+#define ENABLE "ENABLE"
+#define DISABLE "DISABLE"
+#else
+
+#define ENABLE TRUE
+#define DISABLE 0
+int   decc$feature_get_index (const char *name);
+int   decc$feature_set_value (int index, int mode, int value);
+
+#endif
+
+int   SYS$TRNLNM(
+       const unsigned long * attr,
+       const struct dsc$descriptor_s * table_dsc,
+       struct dsc$descriptor_s * name_dsc,
+       const unsigned char * acmode,
+       const struct itmlst_3 * item_list);
+int   SYS$CRELNM(
+       const unsigned long * attr,
+       const struct dsc$descriptor_s * table_dsc,
+       const struct dsc$descriptor_s * name_dsc,
+       const unsigned char * acmode,
+       const struct itmlst_3 * item_list);
+int   LIB$SIGNAL(int);
+
+/* Take all the fun out of simply looking up a logical name */
+static int sys_trnlnm
+   (const char * logname,
+    char * value,
+    int value_len)
+{
+    const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
+    const unsigned long attr = LNM$M_CASE_BLIND;
+    struct dsc$descriptor_s name_dsc;
+    int status;
+    unsigned short result;
+    struct itmlst_3 itlst[2];
+
+    itlst[0].buflen = value_len;
+    itlst[0].itmcode = LNM$_STRING;
+    itlst[0].bufadr = value;
+    itlst[0].retlen = &result;
+
+    itlst[1].buflen = 0;
+    itlst[1].itmcode = 0;
+
+    name_dsc.dsc$w_length = strlen(logname);
+    name_dsc.dsc$a_pointer = (char *)logname;
+    name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+    name_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+    status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);
+
+    if ($VMS_STATUS_SUCCESS(status)) {
+
+        /* Null terminate and return the string */
+       /*--------------------------------------*/
+       value[result] = '\0';
+    }
+
+    return status;
+}
+
+/* How to simply create a logical name */
+static int sys_crelnm
+   (const char * logname,
+    const char * value)
+{
+    int ret_val;
+    const char * proc_table = "LNM$PROCESS_TABLE";
+    struct dsc$descriptor_s proc_table_dsc;
+    struct dsc$descriptor_s logname_dsc;
+    struct itmlst_3 item_list[2];
+
+    proc_table_dsc.dsc$a_pointer = (char *) proc_table;
+    proc_table_dsc.dsc$w_length = strlen(proc_table);
+    proc_table_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+    proc_table_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+    logname_dsc.dsc$a_pointer = (char *) logname;
+    logname_dsc.dsc$w_length = strlen(logname);
+    logname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+    logname_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+    item_list[0].buflen = strlen(value);
+    item_list[0].itmcode = LNM$_STRING;
+    item_list[0].bufadr = (char *)value;
+    item_list[0].retlen = NULL;
+
+    item_list[1].buflen = 0;
+    item_list[1].itmcode = 0;
+
+    ret_val = SYS$CRELNM(NULL, &proc_table_dsc, &logname_dsc, NULL, item_list);
+
+    return ret_val;
+}
+
+
+ /* Start of DECC RTL Feature handling */
+
+/*
+** Sets default value for a feature
+*/
+#ifdef __VAX
+static void set_feature_default(const char *name, const char *value)
+{
+    sys_crelnm(name, value);
+}
+#else
+static void set_feature_default(const char *name, int value)
+{
+     int index;
+
+     index = decc$feature_get_index(name);
+
+     if (index > 0)
+       decc$feature_set_value (index, 0, value);
+}
+#endif
+
+static void set_coe ( void )
+{
+
+    char gnv_posix_root[4096];
+    char unix_shell_name[255];
+    int use_unix_settings = 0;
+    int status;
+    int gnv_posix_root_found = 0;
+
+    /* If this is compiled for use with a UNIX shell, then the logical
+     * name GNV$UNIX_SHELL will be set to that shell name.
+     *
+     * Else, if the GNV$UNIX_SHELL logical name is set, then this application
+     * is running under some UNIX like shell, so it should modify it's
+     * behavior to be UNIX like.
+     *
+     * If the above logical name is not set, then the application should
+     * expect that it is running under DCL, and should expect VMS filenames
+     * on input, and may need to output filenames in VMS format.
+     *
+     * This can be overriden at compile time with GNV_UNIX_TOOL being
+     * defined.
+     *
+     * So this means that there will be multiple object modules from this
+     * source module.  One for each shell, one for programs that can function
+     * in both DCL and UNIX environments, and one for programs that require
+     * a UNIX environment.
+     */
+
+#ifdef GNV_UNIX_SHELL
+    use_unix_settings = 1;
+
+    status = sys_crelnm("GNV$UNIX_SHELL", GNV_UNIX_SHELL);
+    if (!$VMS_STATUS_SUCCESS(status)) {
+       /* We have a big problem */
+       LIB$SIGNAL(status);
+    }
+#else
+
+#ifdef GNV_UNIX_TOOL
+    use_unix_settings = 1;
+#else
+    status = sys_trnlnm("GNV$UNIX_SHELL",
+                       unix_shell_name, sizeof
+                       unix_shell_name -1);
+    if (!$VMS_STATUS_SUCCESS(status)) {
+       unix_shell_name[0] = 0;
+       use_unix_settings = 0;
+    }
+#endif /* GNV_UNIX_TOOL */
+
+#endif /* GNV_UNIX_SHELL */
+
+    /* New style interface that works only on very recent
+       (Apr 2001 and beyond) CRTLs */
+
+    /*
+     * Only setting defaults allows logical names to
+     * override these settings.
+     */
+
+    /* Always set */
+
+    /* ACCESS should check ACLs or it is lying. */
+    set_feature_default("DECC$ACL_ACCESS_CHECK"                , ENABLE);
+
+    /* We always want the new parse style */
+    set_feature_default ("DECC$ARGV_PARSE_STYLE"       , ENABLE);
+
+    /* Unless we are in POSIX compliant mode, we want the old POSIX root
+     * enabled.
+     */
+    set_feature_default("DECC$DISABLE_POSIX_ROOT", DISABLE);
+
+    /* EFS charset, means UTF-8 support */
+    /* VTF-7 support is controlled by a feature setting called UTF8 */
+    set_feature_default ("DECC$EFS_CHARSET"            , ENABLE);
+    set_feature_default ("DECC$EFS_CASE_PRESERVE"      , ENABLE);
+
+
+    /* Support timestamps when available */
+    set_feature_default ("DECC$EFS_FILE_TIMESTAMPS"    , ENABLE);
+
+    /* Cache environment varibles - performance improvements */
+    set_feature_default ("DECC$ENABLE_GETENV_CACHE"    , ENABLE);
+
+    /* Start out with new file attribute inheritance */
+#ifdef __VAX
+    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", "2");
+#else
+    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", 2);
+#endif
+
+    /* Don't display trailing dot after files without type */
+    set_feature_default ("DECC$READDIR_DROPDOTNOTYPE"  , ENABLE);
+
+    /* For standard output channels buffer output until terminator */
+    /* Gets rid of output logs with single character lines in them. */
+    set_feature_default ("DECC$STDIO_CTX_EOL"          , ENABLE);
+
+    /* Fix mv aa.bb aa                                         */
+    set_feature_default ("DECC$RENAME_NO_INHERIT"      , ENABLE);
+
+    if (use_unix_settings) {
+
+       /* POSIX requires that open files be able to be removed */
+       set_feature_default ("DECC$ALLOW_REMOVE_OPEN_FILES", ENABLE);
+
+       set_feature_default ("DECC$FILENAME_UNIX_ONLY"  , ENABLE);
+               /* FILENAME_UNIX_ONLY Implicitly sets
+                 decc$disable_to_vms_logname_translation */
+
+       set_feature_default ("DECC$FILE_PERMISSION_UNIX", ENABLE);
+
+       /* For now this only with UNIX mode, applications can override
+        * with out using a LIB$INITIALIZE setting.
+        * This should be an application specific setting only enabled
+        * if the application requires it.
+        * Left here for now for backwards compatibility
+         */
+       set_feature_default ("DECC$FILE_SHARING"        , ENABLE);
+
+        set_feature_default ("DECC$FILE_OWNER_UNIX"    , ENABLE);
+        set_feature_default ("DECC$POSIX_SEEK_STREAM_FILE", ENABLE);
+
+    } else {
+        set_feature_default("DECC$FILENAME_UNIX_REPORT", ENABLE);
+    }
+
+    /* When reporting UNIX filenames, glob the same way */
+    set_feature_default ("DECC$GLOB_UNIX_STYLE"        , ENABLE);
+
+    /* The VMS version numbers on Unix filenames is incompatible with most */
+    /* ported packages. */
+    set_feature_default("DECC$FILENAME_UNIX_NO_VERSION", ENABLE);
+
+    /* The VMS version numbers on Unix filenames is incompatible with most */
+    /* ported packages. */
+    set_feature_default("DECC$UNIX_PATH_BEFORE_LOGNAME", ENABLE);
+
+    /* Set strtol to proper behavior */
+    set_feature_default("DECC$STRTOL_ERANGE", ENABLE);
+
+    /*  Pipe feature settings are longer needed with virtual memory pipe
+       code.  Programs that use  pipe need to be converted to use the
+       virtual memory pipe code, which effectively removes the hangs and
+       left over temporary files.
+
+        Comment left here to prevent regressions, as the larger pipe size
+        actually hurts memory usage with the new algorithm.
+     */
+    /* do_not_set_default ("DECC$PIPE_BUFFER_SIZE"     , 8192); */
+
+
+    /* Rather than remove this completely, a comment is left here to warn
+     * someone from putting this bug back in.
+     *
+     * POSIX style UIDs require that the system administrator have set the
+     * system up to use POSIX style UIDs and GIDs.  And if they have done
+     * so, then they should set the DECC$POSIX_STYLE_UID as a system wide
+     * logical name.
+     *
+     * Setting them in a program will break all routines that expect GID/UID
+     * stuff to work on systems set up by default with out mappings.
+     *
+     * Most utilities do not reference GID/UID values, so it took a while for
+     * this bug to surface.
+     */
+     /*  do_not_set_default ("DECC$POSIX_STYLE_UID"    , TRUE); */
+
+
+
+    /* GNV depends on SYS$POSIX_ROOT to be properly set.  Since SYS$POSIX_ROOT
+     * globally affects all C applications, SYS$POSIX_ROOT can not be set
+     * anywhere that can be seen by other applications.
+     *
+     * So GNV$GNU is used instead, and SYS$POSIX_ROOT will be set in
+     * in the process table in user mode to that value.
+     *
+     * Restriction: The system manager should not point GNV$GNU at
+     * SYS$POSIX_ROOT, or anything that resolves to SYS$POSIX_ROOT.
+     *
+     */
+
+    status = sys_trnlnm("GNV$GNU",
+                       gnv_posix_root,
+                       sizeof gnv_posix_root - 1);
+    if ($VMS_STATUS_SUCCESS(status)) {
+       status = sys_crelnm("SYS$POSIX_ROOT", "GNV$GNU:");
+       gnv_posix_root_found = 1;
+    }
+
+    /* GNV depends on BIN being set to GNV$GNU:[bin].  Since BIN
+     * is not prefixed, and it affects everything globally, it needs to
+     * be set here if it is not defined already.
+     * If it is set already, assume that it is correct, rather than
+     * trying to second guess the user.
+     * If GNV$GNU is not defined, then define bin to be SYS$POSIX_ROOT.
+     */
+
+    status = sys_trnlnm("BIN",
+                       gnv_posix_root,
+                       sizeof gnv_posix_root - 1);
+    if (!$VMS_STATUS_SUCCESS(status)) {
+       if (gnv_posix_root_found) {
+           status = sys_crelnm("BIN", "GNV$GNU:[BIN]");
+       } else {
+           status = sys_crelnm("BIN", "SYS$POSIX_ROOT:[BIN]");
+       }
+    }
+
+}
+
+#pragma nostandard
+#pragma extern_model save
+#ifdef __VAX
+#pragma extern_model strict_refdef "LIB$INITIALIZE" nowrt, long, nopic
+#else
+#pragma extern_model strict_refdef "LIB$INITIALIZE" nowrt, long
+#    if __INITIAL_POINTER_SIZE
+#        pragma __pointer_size __save
+#        pragma __pointer_size 32
+#    else
+#        pragma __required_pointer_size __save
+#        pragma __required_pointer_size 32
+#    endif
+#endif
+/* Set our contribution to the LIB$INITIALIZE array */
+void (* const iniarray[])(void) = {set_coe, } ;
+#ifndef __VAX
+#    if __INITIAL_POINTER_SIZE
+#        pragma __pointer_size __restore
+#    else
+#        pragma __required_pointer_size __restore
+#    endif
+#endif
+
+
+/*
+** Force a reference to LIB$INITIALIZE to ensure it
+** exists in the image.
+*/
+int LIB$INITIALIZE(void);
+#ifdef __DECC
+#pragma extern_model strict_refdef
+#endif
+    int lib_init_ref = (int) LIB$INITIALIZE;
+#ifdef __DECC
+#pragma extern_model restore
+#pragma standard
+#endif
diff --git a/vms/vms_gawk_main_wrapper.c b/vms/vms_gawk_main_wrapper.c
new file mode 100644
index 0000000..367f0cc
--- /dev/null
+++ b/vms/vms_gawk_main_wrapper.c
@@ -0,0 +1,487 @@
+/* File: vms_gawk_main_wrapper.c
+ *
+ * This module provides a wrapper around the main() function of a ported
+ * program for two functions:
+ *
+ * 1. Make sure that the argv[0] string is set as close as possible to
+ *    what the original command was given.
+ *
+ * 2. Make sure that the posix exit is called.
+ *
+ * 3. Fixup the timezone information.
+ *
+ * Copyright 2012, John Malmberg
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <descrip.h>
+#include <dvidef.h>
+#include <efndef.h>
+#include <fscndef.h>
+#include <stsdef.h>
+#include <time.h>
+#include <lnmdef.h>
+
+
+#pragma member_alignment save
+#pragma nomember_alignment longword
+struct item_list_3 {
+       unsigned short len;
+       unsigned short code;
+       void * bufadr;
+       unsigned short * retlen;
+};
+
+struct filescan_itmlst_2 {
+    unsigned short length;
+    unsigned short itmcode;
+    char * component;
+};
+
+#pragma member_alignment
+
+int SYS$GETDVIW
+       (unsigned long efn,
+       unsigned short chan,
+       const struct dsc$descriptor_s * devnam,
+       const struct item_list_3 * itmlst,
+       void * iosb,
+       void (* astadr)(unsigned long),
+       unsigned long astprm,
+       void * nullarg);
+
+int SYS$FILESCAN
+   (const struct dsc$descriptor_s * srcstr,
+    struct filescan_itmlst_2 * valuelist,
+    unsigned long * fldflags,
+    struct dsc$descriptor_s *auxout,
+    unsigned short * retlen);
+
+int   SYS$TRNLNM(
+       const unsigned long * attr,
+       const struct dsc$descriptor_s * table_dsc,
+       struct dsc$descriptor_s * name_dsc,
+       const unsigned char * acmode,
+       const struct item_list_3 * item_list);
+
+/* Take all the fun out of simply looking up a logical name */
+static int sys_trnlnm
+   (const char * logname,
+    char * value,
+    int value_len)
+{
+    const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
+    const unsigned long attr = LNM$M_CASE_BLIND;
+    struct dsc$descriptor_s name_dsc;
+    int status;
+    unsigned short result;
+    struct item_list_3 itlst[2];
+
+    itlst[0].len = value_len;
+    itlst[0].code = LNM$_STRING;
+    itlst[0].bufadr = value;
+    itlst[0].retlen = &result;
+
+    itlst[1].len = 0;
+    itlst[1].code = 0;
+
+    name_dsc.dsc$w_length = strlen(logname);
+    name_dsc.dsc$a_pointer = (char *)logname;
+    name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+    name_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+    status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);
+
+    if ($VMS_STATUS_SUCCESS(status)) {
+
+        /* Null terminate and return the string */
+       /*--------------------------------------*/
+       value[result] = '\0';
+    }
+
+    return status;
+}
+
+int original_main(int argc, char ** argv, char **env);
+
+int main(int argc, char ** argv, char **env) {
+int status;
+int result;
+char arg_nam[256];
+char **new_argv;
+char *tz_rule;
+
+#ifdef TEST_MAIN
+    printf("original argv[0] = %s\n", argv[0]);
+#endif
+
+    new_argv = argv;
+    result = 0;
+
+    /* If the path name starts with a /, then it is an absolute path        */
+    /* that may have been generated by the CRTL instead of the command name  */
+    /* If it is the device name between the slashes, then this was likely    */
+    /* from the run command and needs to be fixed up.                       */
+    /* If the DECC$POSIX_COMPLIANT_PATHNAMES is set to 2, then it is the     */
+    /* DISK$VOLUME that will be present, and it will still need to be fixed. */
+    if (argv[0][0] == '/') {
+       char * nextslash;
+       int length;
+       struct item_list_3 itemlist[3];
+       unsigned short dvi_iosb[4];
+       char alldevnam[64];
+       unsigned short alldevnam_len;
+       struct dsc$descriptor_s devname_dsc;
+       char diskvolnam[256];
+       unsigned short diskvolnam_len;
+
+         /* Get some information about the disk */
+       /*--------------------------------------*/
+       itemlist[0].len = (sizeof alldevnam) - 1;
+       itemlist[0].code = DVI$_ALLDEVNAM;
+       itemlist[0].bufadr = alldevnam;
+       itemlist[0].retlen = &alldevnam_len;
+       itemlist[1].len = (sizeof diskvolnam) - 1 - 5;
+       itemlist[1].code = DVI$_VOLNAM;
+       itemlist[1].bufadr = &diskvolnam[5];
+       itemlist[1].retlen = &diskvolnam_len;
+       itemlist[2].len = 0;
+       itemlist[2].code = 0;
+
+       /* Add the prefix for the volume name. */
+       /* SYS$GETDVI will append the volume name to this */
+       strcpy(diskvolnam,"DISK$");
+
+       nextslash = strchr(&argv[0][1], '/');
+       if (nextslash != NULL) {
+           length = nextslash - argv[0] - 1;
+
+           /* Cast needed for HP C compiler diagnostic */
+           devname_dsc.dsc$a_pointer = (char *)&argv[0][1];
+           devname_dsc.dsc$w_length = length;
+           devname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
+           devname_dsc.dsc$b_class = DSC$K_CLASS_S;
+
+           status = SYS$GETDVIW
+              (EFN$C_ENF,
+               0,
+               &devname_dsc,
+               itemlist,
+               dvi_iosb,
+               NULL, 0, 0);
+           if (!$VMS_STATUS_SUCCESS(status)) {
+               /* If the sys$getdviw fails, then this path was passed by */
+               /* An exec() program and not from DCL, so do nothing */
+               /* An example is "/tmp/program" where tmp: does not exist */
+#ifdef TEST_MAIN
+               printf("sys$getdviw failed with status %d\n", status);
+#endif
+               result = 0;
+           } else if (!$VMS_STATUS_SUCCESS(dvi_iosb[0])) {
+#ifdef TEST_MAIN
+               printf("sys$getdviw failed with iosb %d\n", dvi_iosb[0]);
+#endif
+               result = 0;
+           } else {
+               char * devnam;
+               int devnam_len;
+               char argv_dev[64];
+
+               /* Null terminate the returned alldevnam */
+               alldevnam[alldevnam_len] = 0;
+               devnam = alldevnam;
+               devnam_len = alldevnam_len;
+
+               /* Need to skip past any leading underscore */
+               if (devnam[0] == '_') {
+                   devnam++;
+                   devnam_len--;
+               }
+
+               /* And remove the trailing colon */
+               if (devnam[devnam_len - 1] == ':') {
+                   devnam_len--;
+                   devnam[devnam_len] = 0;
+               }
+
+               /* Null terminate the returned volnam */
+               diskvolnam_len += 5;
+               diskvolnam[diskvolnam_len] = 0;
+
+               /* Check first for normal CRTL behavior */
+               if (devnam_len == length) {
+                   strncpy(arg_nam, &argv[0][1], length);
+                   arg_nam[length] = 0;
+                   result = (strcasecmp(devnam, arg_nam) == 0);
+               }
+
+               /* If we have not got a match check for POSIX Compliant */
+               /* behavior.  To be more accurate, we could also check */
+               /* to see if that feature is active. */
+               if ((result == 0) && (diskvolnam_len == length)) {
+                   strncpy(arg_nam, &argv[0][1], length);
+                   arg_nam[length] = 0;
+                   result = (strcasecmp(diskvolnam, arg_nam) == 0);
+               }
+           }
+       }
+    } else {
+       /* The path did not start with a slash, so it could be VMS format */
+       /* If it is vms format, it has a volume/device in it as it must   */
+       /* be an absolute path */
+       struct dsc$descriptor_s path_desc;
+       int status;
+       unsigned long field_flags;
+       struct filescan_itmlst_2 item_list[5];
+       char * volume;
+       char * name;
+       int name_len;
+       char * ext;
+
+       path_desc.dsc$a_pointer = (char *)argv[0]; /* cast ok */
+       path_desc.dsc$w_length = strlen(argv[0]);
+       path_desc.dsc$b_dtype = DSC$K_DTYPE_T;
+       path_desc.dsc$b_class = DSC$K_CLASS_S;
+
+       /* Don't actually need to initialize anything buf itmcode */
+       /* I just do not like uninitialized input values */
+
+       /* Sanity check, this must be the same length as input */
+       item_list[0].itmcode = FSCN$_FILESPEC;
+       item_list[0].length = 0;
+       item_list[0].component = NULL;
+
+       /* If the device is present, then it if a VMS spec */
+       item_list[1].itmcode = FSCN$_DEVICE;
+       item_list[1].length = 0;
+       item_list[1].component = NULL;
+
+       /* we need the program name and type */
+       item_list[2].itmcode = FSCN$_NAME;
+       item_list[2].length = 0;
+       item_list[2].component = NULL;
+
+       item_list[3].itmcode = FSCN$_TYPE;
+       item_list[3].length = 0;
+       item_list[3].component = NULL;
+
+       /* End the list */
+       item_list[4].itmcode = 0;
+       item_list[4].length = 0;
+       item_list[4].component = NULL;
+
+       status = SYS$FILESCAN(
+               (const struct dsc$descriptor_s *)&path_desc,
+               item_list, &field_flags, NULL, NULL);
+
+       if ($VMS_STATUS_SUCCESS(status) &&
+          (item_list[0].length == path_desc.dsc$w_length) &&
+          (item_list[1].length != 0)) {
+
+           char * dollar;
+           int keep_ext;
+           int i;
+
+           /* We need the filescan to be successful, */
+           /* same length as input, and a volume to be present */
+
+           /* Need a new argv array */
+           new_argv = malloc((argc + 1) * (sizeof(char *)));
+           new_argv[0] = arg_nam;
+           i = 1;
+           while (i < argc) {
+               new_argv[i] = argv[i];
+               i++;
+           }
+
+           /* We will assume that we only get to this path on a version */
+           /* of VMS that does not support the EFS character set */
+
+           /* There may be a xxx$ prefix on the image name.  Linux */
+           /* programs do not handle that well, so strip the prefix */
+           name = item_list[2].component;
+           name_len = item_list[2].length;
+           dollar = strrchr(name, '$');
+           if (dollar != NULL) {
+               dollar++;
+               name_len = name_len - (dollar - name);
+               name = dollar;
+           }
+
+           strncpy(arg_nam, name, name_len);
+           arg_nam[name_len] = 0;
+
+           /* We only keep the extension if it is not ".exe" */
+           keep_ext = 0;
+           ext = item_list[3].component;
+
+           if (item_list[3].length != 1) {
+               if (item_list[3].length != 4) {
+                   keep_ext = 1;
+               } else {
+                   int x;
+                   x = strncmp(ext, ".exe", 4);
+                   if (x != 0) {
+                       keep_ext = 1;
+                   }
+               }
+           }
+
+           if (keep_ext == 1) {
+               strncpy(&arg_nam[name_len], ext, item_list[3].length);
+           }
+       }
+    }
+
+    if (result) {
+       char * lastslash;
+       char * dollar;
+       char * dotexe;
+       char * lastdot;
+       char * extension;
+
+       /* This means it is probably the name from a DCL command */
+       /* Find the last slash which separates the file from the */
+       /* path. */
+       lastslash = strrchr(argv[0], '/');
+
+       if (lastslash != NULL) {
+           int i;
+
+           lastslash++;
+
+           /* There may be a xxx$ prefix on the image name.  Linux */
+           /* programs do not handle that well, so strip the prefix */
+           dollar = strrchr(lastslash, '$');
+
+           if (dollar != NULL) {
+               dollar++;
+               lastslash = dollar;
+           }
+
+           strcpy(arg_nam, lastslash);
+
+           /* In UNIX mode + EFS character set, there should not be a */
+           /* version present, as it is not possible when parsing to  */
+           /* tell if it is a version or part of the UNIX filename as */
+           /* UNIX programs use numeric extensions for many reasons.  */
+
+           lastdot = strrchr(arg_nam, '.');
+           if (lastdot != NULL) {
+               int i;
+
+               i = 1;
+               while (isdigit(lastdot[i])) {
+                   i++;
+               }
+               if (lastdot[i] == 0) {
+                   *lastdot = 0;
+               }
+           }
+
+           /* Find the .exe on the name (case insenstive) and toss it */
+           dotexe = strrchr(arg_nam, '.');
+           if (dotexe != NULL) {
+               if ((dotexe[1] == 'e' || dotexe[1] == 'E') &&
+                   (dotexe[2] == 'x' || dotexe[2] == 'X') &&
+                   (dotexe[3] == 'e' || dotexe[3] == 'E') &&
+                   (dotexe[4] == 0)) {
+
+                   *dotexe = 0;
+               } else {
+                   /* Also need to handle a null extension because of a */
+                   /* CRTL bug. */
+                   if (dotexe[1] == 0) {
+                       *dotexe = 0;
+                   }
+               }
+           }
+
+           /* Need a new argv array */
+           new_argv = malloc((argc + 1) * (sizeof(char *)));
+           new_argv[0] = arg_nam;
+           i = 1;
+           while (i < argc) {
+               new_argv[i] = argv[i];
+               i++;
+           }
+           new_argv[i] = 0;
+
+       } else {
+           /* There is no way that the code should ever get here */
+           /* As we already verified that the '/' was present */
+           fprintf(stderr, "Sanity failure somewhere we lost a '/'\n");
+       }
+
+    }
+
+    /*
+     * The vms_main_wrapper fixes up the name, but for the DCL shell
+     * may leave it in upper case, which messes up the self tests.
+     * force it to lower case here.
+     */
+    char * shell;
+    int lcname = 0;
+    shell = getenv("SHELL");
+    if (shell != NULL) {
+        if (strcmp(shell, "DCL") == 0) {
+            lcname = 1;
+        }
+    } else {
+        lcname = 1;
+    }
+    if (lcname == 1) {
+        int i = 0;
+        while (new_argv[0][i] != 0) {
+               new_argv[0][i] = tolower(new_argv[0][i]);
+            i++;
+        }
+    }
+
+    /* Fix up the time zone */
+    tz_rule = malloc(1024);
+    status = sys_trnlnm("TZ", tz_rule, 1024);
+    if ($VMS_STATUS_SUCCESS(status)) {
+        setenv("TZ", tz_rule, 1);
+    } else {
+        status = sys_trnlnm("SYS$TIMEZONE_RULE", tz_rule, 1024);
+        if ($VMS_STATUS_SUCCESS(status)) {
+            setenv("TZ", tz_rule, 1);
+        }
+    }
+    free(tz_rule);
+
+    exit(original_main(argc, new_argv, env));
+    return 1; /* Needed to silence compiler diagnostic */
+}
+
+#define main original_main
+
+#ifdef TEST_MAIN
+
+int main(int argc, char ** argv, char **env) {
+
+    printf("modified argv[0] = %s\n", argv[0]);
+
+    return 0;
+}
+
+#endif
diff --git a/vms/vms_misc.c b/vms/vms_misc.c
index cd92d7e..ce19034 100644
--- a/vms/vms_misc.c
+++ b/vms/vms_misc.c
@@ -118,15 +118,24 @@ vms_open( const char *name, int mode, ... )
        result = creat(name, 0, "rfm=stmlf", "rat=cr", "shr=nil", "mbc=32");
     } else {
        struct stat stb;
+       int stat_result;
        const char *mbc, *shr = "shr=get", *ctx = "ctx=stm";
-
-       if (stat((char *)name, &stb) < 0) {     /* assume DECnet */
+ 
+       stat_result = stat((char *)name, &stb);
+       if ( stat_result < 0) { /* assume DECnet */
            mbc = "mbc=8";
        } else {    /* ordinary file; allow full sharing iff record format */
            mbc = "mbc=32";
            if ((stb.st_fab_rfm & 0x0F) < FAB$C_STM) shr = "shr=get,put,upd";
        }
        result = open(name, mode, 0, shr, mbc, "mbf=2");
+       if ((stat_result >= 0) && (result < 0) && (errno == ENOENT)) {
+           /* ENOENT not possible because stat succeeded */
+           errno = EMFILE;
+           if (S_ISDIR(stb.st_mode)) {
+               errno = EISDIR; /* Bug seen in VMS 8.3 */
+           }
+        }
     }
 
     /* This is only approximate; the ACP -> RMS -> VAXCRTL interface
diff --git a/vms/vmsbuild.com b/vms/vmsbuild.com
index 95c6aeb..ff5dc92 100644
--- a/vms/vmsbuild.com
+++ b/vms/vmsbuild.com
@@ -15,9 +15,18 @@ $!
 $ REL = "4.1"  !release version number
 $ PATCHLVL = "0"
 $!
+$ if (f$getsyi("HW_MODEL") .lt. 1024)
+$ then
+$   arch_name = "VAX"
+$ else
+$   arch_name = f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
+$ endif
 $!
 $ CCFLAGS = "/noList"  ! "/noOpt/Debug"
+$! CCFLAGS = "/list/show=(expan,incl)
 $ CDEFS          = "GAWK,HAVE_CONFIG_H"
+$! Do not specify _POSIX_EXIT here, we are using other tricks for that.
+$!
 $!
 $ if p1.eqs."" then  p1 = "DECC"       !default compiler
 $ if p1.eqs."GNUC"
@@ -38,8 +47,16 @@ $   CFLAGS = 
"/Incl=[]/Obj=[]/Opt=noInline/Def=(''CDEFS')''CCFLAGS'"
 $   LIBS = "sys$share:vaxcrtl.exe/Shareable"
 $  else  !!VAXC
 $!  neither GNUC nor VAXC, assume DECC (same for either VAX or Alpha)
+$ if arch_name .eqs. "vax"
+$ then
+$   cfloat = ""
+$ else
+$   cfloat = "/float=ieee/ieee_mode=denorm_results"
+$ endif
 $   CC = "cc/DECC/Prefix=All"
-$   CFLAGS = "/Incl=[]/Obj=[]/Def=(''CDEFS')''CCFLAGS'"
+$   CINC = "/NESTED_INCLUDE=NONE"
+$   CFLAGS = "/Incl=([],[.vms])/Obj=[]/Def=(''CDEFS')''CINC'''CCFLAGS'"
+$   CFLAGS = cfloat + CFLAGS
 $   LIBS = ""  ! DECC$SHR instead of VAXCRTL, no special link option needed
 $  endif !VAXC
 $ endif !GNUC
@@ -47,12 +64,15 @@ $!
 $ cc = CC + CFLAGS
 $ show symbol cc
 $!
-$ if f$search("config.h").nes."" then -
-    if f$cvtime(f$file_attr("config.h","RDT")).ges.-
-       f$cvtime(f$file_attr("[.vms]vms-conf.h","RDT")) then  goto config_ok
-$ v = f$verify(1)
-$ copy [.vms]vms-conf.h []config.h
-$! 'f$verify(v)'
+$ if f$search("config.h") .nes. ""
+$ then
+$    if f$cvtime(f$file_attr("config.h", "RDT")) .ges. -
+        f$cvtime(f$file_attr("configh.in","RDT")) then  goto config_ok
+$ endif
+$ v = f$verify(0)
+$ @[.vms]generate_config_vms_h_gawk.com
+$ @[.vms]config_h.com NOBUILTINS
+$!
 $config_ok:
 $ if f$search("awkgram.c").nes."" then  goto awkgram_ok
 $      write sys$output " You must process `awkgram.y' with ""yacc"" or 
""bison"""
@@ -106,7 +126,8 @@ $ cc [.vms]vms_fwrite.c
 $ cc [.vms]vms_args.c
 $ cc [.vms]vms_gawk.c
 $ cc [.vms]vms_cli.c
-$ set command/Object=[]gawk_cmd.obj [.vms]gawk.cld
+$ cc [.vms]vms_crtl_init.c
+$ set command/Object=[]gawk_cmd.obj sys$disk:[.vms]gawk.cld
 $! 'f$verify(v)'
 $!
 $ close/noLog Fopt
@@ -116,15 +137,18 @@ 
array.obj,awkgram.obj,builtin.obj,dfa.obj,ext.obj,field.obj,floatcomp.obj
 gawkmisc.obj,getopt.obj,getopt1.obj,io.obj
 main.obj,msg.obj,node.obj
 random.obj,re.obj,regex.obj,replace.obj,version.obj,eval.obj,profile.obj
-command.obj,debug.obj,int_array.obj,cint_array.obj,gawkapi.obj,mpfr.obj,str_array.obj,symbol.obj
+command.obj,debug.obj,int_array.obj,cint_array.obj,gawkapi.obj,mpfr.obj
+str_array.obj,symbol.obj
 []vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj
-[]vms_gawk.obj,vms_cli.obj,gawk_cmd.obj
+[]vms_gawk.obj,vms_cli.obj,gawk_cmd.obj,vms_crtl_init.obj
 psect_attr=environ,noshr       !extern [noshare] char **
 stack=48       !preallocate more pages (default is 20)
 iosegment=128  !ditto (default is 32)
+$!
+$ v = f$verify(1)
+$ @[.vms]gawk_ident.com
 $ open/append Fopt gawk.opt
 $ write Fopt libs
-$ write Fopt "identification=""V''REL'.''PATCHLVL'"""
 $ close Fopt
 $!
 $ v = f$verify(1)
diff --git a/vms/vmstest.com b/vms/vmstest.com
index 2540437..7b1c3a3 100644
--- a/vms/vmstest.com
+++ b/vms/vmstest.com
@@ -601,7 +601,7 @@ $   mon = f$cvtime(now,"ABSOLUTE","MONTH")
 $      mon = f$extract(0,1,mon) + f$edit(f$extract(1,2,mon),"LOWERCASE")
 $      day = f$cvtime(now,,"DAY")
 $      tim = f$extract(0,8,f$cvtime(now,,"TIME"))
-$      tz  = ""
+$      tz = f$trnlnm("SYS$TIMEZONE_NAME")
 $      yr  = f$cvtime(now,,"YEAR")
 $      if f$trnlnm("FTMP").nes."" then  close/noLog ftmp
 $      open/Write ftmp strftime.in

-----------------------------------------------------------------------


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]