Add -V version flag
This commit is contained in:
parent
4d6110812c
commit
e9b63e2f71
15
src/unroff.c
15
src/unroff.c
|
@ -25,6 +25,10 @@ const char *get_version_string(void) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
static void version(void) {
|
||||
printf("unroff %s\n", get_version_string());
|
||||
}
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [options] [file...]\n\n", get_progname());
|
||||
fprintf(stderr, " -mname name of troff macro package (e.g. -ms)\n");
|
||||
|
@ -166,16 +170,20 @@ int main(int ac, char **av) {
|
|||
eav = safe_malloc((ac+3+1) * sizeof(char *));
|
||||
eav[0] = av[0];
|
||||
opterr = 0;
|
||||
while ((c = getopt(ac, av, "h:gm:f:tC")) != EOF) {
|
||||
while ((c = getopt(ac, av, "h:gm:f:tCV")) != EOF) {
|
||||
switch (c) {
|
||||
case 'g':
|
||||
eav[eac++] = "-g"; break;
|
||||
case 'h':
|
||||
/* Unroff help flag */
|
||||
if (strcmp(optarg, "elp") == 0) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
eav[eac++] = "-h"; eav[eac++] = optarg; break;
|
||||
/* Elk heap size flag */
|
||||
eav[eac++] = "-h";
|
||||
eav[eac++] = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
macros = optarg; break;
|
||||
case 'f':
|
||||
|
@ -184,6 +192,9 @@ int main(int ac, char **av) {
|
|||
tflag = 1; break;
|
||||
case 'C':
|
||||
compatible = 1; break;
|
||||
case 'V':
|
||||
version();
|
||||
return 0;
|
||||
case '?':
|
||||
usage();
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue