hello everybody!
after reading the following article, about a missing switch in wc http://safari.oreilly.com/?XmlId=0-596-00461-3/linuxsvrhack-CHP-1-SECT-6 i had fun of looking at the wc src and the patch ads the demanded switch for a word count without trailing '\n' the patch is quite trivial and against Version 2.0, -n was choosen because auf echo(1) syntax thanks for taking a look and any feedback maks
--- wc-orig.c Wed Jun 25 11:44:53 2003
+++ wc.c Wed Jun 25 11:55:20 2003
@@ -52,6 +52,9 @@
/* Which counts to print. */
static int print_lines, print_words, print_chars, print_linelength;
+/* How to print output. */
+static int print_newline;
+
/* Nonzero if we have ever read the standard input. */
static int have_read_stdin;
@@ -67,6 +70,7 @@
{"bytes", no_argument, NULL, 'c'},
{"chars", no_argument, NULL, 'c'},
{"lines", no_argument, NULL, 'l'},
+ {"no-newline", no_argument, NULL, 'n'},
{"words", no_argument, NULL, 'w'},
{"max-line-length", no_argument, NULL, 'L'},
{GETOPT_HELP_OPTION_DECL},
@@ -93,6 +97,7 @@
-c, --bytes, --chars print the byte counts\n\
-l, --lines print the newline counts\n\
-L, --max-line-length print the length of the longest line\n\
+ -n, --no-newline print without trailing newline\n\
-w, --words print the word counts\n\
--help display this help and exit\n\
--version output version information and exit\n\
@@ -135,7 +140,8 @@
}
if (*file)
printf (" %s", file);
- putchar ('\n');
+ if (print_newline)
+ putchar ('\n');
}
static void
@@ -312,9 +318,10 @@
exit_status = 0;
posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
print_lines = print_words = print_chars = print_linelength = 0;
+ print_newline = 1;
total_lines = total_words = total_chars = max_line_length = 0;
- while ((optc = getopt_long (argc, argv, "clLw", longopts, NULL)) != -1)
+ while ((optc = getopt_long (argc, argv, "clLnw", longopts, NULL)) != -1)
switch (optc)
{
case 0:
@@ -326,6 +333,10 @@
case 'l':
print_lines = 1;
+ break;
+
+ case 'n':
+ print_newline = 0;
break;
case 'w':
pgp00000.pgp
Description: PGP signature
_______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils
