getopt changes

Freddie Chopin freddie_chopin@op.pl
Wed Nov 13 19:47:00 GMT 2013


W dniu 2013-11-13 20:38, Corinna Vinschen pisze:
> On Nov 13 20:23, Freddie Chopin wrote:
>> W dniu 2013-11-13 20:01, Gregory Pietsch pisze:
>>> I noticed a few braces were omitted in the last version of getopt. Here
>>> is the file with them added. -- Gregory
>>
>> OMG, you're right (; Sorry about that... If necessary I can provide
>> a patch for these 4 braces only, as the file you posted has some
>> whitespace changes too.
>
> Yes, please.

Patch attached. I don't know how about the changelog entry - it's 
Gregory who spotted the bug, so he should get the credit - I'd prefer to 
put him as the author, so you're free to change the text below.

newlib/ChangeLog
2013-11-13  Freddie Chopin  <freddie_chopin@op.pl>

	* newlib/libc/stdlib/getopt.c (getopt_internal): Add missing
	braces

-------------- next part --------------
From 353c2d625a6e1cced4e3f728eee792443594820b Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Wed, 13 Nov 2013 20:44:03 +0100
Subject: [PATCH] newlib/libc/stdlib/getopt.c: (getopt_internal) add missing
 braces

---
 newlib/libc/stdlib/getopt.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/newlib/libc/stdlib/getopt.c b/newlib/libc/stdlib/getopt.c
index 2ab53aa..1094747 100644
--- a/newlib/libc/stdlib/getopt.c
+++ b/newlib/libc/stdlib/getopt.c
@@ -317,14 +317,16 @@ getopt_internal (int argc, char *const argv[], const char *shortopts,
 		    {
 		      /* we have ambiguous options */
 		      if (data->opterr)
-			fputs (argv[0], stderr);
-			fputs (": option `", stderr);
-			fputs (argv[data->optind], stderr);
-			fputs ("' is ambiguous (could be `--", stderr);
-			fputs (longopts[longopt_match].name, stderr);
-			fputs ("' or `--", stderr);
-			fputs (longopts[optindex].name, stderr);
-			fputs ("')\n", stderr);
+			{
+			  fputs (argv[0], stderr);
+			  fputs (": option `", stderr);
+			  fputs (argv[data->optind], stderr);
+			  fputs ("' is ambiguous (could be `--", stderr);
+			  fputs (longopts[longopt_match].name, stderr);
+			  fputs ("' or `--", stderr);
+			  fputs (longopts[optindex].name, stderr);
+			  fputs ("')\n", stderr);
+			}
 		      return (data->optopt = '?');
 		    }
 		}
@@ -342,10 +344,12 @@ getopt_internal (int argc, char *const argv[], const char *shortopts,
 	{
 	  /* couldn't find option in shortopts */
 	  if (data->opterr)
-	    fputs (argv[0], stderr);
-	    fputs (": invalid option -- `-", stderr);
-	    fputc (argv[data->optind][data->optwhere], stderr);
-	    fputs ("'\n", stderr);
+	    {
+	      fputs (argv[0], stderr);
+	      fputs (": invalid option -- `-", stderr);
+	      fputc (argv[data->optind][data->optwhere], stderr);
+	      fputs ("'\n", stderr);
+	    }
 	  data->optwhere++;
 	  if (argv[data->optind][data->optwhere] == '\0')
 	    {
-- 
1.8.3.msysgit.0



More information about the Newlib mailing list