This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

recent getopt.c diagnostic change may be disruptive for others, too


Hi Uli,

[ For the record, my attention was drawn to this change because
  it just made it into rawhide, where it triggered a coreutils test
  suite failure, because of the slight change in diagnostic syntax.
  I've already worked around it.  ]

In this change, you modified getopt's diagnostic strings:
(BTW, the ChangeLog mentions the wrong BZ#):

        [BZ #5762]
        * posix/getopt.c (_getopt_internal_r): Clarify error message by
        putting offending option character in quotes.  Clean up error
        messages.

Here's the actual delta:

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=71a54f4af98

Note that it changes this diagnostic,

-   ... "%s: invalid option -- %c\n")
+   ... "%s: invalid option -- '%c'\n")

and that's a fine change, but that same change-set also modifies
the POSIXLY_CORRECT diagnostic:

-	n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
+	n = __asprintf (&buf, _("%s: illegal option -- '%c'\n"),

Since POSIX no longer requires the "illegal option..." syntax, I
suggest that you either revert that part (remove the single quotes),
for those who require the traditional syntax, or remove the "if-block"
altogether.

Here's a patch that does the latter:

	* posix/getopt.c (_getopt_internal_r): Remove the code that
	would print "illegal option ..." in POSIXLY_CORRECT mode.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 posix/getopt.c |   21 ++++-----------------
 1 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/posix/getopt.c b/posix/getopt.c
index 103f572..d5546f9 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -796,26 +796,13 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
 	      int n;
 #endif

-	    if (d->__posixly_correct)
-	      {
-#if defined _LIBC && defined USE_IN_LIBIO
-		n = __asprintf (&buf, _("%s: illegal option -- '%c'\n"),
-				argv[0], c);
-#else
-		fprintf (stderr, _("%s: illegal option -- '%c'\n"), argv[0],
-			 c);
-#endif
-	      }
-	    else
-	      {
 #if defined _LIBC && defined USE_IN_LIBIO
-		n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
-				argv[0], c);
+	      n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
+			      argv[0], c);
 #else
-		fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0],
-			 c);
+	      fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0],
+		       c);
 #endif
-	      }

 #if defined _LIBC && defined USE_IN_LIBIO
 	    if (n >= 0)
--
1.5.5.rc1.13.g79388


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]