xref: /386bsd/usr/src/usr.bin/awk/version.c (revision a2142627)
1 
2 /********************************************
3 version.c
4 copyright 1991, 1992.  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 5.6.1.2  1993/01/20  12:53:13  mike
15  * d_to_l()
16  *
17  * Revision 5.6.1.1  1993/01/15  03:33:54  mike
18  * patch3: safer double to int conversion
19  *
20  * Revision 5.6  1992/12/17  02:48:01  mike
21  * 1.1.2d changes for DOS
22  *
23  * Revision 5.5  1992/12/02  03:18:12  mike
24  * coherent patch
25  *
26  * Revision 5.4  1992/08/27  11:50:38  mike
27  * patch2
28  *
29  * Revision 5.3  1992/03/03  16:42:23  brennan
30  * patch 1
31  *
32  * Revision 5.2  92/01/22  05:34:10  brennan
33  * version 1.1
34  *
35  * Revision 5.1  91/12/05  07:56:33  brennan
36  * 1.1 pre-release
37  *
38 */
39 
40 #include "mawk.h"
41 #include "patchlev.h"
42 
43 static char rcsid[] =
44 "@(#) $Id: version.c,v 5.6.1.2 1993/01/20 12:53:13 mike Exp $" ;
45 
46 #define  VERSION_STRING  \
47   "mawk 1.1%s%s %s, Copyright (C) Michael D. Brennan\n\n"
48 
49 #define  DOS_STRING     ""
50 
51 /* If use different command line syntax for MSDOS
52    mark that in VERSION  */
53 
54 #if  MSDOS
55 #undef   DOS_STRING
56 
57 #if  SM_DOS
58 
59 #if  HAVE_REARGV
60 #define  DOS_STRING     "SM"
61 #else
62 #define  DOS_STRING     "SMDOS"
63 #endif
64 
65 #else  /* LM_DOS  */
66 
67 #if  HAVE_REARGV
68 #define  DOS_STRING     "LM"
69 #else
70 #define  DOS_STRING     "LMDOS"
71 #endif
72 
73 #endif
74 #endif  /* MSDOS */
75 
76 #ifdef THINK_C
77 #undef DOS_STRING
78 #define DOS_STRING ":Mac"
79 #endif
80 
81 static char fmt[] = "%-14s%10lu\n" ;
82 
83 /* print VERSION and exit */
print_version()84 void print_version()
85 {
86 
87   printf(VERSION_STRING, PATCH_STRING, DOS_STRING, DATE_STRING) ;
88   fflush(stdout) ;
89 
90   print_compiler_id() ;
91   fprintf(stderr, "compiled limits:\n") ;
92   fprintf(stderr, fmt,  "largest field", (long)MAX_FIELD) ;
93   fprintf(stderr, fmt,  "sprintf buffer", (long)SPRINTF_SZ) ;
94   print_aux_limits() ;
95   exit(0) ;
96 }
97 
98 
99 /*
100   Extra info for MSDOS.  This code contributed by
101   Ben Myers
102 */
103 
104 #ifdef __TURBOC__
105 #include <alloc.h>   /* coreleft() */
106 #define  BORL
107 #endif
108 
109 #ifdef __BORLANDC__
110 #include <alloc.h>   /* coreleft() */
111 #define  BORL
112 #endif
113 
114 #ifdef  BORL
115 #if     LM_DOS
116 extern unsigned  _stklen = 16 * 1024U ;
117    /*  4K of stack is enough for a user function call
118        nesting depth of 75 so this is enough for 300 */
119 #endif
120 #endif
121 
122 #ifdef _MSC_VER
123 #include <malloc.h>
124 #endif
125 
126 #ifdef __ZTC__
127 #include <dos.h>              /* _chkstack */
128 #endif
129 
130 
print_compiler_id()131 int print_compiler_id()
132 {
133 
134 #ifdef  __TURBOC__
135   fprintf(stderr, "MsDOS Turbo C++ %d.%d\n",
136                 __TURBOC__>>8, __TURBOC__&0xff) ;
137 #endif
138 
139 #ifdef __BORLANDC__
140   fprintf (stderr, "MS-DOS Borland C++ __BORLANDC__ %x\n",
141         __BORLANDC__ );
142 #endif
143 
144 #ifdef _MSC_VER
145   fprintf (stderr, "MS-DOS Microsoft C/C++ _MSC_VER %u\n", _MSC_VER );
146 #endif
147 
148 #ifdef __ZTC__
149   fprintf (stderr, "MS-DOS Zortech C++ __ZTC__ %x\n", __ZTC__ );
150 #endif
151 
152   return 0 ; /*shut up */
153 }
154 
155 
print_aux_limits()156 int  print_aux_limits()
157 {
158 #ifdef BORL
159   extern unsigned _stklen ;
160   fprintf(stderr, fmt,  "stack size", (unsigned long)_stklen) ;
161   fprintf(stderr, fmt,  "heap size",  (unsigned long) coreleft()) ;
162 #endif
163 
164 #ifdef _MSC_VER
165   fprintf(stderr, fmt,  "stack size", (unsigned long)_stackavail()) ;
166 #if   SM_DOS
167   fprintf(stderr, fmt,  "heap size", (unsigned long) _memavl()) ;
168 #endif
169 #endif
170 
171 #ifdef __ZTC__
172 /* large memory model only with ztc */
173   fprintf(stderr, fmt,  "stack size??", (unsigned long)_chkstack()) ;
174   fprintf(stderr, fmt,  "heap size", farcoreleft()) ;
175 #endif
176 
177   return 0 ;
178 }
179