maint: update all copyright year number ranges
[platform/upstream/coreutils.git] / src / sum.c
index e53bad2..9ebcc42 100644 (file)
--- a/src/sum.c
+++ b/src/sum.c
@@ -1,6 +1,5 @@
 /* sum -- checksum and count the blocks in a file
-   Copyright (C) 86, 89, 91, 1995-2002, 2004, 2005,
-   2008-2009 Free Software Foundation, Inc.
+   Copyright (C) 1986-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <getopt.h>
 #include "system.h"
 #include "error.h"
+#include "fadvise.h"
 #include "human.h"
 #include "safe-read.h"
 #include "xfreopen.h"
 
-/* The official name of this program (e.g., no `g' prefix).  */
+/* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "sum"
 
 #define AUTHORS \
@@ -52,8 +52,7 @@ void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
-    fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             program_name);
+    emit_try_help ();
   else
     {
       printf (_("\
@@ -72,7 +71,7 @@ Print checksum and block counts for each FILE.\n\
 \n\
 With no FILE, or when FILE is -, read standard input.\n\
 "), stdout);
-      emit_bug_reporting_address ();
+      emit_ancillary_info ();
     }
   exit (status);
 }
@@ -110,6 +109,8 @@ bsd_sum_file (const char *file, int print_name)
         }
     }
 
+  fadvise (fp, FADVISE_SEQUENTIAL);
+
   while ((ch = getc (fp)) != EOF)
     {
       total_bytes++;
@@ -233,6 +234,10 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
+  /* Line buffer stdout to ensure lines are written atomically and immediately
+     so that processes running in parallel do not intersperse their output.  */
+  setvbuf (stdout, NULL, _IOLBF, 0);
+
   have_read_stdin = false;
 
   while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1)