1 /* printversion.c: Output for the standard GNU option --version.
3 Written in 1996 by Karl Berry. Public domain. */
5 #include <w2c/config.h>
7 #include <kpathsea/version.h>
9 #include <ptexenc/ptexenc.h>
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 ... */
24 printversionandexit (const_string banner
,
25 const_string copyright_holder
,
27 const_string extra_info
)
31 const_string prog_name_end
= strchr (banner
, ',');
32 const_string prog_version
= strrchr (banner
, ' ');
33 assert (prog_name_end
&& 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
);
41 /* The Web2c version string starts with a space. */
43 printf ("%s %s (%s)%s\n", prog_name
, prog_version
, get_enc_string(),
46 printf ("%s %s%s\n", prog_name
, prog_version
, versionstring
);
48 puts (kpathsea_version_string
);
50 puts (ptexenc_version_string
);
53 if (copyright_holder
) {
54 printf ("Copyright 2015 %s.\n", copyright_holder
);
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
);
68 fputs (extra_info
, stdout
);