preparation for the tag 0.80
[luatex.git] / source / texk / web2c / lib / printversion.c
blobc1a32c8874f3aae76b684345aa1718ae2b21094a
1 /* printversion.c: Output for the standard GNU option --version.
3 Written in 1996 by Karl Berry. Public domain. */
5 #include <w2c/config.h>
6 #include "lib.h"
7 #include <kpathsea/version.h>
8 #ifdef PTEX
9 #include <ptexenc/ptexenc.h>
10 #endif
12 /* We're passed in the original WEB banner string, which has the form
13 This is PROGRAM, Version VERSION-NUMBER
14 We parse the PROGRAM and VERSION-NUMBER out of this.
16 If COPYRIGHT_HOLDER is specified and AUTHOR isn't, then use the
17 former for the latter. If AUTHOR is specified and COPYRIGHT_HOLDER
18 isn't, it means the original program is public domain.
20 Maybe I should have just done it all inline in each individual
21 program, but tangle doesn't allow multiline string constants ... */
23 void
24 printversionandexit (const_string banner,
25 const_string copyright_holder,
26 const_string author,
27 const_string extra_info)
29 string prog_name;
30 unsigned len;
31 const_string prog_name_end = strchr (banner, ',');
32 const_string prog_version = strrchr (banner, ' ');
33 assert (prog_name_end && prog_version);
34 prog_version++;
36 len = prog_name_end - banner - sizeof ("This is");
37 prog_name = xmalloc (len + 1);
38 strncpy (prog_name, banner + sizeof ("This is"), len);
39 prog_name[len] = 0;
41 /* The Web2c version string starts with a space. */
42 #ifdef PTEX
43 printf ("%s %s (%s)%s\n", prog_name, prog_version, get_enc_string(),
44 versionstring);
45 #else
46 printf ("%s %s%s\n", prog_name, prog_version, versionstring);
47 #endif
48 puts (kpathsea_version_string);
49 #ifdef PTEX
50 puts (ptexenc_version_string);
51 #endif
53 if (copyright_holder) {
54 printf ("Copyright 2015 %s.\n", copyright_holder);
55 if (!author)
56 author = copyright_holder;
59 puts ("There is NO warranty. Redistribution of this software is");
60 fputs ("covered by the terms of ", stdout);
61 printf ("both the %s copyright and\n", prog_name);
62 puts ("the Lesser GNU General Public License.");
63 puts ("For more information about these matters, see the file");
64 printf ("named COPYING and the %s source.\n", prog_name);
65 printf ("Primary author of %s: %s.\n", prog_name, author);
67 if (extra_info)
68 fputs (extra_info, stdout);
70 uexit (0);