Git init
[external/mawk.git] / version.c
1
2 /********************************************
3 version.c
4 copyright 1991-95.  Michael D. Brennan
5
6 This is a source file for mawk, an implementation of
7 the AWK programming language.
8
9 Mawk is distributed without warranty under the terms of
10 the GNU General Public License, version 2, 1991.
11 ********************************************/
12
13 /*$Log: version.c,v $
14  *Revision 1.10  1996/07/28 21:47:07  mike
15  *gnuish patch
16  *
17  * Revision 1.9  1996/02/01  04:44:15  mike
18  * roll a beta version
19  *
20  * Revision 1.8  1995/08/20  17:40:45  mike
21  * changed _stackavail to stackavail for MSC
22  *
23  * Revision 1.7  1995/06/10  17:04:10  mike
24  * "largest field" replaced by "max NF"
25  *
26 */
27
28 #include "mawk.h"
29 #include "patchlev.h"
30
31 static char mawkid[] = MAWK_ID ;
32
33 #define  VERSION_STRING  \
34   "mawk 1.3%s%s %s, Copyright (C) Michael D. Brennan\n\n"
35
36 /* If use different command line syntax for MSDOS
37    mark that in VERSION  */
38
39 #ifndef DOS_STRING
40 #if  MSDOS && ! HAVE_REARGV
41 #define DOS_STRING  "MsDOS"
42 #endif
43 #endif
44
45 #ifndef DOS_STRING
46 #define DOS_STRING      ""
47 #endif
48
49 int print_compiler_id();
50 int print_aux_limits();
51
52 static char fmt[] = "%-14s%10lu\n" ;
53
54 /* print VERSION and exit */
55 void
56 print_version()
57 {
58
59    printf(VERSION_STRING, PATCH_STRING, DOS_STRING, DATE_STRING) ;
60    fflush(stdout) ;
61
62    print_compiler_id() ;
63    fprintf(stderr, "compiled limits:\n") ;
64    fprintf(stderr, fmt, "max NF", (long) MAX_FIELD) ;
65    fprintf(stderr, fmt, "sprintf buffer", (long) SPRINTF_SZ) ;
66    print_aux_limits() ;
67    exit(0) ;
68 }
69
70
71 /*
72   Extra info for MSDOS.  This code contributed by
73   Ben Myers
74 */
75
76 #ifdef __TURBOC__
77 #include <alloc.h>              /* coreleft() */
78 #define  BORL
79 #endif
80
81 #ifdef __BORLANDC__
82 #include <alloc.h>              /* coreleft() */
83 #define  BORL
84 #endif
85
86 #ifdef  BORL
87 extern unsigned _stklen = 16 * 1024U ;
88  /*  4K of stack is enough for a user function call
89        nesting depth of 75 so this is enough for 300 */
90 #endif
91
92 #ifdef _MSC_VER
93 #include <malloc.h>
94 #endif
95
96 #ifdef __ZTC__
97 #include <dos.h>                /* _chkstack */
98 #endif
99
100
101 int
102 print_compiler_id()
103 {
104
105 #ifdef  __TURBOC__
106    fprintf(stderr, "MsDOS Turbo C++ %d.%d\n",
107            __TURBOC__ >> 8, __TURBOC__ & 0xff) ;
108 #endif
109
110 #ifdef __BORLANDC__
111    fprintf(stderr, "MS-DOS Borland C++ __BORLANDC__ %x\n",
112            __BORLANDC__) ;
113 #endif
114
115 #ifdef _MSC_VER
116    fprintf(stderr, "Microsoft C/C++ _MSC_VER %u\n", _MSC_VER) ;
117 #endif
118
119 #ifdef __ZTC__
120    fprintf(stderr, "MS-DOS Zortech C++ __ZTC__ %x\n", __ZTC__) ;
121 #endif
122
123    return 0 ;                    /*shut up */
124 }
125
126
127 int
128 print_aux_limits()
129 {
130 #ifdef BORL
131    extern unsigned _stklen ;
132    fprintf(stderr, fmt, "stack size", (unsigned long) _stklen) ;
133    fprintf(stderr, fmt, "heap size", (unsigned long) coreleft()) ;
134 #endif
135
136 #ifdef _MSC_VER
137    fprintf(stderr, fmt, "stack size", (unsigned long) stackavail()) ;
138 #endif
139
140 #ifdef __ZTC__
141 /* large memory model only with ztc */
142    fprintf(stderr, fmt, "stack size??", (unsigned long) _chkstack()) ;
143    fprintf(stderr, fmt, "heap size", farcoreleft()) ;
144 #endif
145
146    return 0 ;
147 }