From 7aaa5c0d95c1bcef8a56463fda722bd1baa76fdc Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 17 Dec 2014 15:32:02 -0800 Subject: Bump version to 004. Remove dead code and trailing spaces. --- autotab.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/autotab.c b/autotab.c index 9d709f2..278c568 100644 --- a/autotab.c +++ b/autotab.c @@ -1,5 +1,5 @@ /* - * Autotab v003. + * Autotab v004. * 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. @@ -10,8 +10,8 @@ * * To use this, compile to an executable called "autotab". * Then in the .vimrc file, add something like this: - * - * :au BufRead * execute 'set' system("autotab < " . bufname("%")) + * + * :au BufRead * execute 'set' system("autotab < " . bufname("%")) * * Or, better still, with this (all joined to one line): * @@ -82,7 +82,7 @@ static int grow_buffer(buffer_t *buf) return 0; } - new_base = realloc(base, new_size); + new_base = realloc(base, new_size); if (new_base == 0) { oops("out of memory\n"); @@ -389,9 +389,9 @@ static long compute_alignment_score(line_t *lines, int tabsize, int shiftwidth) /* Loop over pairs of lines. After each iteration, the second one of the pair becomes the first line in the next pair. The pair of lines are not always consecutive. */ - for (next = lines ? lines->next : 0, lineno0 = 1, lineno1 = lineno0 + 1; + for (next = lines ? lines->next : 0, lineno0 = 1, lineno1 = lineno0 + 1; lines && next; - lines = next, next = next ? next->next : 0, lineno0 = lineno1++) + lines = next, next = next ? next->next : 0, lineno0 = lineno1++) { char *str0 = lines->str; size_t len0 = strlen(str0); @@ -416,10 +416,10 @@ static long compute_alignment_score(line_t *lines, int tabsize, int shiftwidth) { char *str1 = next->str; size_t len1 = strlen(str1); - long tnd1 = strspn(str1, LETAB); + long tnd1 = strspn(str1, LETAB); long ind1 = strspn(str1, ANYSP); long int1 = strcspn(str1, INTAB); - + if (len1 == ind1) { /* Second line is blank or pure indentation; choose the next line to be used as second. */ @@ -447,7 +447,7 @@ static long compute_alignment_score(line_t *lines, int tabsize, int shiftwidth) of interesting cases here, when the first line opens an indented group. */ if (ind1 >= len0) { - if (len0 && strchr(OPGRP, str0[len0-1]) && + if (len0 && strchr(OPGRP, str0[len0-1]) && ind1 != tnd1 && ind0 != tnd0) { /* First line ends with opening parenthesis, bracket or brace. */ if (ind1 == len0 && ind0 < len0 - 1) { @@ -617,8 +617,8 @@ static int determine_shiftwidth(line_t *lines_in, int tabsize, int munged) /* Indentation out of column zero tabulated separately. Consider only if second line goes beyond previous line, or if the indentation does not suspiciously look like alignment. */ - if (strlen(str0) < ind1 || - !(strchr(ANYSP, str0[ind1 - 1]) != 0 && + if (strlen(str0) < ind1 || + !(strchr(ANYSP, str0[ind1 - 1]) != 0 && strchr(ANYSP, str0[ind1]) == 0)) zerocol_hist[move]++; } @@ -685,31 +685,6 @@ static int determine_tabsize(line_t *lines) return best_tabsize; } -#if 0 -static int compute_alignment_histogram(long (*array)[128], line_t *lines) -{ - line_t iter; - - for (iter = lines; iter != 0; iter = iter->next) { - char *str = iter->str; - size_t pos = 0; - - for (;;) { - size_t skipnonblanks = strcspn(str, ANYSP); - size_t skipblanks = strspn(str, ANYSP); - - pos += skipnonblanks + skipblanks; - - if (str[pos] == 0 || pos >= 128) - break; - - if (skipblanks >= 2) - array[pos]++; - } - } -} -#endif - int determine_expandtab(line_t *lines_in, int tabsize, int shiftwidth) { line_t *lines = tab_munge(lines_in, tabsize); @@ -749,7 +724,7 @@ int main(int argc, char **argv) line_t *lines; int tabsize = 8, expandtabs = 1, shiftwidth = 8; int ret = EXIT_FAILURE; - + if (argc > 1 && !strcmp(argv[1], "-d")) debug_enabled = 1; -- cgit v1.2.3