summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/awk/version.c
blob: 6aaee40cde6a7add520b9ee08ad3418d172ff0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

/********************************************
version.c
copyright 1991, 1992.  Michael D. Brennan

This is a source file for mawk, an implementation of
the AWK programming language.

Mawk is distributed without warranty under the terms of
the GNU General Public License, version 2, 1991.
********************************************/

/*$Log: version.c,v $
/*Revision 1.2  1993/07/02 23:58:02  jtc
/*Updated to mawk 1.1.4
/*
 * Revision 5.6.1.3  1993/05/05  00:02:18  mike
 * patch4
 *
 * Revision 5.6.1.2  1993/01/20  12:53:13  mike
 * d_to_l()
 *
 * Revision 5.6.1.1  1993/01/15  03:33:54  mike
 * patch3: safer double to int conversion
 *
 * Revision 5.6  1992/12/17  02:48:01  mike
 * 1.1.2d changes for DOS
 *
 * Revision 5.5  1992/12/02  03:18:12  mike
 * coherent patch
 *
 * Revision 5.4  1992/08/27  11:50:38  mike
 * patch2
 *
 * Revision 5.3  1992/03/03  16:42:23  brennan
 * patch 1
 *
 * Revision 5.2  92/01/22  05:34:10  brennan
 * version 1.1
 * 
 * Revision 5.1  91/12/05  07:56:33  brennan
 * 1.1 pre-release
 * 
*/

#include "mawk.h"
#include "patchlev.h"

static char rcsid[] =
"@(#) $Id: version.c,v 1.2 1993/07/02 23:58:02 jtc Exp $" ;

#define  VERSION_STRING  \
  "mawk 1.1%s%s %s, Copyright (C) Michael D. Brennan\n\n"

#define  DOS_STRING     ""

/* If use different command line syntax for MSDOS
   mark that in VERSION  */

#if  MSDOS 
#undef   DOS_STRING

#if  SM_DOS

#if  HAVE_REARGV
#define  DOS_STRING     "SM"
#else
#define  DOS_STRING     "SMDOS"
#endif  

#else  /* LM_DOS  */

#if  HAVE_REARGV
#define  DOS_STRING     "LM"
#else
#define  DOS_STRING     "LMDOS"
#endif  

#endif
#endif  /* MSDOS */

#ifdef THINK_C
#undef DOS_STRING
#define DOS_STRING ":Mac"
#endif

static char fmt[] = "%-14s%10lu\n" ;

/* print VERSION and exit */
void print_version()
{ 

  printf(VERSION_STRING, PATCH_STRING, DOS_STRING, DATE_STRING) ;
  fflush(stdout) ;

  print_compiler_id() ;
  fprintf(stderr, "compiled limits:\n") ;
  fprintf(stderr, fmt,  "largest field", (long)MAX_FIELD) ;
  fprintf(stderr, fmt,  "sprintf buffer", (long)SPRINTF_SZ) ;
  print_aux_limits() ;
  exit(0) ;
}


/*
  Extra info for MSDOS.  This code contributed by
  Ben Myers 
*/

#ifdef __TURBOC__
#include <alloc.h>   /* coreleft() */
#define  BORL
#endif

#ifdef __BORLANDC__
#include <alloc.h>   /* coreleft() */
#define  BORL
#endif

#ifdef  BORL 
#if     LM_DOS
extern unsigned  _stklen = 16 * 1024U ; 
   /*  4K of stack is enough for a user function call 
       nesting depth of 75 so this is enough for 300 */
#endif
#endif

#ifdef _MSC_VER
#include <malloc.h>
#endif

#ifdef __ZTC__
#include <dos.h>              /* _chkstack */
#endif


int print_compiler_id()
{

#ifdef  __TURBOC__
  fprintf(stderr, "MsDOS Turbo C++ %d.%d\n",
                __TURBOC__>>8, __TURBOC__&0xff) ;
#endif
  
#ifdef __BORLANDC__
  fprintf (stderr, "MS-DOS Borland C++ __BORLANDC__ %x\n",
        __BORLANDC__ );
#endif

#ifdef _MSC_VER
  fprintf (stderr, "MS-DOS Microsoft C/C++ _MSC_VER %u\n", _MSC_VER );
#endif

#ifdef __ZTC__
  fprintf (stderr, "MS-DOS Zortech C++ __ZTC__ %x\n", __ZTC__ );
#endif

  return 0 ; /*shut up */
}


int  print_aux_limits()
{
#ifdef BORL
  extern unsigned _stklen ;
  fprintf(stderr, fmt,  "stack size", (unsigned long)_stklen) ;
  fprintf(stderr, fmt,  "heap size",  (unsigned long) coreleft()) ;
#endif

#ifdef _MSC_VER
  fprintf(stderr, fmt,  "stack size", (unsigned long)_stackavail()) ;
#if   SM_DOS
  fprintf(stderr, fmt,  "heap size", (unsigned long) _memavl()) ;
#endif
#endif

#ifdef __ZTC__
/* large memory model only with ztc */
  fprintf(stderr, fmt,  "stack size??", (unsigned long)_chkstack()) ;
  fprintf(stderr, fmt,  "heap size", farcoreleft()) ;
#endif

  return 0 ;
}