File: version.c

package info (click to toggle)
mawk 1.3.4.20260302-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,244 kB
  • sloc: ansic: 19,997; sh: 4,627; yacc: 1,182; awk: 903; makefile: 301
file content (61 lines) | stat: -rw-r--r-- 1,737 bytes parent folder | download
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
/********************************************
version.c
copyright 2008-2025,2026   Thomas E. Dickey
copyright 1991-1996,2014   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.
********************************************/

/*
 * $MawkId: version.c,v 1.40 2026/01/08 09:20:06 tom Exp $
 */

#include <mawk.h>
#include <init.h>
#include <patchlev.h>

#define	 VERSION_STRING	 \
  "mawk %d.%d%s %s\n\
Copyright 2008-2025,2026, Thomas E. Dickey\n\
Copyright 1991-1996,2014, Michael D. Brennan\n\n"

#define FMT_N "%-20s%.0f\n"
#define FMT_S "%-20s%s\n"

/* print VERSION and exit */
void
print_version(FILE *fp)
{
    fprintf(fp, VERSION_STRING, PATCH_BASE, PATCH_LEVEL, PATCH_STRING, DATE_STRING);
    fflush(fp);

#define SHOW_RANDOM "random-funcs:"
#if defined(NAME_RANDOM)
    fprintf(fp, FMT_S, SHOW_RANDOM, NAME_RANDOM);
#else
    fprintf(fp, FMT_S, SHOW_RANDOM, "internal");
#endif

#define SHOW_REGEXP "regex-funcs:"
#ifdef LOCAL_REGEXP
    fprintf(fp, FMT_S, SHOW_REGEXP, "internal");
#else
    fprintf(fp, FMT_S, SHOW_REGEXP, "external");
#endif

    fprintf(fp, "\ncompiled limits:\n");
    fprintf(fp, FMT_N, "sprintf buffer", (double) SPRINTF_LIMIT);
    fprintf(fp, FMT_N, "maximum-integer", (double) MAX__INT);
#if defined(VERBOSE_VERSION)
    /* we could show these, but for less benefit: */
    fprintf(fp, FMT_N, "maximum-unsigned", (double) MAX__UINT);
    fprintf(fp, FMT_N, "maximum-long", (double) MAX__LONG);
    fprintf(fp, "\nactual limits:\n");
    fprintf(fp, FMT_N, "sprintf buffer", (double) (sprintf_limit - sprintf_buff));
#endif
    mawk_exit(0);
}