aboutsummaryrefslogtreecommitdiffstats
path: root/vms
diff options
context:
space:
mode:
Diffstat (limited to 'vms')
-rw-r--r--vms/descrip.mms65
-rw-r--r--vms/gawk.hlp57
-rw-r--r--vms/unixlib.h5
-rw-r--r--vms/vms.h6
-rw-r--r--vms/vms_args.c46
-rw-r--r--vms/vms_cli.c3
-rw-r--r--vms/vms_fwrite.c6
-rw-r--r--vms/vms_gawk.c4
-rw-r--r--vms/vms_misc.c58
-rw-r--r--vms/vms_popen.c6
-rw-r--r--vms/vmsbuild.com44
11 files changed, 204 insertions, 96 deletions
diff --git a/vms/descrip.mms b/vms/descrip.mms
index 040d458a..e22df05e 100644
--- a/vms/descrip.mms
+++ b/vms/descrip.mms
@@ -10,14 +10,14 @@
# enable the following ".first" rule and its associated action. For
# GNU C, change the LIBS macro definition.
#
-# awk_tab.c :
-# If you have DEC/Shell, change the PARSER and PASERINIT macros to use
-# yacc rather than bison. If you have neither yacc nor bison, you'll
-# have to make sure that the distributed version of "awk.tab.c" is
-# named "awk_tab.c" and that its modification date is later than the
-# date of "awk.y", so that MMS won't try to build that target. If you
-# use bison and it is already defined system-wide, comment out the
-# PARSERINIT definition.
+# awktab.c :
+# If you don't have bison but do have VMS POSIX or DEC/Shell,
+# change the PARSER and PASERINIT macros to use yacc. If you don't
+# have either yacc or bison, you'll have to make sure that the
+# distributed version of "awktab.c" has its modification date later
+# than the date of "awk.y", so that MMS won't try to build that
+# target. If you use bison and it is already defined system-wide,
+# comment out the PARSERINIT definition.
#
# install.help :
# You can make the target 'install.help' to load the VMS help text
@@ -27,7 +27,7 @@
#
# gawk.dvi :
# If you have TeX, you can make the target 'gawk.dvi' to process
-# _The_GAWK_Manual_ from gawk.texinfo. You'll need to use a device
+# _The_GAWK_Manual_ from gawk.texi. You'll need to use a device
# specific post-processor on gawk.dvi in order to get printable data.
#
@@ -40,11 +40,15 @@ MAKEFILE = $(VMSDIR)Descrip.MMS
# work within the main directory, even when handling files in [.vms]
# note: use 2nd variant for either VAX C V2.x or for GNU C
-CFLAGS = /Include=[]/Object=[]/Opt=noInline $(CCFLAGS)
-#CFLAGS = /Include=([],$(VMSDIR))/Object=[] $(CCFLAGS)
+CFLAGS = /Include=[]/Object=[]/Opt=noInline/Define="GAWK" $(CCFLAGS)
+#CFLAGS = /Include=([],$(VMSDIR))/Object=[]/Define="GAWK" $(CCFLAGS)
# uncomment this for GNU C
#CC = gcc
+# beta VAX/VMS -> Alpha/VMS cross-compiler
+#CC = gemcc/Standard=VAXC/G_Float
+# Alpha/VMS
+#CC = cc/Standard=VAXC/G_Float
# uncomment these two lines for GNU C _if_ it's not installed system-wide
#.first !compiler init, needed if there's no system-wide setup
@@ -60,10 +64,12 @@ CFLAGS = /Include=[]/Object=[]/Opt=noInline $(CCFLAGS)
# run-time libraries; use the 2nd one for GNU C
LIBS = sys$share:vaxcrtl.exe/Shareable
#LIBS = gnu_cc:[000000]gcclib.olb/Library,sys$library:vaxcrtl.olb/Library
+#LIBS = # DECC$SHR instead of VAXCRTL; for Alpha/VMS (or VMS V6.x?)
PARSER = bison
PARSERINIT = set command gnu_bison:[000000]bison
#PARSER = yacc
+#PARSERINIT = yacc := posix/run/path=posix """/bin/yacc"
#PARSERINIT = yacc := $shell$exe:yacc
# this is used for optional target 'install.help'
@@ -79,9 +85,9 @@ ALLOCA = alloca.obj
# object files
AWKOBJS = main.obj,eval.obj,builtin.obj,msg.obj,iop.obj,io.obj,\
- field.obj,array.obj,node.obj,version.obj,missing.obj,re.obj
+ field.obj,array.obj,node.obj,version.obj,missing.obj,re.obj,getopt.obj
-ALLOBJS = $(AWKOBJS),awk_tab.obj
+ALLOBJS = $(AWKOBJS),awktab.obj
# GNUOBJS
# GNU stuff that gawk uses as library routines.
@@ -101,8 +107,8 @@ VMSOTHR = $(VMSDIR)Descrip.MMS,$(VMSDIR)vmsbuild.com,$(VMSDIR)version.com,\
$(VMSDIR)gawk.hlp
# Release of gawk
-REL=2.13
-PATCHLVL=2
+REL=2.14
+PATCHLVL=0
# dummy target to allow building "gawk" in addition to explicit "gawk.exe"
gawk : gawk.exe
@@ -120,7 +126,8 @@ gawk.opt : $(MAKEFILE) # create linker options file
@ write opt "$(VMSOBJS)"
@ write opt "$(LIBS)"
@ write opt "psect_attr=environ,noshr !extern [noshare] char **"
- @ write opt "stack=50 !preallocate more pages (default is 20)"
+ @ write opt "stack=48 !preallocate more pages (default is 20)"
+ @ write opt "iosegment=128 !ditto (default is 32)"
write opt "identification=""V$(REL).$(PATCHLVL)"""
close opt
@@ -134,18 +141,20 @@ vms_gawk.obj : $(VMSDIR)vms_gawk.c
vms_cli.obj : $(VMSDIR)vms_cli.c
dfa.obj : awk.h config.h dfa.h
regex.obj : awk.h config.h regex.h
+getopt.obj : getopt.h
main.obj : patchlevel.h
-awk_tab.obj : awk.h awk_tab.c
+awktab.obj : awk.h awktab.c
# bison or yacc required
-awk_tab.c : awk.y # foo.y :: yacc => y_tab.c, bison => foo_tab.c
- @- if f$search("y_tab.c").nes."" then delete y_tab.c;*
+awktab.c : awk.y # foo.y :: yacc => y[_]tab.c, bison => foo_tab.c
+ @- if f$search("ytab.c") .nes."" then delete ytab.c;* !POSIX yacc
+ @- if f$search("y_tab.c") .nes."" then delete y_tab.c;* !DEC/Shell yacc
+ @- if f$search("awk_tab.c").nes."" then delete awk_tab.c;* !bison
- $(PARSERINIT)
$(PARSER) $(YFLAGS) $<
- @- if f$search("y_tab.c").nes."" then rename/new_vers y_tab.c $@ !yacc
-
-##version.c : version.sh $(MAKEFILE)
-## @$(VMSDIR)version.com "$(REL)"
+ @- 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("awk_tab.c").nes."" then rename/new_vers awk_tab.c $@
config.h : [.config]vms-conf.h
copy $< $@
@@ -155,7 +164,7 @@ alloca.obj : alloca.c
$(CC) $(CFLAGS) /define=("STACK_DIRECTION=(-1)","exit=vms_exit") $<
$(VMSCMD) : $(VMSDIR)gawk.cld
- set command/object=$@ $(CLDFLAGS) $<
+ set command $(CLDFLAGS)/object=$@ $<
# special target for loading the help text into a VMS help library
install.help : $(VMS)gawk.hlp
@@ -175,16 +184,16 @@ spotless : clean tidy
#
# build gawk.dvi from within the 'support' subdirectory
#
-gawk.dvi : [.support]texindex.exe gawk.texinfo
+gawk.dvi : [.support]texindex.exe gawk.texi
@ set default [.support]
@ write sys$output " Warnings from TeX are expected during the first pass"
- TeX [-]gawk.texinfo
+ TeX [-]gawk.texi
mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr
@ write sys$output " Second pass"
- TeX [-]gawk.texinfo
+ TeX [-]gawk.texi
mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr
@ write sys$output " Third (final) pass"
- TeX [-]gawk.texinfo
+ TeX [-]gawk.texi
-@ purge
-@ delete gawk.lis;,.aux;,gawk.%%;,.cps;,.fns;,.kys;,.pgs;,.toc;,.tps;,.vrs;
@ rename/new_vers gawk.dvi [-]*.*
diff --git a/vms/gawk.hlp b/vms/gawk.hlp
index 660e0353..c8f4b453 100644
--- a/vms/gawk.hlp
+++ b/vms/gawk.hlp
@@ -1,6 +1,7 @@
! Gawk.Hlp
! Pat Rankin, Jun'90
! revised, Jun'91
+! revised, Jul'92
! Online help for GAWK.
!
1 GAWK
@@ -30,6 +31,8 @@
program. However, GAWK is written in 'C' and the C Run-Time Library
(VAXCRTL) converts unquoted text into *lowercase*. Therefore, the
-Fval and -W options must be enclosed in quotes.
+
+ Note: under VMS POSIX, the usual shell command line processing occurs.
3 options
-f file use the specified file as the awk program source; if more
than one instance of -f is used, each file will be read
@@ -57,7 +60,7 @@
(since awk's 'print' statement includes the trailing 'newline').
On VMS, to include a quote character inside of a quoted string, two
- successive quotes ("") must be used.
+ successive quotes ("") must be used. (Not necessary for VMS POSIX.)
3 data_files
After all dash-options are examined, and after the program text if
there were no occurrences of the -f option, remaining (space separated)
@@ -80,7 +83,7 @@
perform some file manipulation from the command line:
<ifile open file 'ifile' (readonly) as 'stdin' [SYS$INPUT]
- >nfile create 'nfile' at 'stdout' [SYS$OUTPUT], in stream-lf format
+ >nfile create 'nfile' as 'stdout' [SYS$OUTPUT], in stream-lf format
>>ofile append to 'ofile' for 'stdout'; create it if necessary
>&efile point 'stderr' [SYS$ERROR] at 'efile', but don't open it yet
>$vfile create 'vfile' as 'stdout', using RMS attributes appropriate
@@ -93,6 +96,10 @@
>>$vfile incorrect; would be interpreted as file "$vfile" in stream-lf
format rather than as file "vfile" in RMS 'text' format
| error; command line pipes not supported
+
+ Note: under VMS POSIX these features are implemented by the shell
+ rather than inside GAWK, so consult the shell documentation for
+ specific details.
3 wildcard_expansion
The command parsing in the VMS implementation of GAWK does some
emulation of a UN*X-style shell, where certain characters on the
@@ -109,6 +116,11 @@
found, those filenames are put into the command line in place of the
original pattern. If no matching files are found, the original
pattern is left in place.
+
+ Note: under VMS POSIX wildcard expansion, or "file globbing", is
+ performed by the shell rather than inside GAWK, so consult the shell
+ documentation for details. In particular, the last sentence of the
+ previous paragraph does not apply.
2 DCL_syntax
GAWK's DCL-style interface is more or less a standard DCL command, with
one required parameter. Multiple values--when present--are separated
@@ -120,6 +132,8 @@
Usage: GAWK /COMMANDS="awk program text" data_file[,data_file,...]
or GAWK /INPUT=awk_file data_file[,"Var=value",data_file,...]
( or GAWK /INPUT=(awk_file1,awk_file2,...) data_file[,...] )
+
+ Not applicable under VMS POSIX.
3 Parameter
data_file[,datafile,...] (data_file data_file ...)
data_file[,"Var=value",...,data_file,...] (data_file Var=value &c)
@@ -536,9 +550,10 @@
false (instead of actually re-evaluating it). In this case, the
increment-expression of a for-loop is also skipped.
- Both 'break' and 'continue' are only allowed within a loop ('for',
- 'while', or 'do-while'), and in nested loops they only apply to the
- innermost loop.
+ 'break' is only allowed within a loop ('for', 'while', or
+ 'do-while'). If 'continue' is used outside of a loop, it is
+ treated like 'next' (see action-controls). Inside nested loops,
+ both 'break' and 'continue' only apply to the innermost loop.
4 action-controls
There are two special statements for controlling statement execution.
The 'next' statement, when executed, causes the rest of the current
@@ -546,6 +561,10 @@
the next input record will be immediately processed. This is useful
if any early action knows that the current record will fail all the
remaining patterns; skipping those rules will reduce processing time.
+ An extended form, 'next file', is also available. It causes the
+ remainder of the current file to be skipped, and then either the
+ next input file will be processed, if any, or the END action will be
+ performed. 'next file' is not available in traditional awk.
The 'exit' statement causes GAWK execution to terminate. All open
files are closed, and no further processing is done. The END rule,
@@ -1031,10 +1050,10 @@
incorporated into the official GNU distribution of version 2.13 in
Spring 1991. (Version 2.12 was never publically released.)
2 release_notes
- GAWK 2.13 tested under VMS V5.3 and V5.4-2, May, 1991; compatible with
- VMS versions V4.6 and later. Current source code compatible with DEC's
- VAXC v3.x and v2.4 or v2.3; also compiles successfully with GNUC (GNU's
- gcc).
+ GAWK 2.14 tested under VMS V5.5, July, 1992; compatible with VMS
+ versions V4.6 and later. Current source code compatible with DEC's
+ VAXC v3.x and v2.4 or v2.3; also compiles successfully with GNUC
+ (GNU's gcc). VMS POSIX uses c89 and requires VAXC V3.x.
3 AWK_LIBRARY
GAWK uses a built in search path when looking for a program file
specified by the -f option (or the /input qualifier) when that file
@@ -1042,9 +1061,12 @@
look in the current default directory, then if the file wasn't found
it will look in the directory specified by the translation of logical
name "AWK_LIBRARY".
+
+ Not applicable under VMS POSIX.
3 known_problems
There are several known problems with GAWK running on VMS. Some can
- be ignored, others require work-arounds.
+ be ignored, others require work-arounds. Note: GAWK in the VMS POSIX
+ environment does not have these problems.
4 command_line_parsing
The command
gawk "program text"
@@ -1117,6 +1139,21 @@
failure. The final exit status will be 1 (VMS success) if 0 is
used, or even (VMS non-success) if non-zero is used.
3 changes
+ Changes between version 2.14 and 2.13.2:
+
+ General
+ 'next file' construct added
+ 'continue' outside of any loop is treated as 'next'
+ Assorted bug fixes and efficiency improvements
+ _The_GAWK_Manual_ updated
+ Test suite expanded
+
+ VMS-specific
+ VMS POSIX support added
+ Disk I/O throughput enhanced
+ Pipe emulation improved and incorrect interaction with user-mode
+ redefinition of SYS$OUTPUT eliminated
+3 prior_changes
Changes between version 2.13 and 2.11.1: (2.12 was not released)
General
diff --git a/vms/unixlib.h b/vms/unixlib.h
index 17d99706..24fadce1 100644
--- a/vms/unixlib.h
+++ b/vms/unixlib.h
@@ -20,5 +20,8 @@ char *ecvt(), *fcvt(), *gcvt();
int getpid(), getppid();
-unsigned getgid(), getuid(), getegid(), geteuid();
+unsigned getuid();
+#ifndef _stdlib_h /* gcc's stdlib.h has these with conflicting types */
+unsigned getgid(), getegid(), geteuid();
+#endif
int setgid(), setuid(); /* no-ops */
diff --git a/vms/vms.h b/vms/vms.h
index 378adba2..f2a180a2 100644
--- a/vms/vms.h
+++ b/vms/vms.h
@@ -59,10 +59,10 @@ extern u_long LIB$FIND_FILE_END P((void *));
extern u_long LIB$GET_EF P((long *));
extern u_long SYS$ASSIGN P((const Dsc *, short *, long, const Dsc *));
extern u_long SYS$DASSGN P((short));
-extern u_long SYS$QIO P((long, short, long, void *, const void *, long,
+extern u_long SYS$QIO P((u_long, u_long, u_long, void *, void (*)(), u_long,
const char *, int, int, u_long, int, int));
extern u_long SYS$SYNCH P((long, void *));
-#endif !NO_TTY_FWRITE
+#endif /*!NO_TTY_FWRITE*/
/* system services for logical name manipulation */
extern u_long SYS$TRNLNM P((const u_long *,const Dsc *,const Dsc *,
const unsigned char *,Itm *));
@@ -75,7 +75,7 @@ extern void v_add_arg P((int, const char *));
extern void vms_exit P((int));
extern char *vms_strerror P((int));
extern char *vms_strdup P((const char *));
-extern int vms_devopen P((const char *));
+extern int vms_devopen P((const char *,int));
extern int vms_execute P((const char *, const char *, const char *));
extern int vms_gawk P((void));
extern u_long Cli_Present P((const char *));
diff --git a/vms/vms_args.c b/vms/vms_args.c
index b317d8d0..1ba179a3 100644
--- a/vms/vms_args.c
+++ b/vms/vms_args.c
@@ -69,6 +69,13 @@
* file-spec is left in the argument list rather than having it expand
* into thin air. No attempt is made to identify and make $(var)
* environment substitutions--must draw the line somewhere!
+ *
+ * Oct'91, gawk 2.13.3
+ * Open '<' with full sharing allowed, so that we can read batch logs
+ * and other open files. Create record-format output ('>$') with read
+ * sharing permited, so that others can read our output file to check
+ * progess. For stream output ('>' or '>>'), sharing is disallowed
+ * (for performance reasons).
*/
#include "awk.h" /* really "../awk.h" */
@@ -91,14 +98,14 @@ void
vms_arg_fixup( int *pargc, char ***pargv )
{
char *f_in, *f_out, *f_err,
- *out_mode, *rms_opt1, *rms_opt2;
+ *out_mode, *rms_opt1, *rms_opt2, *rms_opt3, *rms_opt4;
char **argv = *pargv;
int i, argc = *pargc;
int err_to_out_redirect = 0, out_to_err_redirect = 0;
-#ifndef NO_CHECK_SHELL
+#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 DECshell */
+ return; /* don't do anything if we're running DEC/Shell */
#endif
#ifndef NO_DCL_CMD
for (i = 1; i < argc ; i++) /* check for dash or other non-VMS args */
@@ -109,11 +116,13 @@ vms_arg_fixup( int *pargc, char ***pargv )
v_argz = v_argc = 0, v_argv = NULL;
}
#endif
- v_add_arg(v_argc = 0, basename(argv[0])); /* store arg #0 (image name) */
+ v_add_arg(v_argc = 0, argv[0]); /* store arg #0 (image name) */
f_in = f_out = f_err = NULL; /* stdio setup (no filenames yet) */
out_mode = "w"; /* default access for stdout */
rms_opt1 = rms_opt2 = "ctx=stm"; /* ("context = stream") == no-opt */
+ rms_opt3 = "shr=nil"; /* no sharing (for '>' output file) */
+ rms_opt4 = "mrs=0"; /* maximum record size */
for (i = 1; i < argc; i++) {
char *p, *fn;
@@ -147,9 +156,10 @@ vms_arg_fixup( int *pargc, char ***pargv )
else if (*p == '&') /* '>&' => stderr */
is_out = 0, p++;
else if (*p == '$') /* '>$' => kludge for record format */
- rms_opt1 = "rfm=var", rms_opt2 = "rat=cr", p++;
+ rms_opt1 = "rfm=var", rms_opt2 = "rat=cr",
+ rms_opt3 = "shr=get", rms_opt4 = "mrs=32767", p++;
else /* '>' => create */
- ; /* use default values initialized prior to loop */
+ {} /* use default values initialized prior to loop */
p = skipblanks(p);
fn = (*p ? p : argv[++i]); /* use next arg if necessary */
if (i >= argc || *fn == '-') {
@@ -197,8 +207,9 @@ vms_arg_fixup( int *pargc, char ***pargv )
if (*(p+1) == '\0' && i == argc - 1) {
fatal("background tasks not available ('&' encountered)");
break;
- } else /* fall through */
+ } else { /* fall through */
; /*NOBREAK*/
+ }
case '-': /* argument */
is_arg = 1; /*(=> skip wildcard check)*/
default: /* other (filespec assumed) */
@@ -239,24 +250,23 @@ ordinary_arg:
else
(void) vms_define("SYS$ERROR", f_err);
}
- /* do stdin before stdout, so we bomb we won't create empty output file */
+ /* do stdin before stdout, so if we bomb we won't make empty output file */
if (f_in) { /* [re]open file and define logical name */
- stdin = freopen(f_in, "r", stdin, "mbf=2");
+ stdin = freopen(f_in, "r", stdin,
+ "ctx=rec", "shr=get,put,del,upd",
+ "mrs=32767", "mbc=24", "mbf=2");
if (stdin != NULL)
(void) vms_define("SYS$INPUT", f_in);
else
fatal("<%s (%s)", f_in, strerror(errno));
}
- if (f_out) { /* disallow file sharing to reduce overhead */
+ if (f_out) {
stdout = freopen(f_out, out_mode, stdout,
- rms_opt1, rms_opt2, "shr=nil", "mbf=2"); /*VAXCRTL*/
- if (stdout != NULL) {
-#ifdef crtl_bug /* eof sometimes doesn't get set properly for stm_lf file */
-# define BIGBUF 8*BUFSIZ /* maximum record size: 4096 instead of 512 */
- setvbuf(stdout, malloc(BIGBUF), _IOFBF, BIGBUF);
-#endif
+ rms_opt1, rms_opt2, rms_opt3, rms_opt4,
+ "mbc=24", "mbf=2");
+ if (stdout != NULL)
(void) vms_define("SYS$OUTPUT", f_out);
- } else
+ else
fatal(">%s%s (%s)", (*out_mode == 'a' ? ">" : ""),
f_out, strerror(errno));
}
@@ -342,8 +352,6 @@ v_add_arg( int idx, const char *val )
fatal("%s: %s: can't allocate memory (%s)", "vms_args",
"v_argv", strerror(errno));
} else {
- memmsg((oldsize == 0 ? "v_argv" : "re: v_argv"), v_argz,
- "vms_args", v_argv);
while (old_size < v_argz) v_argv[old_size++] = NULL;
}
}
diff --git a/vms/vms_cli.c b/vms/vms_cli.c
index e4e33404..2f475b11 100644
--- a/vms/vms_cli.c
+++ b/vms/vms_cli.c
@@ -7,6 +7,9 @@
#define P(foo) ()
#include "config.h" /* in case we want to suppress 'const' &c */
#include "vms.h"
+#ifndef _STRING_H
+#include <string.h>
+#endif
extern u_long CLI$PRESENT(const Dsc *);
extern u_long CLI$GET_VALUE(const Dsc *, Dsc *, short *);
diff --git a/vms/vms_fwrite.c b/vms/vms_fwrite.c
index 94c345a5..6f2637b3 100644
--- a/vms/vms_fwrite.c
+++ b/vms/vms_fwrite.c
@@ -42,8 +42,8 @@ static int find_c( const char *s, int n, char c ) {
#define is_stdout(file_no) ((file_no) == 1) /* fileno(stdout) */
#define is_stderr(file_no) ((file_no) == 2) /* fileno(stderr) */
-#define PREFIX_CR (0x8D << 16) /* leading carriage return */
-#define POSTFIX_CR (0x8D << 24) /* trailing carriage return (=> lf/cr) */
+#define PREFIX_CR 0x008D0000 /* leading carriage return */
+#define POSTFIX_CR 0x8D000000 /* trailing carriage return (=> lf/cr) */
static short channel[_NFILE] = {0};
static FILE *prev_file = 0;
@@ -121,7 +121,7 @@ tty_fwrite( const void *buf, size_t size, size_t number, FILE *file )
if (vmsfail(sts)) break;
}
/* queue an asynchronous write */
- sts = SYS$QIO(evfn, chan, io_func, &iosb, (u_long (*)())0, 0,
+ sts = SYS$QIO(evfn, chan, io_func, &iosb, (void (*)())0, 0L,
pt, pos, 0, cc_fmt, 0, 0);
if (vmsfail(sts)) break; /*(should never happen)*/
pt += pos, count -= pos;
diff --git a/vms/vms_gawk.c b/vms/vms_gawk.c
index ec4747d3..552139bd 100644
--- a/vms/vms_gawk.c
+++ b/vms/vms_gawk.c
@@ -43,6 +43,8 @@
#define Get_Value(arg,buf,siz) vmswork(Cli_Get_Value(arg,buf,siz))
extern void gawk_cmd(); /* created with $ SET COMMAND/OBJECT */
+#define GAWK_CMD ((const void *)gawk_cmd)
+extern void _exit(int);
static int vms_usage(int);
#define ARG_SIZ 250
@@ -77,7 +79,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, COMMAND_NAME);
+ sts = Cli_Parse_Command(GAWK_CMD, COMMAND_NAME);
if (vmswork(sts))
sts = Cli_Present("GAWK_P1");
}
diff --git a/vms/vms_misc.c b/vms/vms_misc.c
index c7044348..58231ff4 100644
--- a/vms/vms_misc.c
+++ b/vms/vms_misc.c
@@ -23,7 +23,13 @@
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include "awk.h" /* really "../awk.h" */
+#define creat creat_dummy /* one of gcc-vms's headers has bad prototype */
+#include "awk.h"
+#undef creat
+#include <fab.h>
+#ifndef O_RDONLY
+#include <fcntl.h>
+#endif
#include <ssdef.h>
#include <stsdef.h>
@@ -36,9 +42,9 @@
# undef exit
#endif
void
-vms_exit( int errno ) /* note: local override of global 'errno' */
+vms_exit( int final_status )
{
- exit(errno == 0 ? SS$_NORMAL : (SS$_ABORT | STS$M_INHIB_MSG));
+ exit(final_status == 0 ? SS$_NORMAL : (SS$_ABORT | STS$M_INHIB_MSG));
}
#define exit(v) vms_exit(v)
@@ -55,7 +61,7 @@ vms_exit( int errno ) /* note: local override of global 'errno' */
char *
vms_strerror( int errnum )
{
- extern char *strerror( /* int, ... */ );
+ extern char *strerror P((int,...));
return ( errnum != EVMSERR ? strerror(errnum)
: strerror(EVMSERR, vaxc$errno) );
}
@@ -93,21 +99,53 @@ unlink( const char *file_spec ) {
}
/*
+ * Work-around an open(O_CREAT+O_TRUNC) bug (screwed up modification
+ * and creation dates when new version is created), and also use some
+ * VMS-specific file options. Note: optional 'prot' arg is completely
+ * ignored; gawk doesn't need it.
+ */
+#ifdef open
+# undef open
+#endif
+/* vms_open() - open a file, possibly creating it */
+int
+vms_open( const char *name, int mode, ... )
+{
+ extern int creat P((const char *,int,...));
+ extern int open P((const char *,int,unsigned,...));
+
+ if (mode == (O_WRONLY|O_CREAT|O_TRUNC))
+ return creat(name, 0, "shr=nil", "mbc=24");
+ else {
+ struct stat stb;
+ const char *mbc, *shr = "shr=get";
+
+ if (stat(name, &stb) < 0) { /* assume DECnet */
+ mbc = "mbc=8";
+ } else { /* ordinary file; allow full sharing iff record format */
+ mbc = "mbc=12";
+ if (stb.st_fab_rfm < FAB$C_STM) shr = "shr=get,put,upd";
+ }
+ return open(name, mode, 0, shr, mbc, "mbf=2");
+ }
+}
+
+ /*
* Check for attempt to (re-)open known file.
*/
/* vms_devopen() - check for "SYS$INPUT" or "SYS$OUTPUT" or "SYS$ERROR" */
int
-vms_devopen( const char *name )
+vms_devopen( const char *name, int mode )
{
FILE *file = NULL;
if (strncasecmp(name, "SYS$", 4) == 0) {
name += 4; /* skip "SYS$" */
- if (strncasecmp(name, "INPUT", 5) == 0)
+ if (strncasecmp(name, "INPUT", 5) == 0 && (mode & O_WRONLY) == 0)
file = stdin, name += 5;
- else if (strncasecmp(name, "OUTPUT", 6) == 0)
+ else if (strncasecmp(name, "OUTPUT", 6) == 0 && (mode & O_WRONLY) != 0)
file = stdout, name += 6;
- else if (strncasecmp(name, "ERROR", 5) == 0)
+ else if (strncasecmp(name, "ERROR", 5) == 0 && (mode & O_WRONLY) != 0)
file = stderr, name += 5;
if (*name == ':') name++; /* treat trailing colon as optional */
}
@@ -132,9 +170,9 @@ void tzset()
# ifdef bcopy
# undef bcopy
# endif
-void bcopy( char *src, char *dst, int len )
+void bcopy( const char *src, char *dst, int len )
{
- (void) OTS$MOVE3(len, src, dst);
+ (void) memcpy(dst, src, len);
}
#endif /*!__GNUC__*/
diff --git a/vms/vms_popen.c b/vms/vms_popen.c
index 654364c4..b962d01d 100644
--- a/vms/vms_popen.c
+++ b/vms/vms_popen.c
@@ -54,7 +54,7 @@ fork()
return -1;
}
-#else PIPES_SIMULATED
+#else /*PIPES_SIMULATED*/
/*
* Simulate pipes using temporary files; hope that the user
* doesn't expect pipe i/o to be interleaved with other i/o ;-}.
@@ -116,7 +116,7 @@ popen( const char *command, const char *mode )
/* an input pipe reads a temporary file created by the command */
vms_execute(command, (char *)0, name); /* 'command >tempfile' */
}
- if ((current = fopen(name, mode, "mbf=2")) == NULL) {
+ if ((current = fopen(name, mode, "mbc=24", "mbf=2")) == NULL) {
free(name);
return NULL;
}
@@ -344,6 +344,6 @@ restore_translation( const Dsc *logname, const Itm *itemlist )
}
}
-#endif /* PIPES_SIMULATED */
+#endif /*PIPES_SIMULATED*/
#endif /*!NO_VMS_PIPES*/
diff --git a/vms/vmsbuild.com b/vms/vmsbuild.com
index e823eb1b..069a4ca8 100644
--- a/vms/vmsbuild.com
+++ b/vms/vmsbuild.com
@@ -1,34 +1,40 @@
$! vmsbuild.com -- Commands to build GAWK Pat Rankin, Dec'89
$! revised, Mar'90
$! gawk 2.13 revised, Jun'91
+$! gawk 2.14 revised, Sep'92
$!
-$ REL = "2.13" !release version number
-$ PATCHLVL = "2"
+$ REL = "2.14" !release version number
+$ PATCHLVL = "0"
$!
-$! [ remove "/optimize=noinline" for VAX C V2.x ]
+$! [ remove "/optimize=noinline" for VAX C V2.x or DEC C ]
+$! [ add "/standard=VAXC" for DEC C and "/g_float" for Alpha ]
$ if f$type(cc) .nes."STRING" then cc := cc/nolist/optimize=noinline
$ if f$type(link).nes."STRING" then link := link/nomap
+$ if f$type(set_command).nes."STRING" then set_command := set command
$!
-$ cc := 'cc'/include=[]
+$ cc := 'cc'/Include=[]/Define="""GAWK"""
$ libs = "sys$share:vaxcrtl.exe/Shareable"
$
+$! uncomment for DEC C
+$ ! libs = ""
+$
$! uncomment the next two lines for VAX C V2.x
$ ! define vaxc$library sys$library:,sys$disk:[.vms]
$ ! define c$library [],[.vms]
$!
$! uncomment next two lines for GNU C
-$ ! cc := gcc/include=([],[.vms]) !use GNU C rather than VAX C
+$ ! cc := gcc/Include=([],[.vms])/Define="""GAWK""" !use GNU C rather than VAX C
$ ! libs = "gnu_cc:[000000]gcclib.olb/Library,sys$library:vaxcrtl.olb/Library"
$!
-$ if f$search("config.h") .eqs."" then copy [.config]vms-conf.h []config.h
-$ if f$search("awk_tab.c").nes."" then goto awk_tab_ok
+$ if f$search("config.h").eqs."" then copy [.config]vms-conf.h []config.h
+$ if f$search("awktab.c").nes."" then goto awktab_ok
$ write sys$output " You must process `awk.y' with ""yacc"" or ""bison"""
-$ if f$search("awk.tab_c").nes."" then - !unpacked with poor 'tar' reader
- write sys$output " or else rename `awk.tab_c' to `awk_tab.c'."
-$ if f$search("y_tab.c").nes."" then - !yacc was run manually
- write sys$output " or else rename `y_tab.c' to `awk_tab.c'."
+$ if f$search("awk_tab.c").nes."" then - !bison was run manually
+ write sys$output " or else rename `awk_tab.c' to `awktab.c'."
+$ 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 `awktab.c'."
$ exit
-$awk_tab_ok:
+$awktab_ok:
$ cc main.c
$ cc eval.c
$ cc builtin.c
@@ -40,9 +46,10 @@ $ cc array.c
$ cc node.c
$ cc version.c
$ cc missing.c
-$ cc awk_tab.c
-$ cc regex.c
$ cc re.c
+$ cc getopt.c
+$ cc awktab.c
+$ cc regex.c
$ cc dfa.c
$ cc/define=("STACK_DIRECTION=(-1)","exit=vms_exit") alloca
$ cc [.vms]vms_misc.c
@@ -51,17 +58,18 @@ $ 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
+$ set_command/object=[]gawk_cmd.obj [.vms]gawk.cld
$!
$ create gawk.opt
! GAWK -- Gnu AWK
main.obj,eval.obj,builtin.obj,msg.obj,iop.obj,io.obj
-field.obj,array.obj,node.obj,version.obj,missing.obj,awk_tab.obj
-regex.obj,re.obj,dfa.obj,[]alloca.obj
+field.obj,array.obj,node.obj,version.obj,missing.obj
+re.obj,getopt.obj,awktab.obj,regex.obj,dfa.obj,[]alloca.obj
[]vms_misc.obj,vms_popen.obj,vms_fwrite.obj
[]vms_args.obj,vms_gawk.obj,vms_cli.obj,gawk_cmd.obj
psect_attr=environ,noshr !extern [noshare] char **
-stack=50 !preallocate more pages (default is 20)
+stack=48 !preallocate more pages (default is 20)
+iosegment=128 !ditto (default is 32)
$ open/append Fopt gawk.opt
$ write Fopt libs
$ write Fopt "identification=""V''REL'.''PATCHLVL'"""