summaryrefslogtreecommitdiff
path: root/vms
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-12-21 19:20:17 +0200
committerArnold D. Robbins <arnold@skeeve.com>2013-12-21 19:20:17 +0200
commit4fe032a32469509d548919624f1eaa459f82a160 (patch)
treea486f93db235e3f05d3fa31f664766e953f5a0b7 /vms
parentf2967e7bacc594ebcd7d33401ef220393d6fac05 (diff)
downloadgawk-4fe032a32469509d548919624f1eaa459f82a160.tar.gz
Add exact case build support and doc fixes for VMS.
Diffstat (limited to 'vms')
-rw-r--r--vms/ChangeLog12
-rw-r--r--vms/descrip.mms5
-rw-r--r--vms/gawk.hlp26
-rw-r--r--vms/generate_config_vms_h_gawk.com34
-rw-r--r--vms/vms.h24
-rw-r--r--vms/vms_args.c22
-rw-r--r--vms/vms_cli.c28
-rw-r--r--vms/vms_fwrite.c12
-rw-r--r--vms/vms_gawk.c14
-rw-r--r--vms/vms_misc.c16
-rw-r--r--vms/vms_popen.c10
-rw-r--r--vms/vmsbuild.com13
-rw-r--r--vms/vmstest.com45
13 files changed, 154 insertions, 107 deletions
diff --git a/vms/ChangeLog b/vms/ChangeLog
index b941fbe5..6cc5afb7 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,6 +1,16 @@
+2013-12-20 John E. Malmberg <wb8tyw@qsl.net>
+
+ * descrip.mms: Set CC exact symbol names, cleanup repository.
+ * generate_config_vms_h_gawk.com: Use correct VMS exit codes.
+ * vmsbuild.com: Set CC exact symbol names.
+ * vmstest.com: Extract correct Unix status for failed tests.
+ * vms.h, vms_args.c, vms_cli.c, vms_fwrite.c, vms_gawk.c,
+ vms_misc.c, vms_popen.c: Correct case of function names.
+ * vms.hlp: Updated with new information about exit codes.
+
2013-12-10 John E. Malmberg <wb8tyw@qsl.net>
- * gawkmisc.mvs: Add lots of includes.
+ * gawkmisc.vms: Add lots of includes.
(sys_trnlnm): New function.
(gawk_name): Improved.
(os_arg_fixup): Fix up time zone.
diff --git a/vms/descrip.mms b/vms/descrip.mms
index 5bf1b9e3..2000e680 100644
--- a/vms/descrip.mms
+++ b/vms/descrip.mms
@@ -73,8 +73,9 @@ CFLOAT =
.else
CFLOAT = /float=ieee/ieee_mode=denorm_results
.endif
+CNAME = /NAME=(AS_IS,SHORT)
CC = cc/DECC/Prefix=All/NESTED_INCLUDE=NONE$(CFLOAT)
-CFLAGS = /Incl=([],[.vms])/Obj=[]/Def=($(CDEFS)) $(CCFLAGS)
+CFLAGS = /Incl=([],[.vms])/Obj=[]/Def=($(CDEFS))$(CNAME) $(CCFLAGS)
LIBS = # DECC$SHR instead of VAXCRTL, no special link option needed
.endif !VAXC
.endif !GNUC
@@ -256,6 +257,8 @@ spotless : clean tidy
- 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("[.cxx_repository]*.*;").nes."" then \
+ delete [.cxx_repository]*.*;*
#
# Note: this only works if you kept a copy of [.support]texindex.c
diff --git a/vms/gawk.hlp b/vms/gawk.hlp
index 4b82e7e9..177ef91c 100644
--- a/vms/gawk.hlp
+++ b/vms/gawk.hlp
@@ -1557,9 +1557,24 @@
4 exit
The exit statement can optionally pass a final status value to the
operating system. GAWK expects a UN*X-style value instead of a
- VMS status value, so 0 indicates success and non-zero indicates
- failure. The final exit status will be 1 (VMS success) if 0 is
- used, or even (VMS non-success) if non-zero is used.
+ VMS status value, so 0 indicates success. A failure is indicated
+ by 1 and VMS will set the ERROR status. A fatal error is indicated
+ by 2 and VMS seet the FATAL status. All other values will will have
+ the SUCCESS status. The exit value is encoded to comply with VMS
+ coding standards and will have the C_FACILITY_NO of 0x350000 with
+ the constant 0xA000 added to the number shifted over by 3 bits to
+ make room for the severity codes.
+
+ To extract the actual gawk exit code from the VMS status use:
+ unix_status = (vms_status .and. &x7f8) / 8
+
+ A C program that uses exec() to call gawk will get the original
+ UN*X-style exit value.
+
+ Older versions of Gawk treated Unix exit code 0 as 1, A failure as
+ 2, and a fatal error as 4, and passed all the other numbers through.
+ This violate the VMS exit status coding requirements.
+
3 changes
Changes between version 4.0.0 and earlier versions
@@ -1569,6 +1584,7 @@
General
dgawk.exe does interactive debugging of awk programs
pgawk.exe does comprehensive execution profiling of awk programs
+ pgawk.exe is not currently supplied for VMS.
-d[file] and -p[file] options added
-Wcompat and -Wusage options dropped; use -Wtraditional and -Whelp
BEGINFILE and ENDFILE built-in rule patterns
@@ -1594,6 +1610,10 @@
support for radix prefix '0' (octal) and '0x' (hexadecimal)
VMS-specific
+ The VMS exit codes now correctly encode the gawk exit status and
+ the VMS severity bits are set.
+ Large file support is enabled on the platforms that support it.
+ Extended filename support is enabled on the platforms that support it.
New command qualifiers: /EXTRA_COMMANDS, /PROFILE, /DUMP_VARIABLES,
/OPTIMIZE, /TRADITIONAL, /SANDBOX, /NON_DECIMAL_DATA
Revised qualifier: /LINT, takes optional argument list
diff --git a/vms/generate_config_vms_h_gawk.com b/vms/generate_config_vms_h_gawk.com
index 11493e5d..03ad2015 100644
--- a/vms/generate_config_vms_h_gawk.com
+++ b/vms/generate_config_vms_h_gawk.com
@@ -242,40 +242,34 @@ $ 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 "/* Use POSIX exit codes here */"
+$ write cvh "#ifdef EXIT_FAILURE"
+$ write cvh "#undef EXIT_FAILURE"
+$ write cvh "#endif"
+$ write cvh "#define EXIT_FAILURE (1)"
+$ write cvh ""
+$ write cvh "#define EXIT_FATAL (2)"
$ 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 "/* Build a Posix Exit with VMS severity */
$ 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 " /* Undocumented correct way to do this. */"
$ write cvh " vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;"
+$ write cvh " vms_status |= (status << 3);"
$ write cvh " if (status == EXIT_FAILURE) {"
-$ write cvh " vms_status |= (1 << 3) | STS$K_ERROR;"
+$ write cvh " vms_status |= STS$K_ERROR;"
$ write cvh " } else if (status == EXIT_FATAL) {"
-$ write cvh " vms_status |= (2 << 3) | STS$K_SEVERE;"
+$ write cvh " vms_status |= STS$K_SEVERE;"
+$ write cvh " } else {"
+$ write cvh " vms_status |= STS$K_SUCCESS;"
$ write cvh " }"
$ write cvh " decc$exit(vms_status);"
$ write cvh "}"
diff --git a/vms/vms.h b/vms/vms.h
index 0fb73d5b..3991d39b 100644
--- a/vms/vms.h
+++ b/vms/vms.h
@@ -54,26 +54,26 @@ typedef struct _itm { U_Short len, code; void *buffer; U_Short *retlen; } Itm;
#define Descrip(strdsc,strbuf) Dsc strdsc = {sizeof strbuf - 1, (char *)strbuf}
extern int shell$is_shell(void);
-extern U_Long lib$find_file(const Dsc *, Dsc *, void *, ...);
-extern U_Long lib$find_file_end(void *);
+extern U_Long LIB$FIND_FILE(const Dsc *, Dsc *, void *, ...);
+extern U_Long LIB$FIND_FILE_END(void *);
#ifndef NO_TTY_FWRITE
-extern U_Long lib$get_ef(long *);
-extern U_Long sys$assign(const Dsc *, short *, long, const Dsc *);
-extern U_Long sys$dassgn(short);
-extern U_Long sys$qio(U_Long, U_Long, U_Long, void *,
+extern U_Long LIB$GET_EF(long *);
+extern U_Long SYS$ASSIGN(const Dsc *, short *, long, const Dsc *);
+extern U_Long SYS$DASSGN(short);
+extern U_Long SYS$QIO(U_Long, U_Long, U_Long, void *,
void (*)(U_Long), U_Long,
const char *, int, int, U_Long, int, int);
-extern U_Long sys$synch(long, void *);
+extern U_Long SYS$SYNCH(long, void *);
#endif /*!NO_TTY_FWRITE*/
-extern U_Long lib$spawn(const Dsc *,const Dsc *,const Dsc *,
+extern U_Long LIB$SPAWN(const Dsc *,const Dsc *,const Dsc *,
const U_Long *,const Dsc *,U_Long *,U_Long *,...);
/* system services for logical name manipulation */
-extern U_Long sys$trnlnm(const U_Long *,const Dsc *,const Dsc *,
+extern U_Long SYS$TRNLNM(const U_Long *,const Dsc *,const Dsc *,
const unsigned char *,Itm *);
-extern U_Long sys$crelnm(const U_Long *,const Dsc *,const Dsc *,
+extern U_Long SYS$CRELNM(const U_Long *,const Dsc *,const Dsc *,
const unsigned char *,const Itm *);
-extern U_Long sys$crelog(int,const Dsc *,const Dsc *,unsigned char);
-extern U_Long sys$dellnm(const Dsc *,const Dsc *,const unsigned char *);
+extern U_Long SYS$CRELOG(int,const Dsc *,const Dsc *,unsigned char);
+extern U_Long SYS$DELLNM(const Dsc *,const Dsc *,const unsigned char *);
extern void v_add_arg(int, const char *);
extern void vms_exit(int);
diff --git a/vms/vms_args.c b/vms/vms_args.c
index 0a296105..9788275d 100644
--- a/vms/vms_args.c
+++ b/vms/vms_args.c
@@ -106,10 +106,26 @@ vms_arg_fixup( int *pargc, char ***pargv )
char **argv = *pargv;
int i, argc = *pargc;
int err_to_out_redirect = 0, out_to_err_redirect = 0;
+ char * shell;
+ int using_shell;
/* make sure AWK_LIBRARY has a value */
if (!getenv("AWK_LIBRARY"))
vms_define("AWK_LIBRARY", "SYS$LIBRARY:");
+
+ /* Check if running under a shell instead of DCL */
+ using_shell = 1;
+ shell = getenv("SHELL");
+ if (shell != NULL) {
+ if (strcmp(shell, "DCL") == 0) {
+ using_shell = 0;
+ }
+ } else {
+ using_shell = 0;
+ }
+ if (using_shell) {
+ return;
+ }
#ifdef CHECK_DECSHELL /* don't define this if linking with DECC$SHR */
if (shell$is_shell())
return; /* don't do anything if we're running DEC/Shell */
@@ -325,12 +341,12 @@ vms_expand_wildcards( const char *prospective_filespec )
*/
len = -1; /* overload 'len' with flag value */
context = NULL; /* init */
- while (vmswork(lib$find_file(&spec, &result, &context))) {
+ while (vmswork(LIB$FIND_FILE(&spec, &result, &context))) {
for (len = sizeof(res_buf)-1; len > 0 && res_buf[len-1] == ' '; len--) ;
res_buf[len] = '\0'; /* terminate after discarding trailing blanks */
v_add_arg(v_argc++, strdup(res_buf)); /* store result */
}
- (void)lib$find_file_end(&context);
+ (void)LIB$FIND_FILE_END(&context);
if (len >= 0) /* (still -1 => never entered loop) */
--v_argc; /* undo final post-increment */
return;
@@ -395,7 +411,7 @@ vms_define( const char *log_name, const char *trans_val )
log_dsc.len = len;
itemlist[0].buffer = (char *)trans_val;
itemlist[0].len = strlen(trans_val);
- return sys$crelnm(&attr, &lnmtable, &log_dsc, &acmode, itemlist);
+ return SYS$CRELNM(&attr, &lnmtable, &log_dsc, &acmode, itemlist);
}
/* t_strstr -- strstr() substitute; search 'str' for 'sub' */
diff --git a/vms/vms_cli.c b/vms/vms_cli.c
index ac793c1a..0cfe96fc 100644
--- a/vms/vms_cli.c
+++ b/vms/vms_cli.c
@@ -29,13 +29,13 @@
#include <string.h>
#endif
-extern U_Long cli$present(const Dsc *);
-extern U_Long cli$get_value(const Dsc *, Dsc *, short *);
-extern U_Long cli$dcl_parse(const Dsc *, const void *, ...);
-extern U_Long sys$cli(void *, ...);
-extern U_Long sys$filescan(const Dsc *, void *, long *);
+extern U_Long CLI$PRESENT(const Dsc *);
+extern U_Long CLI$GET_VALUE(const Dsc *, Dsc *, short *);
+extern U_Long CLI$DCL_PARSE(const Dsc *, const void *, ...);
+extern U_Long SYS$CLI(void *, ...);
+extern U_Long SYS$FILESCAN(const Dsc *, void *, long *);
extern void *lib$establish(U_Long (*handler)(void *, void *));
-extern U_Long lib$sig_to_ret(void *, void *); /* condition handler */
+extern U_Long LIB$SIG_TO_RET(void *, void *); /* condition handler */
/* Cli_Present() - call CLI$PRESENT to determine whether a parameter or */
/* qualifier is present on the [already parsed] command line */
@@ -43,10 +43,10 @@ U_Long
Cli_Present( const char *item )
{
Dsc item_dsc;
- (void)lib$establish(lib$sig_to_ret);
+ (void)lib$establish(LIB$SIG_TO_RET);
item_dsc.len = strlen(item_dsc.adr = (char *)item);
- return cli$present(&item_dsc);
+ return CLI$PRESENT(&item_dsc);
}
/* Cli_Get_Value() - call CLI$GET_VALUE to retreive the value of a */
@@ -57,11 +57,11 @@ Cli_Get_Value( const char *item, char *result, int size )
Dsc item_dsc, res_dsc;
U_Long sts;
short len = 0;
- (void)lib$establish(lib$sig_to_ret);
+ (void)lib$establish(LIB$SIG_TO_RET);
item_dsc.len = strlen(item_dsc.adr = (char *)item);
res_dsc.len = size, res_dsc.adr = result;
- sts = cli$get_value(&item_dsc, &res_dsc, &len);
+ sts = CLI$GET_VALUE(&item_dsc, &res_dsc, &len);
result[len] = '\0';
return sts;
}
@@ -79,11 +79,11 @@ Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb )
U_Long sts;
int ltmp;
char longbuf[8200];
- (void)lib$establish(lib$sig_to_ret);
+ (void)lib$establish(LIB$SIG_TO_RET);
memset(&cmd, 0, sizeof cmd);
cmd.rqtype = CLI$K_GETCMD; /* command line minus the verb */
- sts = sys$cli(&cmd, (void *)0, (void *)0); /* get actual command line */
+ sts = SYS$CLI(&cmd, (void *)0, (void *)0); /* get actual command line */
if (vmswork(sts)) { /* ok => cli available & verb wasn't "RUN" */
/* invoked via symbol => have command line (which might be empty) */
@@ -92,7 +92,7 @@ Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb )
/* need to strip image name from MCR invocation */
memset(fscn, 0, sizeof fscn);
fscn[0].code = FSCN$_FILESPEC; /* full file specification */
- (void)sys$filescan(&cmd.rdesc, fscn, (long *)0);
+ (void)SYS$FILESCAN(&cmd.rdesc, fscn, (long *)0);
cmd.rdesc.len -= fscn[0].len; /* shrink size */
cmd.rdesc.adr += fscn[0].len; /* advance ptr */
}
@@ -102,7 +102,7 @@ Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb )
cmd.rdesc.len = sizeof longbuf - ltmp;
strncpy(&longbuf[ltmp], cmd.rdesc.adr, cmd.rdesc.len);
cmd.rdesc.len += ltmp, cmd.rdesc.adr = longbuf;
- sts = cli$dcl_parse(&cmd.rdesc, cmd_tables);
+ sts = CLI$DCL_PARSE(&cmd.rdesc, cmd_tables);
}
return sts;
diff --git a/vms/vms_fwrite.c b/vms/vms_fwrite.c
index 1a16f58c..435fead2 100644
--- a/vms/vms_fwrite.c
+++ b/vms/vms_fwrite.c
@@ -83,9 +83,9 @@ tty_fwrite( const void *buf, size_t size, size_t number, FILE *file )
fgetname(file, devnam); /* get 'file's name */
device.len = strlen(device.adr = devnam); /* create descriptor */
- if (vmswork(sys$assign(&device, &chan, 0, (Dsc *)0))) {
+ if (vmswork(SYS$ASSIGN(&device, &chan, 0, (Dsc *)0))) {
/* get an event flag; use #0 if problem */
- if (evfn == -1 && vmsfail(lib$get_ef(&evfn))) evfn = 0;
+ if (evfn == -1 && vmsfail(LIB$GET_EF(&evfn))) evfn = 0;
} else chan = 0; /* $ASSIGN failed */
}
/* store channel for later use; -1 => don't repeat failed init attempt */
@@ -119,19 +119,19 @@ tty_fwrite( const void *buf, size_t size, size_t number, FILE *file )
else if (pos < count) pos++, cc_fmt |= POSTFIX_CR, extra++;
/* wait for previous write, if any, to complete */
if (pt > (char *)buf) {
- sts = sys$synch(evfn, &iosb);
+ sts = SYS$SYNCH(evfn, &iosb);
if (vmswork(sts)) sts = iosb.status, result += iosb.count;
if (vmsfail(sts)) break;
}
/* queue an asynchronous write */
- sts = sys$qio(evfn, chan, io_func, &iosb, (void (*)(U_Long))0, 0L,
+ sts = SYS$QIO(evfn, chan, io_func, &iosb, (void (*)(U_Long))0, 0L,
pt, pos, 0, cc_fmt, 0, 0);
if (vmsfail(sts)) break; /*(should never happen)*/
pt += pos, count -= pos;
}
/* wait for last write to complete */
if (pt > (char *)buf && vmswork(sts)) {
- sts = sys$synch(evfn, &iosb);
+ sts = SYS$SYNCH(evfn, &iosb);
if (vmswork(sts)) sts = iosb.status, result += iosb.count;
}
if (vmsfail(sts)) errno = EVMSERR, vaxc$errno = sts;
@@ -202,7 +202,7 @@ tty_fclose( FILE *file )
short chan = file_num < _NFILE ? channel[file_num] : -1;
if (chan > 0)
- (void)sys$dassgn(chan); /* deassign the channel (ie, close) */
+ (void)SYS$DASSGN(chan); /* deassign the channel (ie, close) */
if (file_num < _NFILE)
channel[file_num] = 0; /* clear stale info */
}
diff --git a/vms/vms_gawk.c b/vms/vms_gawk.c
index f22e2fa9..fce0fa85 100644
--- a/vms/vms_gawk.c
+++ b/vms/vms_gawk.c
@@ -37,16 +37,16 @@
#define Present(arg) vmswork(Cli_Present(arg))
#define Get_Value(arg,buf,siz) vmswork(Cli_Get_Value(arg,buf,siz))
-#ifndef __ia64__
-extern void gawk_cmd(); /* created with $ SET COMMAND/OBJECT */
-#define GAWK_CMD ((const void *)gawk_cmd)
-#else /* linker on Itanium is much pickier about such things */
+#ifndef __DECC
+extern void GAWK_CMD(); /* created with $ SET COMMAND/OBJECT */
+#define gawk_cmd ((const void *)GAWK_CMD) */
+#else /* Use ANSI definitions for DEC C */
#pragma extern_model save
#pragma extern_model strict_refdef
/* (could use globalvalue rather than _refdef if we omit GAWK_CMD's `&') */
-extern void *gawk_cmd;
+extern void *GAWK_CMD;
#pragma extern_model restore
-#define GAWK_CMD ((const void *)&gawk_cmd)
+#define gawk_cmd ((const void *)&GAWK_CMD)
#endif
extern void _exit(int);
static int vms_usage(int);
@@ -88,7 +88,7 @@ vms_gawk()
command, so we'll now attempt to generate a command from the
foreign command string and parse that.
*/
- sts = Cli_Parse_Command(GAWK_CMD, "GAWK"); /* (*not* CmdName) */
+ sts = Cli_Parse_Command(gawk_cmd, "GAWK"); /* (*not* CmdName) */
if (vmswork(sts))
sts = Cli_Present("GAWK_P1");
}
diff --git a/vms/vms_misc.c b/vms/vms_misc.c
index ce190341..ed479539 100644
--- a/vms/vms_misc.c
+++ b/vms/vms_misc.c
@@ -118,7 +118,7 @@ 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;
+ int stat_result;
const char *mbc, *shr = "shr=get", *ctx = "ctx=stm";
stat_result = stat((char *)name, &stb);
@@ -174,8 +174,8 @@ vms_devopen( const char *name, int mode )
#define VMS_UNITS_PER_SECOND 10000000L /* hundreds of nanoseconds, 1e-7 */
#define UNIX_EPOCH "01-JAN-1970 00:00:00.00"
-extern U_Long sys$bintim(), sys$gettim();
-extern U_Long lib$subx(), lib$ediv();
+extern U_Long SYS$BINTIM(), SYS$GETTIM();
+extern U_Long LIB$SUBX(), LIB$EDIV();
/*
* Get current time in microsecond precision.
@@ -192,13 +192,13 @@ vms_gettimeofday(struct timeval *tv, void *timezone__not_used)
const long thunk = VMS_UNITS_PER_SECOND;
long now[2], quad[2];
- if (!epoch[0]) sys$bintim(&epoch_dsc, epoch); /* 1 Jan 0:0:0 1970 */
+ if (!epoch[0]) SYS$BINTIM(&epoch_dsc, epoch); /* 1 Jan 0:0:0 1970 */
/* get current time, as VMS quadword time */
- sys$gettim(now);
+ SYS$GETTIM(now);
/* convert the quadword time so that it's relative to Unix epoch */
- lib$subx(now, epoch, quad); /* quad = now - epoch; */
+ LIB$SUBX(now, epoch, quad); /* quad = now - epoch; */
/* convert 1e-7 units into seconds and fraction of seconds */
- lib$ediv(&thunk, quad, &tv->tv_sec, &tv->tv_usec);
+ LIB$EDIV(&thunk, quad, &tv->tv_sec, &tv->tv_usec);
/* convert fraction of seconds into microseconds */
tv->tv_usec /= (VMS_UNITS_PER_SECOND / 1000000);
@@ -281,7 +281,7 @@ int fork( void ) {
#include <fab.h>
#include <nam.h>
-extern unsigned long sys$parse(), sys$search();
+extern unsigned long SYS$PARSE(), SYS$SEARCH();
/* Work around a VAXCRTL bug. If a file is located via a searchlist,
and if the device it's on is not the same device as the one specified
diff --git a/vms/vms_popen.c b/vms/vms_popen.c
index 62f3f719..6c5c5086 100644
--- a/vms/vms_popen.c
+++ b/vms/vms_popen.c
@@ -172,7 +172,7 @@ vms_execute( const char *command, const char *input, const char *output )
out_p = 0;
push_logicals(); /* guard against user-mode definitions of sys$Xput */
- sts = lib$spawn(&cmd, in_p, out_p, (U_Long *)0,
+ sts = LIB$SPAWN(&cmd, in_p, out_p, (U_Long *)0,
(Dsc *)0, (U_Long *)0, &cmpltn_sts);
pop_logicals(); /* restore environment */
@@ -219,9 +219,9 @@ static const Descrip(sys_output,"SYS$OUTPUT");
static const unsigned char acmode = PSL$C_USER; /* only care about user-mode */
/* macros for simplfying the code a bunch */
-#define DelTrans(l) sys$dellnm(&lnmtable, (l), &acmode)
-#define GetTrans(l,i) sys$trnlnm((U_Long *)0, &lnmtable, (l), &acmode, (i))
-#define SetTrans(l,i) sys$crelnm((U_Long *)0, &lnmtable, (l), &acmode, (i))
+#define DelTrans(l) SYS$DELLNM(&lnmtable, (l), &acmode)
+#define GetTrans(l,i) SYS$TRNLNM((U_Long *)0, &lnmtable, (l), &acmode, (i))
+#define SetTrans(l,i) SYS$CRELNM((U_Long *)0, &lnmtable, (l), &acmode, (i))
/* itemlist manipulation macros; separate versions for aggregate and scalar */
#define SetItmA(i,c,p,r) ((i).code = (c), (i).len = sizeof (p),\
(i).buffer = (p), (i).retlen = (U_Short *)(r))
@@ -333,7 +333,7 @@ restore_translation( const Dsc *logname, const Itm *itemlist )
/* assert( itemlist[2].code == LNM$_STRING ); */
trans_val.adr = itemlist[2].buffer;
trans_val.len = itemlist[2].len;
- (void) sys$crelog(LOG_PROCESS_TABLE, logname, &trans_val, LOG_USERMODE);
+ (void) SYS$CRELOG(LOG_PROCESS_TABLE, logname, &trans_val, LOG_USERMODE);
} else {
/* $crelnm definition; itemlist could specify multiple translations,
but has already been setup properly for use as-is.
diff --git a/vms/vmsbuild.com b/vms/vmsbuild.com
index ff5dc929..2c0d39f0 100644
--- a/vms/vmsbuild.com
+++ b/vms/vmsbuild.com
@@ -49,14 +49,15 @@ $ else !!VAXC
$! neither GNUC nor VAXC, assume DECC (same for either VAX or Alpha)
$ if arch_name .eqs. "vax"
$ then
-$ cfloat = ""
+$ CFLOAT = ""
$ else
-$ cfloat = "/float=ieee/ieee_mode=denorm_results"
+$ CFLOAT = "/float=ieee/ieee_mode=denorm_results"
$ endif
$ CC = "cc/DECC/Prefix=All"
+$ CNAME = "/NAME=(AS_IS,SHORT)
$ CINC = "/NESTED_INCLUDE=NONE"
$ CFLAGS = "/Incl=([],[.vms])/Obj=[]/Def=(''CDEFS')''CINC'''CCFLAGS'"
-$ CFLAGS = cfloat + CFLAGS
+$ CFLAGS = CNAMES + CFLOAT + CFLAGS
$ LIBS = "" ! DECC$SHR instead of VAXCRTL, no special link option needed
$ endif !VAXC
$ endif !GNUC
@@ -90,7 +91,7 @@ $ if f$search("ytab.c").nes."" .or. f$search("y_tab.c").nes."" then - !yacc
write sys$output " or else rename `ytab.c' or `y_tab.c' to `command.c'."
$ exit
$command_ok:
-$ v = f$verify(1)
+$ v1 = f$verify(1)
$ cc array.c
$ cc awkgram.c
$ cc builtin.c
@@ -145,13 +146,13 @@ 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)
+$ v1 = f$verify(1)
$ @[.vms]gawk_ident.com
$ open/append Fopt gawk.opt
$ write Fopt libs
$ close Fopt
$!
-$ v = f$verify(1)
+$ v1 = f$verify(1)
$ link/exe=gawk.exe gawk.opt/options
$! 'f$verify(v)'
$ exit
diff --git a/vms/vmstest.com b/vms/vmstest.com
index 7b1c3a36..1b5b7ed9 100644
--- a/vms/vmstest.com
+++ b/vms/vmstest.com
@@ -578,7 +578,7 @@ $defref: echo "defref"
$ set noOn
$ AWKPATH_srcdir
$ gawk --lint -f defref.awk >_defref.tmp 2>&1
-$ if .not.$status then call exit_code 2 _defref.tmp
+$ if .not. $status then call exit_code '$status' _defref.tmp
$ set On
$ cmp defref.ok sys$disk:[]_defref.tmp
$ if $status then rm _defref.tmp;
@@ -637,7 +637,7 @@ $
$incdupe: echo "''test'"
$ set noOn
$ gawk --lint -i inclib -i inclib.awk "BEGIN {print sandwich(""a"", ""b"", ""c"")}" > _'test'.tmp 2>&1
-$ if .not. $status then call exit_code 1 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -646,7 +646,7 @@ $
$incdupe2: echo "''test'"
$ set noOn
$ gawk --lint -f inclib -f inclib.awk >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 1 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -661,7 +661,7 @@ $
$incdupe4: echo "''test'"
$ set NoOn
$ gawk --lint -f hello -i hello.awk >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -670,7 +670,7 @@ $
$incdupe5: echo "''test'"
$ set NoOn
$ gawk --lint -i hello -f hello.awk >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -679,7 +679,7 @@ $
$incdupe6: echo "''test'"
$ set NoOn
$ gawk --lint -i inchello -f hello.awk >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -688,7 +688,7 @@ $
$incdupe7: echo "''test'"
$ set NoOn
$ gawk --lint -f hello -i inchello >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -706,7 +706,7 @@ $symtab2:
$symtab3: echo "''test'"
$ set noOn
$ gawk -f 'test'.awk >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -717,7 +717,7 @@ $symtab5:
$symtab7: echo "''test'"
$ set noOn
$ gawk -f 'test'.awk <'test'.in >_'test'.tmp 2>&1
-$ if .not. $status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;*
$ set On
@@ -897,7 +897,7 @@ $noparms: echo "noparms"
$ set noOn
$ AWKPATH_srcdir
$ gawk -f noparms.awk >_noparms.tmp 2>&1
-$ if .not.$status then call exit_code 1 _noparms.tmp
+$ if .not. $status then call exit_code '$status' _noparms.tmp
$ set On
$ cmp noparms.ok sys$disk:[]_noparms.tmp
$ if $status then rm _noparms.tmp;
@@ -968,8 +968,9 @@ $subslash:
$ echo "''test'"
$ set noOn
$ gawk -f 'test'.awk >_'test'.tmp 2>&1
-$ if .not.$status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ set On
+$ diff 'test'.ok sys$disk:[]_'test'.tmp/out='test'.diff
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;
$ return
@@ -1077,7 +1078,7 @@ $lintwarn: echo "lintwarn"
$ set noOn
$ AWKPATH_srcdir
$ gawk --lint -f lintwarn.awk >_lintwarn.tmp 2>&1
-$ if .not.$status then call exit_code 1 _lintwarn.tmp
+$ if .not. $status then call exit_code '$status' _lintwarn.tmp
$ set On
$ cmp lintwarn.ok sys$disk:[]_lintwarn.tmp
$ if $status then rm _lintwarn.tmp;
@@ -1120,7 +1121,7 @@ $sclifin:
$ echo "''test'"
$ set noOn
$ gawk -f 'test'.awk 'test'.in >_'test'.tmp 2>&1
-$ if .not.$status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ set On
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;
@@ -1132,7 +1133,7 @@ $ !
$ echo "''test'"
$ set noOn
$ gawk -f 'test'.awk <'test'.in >_'test'.tmp 2>&1
-$ if .not.$status then call exit_code 2 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ set On
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;
@@ -1157,7 +1158,7 @@ $unterm:
$ echo "''test'"
$ set noOn
$ gawk -f 'test'.awk 'test'.in >_'test'.tmp 2>&1
-$ if .not.$status then call exit_code 1 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ set On
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;
@@ -1217,7 +1218,7 @@ $synerr2:
$ echo "''test'"
$ set noOn
$ gawk -f 'test'.awk >_'test'.tmp 2>&1
-$ if .not.$status then call exit_code 1 _'test'.tmp
+$ if .not. $status then call exit_code '$status' _'test'.tmp
$ set On
$ cmp 'test'.ok sys$disk:[]_'test'.tmp
$ if $status then rm _'test'.tmp;
@@ -1237,7 +1238,7 @@ $
$space: echo "space"
$ set noOn
$ gawk -f " " space.awk >_space.tmp 2>&1
-$ if .not.$status then call exit_code 2 _space.tmp
+$ if .not. $status then call exit_code '$status' _space.tmp
$ set On
$! we get a different error from what space.ok expects
$ gawk "{gsub(""file specification syntax error"", ""no such file or directory""); print}" -
@@ -1320,7 +1321,7 @@ $
$! This test is somewhat suspect for vms due to exit code manipulation
$exitval1: echo "exitval1"
$ gawk -f exitval1.awk >_exitval1.tmp 2>&1
-$ if $status then call exit_code 0 _exitval1.tmp
+$ if $status then call exit_code '$status' _exitval1.tmp
$ cmp exitval1.ok sys$disk:[]_exitval1.tmp
$ if $status then rm _exitval1.tmp;
$ return
@@ -1424,7 +1425,7 @@ $! nofile.ok expects no/such/file, but using that name in the test would
$! yield "file specification syntax error" instead of "no such file..."
$ set noOn
$ gawk "{}" no-such-file >_nofile.tmp 2>&1
-$ if .not.$status then call exit_code 2 _nofile.tmp
+$ if .not. $status then call exit_code '$status' _nofile.tmp
$ set On
$! restore altered file name
$ gawk "{gsub(""no-such-file"", ""no/such/file""); print}" _nofile.tmp >_nofile.too
@@ -1496,7 +1497,7 @@ $
$mixed1: echo "mixed1"
$ set noOn
$ gawk -f /dev/null --source "BEGIN {return junk}" >_mixed1.tmp 2>&1
-$ if .not.$status then call exit_code 1 _mixed1.tmp
+$ if .not. $status then call exit_code '$status' _mixed1.tmp
$ set On
$ cmp mixed1.ok sys$disk:[]_mixed1.tmp
$ if $status then rm _mixed1.tmp;
@@ -1869,10 +1870,12 @@ $ endsubroutine !fixup_LRL
$
$! add a fake "EXIT CODE" record to the end of the temporary output file
$! to simulate the ``|| echo EXIT CODE $$? >>_$@'' shell script usage
+$! Unix code = vms_code & (255 * 2^3) >> 3
$exit_code: subroutine
+$ unix_status = (p1 .and. %x7f8) / 8
$ if f$trnlnm("FTMP").nes."" then close/noLog ftmp
$ open/Append ftmp 'p2'
-$ write ftmp "EXIT CODE: ",p1
+$ write ftmp "EXIT CODE: ",'unix_status'
$ close ftmp
$ endsubroutine !exit_code
$