Index: getopt.c
===================================================================
RCS file: /cvs/glibc/libc/posix/getopt.c,v
retrieving revision 1.55
diff -u -r1.55 getopt.c
--- getopt.c	20 Jul 2005 17:50:20 -0000	1.55
+++ getopt.c	31 May 2006 10:05:27 -0000
@@ -600,6 +600,9 @@
 	  d->optind++;
 	  if (*nameend)
 	    {
+	      /* Search for an argument attached directly to `pfound' */
+
+
 	      /* Don't test has_arg with >, because some C compilers don't
 		 allow it to be used on enums.  */
 	      if (pfound->has_arg)
@@ -669,6 +672,9 @@
 	    }
 	  else if (pfound->has_arg == 1)
 	    {
+	      /* Search for an argument of `pfound' located in 
+	       * argv[d->optind] */
+
 	      if (d->optind < argc)
 		d->optarg = argv[d->optind++];
 	      else
@@ -1057,14 +1063,21 @@
       {
 	if (temp[2] == ':')
 	  {
-	    /* This is an option that accepts an argument optionally.  */
-	    if (*d->__nextchar != '\0')
-	      {
-		d->optarg = d->__nextchar;
-		d->optind++;
-	      }
-	    else
-	      d->optarg = NULL;
+	    /* This is an option that accepts an argument optionally,
+	     * therefore we set optarg to NULL, because *d->nextchar
+	     * is another option element. For example:
+	     * 	
+	     * 		bar -abcRdefg
+	     *
+	     * If 'R' is an element that accepts an argument 
+	     * optionally, then the "defg" string is not considered 
+	     * as its arg.
+	     * Only in these cases it is possible to specify an 
+	     * option for 'R'.
+	     * 		bar -abcR option_to_R
+	     * 		bar -abc -R option_to_R
+	     */
+	    d->optarg = NULL;
 	    d->__nextchar = NULL;
 	  }
 	else
