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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void version(void) {
|
||||||
|
printf("unroff %s\n", get_version_string());
|
||||||
|
}
|
||||||
|
|
||||||
static void usage(void) {
|
static void usage(void) {
|
||||||
fprintf(stderr, "Usage: %s [options] [file...]\n\n", get_progname());
|
fprintf(stderr, "Usage: %s [options] [file...]\n\n", get_progname());
|
||||||
fprintf(stderr, " -mname name of troff macro package (e.g. -ms)\n");
|
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 = safe_malloc((ac+3+1) * sizeof(char *));
|
||||||
eav[0] = av[0];
|
eav[0] = av[0];
|
||||||
opterr = 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) {
|
switch (c) {
|
||||||
case 'g':
|
case 'g':
|
||||||
eav[eac++] = "-g"; break;
|
eav[eac++] = "-g"; break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
/* Unroff help flag */
|
||||||
if (strcmp(optarg, "elp") == 0) {
|
if (strcmp(optarg, "elp") == 0) {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
eav[eac++] = "-h"; eav[eac++] = optarg; break;
|
/* Elk heap size flag */
|
||||||
|
eav[eac++] = "-h";
|
||||||
|
eav[eac++] = optarg;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
macros = optarg; break;
|
macros = optarg; break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
@ -184,6 +192,9 @@ int main(int ac, char **av) {
|
||||||
tflag = 1; break;
|
tflag = 1; break;
|
||||||
case 'C':
|
case 'C':
|
||||||
compatible = 1; break;
|
compatible = 1; break;
|
||||||
|
case 'V':
|
||||||
|
version();
|
||||||
|
return 0;
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue