Imported Upstream version 4.5.14
[platform/upstream/findutils.git] / locate / code.c
index 7d06a66..eae02ce 100644 (file)
@@ -1,5 +1,6 @@
 /* code -- bigram- and front-encode filenames for locate
-   Copyright (C) 1994, 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2005, 2007, 2008, 2010, 2011 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
    Written by James A. Woods <jwoods@adobe.com>.
    Modified by David MacKenzie <djm@gnu.org>.  */
 
+/* config.h should always be included first. */
 #include <config.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <string.h>
+
+/* system headers. */
 #include <errno.h>
 #include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
 
+/* gnulib headers. */
+#include "closeout.h"
+#include "error.h"
+#include "gettext.h"
+#include "progname.h"
+#include "xalloc.h"
 
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
+/* find headers. */
+#include "findutils-version.h"
+#include "locatedb.h"
 
 #if ENABLE_NLS
 # include <libintl.h>
 # define N_(String) String
 #endif
 
-#include "locatedb.h"
-#include "closeout.h"
-#include "xalloc.h"
-#include "gnulib-version.h"
-#include "progname.h"
-#include "error.h"
-#include "findutils-version.h"
 
 #ifndef ATTRIBUTE_NORETURN
 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
@@ -165,7 +169,10 @@ main (int argc, char **argv)
   int line_len;                        /* Length of input line.  */
 
   set_program_name (argv[0]);
-  atexit (close_stdout);
+  if (atexit (close_stdout))
+    {
+      error (EXIT_FAILURE, errno, _("The atexit library function failed"));
+    }
 
   bigram[2] = '\0';