bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yet another hello pretest


From: Paul Eggert
Subject: Re: yet another hello pretest
Date: Thu, 09 Nov 2006 09:40:57 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

> ftp://alpha.gnu.org/gnu/hello/hello-2.1.95.tar.bz2 (or .gz)

A quick review.

1.  Here's a warning I observed on Solaris 8 with Sun C 5.8:

source='hello.c' object='hello.o' libtool=no \
        DEPDIR=.deps depmode=none /bin/bash ../build-aux/depcomp \
        cc -xarch=v9 -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H 
-I. -I. -I..  -I../gnulib/lib -I../gnulib/lib -D_REENTRANT  -g -c hello.c
"hello.c", line 114: warning: assignment type mismatch:
        pointer to char "=" pointer to const char

2.  The "#if ENABLE_NLS" isn't needed, since gettext.h does the right
    thing anyway.

3.  "hello a b c" outputs a less-than-helpful diagnostic, which doesn't
    say that it's the "hello" program.

Here are proposed patches:

2006-11-09  Paul Eggert  <address@hidden>

        * src/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.

--- src/hello.c.orig    2006-10-18 15:36:18.000000000 -0700
+++ src/hello.c 2006-11-09 09:39:19.184032000 -0800
@@ -42,18 +42,16 @@ main (int argc, char *argv[])
 {
   int optc;
   int t = 0, n = 0, lose = 0;
-  char *greeting = NULL;
+  const char *greeting = NULL;
 
   program_name = argv[0];
 
   /* Set locale via LC_ALL.  */
   setlocale (LC_ALL, "");
 
-#if ENABLE_NLS
   /* Set the text message domain.  */
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
-#endif
 
   while ((optc = getopt_long (argc, argv, "g:hntv", longopts, NULL)) != -1)
     switch (optc)
@@ -85,7 +83,8 @@ main (int argc, char *argv[])
     {
       /* Print error message and exit.  */
       if (optind < argc)
-        fputs (_("Too many arguments\n"), stderr);
+        fprintf (stderr, _("%s: extra operand: %s\n"),
+                program_name, argv[optind]);
       fprintf (stderr, _("Try `%s --help' for more information.\n"),
                program_name);
       exit (1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]