--- old_src/wc.c 2009-06-03 13:00:56.000000000 -1000 +++ src/wc.c 2009-06-03 11:42:04.000000000 -1000 @@ -64,6 +64,9 @@ static bool print_lines, print_words, print_chars, print_bytes; static bool print_linelength; +/* How many spaces count as a tab. */ +static int tab_width; + /* The print width of each count. */ static int number_width; @@ -85,7 +88,8 @@ non-character as a pseudo short option, starting with CHAR_MAX + 1. */ enum { - FILES0_FROM_OPTION = CHAR_MAX + 1 + FILES0_FROM_OPTION = CHAR_MAX + 1, + TAB_WIDTH_OPTION }; static struct option const longopts[] = @@ -95,6 +99,7 @@ {"lines", no_argument, NULL, 'l'}, {"words", no_argument, NULL, 'w'}, {"files0-from", required_argument, NULL, FILES0_FROM_OPTION}, + {"tab-width", required_argument, NULL, TAB_WIDTH_OPTION}, {"max-line-length", no_argument, NULL, 'L'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -127,6 +132,7 @@ NUL-terminated names in file F;\n\ If F is - then read names from standard input\n\ -L, --max-line-length print the length of the longest line\n\ + --tab-width=SIZE size of tab used by -L\n\ -w, --words print the word counts\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -368,7 +374,7 @@ linepos = 0; goto mb_word_separator; case '\t': - linepos += 8 - (linepos % 8); + linepos += tab_width - (linepos % tab_width); goto mb_word_separator; case ' ': linepos++; @@ -442,7 +448,7 @@ linepos = 0; goto word_separator; case '\t': - linepos += 8 - (linepos % 8); + linepos += tab_width - (linepos % tab_width); goto word_separator; case ' ': linepos++; @@ -601,6 +607,7 @@ print_lines = print_words = print_chars = print_bytes = false; print_linelength = false; total_lines = total_words = total_chars = total_bytes = max_line_length = 0; + tab_width = 8; while ((optc = getopt_long (argc, argv, "clLmw", longopts, NULL)) != -1) switch (optc) @@ -629,6 +636,16 @@ files_from = optarg; break; + case TAB_WIDTH_OPTION: + tab_width = atoi(optarg); + if (0 >= tab_width) + { + fprintf(stderr, "%s\n", + _("tab-width must be greater than 0")); + exit(EXIT_FAILURE); + } + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);