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


gnu-hello       
Info
Commit...:e1d8daeec195fcc9e60c4a23320e49022678ca73
Author...:karl <>
Committer:karl <>
Date.....:Wed Aug 23 13:55:15 2006 +0000
Parents..:147942bb32b5727fba1e062a827748aa0864d2fc

Message
[project @ 2006-08-23 13:55:15 by karl]
program_name, ANSI, etc. improvements

Changes
diff --git a/src/ChangeLog b/src/ChangeLog
line changes: +11/-0
index 9213776..e02344d
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2006-08-23  Bruno Haible  <bruno@clisp.org>
+
+	* hello.c (program_name): Renamed from progname. Make non-static.
+	(main): Update.
+
+2006-08-23  Bruno Haible  <bruno@clisp.org>
+
+	* system.h: Fix double-inclusion guard. Improve comments.
+	* hello.c (longopts): Make const and static.
+	(main): Convert to ANSI C definition.
+
 2006-08-20  Karl Berry  <karl@gnu.org>
 	
 	* hello.c (main): try a new style for the --version output.

diff --git a/src/hello.c b/src/hello.c
line changes: +9/-10
index 60851f4..3f25e9a
--- a/src/hello.c
+++ b/src/hello.c
@@ -20,7 +20,10 @@
 #include <config.h>
 #include "system.h"
 
-struct option longopts[] =
+/* String containing name the program is called with.  */
+const char *program_name;
+ 
+static const struct option longopts[] =
 {
   { "greeting", required_argument, NULL, 'g' },
   { "help", no_argument, NULL, 'h' },
@@ -30,20 +33,16 @@ struct option longopts[] =
   { NULL, 0, NULL, 0 }
 };
 
-static char *progname;
-
 int
-main (argc, argv)
-     int argc;
-     char *argv[];
+main (int argc, char *argv[])
 {
   int optc;
   int h = 0, v = 0, t = 0, n = 0, lose = 0;
   char *greeting = NULL;
 
-  progname = argv[0];
+  program_name = argv[0];
 
-#ifdef HAVE_SETLOCALE
+#if HAVE_SETLOCALE
   /* Set locale via LC_ALL.  */
   setlocale (LC_ALL, "");
 #endif
@@ -84,7 +83,7 @@ main (argc, argv)
       if (optind < argc)
         fputs (_("Too many arguments\n"), stderr);
       fprintf (stderr, _("Try `%s --help' for more information.\n"), 
-               progname);
+               program_name);
       exit (1);
     }
 
@@ -103,7 +102,7 @@ GNU hello, THE greeting printing program.\n"), stdout);
       /* TRANSLATORS: --help output 2
          no-wrap */
       printf (_("\
-Usage: %s [OPTION]...\n"), progname);
+Usage: %s [OPTION]...\n"), program_name);
 
       printf ("\n");
       /* TRANSLATORS: --help output 3 : options 1/2

diff --git a/src/system.h b/src/system.h
line changes: +5/-1
index af32c92..658916c
--- a/src/system.h
+++ b/src/system.h
@@ -16,13 +16,17 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef HELLO_SYSTEM_H
+#define HELLO_SYSTEM_H
 
 /* Assume ANSI C89 headers are available.  */
-#include <getopt.h>
 #include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+/* Use POSIX headers.  If they are not available, we use the substitute
+   provided by gnulib.  */
+#include <getopt.h>
 #include <unistd.h>
 
 /* Internationalization.  */

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