Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:c16e5f24beb3fefd38ad02b8b3de864a372a9254
Author...:karl <>
Committer:karl <>
Date.....:Thu Nov 9 19:43:18 2006 +0000
Parents..:7c2fde45b2eac4a7300ebb0122c9ba6775d5ef46

Message
[project @ 2006-11-09 19:43:18 by karl]
better atexit

Changes
diff --git a/src/ChangeLog b/src/ChangeLog
line changes: +14/-0
index 2471ff1..b6c650b
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
+2006-11-09  Eric Blake  <ebb9@byu.net>
+
+	* hello.c (main): Use atexit, to avoid warning with 'gcc -Wall
+	-Werror'.
+	(my_exit): Delete, no longer needed.
+
+2006-11-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* hello.c (main): Make greeting const char *, to avoid
+	a violation of the C standard when assigning _("...") to it.
+	Remove unnecessary #if ENABLE_NLS bracket.
+	If too many operands are given, report our name, and the first
+	extra one.
+
 2006-10-18  Karl Berry  <karl@gnu.org>
 
 	* hello.c (print_version, print_help, my_exit): new fns.

diff --git a/src/hello.c b/src/hello.c
line changes: +11/-22
index baa7ee6..b579c9a
--- a/src/hello.c
+++ b/src/hello.c
@@ -33,7 +33,6 @@ static const struct option longopts[] =
   { NULL, 0, NULL, 0 }
 };
 
-static void my_exit (void);
 static void print_help (void);
 static void print_version (void);
 
@@ -53,20 +52,27 @@ main (int argc, char *argv[])
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  /* Even exiting has subtleties.  The /dev/full device on GNU/Linux
+     can be used for testing whether writes are checked properly.  For
+     instance, hello >/dev/null should exit unsuccessfully.  On exit,
+     if any writes failed, change the exit status.  This is
+     implemented in the Gnulib module "closeout".  */
+  atexit (close_stdout);
+
   while ((optc = getopt_long (argc, argv, "g:hntv", longopts, NULL)) != -1)
     switch (optc)
       {
       /* One goal here is having --help and --version exit immediately.  */
       case 'v':
         print_version ();
-        my_exit ();
+        exit (EXIT_SUCCESS);
         break;
       case 'g':
         greeting = optarg;
         break;
       case 'h':
         print_help ();
-        my_exit ();
+        exit (EXIT_SUCCESS);
         break;
       case 'n':
         n = 1;
@@ -87,7 +93,7 @@ main (int argc, char *argv[])
 		 program_name, argv[optind]);
       fprintf (stderr, _("Try `%s --help' for more information.\n"),
                program_name);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   /* Print greeting message and exit. */
@@ -114,24 +120,7 @@ main (int argc, char *argv[])
       puts (greeting);
     }
   
-  my_exit ();
-}
-
-
-
-/* Even exiting has subtleties.  The /dev/full device on GNU/Linux can
-   be used for testing whether writes are checked properly.  For instance,
-   hello >/dev/null should exit unsuccessfully.  */
-   
-static void
-my_exit (void)
-{
-  /* Exit unsuccessfully if the write failed.  This is implemented in
-     the Gnulib module "closeout".  */
-  close_stdout ();
-
-  /* Otherwise, exit successfully.  */
-  exit (0);
+  exit (EXIT_SUCCESS);
 }
 
 

This website is licensed under AGPL-3.0. Feel free to copy!