summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-23 10:57:14 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-03-25 21:21:22 -0700
commit1a2cb3f73bcb8b7dc532253c64dc4da5a40e585b (patch)
treebd40d7bebc2976b1469aa1037facba41c418a681
parent451fc9a8a4a6ad7e85e81e8186a0061da91b37c9 (diff)
downloadc-snippets-autotab-5.tar.gz
c-snippets-autotab-5.tar.bz2
c-snippets-autotab-5.zip
Version 5.autotab-5
Support --version option. Put in correct copyright. Change e-mail address to kylheku.com.
-rw-r--r--autotab.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/autotab.c b/autotab.c
index 93c3500..a841eeb 100644
--- a/autotab.c
+++ b/autotab.c
@@ -1,11 +1,12 @@
/*
- * Autotab v004.
- * Program to detect the tabbing style of a text file, and report
+ * Autotab.
+ *
+ * A program to detect the tabbing style of a text file, and report
* it as a Vim command to set up the tabstop, shiftwidth and expandtab
* parameters.
*
- * Copyright 2014
- * Kaz Kylheku <kkylheku@gmail.com>
+ * Copyright 2007-2016
+ * Kaz Kylheku <kaz@kylheku.com>
* Vancouver, Canada
*
* To use this, compile to an executable called "autotab".
@@ -19,6 +20,7 @@
* execute 'set' system("autotab < " . bufname("%")) | endif
*/
+#define AUTOTAB_VER 5
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -725,8 +727,17 @@ int main(int argc, char **argv)
int tabsize = 8, expandtabs = 1, shiftwidth = 8;
int ret = EXIT_FAILURE;
- if (argc > 1 && !strcmp(argv[1], "-d"))
- debug_enabled = 1;
+ if (argc > 1) {
+ if (!strcmp(argv[1], "-d")) {
+ debug_enabled = 1;
+ } else if (!strcmp(argv[1], "--version")) {
+ printf("Autotab %d\n", AUTOTAB_VER);
+ return EXIT_SUCCESS;
+ } else {
+ fputs("invalid argument\n", stderr);
+ return EXIT_FAILURE;
+ }
+ }
if ((lines = snarf_lines(stdin)) == 0)
goto out_default;